diff -u b/core/modules/menu_link/js/menu_link.js /dev/null --- b/core/modules/menu_link/js/menu_link.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @file - * Menu UI behaviors. - */ - -(function ($, Drupal) { - - 'use strict'; - - /** - * Set a summary on the menu link form. - * - * @type {Drupal~behavior} - * - * @prop {Drupal~behaviorAttach} attach - * Find the form and call `drupalSetSummary` on it. - */ - Drupal.behaviors.menuLinkDetailsSummaries = { - attach: function (context) { - $(context).find('.menu-link-form').drupalSetSummary(function (context) { - var $context = $(context); - if ($context.find('.js-form-item-menu-enabled input').is(':checked')) { - return Drupal.checkPlain($context.find('.js-form-item-menu-title input').val()); - } - else { - return Drupal.t('Not in menu'); - } - }); - } - }; - - /** - * Automatically fill in a menu link title, if possible. - * - * @type {Drupal~behavior} - * - * @prop {Drupal~behaviorAttach} attach - * Attaches change and keyup behavior for automatically filling out menu - * link titles. - */ - Drupal.behaviors.menuLinkLinkAutomaticTitle = { - attach: function (context) { - var $context = $(context); - $context.find('.menu-link-form').each(function () { - var $this = $(this); - // Try to find menu settings widget elements as well as a 'title' field - // in the form, but play nicely with user permissions and form - // alterations. - var $checkbox = $this.find('.js-form-item-menu-enabled input'); - var $link_title = $context.find('.js-form-item-menu-title input'); - var $title = $this.closest('form').find('.js-form-item-title-0-value input'); - // Bail out if we do not have all required fields. - if (!($checkbox.length && $link_title.length && $title.length)) { - return; - } - // If there is a link title already, mark it as overridden. The user - // expects that toggling the checkbox twice will take over the node's - // title. - if ($checkbox.is(':checked') && $link_title.val().length) { - $link_title.data('menuLinkAutomaticTitleOverridden', true); - } - // Whenever the value is changed manually, disable this behavior. - $link_title.on('keyup', function () { - $link_title.data('menuLinkAutomaticTitleOverridden', true); - }); - // Global trigger on checkbox (do not fill-in a value when disabled). - $checkbox.on('change', function () { - if ($checkbox.is(':checked')) { - if (!$link_title.data('menuLinkAutomaticTitleOverridden')) { - $link_title.val($title.val()); - } - } - else { - $link_title.val(''); - $link_title.removeData('menuLinkAutomaticTitleOverridden'); - } - $checkbox.closest('.vertical-tabs-pane').trigger('summaryUpdated'); - $checkbox.trigger('formUpdated'); - }); - // Take over any title change. - $title.on('keyup', function () { - if (!$link_title.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) { - $link_title.val($title.val()); - $link_title.val($title.val()).trigger('formUpdated'); - } - }); - }); - } - }; - -})(jQuery, Drupal); diff -u b/core/modules/menu_link/src/Tests/MenuLinkFieldStandardTest.php b/core/modules/menu_link/src/Tests/MenuLinkFieldStandardTest.php --- b/core/modules/menu_link/src/Tests/MenuLinkFieldStandardTest.php +++ b/core/modules/menu_link/src/Tests/MenuLinkFieldStandardTest.php @@ -39,12 +39,12 @@ */ public function testLinkEdit() { // Ensure that the field_menu link got created. - $node = $this->drupalCreateNode(array( + $node = $this->drupalCreateNode([ 'type' => 'article', 'title' => 'Foobar', 'promote' => 1, 'status' => 1, - )); + ]); $this->drupalGet("node/{$node->id()}/edit"); $this->assertNoFieldChecked('edit-field-menu-0-enabled'); $title = $this->randomString(); diff -u b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php --- b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php @@ -187,7 +187,7 @@ $node2 = $this->drupalCreateNode([ 'type' => $type, 'title' => $title, - )); + ]); $node2->menu->title = 'Parent ' . $title; $node2->menu->description = ''; $node2->menu->menu_name = $menu; diff -u b/core/profiles/standard/tests/src/Functional/StandardTest.php b/core/profiles/standard/tests/src/Functional/StandardTest.php --- b/core/profiles/standard/tests/src/Functional/StandardTest.php +++ b/core/profiles/standard/tests/src/Functional/StandardTest.php @@ -103,12 +103,12 @@ $this->assertNoText('Then she picked out two somebodies, Sally and me'); // Ensure that the field_menu link got created. - $node = $this->drupalCreateNode(array( + $node = $this->drupalCreateNode([ 'type' => 'page', 'title' => 'Foobar', 'promote' => 1, 'status' => 1, - )); + ]); $this->drupalGet("node/{$node->id()}/edit"); $this->assertFieldById('edit-field-menu-0-enabled', FALSE); only in patch2: unchanged: --- /dev/null +++ b/core/modules/menu_link/js/menu_link.js @@ -0,0 +1,91 @@ +/** + * @file + * Menu UI behaviors. + */ + +(function ($, Drupal) { + + 'use strict'; + + /** + * Set a summary on the menu link form. + * + * @type {Drupal~behavior} + * + * @prop {Drupal~behaviorAttach} attach + * Find the form and call `drupalSetSummary` on it. + */ + Drupal.behaviors.menuLinkDetailsSummaries = { + attach: function (context) { + $(context).find('.menu-link-form').drupalSetSummary(function (context) { + var $context = $(context); + if ($context.find('.js-form-item-menu-enabled input').is(':checked')) { + return Drupal.checkPlain($context.find('.js-form-item-menu-title input').val()); + } + else { + return Drupal.t('Not in menu'); + } + }); + } + }; + + /** + * Automatically fill in a menu link title, if possible. + * + * @type {Drupal~behavior} + * + * @prop {Drupal~behaviorAttach} attach + * Attaches change and keyup behavior for automatically filling out menu + * link titles. + */ + Drupal.behaviors.menuLinkLinkAutomaticTitle = { + attach: function (context) { + var $context = $(context); + $context.find('.menu-link-form').each(function () { + var $this = $(this); + // Try to find menu settings widget elements as well as a 'title' field + // in the form, but play nicely with user permissions and form + // alterations. + var $checkbox = $this.find('.js-form-item-menu-enabled input'); + var $link_title = $context.find('.js-form-item-menu-title input'); + var $title = $this.closest('form').find('.js-form-item-title-0-value input'); + // Bail out if we do not have all required fields. + if (!($checkbox.length && $link_title.length && $title.length)) { + return; + } + // If there is a link title already, mark it as overridden. The user + // expects that toggling the checkbox twice will take over the node's + // title. + if ($checkbox.is(':checked') && $link_title.val().length) { + $link_title.data('menuLinkAutomaticTitleOverridden', true); + } + // Whenever the value is changed manually, disable this behavior. + $link_title.on('keyup', function () { + $link_title.data('menuLinkAutomaticTitleOverridden', true); + }); + // Global trigger on checkbox (do not fill-in a value when disabled). + $checkbox.on('change', function () { + if ($checkbox.is(':checked')) { + if (!$link_title.data('menuLinkAutomaticTitleOverridden')) { + $link_title.val($title.val()); + } + } + else { + $link_title.val(''); + $link_title.removeData('menuLinkAutomaticTitleOverridden'); + } + $checkbox.closest('.vertical-tabs-pane').trigger('summaryUpdated'); + $checkbox.trigger('formUpdated'); + }); + // Take over any title change. + $title.on('keyup', function () { + if (!$link_title.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) { + $link_title.val($title.val()); + $link_title.val($title.val()).trigger('formUpdated'); + } + }); + }); + } + }; + +})(jQuery, Drupal);