diff options
Diffstat (limited to 'data/assets/js/dropdown.js')
-rw-r--r-- | data/assets/js/dropdown.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/data/assets/js/dropdown.js b/data/assets/js/dropdown.js new file mode 100644 index 0000000..1ab5785 --- /dev/null +++ b/data/assets/js/dropdown.js @@ -0,0 +1,29 @@ +jQuery(function($) { + "use strict"; + + $('.guff-dropdown').on('click', 'a', function() { + var data = $(this).data(), + ul = $(this).parents('ul'), + is_default = (data.id == ul.data('default')); + + // update ui + ul.find('li').removeClass('active'); + $(this).parents('li').addClass('active'); + ul.prev('a') + .toggleClass('btn-default', is_default) + .toggleClass('btn-primary', !is_default) + .find('span').text(data.name); + + // hide dropdown + $('body').trigger('click'); + + // trigger choose + $(this).trigger({ + type: 'guff.choose', + item: $(this).data(), + }); + + // stop event + return false; + }); +}); |