Skip to content

Commit d0320cb

Browse files
committed
changed from variable to .navbar-toggle visibility
Instead of having a variable for nav breakpoint we now check if .navbar-toggle is visible. We also have added the check to the close on mouseout, so the menu doesn't close when we hover outside the submenu. Made a function isCollapsed so we can have our logic in one place.
1 parent 60b5392 commit d0320cb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bootstrap-hover-dropdown.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
$parent = $this.parent(),
3131
defaults = {
3232
delay: 500,
33-
instantlyCloseOthers: true,
34-
navBreakpoint: 768
33+
instantlyCloseOthers: true
3534
},
3635
data = {
3736
delay: $(this).data('delay'),
@@ -54,6 +53,7 @@
5453

5554
openDropdown(event);
5655
}, function () {
56+
if ( isCollapsed ){ return; }
5757
timeout = window.setTimeout(function () {
5858
$parent.removeClass('open');
5959
$this.trigger(hideEvent);
@@ -91,9 +91,7 @@
9191
});
9292

9393
function openDropdown(event) {
94-
if ( ($( window ).width() < settings.navBreakpoint ) && ($this.parents('.navbar-collapse').length) ){//prevent acting on navbar in collapsed mode
95-
return;
96-
}
94+
if ( isCollapsed ){ return; }
9795

9896
$allDropdowns.find(':focus').blur();
9997

@@ -104,6 +102,12 @@
104102
$parent.addClass('open');
105103
$this.trigger(showEvent);
106104
}
105+
106+
function isCollapsed() {
107+
if ( ($(".navbar-toggle").filter(":visible").length ) && ($this.parents('.navbar-collapse').length) ){//prevent acting on navbar in collapsed mode
108+
return true;
109+
}
110+
}
107111
});
108112
};
109113

0 commit comments

Comments
 (0)