diff --git a/core/core.libraries.yml b/core/core.libraries.yml index ccc5761181..4130ef46f2 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -903,3 +903,15 @@ underscore: gpl-compatible: true js: assets/vendor/underscore/underscore-min.js: { weight: -20, minified: true } + +drupal.dialog.off_canvas: + version: VERSION + js: + misc/dialog/off-canvas.js: {} + dependencies: + - core/jquery + - core/drupal + - core/drupal.ajax + - core/drupal.announce + - core/drupal.dialog + - core/drupal.dialog.ajax diff --git a/core/core.services.yml b/core/core.services.yml index 76088786cd..98996a6101 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1065,6 +1065,11 @@ services: arguments: ['@title_resolver'] tags: - { name: render.main_content_renderer, format: drupal_dialog } + main_content_renderer.off_canvas: + class: Drupal\Core\Render\MainContent\OffCanvasRenderer + arguments: ['@title_resolver', '@renderer'] + tags: + - { name: render.main_content_renderer, format: drupal_dialog.off_canvas } main_content_renderer.modal: class: Drupal\Core\Render\MainContent\ModalRenderer arguments: ['@title_resolver'] diff --git a/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php b/core/lib/Drupal/Core/Ajax/OpenOffCanvasDialogCommand.php similarity index 94% rename from core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php rename to core/lib/Drupal/Core/Ajax/OpenOffCanvasDialogCommand.php index 0dd3736f28..24663e726e 100644 --- a/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php +++ b/core/lib/Drupal/Core/Ajax/OpenOffCanvasDialogCommand.php @@ -1,8 +1,6 @@ dialogOptions['buttons'] = []; + if (empty($dialog_options['dialogClass'])) { + $this->dialogOptions['dialogClass'] = 'ui-dialog-off-canvas'; + } // If no width option is provided then use the default width to avoid the // dialog staying at the width of the previous instance when opened // more than once, with different widths, on a single page. diff --git a/core/modules/outside_in/src/Render/MainContent/OffCanvasRenderer.php b/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php similarity index 89% rename from core/modules/outside_in/src/Render/MainContent/OffCanvasRenderer.php rename to core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php index 8bcaa578d4..55bf8eb7d1 100644 --- a/core/modules/outside_in/src/Render/MainContent/OffCanvasRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/OffCanvasRenderer.php @@ -1,13 +1,12 @@ renderer->renderRoot($main_content); // Attach the library necessary for using the OpenOffCanvasDialogCommand and // set the attachments for this Ajax response. - $main_content['#attached']['library'][] = 'outside_in/drupal.off_canvas'; + $main_content['#attached']['library'][] = 'core/drupal.dialog.off_canvas'; $response->setAttachments($main_content['#attached']); // If the main content doesn't provide a title, use the title resolver. diff --git a/core/modules/outside_in/js/off-canvas.es6.js b/core/misc/dialog/off-canvas.es6.js similarity index 100% rename from core/modules/outside_in/js/off-canvas.es6.js rename to core/misc/dialog/off-canvas.es6.js diff --git a/core/modules/outside_in/js/off-canvas.js b/core/misc/dialog/off-canvas.js similarity index 98% rename from core/modules/outside_in/js/off-canvas.js rename to core/misc/dialog/off-canvas.js index 85a9e53675..9a958d4692 100644 --- a/core/modules/outside_in/js/off-canvas.js +++ b/core/misc/dialog/off-canvas.js @@ -111,4 +111,4 @@ }); } }; -})(jQuery, Drupal, Drupal.debounce, Drupal.displace); \ No newline at end of file +})(jQuery, Drupal, Drupal.debounce, Drupal.displace); diff --git a/core/modules/outside_in/outside_in.libraries.yml b/core/modules/outside_in/outside_in.libraries.yml index 5c388b82f1..cf12dc0894 100644 --- a/core/modules/outside_in/outside_in.libraries.yml +++ b/core/modules/outside_in/outside_in.libraries.yml @@ -20,14 +20,3 @@ drupal.outside_in: - core/drupal - core/jquery.once - core/drupal.ajax -drupal.off_canvas: - version: VERSION - js: - js/off-canvas.js: {} - dependencies: - - core/jquery - - core/drupal - - core/drupal.ajax - - core/drupal.announce - - core/drupal.dialog - - core/drupal.dialog.ajax diff --git a/core/modules/outside_in/outside_in.module b/core/modules/outside_in/outside_in.module index 69517b9919..b465208ba7 100644 --- a/core/modules/outside_in/outside_in.module +++ b/core/modules/outside_in/outside_in.module @@ -50,7 +50,7 @@ function outside_in_contextual_links_view_alter(&$element, $items) { $element['#links']['outside-inblock-configure']['title'] = t('Quick edit settings'); } - $element['#attached']['library'][] = 'outside_in/drupal.off_canvas'; + $element['#attached']['library'][] = 'core/drupal.dialog.off_canvas'; } } @@ -67,26 +67,6 @@ function outside_in_block_view_alter(array &$build) { } /** - * Implements hook_element_info_alter(). - */ -function outside_in_element_info_alter(&$type) { - if (isset($type['page'])) { - $type['page']['#theme_wrappers']['outside_in_page_wrapper'] = ['#weight' => -1000]; - } -} - -/** - * Implements hook_theme(). - */ -function outside_in_theme() { - return [ - 'outside_in_page_wrapper' => [ - 'variables' => ['children' => NULL], - ], - ]; -} - -/** * Implements hook_entity_type_build(). */ function outside_in_entity_type_build(array &$entity_types) { diff --git a/core/modules/outside_in/outside_in.services.yml b/core/modules/outside_in/outside_in.services.yml deleted file mode 100644 index ce8214697a..0000000000 --- a/core/modules/outside_in/outside_in.services.yml +++ /dev/null @@ -1,6 +0,0 @@ -services: - main_content_renderer.off_canvas: - class: Drupal\outside_in\Render\MainContent\OffCanvasRenderer - arguments: ['@title_resolver', '@renderer'] - tags: - - { name: render.main_content_renderer, format: drupal_dialog.off_canvas } diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php index 04fc230f5e..2dd3d69c57 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php @@ -5,6 +5,7 @@ use Drupal\block\Entity\Block; use Drupal\block_content\Entity\BlockContent; use Drupal\block_content\Entity\BlockContentType; +use Drupal\Tests\system\FunctionalJavascript\OffCanvasTestBase; use Drupal\user\Entity\Role; /** @@ -12,7 +13,7 @@ * * @group outside_in */ -class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { +class OutsideInBlockFormTest extends OffCanvasTestBase { const TOOLBAR_EDIT_LINK_SELECTOR = '#toolbar-bar div.contextual-toolbar-tab button'; diff --git a/core/modules/outside_in/src/Tests/Ajax/OffCanvasDialogTest.php b/core/modules/system/src/Tests/Ajax/OffCanvasDialogTest.php similarity index 84% rename from core/modules/outside_in/src/Tests/Ajax/OffCanvasDialogTest.php rename to core/modules/system/src/Tests/Ajax/OffCanvasDialogTest.php index edf055b577..6d7ddbb9d4 100644 --- a/core/modules/outside_in/src/Tests/Ajax/OffCanvasDialogTest.php +++ b/core/modules/system/src/Tests/Ajax/OffCanvasDialogTest.php @@ -1,30 +1,22 @@ drupalLogin($this->drupalCreateUser(['administer contact forms'])); // Ensure the elements render without notices or exceptions. $this->drupalGet('ajax-test/dialog'); @@ -46,6 +38,7 @@ public function testDialog() { 'draggable' => FALSE, 'drupalAutoButtons' => FALSE, 'buttons' => [], + 'dialogClass' => 'ui-dialog-off-canvas', 'width' => 300, ], 'effect' => 'fade', diff --git a/core/modules/system/system.module b/core/modules/system/system.module index d327d4e74b..3e75bcb5fd 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -268,6 +268,9 @@ function system_theme() { ], 'template' => 'entity-add-list', ], + 'off_canvas_page_wrapper' => [ + 'variables' => ['children' => NULL], + ], ]); } @@ -1515,3 +1518,13 @@ function system_query_entity_reference_alter(AlterableInterface $query) { $handler = $query->getMetadata('entity_reference_selection_handler'); $handler->entityQueryAlter($query); } + + +/** + * Implements hook_element_info_alter(). + */ +function system_element_info_alter(&$type) { + if (isset($type['page'])) { + $type['page']['#theme_wrappers']['off_canvas_page_wrapper'] = ['#weight' => -1000]; + } +} diff --git a/core/modules/outside_in/templates/outside-in-page-wrapper.html.twig b/core/modules/system/templates/off-canvas-page-wrapper.html.twig similarity index 100% rename from core/modules/outside_in/templates/outside-in-page-wrapper.html.twig rename to core/modules/system/templates/off-canvas-page-wrapper.html.twig diff --git a/core/modules/outside_in/tests/modules/off_canvas_test/off_canvas_test.info.yml b/core/modules/system/tests/modules/off_canvas_test/off_canvas_test.info.yml similarity index 76% rename from core/modules/outside_in/tests/modules/off_canvas_test/off_canvas_test.info.yml rename to core/modules/system/tests/modules/off_canvas_test/off_canvas_test.info.yml index 8c6cc80242..9680b1842d 100644 --- a/core/modules/outside_in/tests/modules/off_canvas_test/off_canvas_test.info.yml +++ b/core/modules/system/tests/modules/off_canvas_test/off_canvas_test.info.yml @@ -4,6 +4,3 @@ description: 'Provides off-canvas test links.' package: Testing version: VERSION core: 8.x -dependencies: - - block - - outside_in diff --git a/core/modules/outside_in/tests/modules/off_canvas_test/off_canvas_test.routing.yml b/core/modules/system/tests/modules/off_canvas_test/off_canvas_test.routing.yml similarity index 100% rename from core/modules/outside_in/tests/modules/off_canvas_test/off_canvas_test.routing.yml rename to core/modules/system/tests/modules/off_canvas_test/off_canvas_test.routing.yml diff --git a/core/modules/outside_in/tests/modules/off_canvas_test/src/Controller/TestController.php b/core/modules/system/tests/modules/off_canvas_test/src/Controller/TestController.php similarity index 94% rename from core/modules/outside_in/tests/modules/off_canvas_test/src/Controller/TestController.php rename to core/modules/system/tests/modules/off_canvas_test/src/Controller/TestController.php index 6164b06fc2..ea7875a030 100644 --- a/core/modules/outside_in/tests/modules/off_canvas_test/src/Controller/TestController.php +++ b/core/modules/system/tests/modules/off_canvas_test/src/Controller/TestController.php @@ -55,7 +55,7 @@ public function linksDisplay() { ], '#attached' => [ 'library' => [ - 'outside_in/drupal.outside_in', + 'core/drupal.dialog.off_canvas', ], ], ], @@ -73,7 +73,7 @@ public function linksDisplay() { ], '#attached' => [ 'library' => [ - 'outside_in/drupal.outside_in', + 'core/drupal.dialog.off_canvas', ], ], ], @@ -88,7 +88,7 @@ public function linksDisplay() { ], '#attached' => [ 'library' => [ - 'outside_in/drupal.outside_in', + 'core/drupal.dialog.off_canvas', ], ], ], @@ -131,7 +131,7 @@ public function otherDialogLinks() { ], '#attached' => [ 'library' => [ - 'outside_in/drupal.outside_in', + 'core/drupal.dialog.off_canvas', ], ], ]; diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OffCanvasTest.php b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php similarity index 97% rename from core/modules/outside_in/tests/src/FunctionalJavascript/OffCanvasTest.php rename to core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php index 2f64d9fe2c..117b8d2da3 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OffCanvasTest.php +++ b/core/modules/system/tests/src/FunctionalJavascript/OffCanvasTest.php @@ -1,13 +1,13 @@ FALSE, 'drupalAutoButtons' => FALSE, 'buttons' => [], + 'dialogClass' => 'ui-dialog-off-canvas', 'width' => 300, ], 'effect' => 'fade', diff --git a/core/themes/stable/templates/content/off-canvas-page-wrapper.html.twig b/core/themes/stable/templates/content/off-canvas-page-wrapper.html.twig new file mode 100644 index 0000000000..a5ae4b6e18 --- /dev/null +++ b/core/themes/stable/templates/content/off-canvas-page-wrapper.html.twig @@ -0,0 +1,20 @@ +{# +/** + * @file + * Theme override for page wrapper. + * + * For consistent wrapping to {{ page }} render in all themes. The + * "data-off-canvas-main-canvas" attribute is required by the off-canvas dialog. + * It cannot be removed without breaking the off-canvas dialog functionality. + * + * Available variables: + * - children: Contains the child elements of the page. + * + * @ingroup themeable + */ +#} +{% if children %} +
+ {{ children }} +
+{% endif %}