vendor/assets/javascripts/hoverdown.js in flashgrid-2.0.0 vs vendor/assets/javascripts/hoverdown.js in flashgrid-2.0.1

- old
+ new

@@ -38,35 +38,29 @@ // stop this event, stop executing any code // in this callback but continue to propagate return true; } - $allDropdowns.find(':focus').blur(); - - if(settings.instantlyCloseOthers === true) - $allDropdowns.removeClass('open'); - - window.clearTimeout(timeout); - $parent.addClass('open'); - $this.trigger(showEvent); + openDropdown(event); }, function () { timeout = window.setTimeout(function () { $parent.removeClass('open'); $this.trigger(hideEvent); }, settings.delay); }); // this helps with button groups! - $this.hover(function () { - $allDropdowns.find(':focus').blur(); + $this.hover(function (event) { + // this helps prevent a double event from firing. + // see https://github.com/CWSpear/bootstrap-hover-dropdown/issues/55 + if(!$parent.hasClass('open') && !$parent.is(event.target)) { + // stop this event, stop executing any code + // in this callback but continue to propagate + return true; + } - if(settings.instantlyCloseOthers === true) - $allDropdowns.removeClass('open'); - - window.clearTimeout(timeout); - $parent.addClass('open'); - $this.trigger(showEvent); + openDropdown(event); }); // handle submenus $parent.find('.dropdown-submenu').each(function (){ var $this = $(this); @@ -81,9 +75,20 @@ subTimeout = window.setTimeout(function () { $submenu.hide(); }, settings.delay); }); }); + + function openDropdown(event) { + $allDropdowns.find(':focus').blur(); + + if(settings.instantlyCloseOthers === true) + $allDropdowns.removeClass('open'); + + window.clearTimeout(timeout); + $parent.addClass('open'); + $this.trigger(showEvent); + } }); }; $(document).ready(function () { // apply dropdownHover to all elements with the data-hover="dropdown" attribute \ No newline at end of file