vendor: 4,796 bytes, lines 1-115
1/** 2 * Project: Bootstrap Hover Dropdown 3 * Author: Cameron Spear 4 * Contributors: Mattia Larentis 5 * 6 * Dependencies: Bootstrap's Dropdown plugin, jQuery 7 * 8 * A simple plugin to enable Bootstrap dropdowns to active on hover and provide a nice user experience. 9 * 10 * License: MIT 11 * 12 * http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/ 13 */ 14"use strict"; 15var isTouchDevice = "ontouchstart" in window || navigator.msMaxTouchPoints; 16if (!isTouchDevice) { 17 ; (function ($, window, undefined) { 18 // outside the scope of the jQuery plugin to 19 // keep track of all dropdowns 20 var $allDropdowns = $(); 21 22 // if instantlyCloseOthers is true, then it will instantly 23 // shut other nav items when a new one is hovered over 24 $.fn.dropdownHover = function (options) { 25 // don't do anything if touch is supported 26 // (plugin causes some issues on mobile) 27 if ('ontouchstart' in document) return this; // don't want to affect chaining 28 29 // the element we really care about 30 // is the dropdown-toggle's parent 31 $allDropdowns = $allDropdowns.add(this.parent()); 32 33 return this.each(function () { 34 var $this = $(this), 35 $parent = $this.parent(), 36 defaults = { 37 delay: 100, 38 instantlyCloseOthers: true 39 }, 40 data = { 41 delay: $(this).data('delay'), 42 instantlyCloseOthers: $(this).data('close-others') 43 }, 44 showEvent = 'show.bs.dropdown', 45 hideEvent = 'hide.bs.dropdown', 46 // shownEvent = 'shown.bs.dropdown', 47 // hiddenEvent = 'hidden.bs.dropdown', 48 settings = $.extend(true, {}, defaults, options, data), 49 timeout; 50 51 $parent.hover(function (event) { 52 // so a neighbor can't open the dropdown 53 if (!$parent.hasClass('open') && !$this.is(event.target)) { 54 // stop this event, stop executing any code 55 // in this callback but continue to propagate 56 return true; 57 } 58 59 openDropdown(event); 60 }, function () { 61 timeout = window.setTimeout(function () { 62 $parent.removeClass('open'); 63 $this.trigger(hideEvent); 64 }, settings.delay); 65 }); 66 67 // this helps with button groups! 68 $this.hover(function (event) { 69 // this helps prevent a double event from firing. 70 // see https://github.com/CWSpear/bootstrap-hover-dropdown/issues/55 71 if (!$parent.hasClass('open') && !$parent.is(event.target)) { 72 // stop this event, stop executing any code 73 // in this callback but continue to propagate 74 return true; 75 } 76 77 openDropdown(event); 78 }); 79 80 // handle submenus 81 $parent.find('.dropdown-submenu').each(function () { 82 var $this = $(this); 83 var subTimeout; 84 $this.hover(function () { 85 window.clearTimeout(subTimeout); 86 $this.children('.dropdown-menu').show(); 87 // always close submenu siblings instantly 88 $this.siblings().children('.dropdown-menu').hide(); 89 }, function () { 90 var $submenu = $this.children('.dropdown-menu'); 91 subTimeout = window.setTimeout(function () { 92 $submenu.hide(); 93 }, settings.delay); 94 }); 95 }); 96 97 function openDropdown(event) { 98 $allDropdowns.find(':focus').blur(); 99 100 if (settings.instantlyCloseOthers === true) 101 $allDropdowns.removeClass('open'); 102 103 window.clearTimeout(timeout); 104 $parent.addClass('open'); 105 $this.trigger(showEvent); 106 } 107 }); 108 }; 109 110 $(document).ready(function () { 111 // apply dropdownHover to all elements with the data-hover="dropdown" attribute 112 $('[data-hover="dropdown"]').dropdownHover(); 113 }); 114 })(jQuery, this); 115}
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.