Skip to content

Instantly share code, notes, and snippets.

@keltanas
Created August 28, 2012 15:59
Show Gist options
  • Save keltanas/3499449 to your computer and use it in GitHub Desktop.
Save keltanas/3499449 to your computer and use it in GitHub Desktop.
Плагин для twitter bootstrap, открывает dropdown меню при наведении, если оно находится внутри navbar
/**
* Плагин для 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