jump-menu.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. (function($) {
  2. Drupal.behaviors.CToolsJumpMenu = {
  3. attach: function(context) {
  4. $('.ctools-jump-menu-hide')
  5. .once('ctools-jump-menu')
  6. .hide();
  7. $('.ctools-jump-menu-change')
  8. .once('ctools-jump-menu')
  9. .change(function() {
  10. var loc = $(this).val();
  11. var urlArray = loc.split('::');
  12. if (urlArray[1]) {
  13. location.href = urlArray[1];
  14. }
  15. else {
  16. location.href = loc;
  17. }
  18. return false;
  19. });
  20. $('.ctools-jump-menu-button')
  21. .once('ctools-jump-menu')
  22. .click(function() {
  23. // Instead of submitting the form, just perform the redirect.
  24. // Find our sibling value.
  25. var $select = $(this).parents('form').find('.ctools-jump-menu-select');
  26. var loc = $select.val();
  27. var urlArray = loc.split('::');
  28. if (urlArray[1]) {
  29. location.href = urlArray[1];
  30. }
  31. else {
  32. location.href = loc;
  33. }
  34. return false;
  35. });
  36. }
  37. }
  38. })(jQuery);