vendor: 5,509 bytes, lines 1-133
1/** 2 * @preserve 3 * Project: Bootstrap Hover Dropdown 4 * Author: Cameron Spear 5 * Version: v2.2.1 6 * Contributors: Mattia Larentis 7 * Dependencies: Bootstrap's Dropdown plugin, jQuery 8 * Description: A simple plugin to enable Bootstrap dropdowns to active on hover and provide a nice user experience. 9 * License: MIT 10 * Homepage: http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/ 11 */ 12;(function ($, window, undefined) { 13 // outside the scope of the jQuery plugin to 14 // keep track of all dropdowns 15 var $allDropdowns = $(); 16 17 // if instantlyCloseOthers is true, then it will instantly 18 // shut other nav items when a new one is hovered over 19 $.fn.dropdownHover = function (options) { 20 // don't do anything if touch is supported 21 // (plugin causes some issues on mobile) 22 if('ontouchstart' in document) return this; // don't want to affect chaining 23 24 // the element we really care about 25 // is the dropdown-toggle's parent 26 $allDropdowns = $allDropdowns.add(this.parent()); 27 28 return this.each(function () { 29 var $this = $(this), 30 $parent = $this.parent(), 31 $ddm = $parent.find('.dropdown-menu'), 32 defaults = { 33 delay: 500, 34 hoverDelay: 0, 35 instantlyCloseOthers: true 36 }, 37 data = { 38 delay: $(this).data('delay'), 39 hoverDelay: $(this).data('hover-delay'), 40 instantlyCloseOthers: $(this).data('close-others') 41 }, 42 showEvent = 'show.bs.dropdown', 43 hideEvent = 'hide.bs.dropdown', 44 // shownEvent = 'shown.bs.dropdown', 45 // hiddenEvent = 'hidden.bs.dropdown', 46 settings = $.extend(true, {}, defaults, options, data), 47 timeout, timeoutHover; 48 49 $parent.hover(function (event) { 50 // so a neighbor can't show the dropdown 51 if(!$parent.hasClass('show') && !$this.is(event.target)) { 52 // stop this event, stop executing any code 53 // in this callback but continue to propagate 54 return true; 55 } 56 57 showDropdown(event); 58 }, function () { 59 // clear timer for hover event 60 window.clearTimeout(timeoutHover) 61 timeout = window.setTimeout(function () { 62 $this.attr('aria-expanded', 'false'); 63 $parent.removeClass('show'); 64 $ddm.removeClass('show'); 65 $this.trigger(hideEvent); 66 }, settings.delay); 67 }); 68 69 // this helps with button groups! 70 $this.hover(function (event) { 71 // this helps prevent a double event from firing. 72 // see https://github.com/CWSpear/bootstrap-hover-dropdown/issues/55 73 if(!$parent.hasClass('show') && !$parent.is(event.target)) { 74 // stop this event, stop executing any code 75 // in this callback but continue to propagate 76 return true; 77 } 78 79 showDropdown(event); 80 }); 81 82 // handle submenus 83 $parent.find('.dropdown-submenu').each(function (){ 84 var $this = $(this); 85 var subTimeout; 86 $this.hover(function () { 87 window.clearTimeout(subTimeout); 88 $this.children('.dropdown-menu').show(); 89 // always close submenu siblings instantly 90 $this.siblings().children('.dropdown-menu').hide(); 91 }, function () { 92 var $submenu = $this.children('.dropdown-menu'); 93 subTimeout = window.setTimeout(function () { 94 $submenu.hide(); 95 }, settings.delay); 96 }); 97 }); 98 99 function showDropdown(event) { 100 if($this.parents(".navbar").find(".navbar-toggle").is(":visible")) { 101 // If we're inside a navbar, don't do anything when the 102 // navbar is collapsed, as it makes the navbar pretty unusable. 103 return; 104 } 105 106 // clear dropdown timeout here so it doesnt close before it should 107 window.clearTimeout(timeout); 108 // restart hover timer 109 window.clearTimeout(timeoutHover); 110 111 // delay for hover event. 112 timeoutHover = window.setTimeout(function () { 113 $allDropdowns.find(':focus').blur(); 114 115 if(settings.instantlyCloseOthers === true) 116 $allDropdowns.removeClass('show'); 117 118 // clear timer for hover event 119 window.clearTimeout(timeoutHover); 120 $this.attr('aria-expanded', 'true'); 121 $parent.addClass('show'); 122 $ddm.addClass('show'); 123 $this.trigger(showEvent); 124 }, settings.hoverDelay); 125 } 126 }); 127 }; 128 129 $(document).ready(function () { 130 // apply dropdownHover to all elements with the data-hover="dropdown" attribute 131 $('[data-hover="dropdown"]').dropdownHover(); 132 }); 133})(jQuery, window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.