X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fmenu_ui%2Fmenu_ui.js;h=b251b6e450f78ecb9bf12edd71b2a638b1f0f684;hb=9424afc6c1f518c301bf87a23c047d1873435d05;hp=5eb10e0781c8f0fb605f3730f5e33b62a75752b4;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/menu_ui/menu_ui.js b/web/core/modules/menu_ui/menu_ui.js index 5eb10e078..b251b6e45 100644 --- a/web/core/modules/menu_ui/menu_ui.js +++ b/web/core/modules/menu_ui/menu_ui.js @@ -1,91 +1,66 @@ /** - * @file - * Menu UI behaviors. - */ +* DO NOT EDIT THIS FILE. +* See the following change record for more information, +* https://www.drupal.org/node/2815083 +* @preserve +**/ (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.menuUiDetailsSummaries = { - attach: function (context) { + attach: function attach(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'); - } + + 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.menuUiLinkAutomaticTitle = { - attach: function (context) { + attach: function attach(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 $linkTitle = $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)) { + + if (!($checkbox.length && $linkTitle.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); + + if ($checkbox.is(':checked') && $linkTitle.val().length) { + $linkTitle.data('menuLinkAutomaticTitleOverridden', true); } - // Whenever the value is changed manually, disable this behavior. - $link_title.on('keyup', function () { - $link_title.data('menuLinkAutomaticTitleOverridden', true); + + $linkTitle.on('keyup', function () { + $linkTitle.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()); + if (!$linkTitle.data('menuLinkAutomaticTitleOverridden')) { + $linkTitle.val($title.val()); } - } - else { - $link_title.val(''); - $link_title.removeData('menuLinkAutomaticTitleOverridden'); + } else { + $linkTitle.val(''); + $linkTitle.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'); + if (!$linkTitle.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) { + $linkTitle.val($title.val()); + $linkTitle.val($title.val()).trigger('formUpdated'); } }); }); } }; - -})(jQuery, Drupal); +})(jQuery, Drupal); \ No newline at end of file