1
|
(function ($) {
|
2
|
|
3
|
Drupal.behaviors.menuChangeParentItems = {
|
4
|
attach: function (context, settings) {
|
5
|
$('fieldset#edit-menu input').each(function () {
|
6
|
$(this).change(function () {
|
7
|
|
8
|
Drupal.menu_update_parent_list();
|
9
|
});
|
10
|
});
|
11
|
}
|
12
|
};
|
13
|
|
14
|
|
15
|
|
16
|
|
17
|
Drupal.menu_update_parent_list = function () {
|
18
|
var values = [];
|
19
|
|
20
|
$('input:checked', $('fieldset#edit-menu')).each(function () {
|
21
|
|
22
|
values.push(Drupal.checkPlain($.trim($(this).val())));
|
23
|
});
|
24
|
|
25
|
var url = Drupal.settings.basePath + 'admin/structure/menu/parents';
|
26
|
$.ajax({
|
27
|
url: location.protocol + '//' + location.host + url,
|
28
|
type: 'POST',
|
29
|
data: {'menus[]' : values},
|
30
|
dataType: 'json',
|
31
|
success: function (options) {
|
32
|
|
33
|
var selected = $('fieldset#edit-menu #edit-menu-parent :selected').val();
|
34
|
|
35
|
$('fieldset#edit-menu #edit-menu-parent').children().remove();
|
36
|
|
37
|
jQuery.each(options, function(index, value) {
|
38
|
$('fieldset#edit-menu #edit-menu-parent').append(
|
39
|
$('<option ' + (index == selected ? ' selected="selected"' : '') + '></option>').val(index).text(value)
|
40
|
);
|
41
|
});
|
42
|
}
|
43
|
});
|
44
|
};
|
45
|
|
46
|
})(jQuery);
|