fe0feed9aabbf8944098cce3098b300d6f4eaef8
[yaffs-website] / web / core / modules / menu_ui / menu_ui.js
1 /**
2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
5 * @preserve
6 **/
7
8 (function ($, Drupal) {
9   Drupal.behaviors.menuUiDetailsSummaries = {
10     attach: function attach(context) {
11       $(context).find('.menu-link-form').drupalSetSummary(function (context) {
12         var $context = $(context);
13         if ($context.find('.js-form-item-menu-enabled input').is(':checked')) {
14           return Drupal.checkPlain($context.find('.js-form-item-menu-title input').val());
15         }
16
17         return Drupal.t('Not in menu');
18       });
19     }
20   };
21
22   Drupal.behaviors.menuUiLinkAutomaticTitle = {
23     attach: function attach(context) {
24       var $context = $(context);
25       $context.find('.menu-link-form').each(function () {
26         var $this = $(this);
27
28         var $checkbox = $this.find('.js-form-item-menu-enabled input');
29         var $link_title = $context.find('.js-form-item-menu-title input');
30         var $title = $this.closest('form').find('.js-form-item-title-0-value input');
31
32         if (!($checkbox.length && $link_title.length && $title.length)) {
33           return;
34         }
35
36         if ($checkbox.is(':checked') && $link_title.val().length) {
37           $link_title.data('menuLinkAutomaticTitleOverridden', true);
38         }
39
40         $link_title.on('keyup', function () {
41           $link_title.data('menuLinkAutomaticTitleOverridden', true);
42         });
43
44         $checkbox.on('change', function () {
45           if ($checkbox.is(':checked')) {
46             if (!$link_title.data('menuLinkAutomaticTitleOverridden')) {
47               $link_title.val($title.val());
48             }
49           } else {
50             $link_title.val('');
51             $link_title.removeData('menuLinkAutomaticTitleOverridden');
52           }
53           $checkbox.closest('.vertical-tabs-pane').trigger('summaryUpdated');
54           $checkbox.trigger('formUpdated');
55         });
56
57         $title.on('keyup', function () {
58           if (!$link_title.data('menuLinkAutomaticTitleOverridden') && $checkbox.is(':checked')) {
59             $link_title.val($title.val());
60             $link_title.val($title.val()).trigger('formUpdated');
61           }
62         });
63       });
64     }
65   };
66 })(jQuery, Drupal);