Mercurial > hg > rr-repo
diff sites/all/modules/ctools/js/jump-menu.js @ 0:ff03f76ab3fe
initial version
author | danieleb <danielebarchiesi@me.com> |
---|---|
date | Wed, 21 Aug 2013 18:51:11 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/all/modules/ctools/js/jump-menu.js Wed Aug 21 18:51:11 2013 +0100 @@ -0,0 +1,42 @@ + +(function($) { + Drupal.behaviors.CToolsJumpMenu = { + attach: function(context) { + $('.ctools-jump-menu-hide') + .once('ctools-jump-menu') + .hide(); + + $('.ctools-jump-menu-change') + .once('ctools-jump-menu') + .change(function() { + var loc = $(this).val(); + var urlArray = loc.split('::'); + if (urlArray[1]) { + location.href = urlArray[1]; + } + else { + location.href = loc; + } + return false; + }); + + $('.ctools-jump-menu-button') + .once('ctools-jump-menu') + .click(function() { + // Instead of submitting the form, just perform the redirect. + + // Find our sibling value. + var $select = $(this).parents('form').find('.ctools-jump-menu-select'); + var loc = $select.val(); + var urlArray = loc.split('::'); + if (urlArray[1]) { + location.href = urlArray[1]; + } + else { + location.href = loc; + } + return false; + }); + } + } +})(jQuery);