Loading js/modal-page.js +5 −5 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ * Default JavaScript file for Modal Page. */ (function ($, Drupal, drupalSettings) { (function ($, cookies, Drupal, drupalSettings) { 'use strict'; Drupal.behaviors.modalPage = { Loading Loading @@ -42,11 +42,11 @@ // Remove the cookie if show only once option is disabled. if (show_once != "1") { $.removeCookie('hide_modal_id_' + id_modal); cookies.remove('hide_modal_id_' + id_modal); } // Get cookies for do not show again option and show only once. var hide_modal_cookie = $.cookie('hide_modal_id_' + id_modal) || $.cookie('please_do_not_show_again_modal_id_' + id_modal); var hide_modal_cookie = cookies.get('hide_modal_id_' + id_modal) || cookies.get('please_do_not_show_again_modal_id_' + id_modal); // Verify don't show again and show only once options. if (hide_modal_cookie) { Loading Loading @@ -74,7 +74,7 @@ modal.on('hide.bs.modal', function () { if (show_once == "1") { $.cookie('hide_modal_id_' + id_modal, true, {expires: 365 * 20, path: '/'}); cookies.set('hide_modal_id_' + id_modal, true, { expires: 365 * 20, path: '/' }); } }); Loading Loading @@ -220,4 +220,4 @@ }); } }; })(jQuery, Drupal, drupalSettings); })(jQuery, window.Cookies, Drupal, drupalSettings); modal_page.info.yml +1 −1 Original line number Diff line number Diff line name: Modal Page description: Create Modal type: module core_version_requirement: ^8.8 || ^9 core_version_requirement: ^9.3 || ^10 package: User interface configure: modal_page.settings dependencies: Loading modal_page.install +1 −1 Original line number Diff line number Diff line Loading @@ -710,7 +710,7 @@ function update_modal_page_views() { return FALSE; } $config_views_path = drupal_get_path('module', 'modal_page') . '/config/optional/views.view.list_modal.yml'; $config_views_path = \Drupal::service('extension.list.module')->getPath('modal_page') . '/config/optional/views.view.list_modal.yml'; $data = Yaml::decode(file_get_contents($config_views_path)); Loading modal_page.libraries.yml +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ modal-page: js/modal-page.js: {} dependencies: - core/jquery - core/jquery.cookie - core/js-cookie - core/drupal modal-page-admin: Loading src/Form/ModalForm.php +13 −5 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Render\RendererInterface; use Drupal\modal_page\Service\ModalPageService; use Drupal\Core\Extension\ExtensionPathResolver; /** * Class Modal Form to use Entity. Loading Loading @@ -44,14 +45,22 @@ class ModalForm extends EntityForm { */ protected $modalPageService; /** * The extension path resolver. * * @var \Drupal\Core\Extension\ExtensionPathResolver */ protected $extensionPathResolver; /** * Construct of Modal Page. */ public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RendererInterface $renderer, ModalPageService $modalPageService) { public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RendererInterface $renderer, ModalPageService $modalPageService, ExtensionPathResolver $extension_path_resolver = NULL) { $this->languageManager = $language_manager; $this->configFactory = $config_factory; $this->renderer = $renderer; $this->modalPageService = $modalPageService; $this->extensionPathResolver = $extension_path_resolver; } /** Loading @@ -62,7 +71,8 @@ class ModalForm extends EntityForm { $container->get('language_manager'), $container->get('config.factory'), $container->get('renderer'), $container->get('modal_page.modals') $container->get('modal_page.modals'), $container->get('extension.path.resolver') ); } Loading @@ -75,7 +85,7 @@ class ModalForm extends EntityForm { /** @var \Drupal\modal_page\Entity\Modal $modal */ $modal = $this->entity; $imagePath = $imageUrl = '/' . drupal_get_path('module', 'modal_page') . '/images/'; $imagePath = $imageUrl = '/' . $this->extensionPathResolver->getPath('module', 'modal_page') . '/images/'; $modalImageMarkup = [ '#theme' => 'modal_page_helper_admin', Loading Loading @@ -1125,7 +1135,6 @@ class ModalForm extends EntityForm { $topRightButtonClass = $this->modalPageService->prepareClass($values['top_right_button_class']); $form_state->setValue('top_right_button_class', $topRightButtonClass); } if (!empty($values['footer_class'])) { Loading @@ -1148,7 +1157,6 @@ class ModalForm extends EntityForm { $form_state->setValue('left_button_class', $leftButtonClass); } } /** Loading Loading
js/modal-page.js +5 −5 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ * Default JavaScript file for Modal Page. */ (function ($, Drupal, drupalSettings) { (function ($, cookies, Drupal, drupalSettings) { 'use strict'; Drupal.behaviors.modalPage = { Loading Loading @@ -42,11 +42,11 @@ // Remove the cookie if show only once option is disabled. if (show_once != "1") { $.removeCookie('hide_modal_id_' + id_modal); cookies.remove('hide_modal_id_' + id_modal); } // Get cookies for do not show again option and show only once. var hide_modal_cookie = $.cookie('hide_modal_id_' + id_modal) || $.cookie('please_do_not_show_again_modal_id_' + id_modal); var hide_modal_cookie = cookies.get('hide_modal_id_' + id_modal) || cookies.get('please_do_not_show_again_modal_id_' + id_modal); // Verify don't show again and show only once options. if (hide_modal_cookie) { Loading Loading @@ -74,7 +74,7 @@ modal.on('hide.bs.modal', function () { if (show_once == "1") { $.cookie('hide_modal_id_' + id_modal, true, {expires: 365 * 20, path: '/'}); cookies.set('hide_modal_id_' + id_modal, true, { expires: 365 * 20, path: '/' }); } }); Loading Loading @@ -220,4 +220,4 @@ }); } }; })(jQuery, Drupal, drupalSettings); })(jQuery, window.Cookies, Drupal, drupalSettings);
modal_page.info.yml +1 −1 Original line number Diff line number Diff line name: Modal Page description: Create Modal type: module core_version_requirement: ^8.8 || ^9 core_version_requirement: ^9.3 || ^10 package: User interface configure: modal_page.settings dependencies: Loading
modal_page.install +1 −1 Original line number Diff line number Diff line Loading @@ -710,7 +710,7 @@ function update_modal_page_views() { return FALSE; } $config_views_path = drupal_get_path('module', 'modal_page') . '/config/optional/views.view.list_modal.yml'; $config_views_path = \Drupal::service('extension.list.module')->getPath('modal_page') . '/config/optional/views.view.list_modal.yml'; $data = Yaml::decode(file_get_contents($config_views_path)); Loading
modal_page.libraries.yml +1 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ modal-page: js/modal-page.js: {} dependencies: - core/jquery - core/jquery.cookie - core/js-cookie - core/drupal modal-page-admin: Loading
src/Form/ModalForm.php +13 −5 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Render\RendererInterface; use Drupal\modal_page\Service\ModalPageService; use Drupal\Core\Extension\ExtensionPathResolver; /** * Class Modal Form to use Entity. Loading Loading @@ -44,14 +45,22 @@ class ModalForm extends EntityForm { */ protected $modalPageService; /** * The extension path resolver. * * @var \Drupal\Core\Extension\ExtensionPathResolver */ protected $extensionPathResolver; /** * Construct of Modal Page. */ public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RendererInterface $renderer, ModalPageService $modalPageService) { public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RendererInterface $renderer, ModalPageService $modalPageService, ExtensionPathResolver $extension_path_resolver = NULL) { $this->languageManager = $language_manager; $this->configFactory = $config_factory; $this->renderer = $renderer; $this->modalPageService = $modalPageService; $this->extensionPathResolver = $extension_path_resolver; } /** Loading @@ -62,7 +71,8 @@ class ModalForm extends EntityForm { $container->get('language_manager'), $container->get('config.factory'), $container->get('renderer'), $container->get('modal_page.modals') $container->get('modal_page.modals'), $container->get('extension.path.resolver') ); } Loading @@ -75,7 +85,7 @@ class ModalForm extends EntityForm { /** @var \Drupal\modal_page\Entity\Modal $modal */ $modal = $this->entity; $imagePath = $imageUrl = '/' . drupal_get_path('module', 'modal_page') . '/images/'; $imagePath = $imageUrl = '/' . $this->extensionPathResolver->getPath('module', 'modal_page') . '/images/'; $modalImageMarkup = [ '#theme' => 'modal_page_helper_admin', Loading Loading @@ -1125,7 +1135,6 @@ class ModalForm extends EntityForm { $topRightButtonClass = $this->modalPageService->prepareClass($values['top_right_button_class']); $form_state->setValue('top_right_button_class', $topRightButtonClass); } if (!empty($values['footer_class'])) { Loading @@ -1148,7 +1157,6 @@ class ModalForm extends EntityForm { $form_state->setValue('left_button_class', $leftButtonClass); } } /** Loading