Current state
This commit is contained in:
97
public/legacy/assets/plugins/bootstrap-dropdown/bootstrap-hover-dropdown.js
vendored
Normal file
97
public/legacy/assets/plugins/bootstrap-dropdown/bootstrap-hover-dropdown.js
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* 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($, window, undefined) {
|
||||
// don't do anything if touch is supported
|
||||
// (plugin causes some issues on mobile)
|
||||
if('ontouchstart' in document) return;
|
||||
|
||||
// outside the scope of the jQuery plugin to
|
||||
// keep track of all dropdowns
|
||||
var $allDropdowns = $();
|
||||
|
||||
// if instantlyCloseOthers is true, then it will instantly
|
||||
// shut other nav items when a new one is hovered over
|
||||
$.fn.dropdownHover = function(options) {
|
||||
|
||||
// the element we really care about
|
||||
// is the dropdown-toggle's parent
|
||||
$allDropdowns = $allDropdowns.add(this.parent());
|
||||
|
||||
return this.each(function() {
|
||||
var $this = $(this),
|
||||
$parent = $this.parent(),
|
||||
defaults = {
|
||||
delay: 500,
|
||||
instantlyCloseOthers: true
|
||||
},
|
||||
data = {
|
||||
delay: $(this).data('delay'),
|
||||
instantlyCloseOthers: $(this).data('close-others')
|
||||
},
|
||||
settings = $.extend(true, {}, defaults, options, data),
|
||||
timeout;
|
||||
|
||||
$parent.hover(function(event) {
|
||||
// so a neighbor can't open the dropdown
|
||||
if(!$parent.hasClass('open') && !$this.is(event.target)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(settings.instantlyCloseOthers === true)
|
||||
$allDropdowns.removeClass('open');
|
||||
|
||||
window.clearTimeout(timeout);
|
||||
$parent.addClass('open');
|
||||
$parent.trigger($.Event('show.bs.dropdown'));
|
||||
}, function() {
|
||||
timeout = window.setTimeout(function() {
|
||||
$parent.removeClass('open');
|
||||
$parent.trigger('hide.bs.dropdown');
|
||||
}, settings.delay);
|
||||
});
|
||||
|
||||
// this helps with button groups!
|
||||
$this.hover(function() {
|
||||
if(settings.instantlyCloseOthers === true)
|
||||
$allDropdowns.removeClass('open');
|
||||
|
||||
window.clearTimeout(timeout);
|
||||
$parent.addClass('open');
|
||||
$parent.trigger($.Event('show.bs.dropdown'));
|
||||
});
|
||||
|
||||
// handle submenus
|
||||
$parent.find('.dropdown-submenu').each(function(){
|
||||
var $this = $(this);
|
||||
var subTimeout;
|
||||
$this.hover(function() {
|
||||
window.clearTimeout(subTimeout);
|
||||
$this.children('.dropdown-menu').show();
|
||||
// always close submenu siblings instantly
|
||||
$this.siblings().children('.dropdown-menu').hide();
|
||||
}, function() {
|
||||
var $submenu = $this.children('.dropdown-menu');
|
||||
subTimeout = window.setTimeout(function() {
|
||||
$submenu.hide();
|
||||
}, settings.delay);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
// apply dropdownHover to all elements with the data-hover="dropdown" attribute
|
||||
$('[data-hover="dropdown"]').dropdownHover();
|
||||
});
|
||||
})(jQuery, this);
|
||||
13
public/legacy/assets/plugins/bootstrap-dropdown/bootstrap-hover-dropdown.min.js
vendored
Normal file
13
public/legacy/assets/plugins/bootstrap-dropdown/bootstrap-hover-dropdown.min.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* 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){if("ontouchstart"in document)return;var r=e();e.fn.dropdownHover=function(n){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=e.extend(!0,{},o,n,u),f;s.hover(function(n){if(!s.hasClass("open")&&!i.is(n.target))return!0;a.instantlyCloseOthers===!0&&r.removeClass("open");t.clearTimeout(f);s.addClass("open");s.trigger(e.Event("show.bs.dropdown"))},function(){f=t.setTimeout(function(){s.removeClass("open");s.trigger("hide.bs.dropdown")},a.delay)});i.hover(function(){a.instantlyCloseOthers===!0&&r.removeClass("open");t.clearTimeout(f);s.addClass("open");s.trigger(e.Event("show.bs.dropdown"))});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()},a.delay)})})})};e(document).ready(function(){e('[data-hover="dropdown"]').dropdownHover()})})(jQuery,this);
|
||||
Reference in New Issue
Block a user