/[drupal]/drupal/modules/menu/menu.admin.js
ViewVC logotype

Contents of /drupal/modules/menu/menu.admin.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Tue Oct 13 01:25:58 2009 UTC (6 weeks, 3 days ago) by dries
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, HEAD
File MIME type: text/javascript
- Patch #351249 by stBorchert, coreyp_1, BrightLoudNoise, catch, kkaefer, sign: finer control over the Parent Menu select box.
1 // $Id$
2
3 (function ($) {
4
5 Drupal.behaviors.menuChangeParentItems = {
6 attach: function (context, settings) {
7 $('fieldset#edit-menu input').each(function () {
8 $(this).change(function () {
9 // Update list of available parent menu items.
10 Drupal.menu_update_parent_list();
11 });
12 });
13 }
14 }
15
16 /**
17 * Function to set the options of the menu parent item dropdown.
18 */
19 Drupal.menu_update_parent_list = function () {
20 var values = [];
21
22 $('input:checked', $('fieldset#edit-menu')).each(function () {
23 // Get the names of all checked menus.
24 values.push(Drupal.checkPlain($.trim($(this).val())));
25 });
26
27 var url = Drupal.settings.basePath + 'admin/structure/menu/parents';
28 $.ajax({
29 url: location.protocol + '//' + location.host + url,
30 type: 'POST',
31 data: {'menus[]' : values},
32 dataType: 'json',
33 success: function (options) {
34 // Save key of last selected element.
35 var selected = $('fieldset#edit-menu #edit-menu-parent :selected').val();
36 // Remove all exisiting options from dropdown.
37 $('fieldset#edit-menu #edit-menu-parent').children().remove();
38 // Add new options to dropdown.
39 jQuery.each(options, function(index, value) {
40 $('fieldset#edit-menu #edit-menu-parent').append(
41 $('<option ' + (index == selected ? ' selected="selected"' : '') + '></option>').val(index).text(value)
42 );
43 });
44 }
45 });
46 }
47
48 })(jQuery);

  ViewVC Help
Powered by ViewVC 1.1.2