More updates to stop using dev or alpha or beta versions.
[yaffs-website] / web / core / modules / menu_ui / menu_ui.admin.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.menuUiChangeParentItems = {
10     attach: function attach(context, settings) {
11       var $menu = $('#edit-menu').once('menu-parent');
12       if ($menu.length) {
13         Drupal.menuUiUpdateParentList();
14
15         $menu.on('change', 'input', Drupal.menuUiUpdateParentList);
16       }
17     }
18   };
19
20   Drupal.menuUiUpdateParentList = function () {
21     var $menu = $('#edit-menu');
22     var values = [];
23
24     $menu.find('input:checked').each(function () {
25       values.push(Drupal.checkPlain($.trim($(this).val())));
26     });
27
28     $.ajax({
29       url: location.protocol + '//' + location.host + Drupal.url('admin/structure/menu/parents'),
30       type: 'POST',
31       data: { 'menus[]': values },
32       dataType: 'json',
33       success: function success(options) {
34         var $select = $('#edit-menu-parent');
35
36         var selected = $select.val();
37
38         $select.children().remove();
39
40         var totalOptions = 0;
41         Object.keys(options || {}).forEach(function (machineName) {
42           $select.append($('<option ' + (machineName === selected ? ' selected="selected"' : '') + '></option>').val(machineName).text(options[machineName]));
43           totalOptions++;
44         });
45
46         $select.closest('div').toggle(totalOptions > 0).attr('hidden', totalOptions === 0);
47       }
48     });
49   };
50 })(jQuery, Drupal);