diff --git a/core/modules/outside_in/css/outside_in.motion.css b/core/modules/outside_in/css/outside_in.motion.css index 3aedbcd..f322241 100644 --- a/core/modules/outside_in/css/outside_in.motion.css +++ b/core/modules/outside_in/css/outside_in.motion.css @@ -1,8 +1,12 @@ /** * @file - * Motion effects for outside-in module - * Motion effects are in a separate file so that they can be easily turned off to improve performance if desired. - * @todo move motion effects file into toolbar module and add a configuration option to performance to disable this file. + * Motion effects for outside-in module. + * + * Motion effects are in a separate file so that they can be easily turned off + * to improve performance if desired. + * + * @todo Move motion effects file into toolbar module and add a configuration + * option to performance to disable this file. */ /* Transition the offcanvas tray container, with 2s delay to match main canvas speed. */ diff --git a/core/modules/outside_in/js/offcanvas.js b/core/modules/outside_in/js/offcanvas.js index ed3bd20..5798077 100644 --- a/core/modules/outside_in/js/offcanvas.js +++ b/core/modules/outside_in/js/offcanvas.js @@ -4,6 +4,7 @@ */ (function ($, Drupal) { + 'use strict'; /** @@ -60,7 +61,7 @@ }).click(function () { pageWrapper .removeClass('js-tray-open') - .one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function (e) { + .one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function () { Drupal.offCanvas.visible = false; offCanvasWrapper.remove(); Drupal.announce(Drupal.t('Configuration tray closed.')); diff --git a/core/modules/outside_in/js/outside_in.js b/core/modules/outside_in/js/outside_in.js index 6d72247..a3e90a1 100644 --- a/core/modules/outside_in/js/outside_in.js +++ b/core/modules/outside_in/js/outside_in.js @@ -4,27 +4,27 @@ */ (function ($, Drupal) { + 'use strict'; // Bind a listener to the 'edit' button // Toggle the js-outside-edit-mode class on items that we want // to disable while in edit mode. - $('div.contextual-toolbar-tab.toolbar-tab button').click(function (e) { + $('div.contextual-toolbar-tab.toolbar-tab button').click(function () { setToggleActiveMode(); }); - // Bind an event listener to the .outside-in-editable div - // This listen for click events and stops default actions of those elements. - $('.outside-in-editable').on('click', '.js-outside-in-edit-mode', function (e) { - if (localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false') { - e.preventDefault(); - } - }); - - // Bind an event listener to the .outside-in-editable div - // When a click occurs try and find the outside-in edit link - // and click it. $('.outside-in-editable') + // Bind an event listener to the .outside-in-editable div + // This listen for click events and stops default actions of those elements. + .on('click', '.js-outside-in-edit-mode', function (e) { + if (localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false') { + e.preventDefault(); + } + }) + // Bind an event listener to the .outside-in-editable div + // When a click occurs try and find the outside-in edit link + // and click it. .not('div.contextual a, div.contextual button') .click(function (e) { if ($(e.target.offsetParent).hasClass('contextual')) { @@ -44,8 +44,8 @@ /** * Add Ajax behaviours to links added by contextual links * - * @todo Fix contextual links to work with use-ajax links. - * @see https://www.drupal.org/node/2764931 + * @todo Fix contextual links to work with use-ajax links in + * https://www.drupal.org/node/2764931. * * @param {jQuery.Event} event * The `drupalContextualLinkAdded` event. @@ -79,7 +79,7 @@ // Bind a listener to all 'Quick Edit' links for blocks // Click "Edit" button in toolbar to force Contextual Edit which starts // Outside In edit mode also. - data.$el.find('.outside-inblock-configure a').click(function (e) { + data.$el.find('.outside-inblock-configure a').click(function () { if (!isActiveMode()) { $('div.contextual-toolbar-tab.toolbar-tab button').click(); } @@ -128,7 +128,7 @@ * Attaches contextual toolbar behavior on a contextualToolbar-init event. */ Drupal.behaviors.outsideinedit = { - attach: function (context) { + attach: function () { var editMode = localStorage.getItem('Drupal.contextualToolbar.isViewing') === 'false'; if (editMode) { setToggleActiveMode(true); diff --git a/core/modules/outside_in/outside_in.module b/core/modules/outside_in/outside_in.module index 0d03d09..7a1d0b1 100644 --- a/core/modules/outside_in/outside_in.module +++ b/core/modules/outside_in/outside_in.module @@ -45,10 +45,9 @@ function outside_in_contextual_links_view_alter(&$element, $items) { /** * Implements hook_page_top(). - * - * Opens a div for consistent wrapping to all {{ page }} render in all themes. */ function outside_in_page_top(array &$page_top) { + // Opens a div for consistent wrapping to {{ page }} render in all themes. $page_top['outside_in_tray_open'] = [ '#markup' => '
', '#weight' => 1000, @@ -57,10 +56,9 @@ function outside_in_page_top(array &$page_top) { /** * Implements hook_page_bottom(). - * - * Closes a div for consistent wrapping to all {{ page }} render in all themes. */ function outside_in_page_bottom(array &$page_bottom) { + // Closes a div for consistent wrapping to {{ page }} render in all themes. $page_bottom['outside_in_tray_close'] = [ '#markup' => '
', '#weight' => -1000, @@ -79,15 +77,13 @@ function outside_in_entity_type_build(array &$entity_types) { /** * Implements hook_preprocess_HOOK() for block templates. - * - * Adds 'outside-in-editable' class to all blocks to allow Javascript to target. */ function outside_in_preprocess_block(&$variables) { // The main system block does not contain the block contextual links. - if (!_outside_in_apply_on_current_page() || $variables['plugin_id'] == 'system_main_block') { - return; + if (_outside_in_apply_on_current_page() && $variables['plugin_id'] !== 'system_main_block') { + // Add class to all blocks to allow Javascript to target. + $variables['attributes']['class'][] = 'outside-in-editable'; } - $variables['attributes']['class'][] = 'outside-in-editable'; } /** @@ -103,7 +99,6 @@ function _outside_in_apply_on_current_page() { // Remove on Block Demo page. $admin_demo = \Drupal::routeMatch()->getRouteName() === 'block.admin_demo'; return \Drupal::currentUser()->hasPermission('administer blocks') && !$admin_route && !$admin_demo; - } /** diff --git a/core/modules/outside_in/outside_in.services.yml b/core/modules/outside_in/outside_in.services.yml index 00b78cf..5cc1620 100644 --- a/core/modules/outside_in/outside_in.services.yml +++ b/core/modules/outside_in/outside_in.services.yml @@ -1,6 +1,6 @@ services: main_content_renderer.off_canvas: - class: Drupal\outside_in\Render\MainContent\OffCanvasRender - arguments: ['@title_resolver', '@renderer'] - tags: - - { name: render.main_content_renderer, format: drupal_offcanvas } + class: Drupal\outside_in\Render\MainContent\OffCanvasRender + arguments: ['@title_resolver', '@renderer'] + tags: + - { name: render.main_content_renderer, format: drupal_offcanvas } diff --git a/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php b/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php index ef6f272..1d0986d 100644 --- a/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php +++ b/core/modules/outside_in/src/Ajax/OpenOffCanvasDialogCommand.php @@ -14,8 +14,8 @@ class OpenOffCanvasDialogCommand extends OpenDialogCommand { /** * Constructs an OpenOffCanvasDialogCommand object. * - * Drupal provides a built-in offcanvas tray for - * this purpose, so no selector needs to be provided. + * Drupal provides a built-in offcanvas tray for this purpose, so no selector + * needs to be provided. * * @todo Do we need a selector? Or act the same as modal? * diff --git a/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php b/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php index f4e09dc..90005a0 100644 --- a/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php +++ b/core/modules/outside_in/src/Form/SystemMenuOffCanvasForm.php @@ -85,9 +85,11 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta '#open' => TRUE, ]; $form['entity_form'] += $this->getEntityForm($this->entity)->buildForm([], $form_state); + // Remove the label, ID, description, and buttons from the entity form. unset($form['entity_form']['label'], $form['entity_form']['id'], $form['entity_form']['description'], $form['entity_form']['actions']); - - $this->ensureFormState($form_state); + // Since the overview form is further nested than expected, update the + // #parents. See \Drupal\menu_ui\MenuForm::form(). + $form_state->set('menu_overview_form_parents', ['settings', 'entity_form', 'links']); return $form; } @@ -96,8 +98,6 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta * {@inheritdoc} */ public function validateConfigurationForm(array &$form, FormStateInterface $form_state) { - $this->ensureFormState($form_state); - $this->plugin->validateConfigurationForm($form, $form_state); $this->getEntityForm($this->entity)->validateForm($form, $form_state); } @@ -106,8 +106,6 @@ public function validateConfigurationForm(array &$form, FormStateInterface $form * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { - $this->ensureFormState($form_state); - $this->plugin->submitConfigurationForm($form, $form_state); $this->getEntityForm($this->entity)->submitForm($form, $form_state); $this->entity->save(); @@ -129,26 +127,6 @@ protected function getEntityForm(MenuInterface $entity) { } /** - * Ensures the form state is set up correctly. - * - * @todo Remove this once https://www.drupal.org/node/2537732 is fixed. - * - * @param \Drupal\Core\Form\FormStateInterface $form_state - * The current state of the form. - */ - protected function ensureFormState(FormStateInterface $form_state) { - // Prepare $form_state for \Drupal\menu_ui\MenuForm::submitOverviewForm(). - $input = &$form_state->getUserInput(); - if (is_null($input)) { - $input = []; - } - - if (!$this->entity->isNew() || $this->entity->isLocked()) { - $form_state->set('menu_overview_form_parents', ['settings', 'entity_form', 'links']); - } - } - - /** * {@inheritdoc} */ public function setPlugin(PluginInspectionInterface $plugin) { diff --git a/core/modules/outside_in/src/Render/MainContent/OffCanvasRender.php b/core/modules/outside_in/src/Render/MainContent/OffCanvasRender.php index 5202f40..87a761d 100644 --- a/core/modules/outside_in/src/Render/MainContent/OffCanvasRender.php +++ b/core/modules/outside_in/src/Render/MainContent/OffCanvasRender.php @@ -23,7 +23,7 @@ class OffCanvasRender extends DialogRenderer { protected $renderer; /** - * Constructs a new DialogRenderer. + * Constructs a new OffCanvasRender. * * @param \Drupal\Core\Controller\TitleResolverInterface $title_resolver * The title resolver. diff --git a/core/modules/outside_in/tests/modules/offcanvas_test/src/Controller/TestController.php b/core/modules/outside_in/tests/modules/offcanvas_test/src/Controller/TestController.php index 8bf28ad..6295f55 100644 --- a/core/modules/outside_in/tests/modules/offcanvas_test/src/Controller/TestController.php +++ b/core/modules/outside_in/tests/modules/offcanvas_test/src/Controller/TestController.php @@ -1,6 +1,7 @@ enableTheme($theme); $this->drupalGet('/offcanvas-test-links'); diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php index 8cc826b..7f74180 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInBlockFormTest.php @@ -8,17 +8,11 @@ * @group outside_in */ class OutsideInBlockFormTest extends OutsideInJavascriptTestBase { + /** * {@inheritdoc} */ - public static $modules = [ - 'block', - 'system', - 'breakpoint', - 'toolbar', - 'contextual', - 'outside_in', - ]; + public static $modules = ['block', 'system', 'breakpoint', 'toolbar', 'contextual', 'outside_in']; /** * {@inheritdoc} @@ -89,7 +83,7 @@ public function testBrandingBlock() { } /** - * Enable Editing mode by pressing "Edit" button in the toolbar. + * Enables Editing mode by pressing "Edit" button in the toolbar. */ protected function enableEditingMode() { $this->waitForElement('div[data-contextual-id="block:block=powered:langcode=en"] .contextual-links a'); diff --git a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php index dda013c..fecb28a 100644 --- a/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php +++ b/core/modules/outside_in/tests/src/FunctionalJavascript/OutsideInJavascriptTestBase.php @@ -2,7 +2,6 @@ namespace Drupal\Tests\outside_in\FunctionalJavascript; - use Drupal\FunctionalJavascriptTests\JavascriptTestBase; /** @@ -40,7 +39,7 @@ protected function waitForOffCanvasToClose() { } /** - * Wait for an element to appear on the page. + * Waits for an element to appear on the page. * * @param string $selector * CSS selector.