2015-06-05 20:17:55 +00:00
|
|
|
/**
|
2017-05-19 22:12:53 +00:00
|
|
|
* DO NOT EDIT THIS FILE.
|
|
|
|
* See the following change record for more information,
|
2017-05-23 14:30:14 +00:00
|
|
|
* https://www.drupal.org/node/2815083
|
2017-05-19 22:12:53 +00:00
|
|
|
* @preserve
|
|
|
|
**/
|
2015-06-05 20:17:55 +00:00
|
|
|
|
2016-02-29 03:25:57 +00:00
|
|
|
(function ($, Drupal) {
|
2014-04-13 19:04:02 +00:00
|
|
|
Drupal.behaviors.menuUiChangeParentItems = {
|
2021-12-18 06:12:16 +00:00
|
|
|
attach(context, settings) {
|
|
|
|
const menu = once('menu-parent', '#edit-menu');
|
2020-01-30 09:08:38 +00:00
|
|
|
|
2021-08-10 10:05:02 +00:00
|
|
|
if (menu.length) {
|
2021-12-18 06:12:16 +00:00
|
|
|
const $menu = $(menu);
|
2014-04-13 19:04:02 +00:00
|
|
|
Drupal.menuUiUpdateParentList();
|
|
|
|
$menu.on('change', 'input', Drupal.menuUiUpdateParentList);
|
2015-03-23 10:29:17 +00:00
|
|
|
}
|
2014-01-27 21:41:32 +00:00
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
};
|
2012-05-08 02:57:33 +00:00
|
|
|
|
2014-04-13 19:04:02 +00:00
|
|
|
Drupal.menuUiUpdateParentList = function () {
|
2021-12-18 06:12:16 +00:00
|
|
|
const $menu = $('#edit-menu');
|
|
|
|
const values = [];
|
2014-01-27 21:41:32 +00:00
|
|
|
$menu.find('input:checked').each(function () {
|
2021-10-12 19:17:13 +00:00
|
|
|
values.push(Drupal.checkPlain($(this).val()));
|
2014-01-06 16:47:16 +00:00
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
$.ajax({
|
2021-12-18 06:12:16 +00:00
|
|
|
url: `${window.location.protocol}//${window.location.host}${Drupal.url('admin/structure/menu/parents')}`,
|
2014-01-27 21:41:32 +00:00
|
|
|
type: 'POST',
|
2020-01-30 09:08:38 +00:00
|
|
|
data: {
|
|
|
|
'menus[]': values
|
|
|
|
},
|
2014-01-27 21:41:32 +00:00
|
|
|
dataType: 'json',
|
2021-12-18 06:12:16 +00:00
|
|
|
|
|
|
|
success(options) {
|
|
|
|
const $select = $('#edit-menu-parent');
|
|
|
|
const selected = $select.val();
|
2014-01-27 21:41:32 +00:00
|
|
|
$select.children().remove();
|
2021-12-18 06:12:16 +00:00
|
|
|
let totalOptions = 0;
|
|
|
|
Object.keys(options || {}).forEach(machineName => {
|
|
|
|
$select.append($(`<option ${machineName === selected ? ' selected="selected"' : ''}></option>`).val(machineName).text(options[machineName]));
|
2018-01-03 23:25:46 +00:00
|
|
|
totalOptions++;
|
|
|
|
});
|
2014-01-27 21:41:32 +00:00
|
|
|
$select.closest('div').toggle(totalOptions > 0).attr('hidden', totalOptions === 0);
|
|
|
|
}
|
2021-12-18 06:12:16 +00:00
|
|
|
|
2014-01-27 21:41:32 +00:00
|
|
|
});
|
|
|
|
};
|
2017-05-19 22:12:53 +00:00
|
|
|
})(jQuery, Drupal);
|