blob: 2390fd9fb8528b62ab7912a93adaf0f169533770 (
plain)
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
28
29
30
31
32
33
34
35
36
|
function Dropdown() {
}
Dropdown.prototype.listen = function() {
var self = this;
$(document).on('click', function() {
self.close();
});
$(document).on('click', '.dropdown-menu', function(e) {
e.preventDefault();
e.stopImmediatePropagation();
var submenu = $(this).next('ul');
var submenuHeight = 240;
if (! submenu.is(':visible')) {
self.close();
if ($(this).offset().top + submenuHeight > $(window).height()) {
submenu.addClass('dropdown-submenu-open dropdown-submenu-top');
}
else {
submenu.addClass('dropdown-submenu-open');
}
}
else {
self.close();
}
});
};
Dropdown.prototype.close = function() {
$('.dropdown-submenu-open').removeClass('dropdown-submenu-open');
};
|