summaryrefslogtreecommitdiff
path: root/modules/menu/menu.admin.js
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2009-10-13 01:25:58 +0000
committerDries Buytaert <dries@buytaert.net>2009-10-13 01:25:58 +0000
commitcad226e60bc5827050789d4900f1a17907c203d3 (patch)
treefacb3b7ea206edfde50ae3da478ddf66048ce44a /modules/menu/menu.admin.js
parent6cd77937db8001bbdca42982515ded9c359aa83b (diff)
downloadbrdo-cad226e60bc5827050789d4900f1a17907c203d3.tar.gz
brdo-cad226e60bc5827050789d4900f1a17907c203d3.tar.bz2
- Patch #351249 by stBorchert, coreyp_1, BrightLoudNoise, catch, kkaefer, sign: finer control over the Parent Menu select box.
Diffstat (limited to 'modules/menu/menu.admin.js')
-rw-r--r--modules/menu/menu.admin.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/modules/menu/menu.admin.js b/modules/menu/menu.admin.js
new file mode 100644
index 000000000..681c4814d
--- /dev/null
+++ b/modules/menu/menu.admin.js
@@ -0,0 +1,48 @@
+// $Id$
+
+(function ($) {
+
+ Drupal.behaviors.menuChangeParentItems = {
+ attach: function (context, settings) {
+ $('fieldset#edit-menu input').each(function () {
+ $(this).change(function () {
+ // Update list of available parent menu items.
+ Drupal.menu_update_parent_list();
+ });
+ });
+ }
+ }
+
+ /**
+ * Function to set the options of the menu parent item dropdown.
+ */
+ Drupal.menu_update_parent_list = function () {
+ var values = [];
+
+ $('input:checked', $('fieldset#edit-menu')).each(function () {
+ // Get the names of all checked menus.
+ values.push(Drupal.checkPlain($.trim($(this).val())));
+ });
+
+ var url = Drupal.settings.basePath + 'admin/structure/menu/parents';
+ $.ajax({
+ url: location.protocol + '//' + location.host + url,
+ type: 'POST',
+ data: {'menus[]' : values},
+ dataType: 'json',
+ success: function (options) {
+ // Save key of last selected element.
+ var selected = $('fieldset#edit-menu #edit-menu-parent :selected').val();
+ // Remove all exisiting options from dropdown.
+ $('fieldset#edit-menu #edit-menu-parent').children().remove();
+ // Add new options to dropdown.
+ jQuery.each(options, function(index, value) {
+ $('fieldset#edit-menu #edit-menu-parent').append(
+ $('<option ' + (index == selected ? ' selected="selected"' : '') + '></option>').val(index).text(value)
+ );
+ });
+ }
+ });
+ }
+
+})(jQuery);