1/* 2 * Project: Twitter Bootstrap Hover Dropdown 3 * Author: Cameron Spear 4 * Contributors: Mattia Larentis 5 * 6 * Dependencies?: Twitter Bootstrap's Dropdown plugin 7 * 8 * A simple plugin to enable twitter bootstrap dropdowns to active on hover and provide a nice user experience. 9 * 10 * No license, do what you want. I'd love credit or a shoutout, though. 11 * 12 * http://cameronspear.com/blog/twitter-bootstrap-dropdown-on-hover-plugin/ 13 */ 14;(function($, window, undefined) { 15 // outside the scope of the jQuery plugin to 16 // keep track of all dropdowns 17 var $allDropdowns = $(); 18 19 // if instantlyCloseOthers is true, then it will instantly 20 // shut other nav items when a new one is hovered over 21 $.fn.dropdownHover = function(options) { 22 23 // the element we really care about 24 // is the dropdown-toggle's parent 25 $allDropdowns = $allDropdowns.add(this.parent()); 26 27 return this.each(function() { 28 var $this = $(this).parent(), 29 defaults = { 30 delay: 500, 31 instantlyCloseOthers: true 32 }, 33 data = { 34 delay: $(this).data('delay'), 35 instantlyCloseOthers: $(this).data('close-others') 36 }, 37 options = $.extend(true, {}, defaults, options, data), 38 timeout; 39 40 $this.hover(function() { 41 if(options.instantlyCloseOthers === true) 42 $allDropdowns.removeClass('open'); 43 44 window.clearTimeout(timeout); 45 $(this).addClass('open'); 46 }, function() { 47 timeout = window.setTimeout(function() { 48 $this.removeClass('open'); 49 }, options.delay); 50 }); 51 }); 52 }; 53 54 $(document).ready(function() { 55 $('[data-hover="dropdown"]').dropdownHover(); 56 }); 57})(jQuery, this);
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.