menu-block.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. (function ($) {
  2. Drupal.behaviors.menu_block = {
  3. attach: function (context, settings) {
  4. // This behavior attaches by ID, so is only valid once on a page.
  5. if ($('#menu-block-settings.menu-block-processed').size()) {
  6. return;
  7. }
  8. $('#menu-block-settings', context).addClass('menu-block-processed');
  9. // Show the "display options" if javascript is on.
  10. $('.form-item-display-options.form-type-radios>label', context).addClass('element-invisible');
  11. $('.form-item-display-options.form-type-radios', context).show();
  12. // Make the radio set into a jQuery UI buttonset.
  13. $('#edit-display-options', context).buttonset();
  14. // Override the default show/hide animation for Form API states.
  15. $('#menu-block-settings', context).bind('state:visible', function(e) {
  16. if (e.trigger) {
  17. e.stopPropagation() /* Stop the handler further up the tree. */
  18. $(e.target).closest('.form-item, .form-wrapper')[e.value ? 'slideDown' : 'slideUp']('fast');
  19. }
  20. });
  21. // Syncronize the display of menu and parent item selects.
  22. $('.menu-block-parent-mlid', context).change( function() {
  23. var menuItem = $(this).val().split(':');
  24. $('.menu-block-menu-name').val(menuItem[0]);
  25. });
  26. $('.menu-block-menu-name', context).change( function() {
  27. $('.menu-block-parent-mlid').val($(this).val() + ':0');
  28. });
  29. }
  30. };
  31. })(jQuery);