X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmenu_ui%2Fmenu_ui.admin.js;fp=web%2Fcore%2Fmodules%2Fmenu_ui%2Fmenu_ui.admin.js;h=324b567a07e51f59905a846ed68e93a02354e6ba;hp=345138f17a47c5ee1e25fba87d0f806b3ee920f1;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/menu_ui/menu_ui.admin.js b/web/core/modules/menu_ui/menu_ui.admin.js index 345138f17..324b567a0 100644 --- a/web/core/modules/menu_ui/menu_ui.admin.js +++ b/web/core/modules/menu_ui/menu_ui.admin.js @@ -1,68 +1,52 @@ /** - * @file - * Menu UI admin 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'; - - /** - * - * @type {Drupal~behavior} - */ Drupal.behaviors.menuUiChangeParentItems = { - attach: function (context, settings) { + attach: function attach(context, settings) { var $menu = $('#edit-menu').once('menu-parent'); if ($menu.length) { - // Update the list of available parent menu items to match the initial - // available menus. Drupal.menuUiUpdateParentList(); - // Update list of available parent menu items. $menu.on('change', 'input', Drupal.menuUiUpdateParentList); } } }; - /** - * Function to set the options of the menu parent item dropdown. - */ Drupal.menuUiUpdateParentList = function () { var $menu = $('#edit-menu'); var values = []; $menu.find('input:checked').each(function () { - // Get the names of all checked menus. values.push(Drupal.checkPlain($.trim($(this).val()))); }); $.ajax({ url: location.protocol + '//' + location.host + Drupal.url('admin/structure/menu/parents'), type: 'POST', - data: {'menus[]': values}, + data: { 'menus[]': values }, dataType: 'json', - success: function (options) { + success: function success(options) { var $select = $('#edit-menu-parent'); - // Save key of last selected element. + var selected = $select.val(); - // Remove all existing options from dropdown. + $select.children().remove(); - // Add new options to dropdown. Keep a count of options for testing later. + var totalOptions = 0; for (var machineName in options) { if (options.hasOwnProperty(machineName)) { - $select.append( - $('').val(machineName).text(options[machineName]) - ); + $select.append($('').val(machineName).text(options[machineName])); totalOptions++; } } - // Hide the parent options if there are no options for it. $select.closest('div').toggle(totalOptions > 0).attr('hidden', totalOptions === 0); } }); }; - -})(jQuery, Drupal); +})(jQuery, Drupal); \ No newline at end of file