/** * project: bootstrap hover dropdown * author: cameron spear * contributors: mattia larentis * * dependencies: bootstrap's dropdown plugin, jquery * * a simple plugin to enable bootstrap dropdowns to active on hover and provide a nice user experience. * * 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(){function h(e){r.find(":focus").blur();l.instantlycloseothers===!0&&r.removeclass("open");t.cleartimeout(c);s.addclass("open");i.trigger(a)}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;h(e)},function(){c=t.settimeout(function(){s.removeclass("open");i.trigger(f)},l.delay)});i.hover(function(e){if(!s.hasclass("open")&&!s.is(e.target))return!0;h(e)});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);