Created
August 28, 2012 15:59
-
-
Save keltanas/3499449 to your computer and use it in GitHub Desktop.
Плагин для twitter bootstrap, открывает dropdown меню при наведении, если оно находится внутри navbar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Плагин для twitter bootstrap, открывает dropdown меню при наведении, если оно находится внутри navbar | |
* <div class="navbar" id="menu1">...</div> | |
* <script type="javascript">$(document).ready(function(){ | |
* $('#menu1').dropdownMouse() | |
* });</script> | |
* @return {*} | |
*/ | |
$.fn.dropdownMouse = function() | |
{ | |
$.fn.dropdownMouse.shown = {}; | |
$.fn.dropdownMouse.timeouts = {}; | |
return $('li.dropdown',this).each(function(){ | |
$(this).on('mouseover', function(){ | |
$(this).addClass('open'); | |
$.fn.dropdownMouse.shown[ this ] = 1; | |
clearTimeout( $.fn.dropdownMouse.timeouts[this] ); | |
}); | |
$(this).on('mouseout', function(event){ | |
$.fn.dropdownMouse.shown[ this ] = 0; | |
$.fn.dropdownMouse.timeouts[this] = setTimeout($.proxy(function(){ | |
if ( 0 == $.fn.dropdownMouse.shown[ this ] ) { | |
$(this).removeClass('open'); | |
} | |
},this), 50); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment