diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-20 11:29:26 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-20 11:29:26 +0100 |
commit | 238cd9f7f09f11ecdb1717a5d07fc33642d29043 (patch) | |
tree | 72eac94839bda4f32cb41441b2b88532eed52603 /theme/javascript/utils/dropdown.js | |
parent | bac25cdf297a7fa54f21977aa17d455e439cdf51 (diff) | |
download | gitbook-238cd9f7f09f11ecdb1717a5d07fc33642d29043.zip gitbook-238cd9f7f09f11ecdb1717a5d07fc33642d29043.tar.gz gitbook-238cd9f7f09f11ecdb1717a5d07fc33642d29043.tar.bz2 |
Add back theme
Diffstat (limited to 'theme/javascript/utils/dropdown.js')
-rw-r--r-- | theme/javascript/utils/dropdown.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/theme/javascript/utils/dropdown.js b/theme/javascript/utils/dropdown.js new file mode 100644 index 0000000..fe4e1f4 --- /dev/null +++ b/theme/javascript/utils/dropdown.js @@ -0,0 +1,27 @@ +define([ + "jQuery" +], function($) { + + var toggleDropdown = function(e) { + var $dropdown = $(e.currentTarget).parent().find(".dropdown-menu"); + + $dropdown.toggleClass("open"); + e.stopPropagation(); + e.preventDefault(); + }; + + var closeDropdown = function(e) { + $(".dropdown-menu").removeClass("open"); + }; + + // Bind all dropdown + var init = function() { + $(document).on('click', ".toggle-dropdown", toggleDropdown); + $(document).on('click', ".dropdown-menu", function(e){ e.stopPropagation(); }); + $(document).on("click", closeDropdown); + }; + + return { + init: init + }; +}); |