forked from GitbookIO/gitbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdropdown.js
More file actions
27 lines (22 loc) · 664 Bytes
/
Copy pathdropdown.js
File metadata and controls
27 lines (22 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
};
});