From e3628d797d3bdc3593370b925e8ee6a5bd0622ee Mon Sep 17 00:00:00 2001 From: Raimund Meyer Date: Thu, 20 Mar 2014 10:39:25 +0100 Subject: [PATCH] Blur potentially focussed menu entries, to clear "sticky" CSS for :focus --- bootstrap-hover-dropdown.js | 4 ++++ bootstrap-hover-dropdown.min.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bootstrap-hover-dropdown.js b/bootstrap-hover-dropdown.js index 31fa7f6..2cc0bd7 100644 --- a/bootstrap-hover-dropdown.js +++ b/bootstrap-hover-dropdown.js @@ -53,6 +53,8 @@ return true; } + $allDropdowns.find(':focus').blur(); + if(settings.instantlyCloseOthers === true) $allDropdowns.removeClass('open'); @@ -68,6 +70,8 @@ // this helps with button groups! $this.hover(function () { + $allDropdowns.find(':focus').blur(); + if(settings.instantlyCloseOthers === true) $allDropdowns.removeClass('open'); diff --git a/bootstrap-hover-dropdown.min.js b/bootstrap-hover-dropdown.min.js index 8d13d6e..0bf4687 100644 --- a/bootstrap-hover-dropdown.min.js +++ b/bootstrap-hover-dropdown.min.js @@ -10,4 +10,4 @@ * License: MIT * * http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/ - */(function(e,t,n){var r=e();e.fn.dropdownHover=function(n){if("ontouchstart"in document)return this;r=r.add(this.parent());return this.each(function(){var i=e(this),s=i.parent(),o={delay:500,instantlyCloseOthers:!0},u={delay:e(this).data("delay"),instantlyCloseOthers:e(this).data("close-others")},a="show.bs.dropdown",f="hide.bs.dropdown",l=e.extend(!0,{},o,n,u),c;s.hover(function(e){if(!s.hasClass("open")&&!i.is(e.target))return!0;l.instantlyCloseOthers===!0&&r.removeClass("open");t.clearTimeout(c);s.addClass("open");i.trigger(a)},function(){c=t.setTimeout(function(){s.removeClass("open");i.trigger(f)},l.delay)});i.hover(function(){l.instantlyCloseOthers===!0&&r.removeClass("open");t.clearTimeout(c);s.addClass("open");i.trigger(a)});s.find(".dropdown-submenu").each(function(){var n=e(this),r;n.hover(function(){t.clearTimeout(r);n.children(".dropdown-menu").show();n.siblings().children(".dropdown-menu").hide()},function(){var e=n.children(".dropdown-menu");r=t.setTimeout(function(){e.hide()},l.delay)})})})};e(document).ready(function(){e('[data-hover="dropdown"]').dropdownHover()})})(jQuery,this); \ No newline at end of file + */(function(b,a,c){var d=b();b.fn.dropdownHover=function(e){if("ontouchstart" in document){return this}d=d.add(this.parent());return this.each(function(){var m=b(this),l=m.parent(),k={delay:500,instantlyCloseOthers:true},i={delay:b(this).data("delay"),instantlyCloseOthers:b(this).data("close-others")},f="show.bs.dropdown",j="hide.bs.dropdown",g=b.extend(true,{},k,e,i),h;l.hover(function(n){if(!l.hasClass("open")&&!m.is(n.target)){return true}d.find(":focus").blur();if(g.instantlyCloseOthers===true){d.removeClass("open")}a.clearTimeout(h);l.addClass("open");m.trigger(f)},function(){h=a.setTimeout(function(){l.removeClass("open");m.trigger(j)},g.delay)});m.hover(function(){d.find(":focus").blur();if(g.instantlyCloseOthers===true){d.removeClass("open")}a.clearTimeout(h);l.addClass("open");m.trigger(f)});l.find(".dropdown-submenu").each(function(){var o=b(this);var n;o.hover(function(){a.clearTimeout(n);o.children(".dropdown-menu").show();o.siblings().children(".dropdown-menu").hide()},function(){var p=o.children(".dropdown-menu");n=a.setTimeout(function(){p.hide()},g.delay)})})})};b(document).ready(function(){b('[data-hover="dropdown"]').dropdownHover()})})(jQuery,this); \ No newline at end of file