Skip to content

Instantly share code, notes, and snippets.

@ramzs
Forked from keltanas/gist:3499449
Created May 13, 2017 16:16
Show Gist options
  • Save ramzs/ca189e7f81b37f2abfc7d975fc215091 to your computer and use it in GitHub Desktop.
Save ramzs/ca189e7f81b37f2abfc7d975fc215091 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