/** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function ($, Drupal) { Drupal.behaviors.menuUiDetailsSummaries = { 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()); } return Drupal.t('Not in menu'); }); } }; Drupal.behaviors.menuUiLinkAutomaticTitle = { attach: function attach(context) { var $context = $(context); $context.find('.menu-link-form').each(function () { var $this = $(this); var $checkbox = $this.find('.js-form-item-menu-enabled input'); var $linkTitle = $context.find('.js-form-item-menu-title input'); var $title = $this.closest('form').find('.js-form-item-title-0-value input'); if (!($checkbox.length && $linkTitle.length && $title.length)) { return; } if ($checkbox.is(':checked') && $linkTitle.val().length) { $linkTitle.data('menuLinkAutomaticTitleOverridden', true); } $linkTitle.on('keyup', function () { $linkTitle.data('menuLinkAutomaticTitleOverridden', true); }); $checkbox.on('change', function () { if ($checkbox.is(':checked')) { if (!$linkTitle.data('menuLinkAutomaticTitleOverridden')) { $linkTitle.val($title.val()); } } else { $linkTitle.val(''); $linkTitle.removeData('menuLinkAutomaticTitleOverridden'); } $checkbox.closest('.vertical-tabs-pane').trigger('summaryUpdated'); $checkbox.trigger('formUpdated'); }); $title.on('keyup', function () { if (!$linkTitle.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) { $linkTitle.val($title.val()); $linkTitle.val($title.val()).trigger('formUpdated'); } }); }); } }; })(jQuery, Drupal);