chameleon
chameleon copied to clipboard
Auto-open menus
This js will open the menus on mouse-over (way better ux) and still work with touch-screens:
/* Open menus on mouse over, don't do anything on touch-devices. */
$(function() {
window.IsTouchDevice = false;
window.addEventListener('touchstart', function onFirstTouch() {
window.IsTouchDevice = true;
window.removeEventListener('touchstart', onFirstTouch, false);
}, false);
$(".dropdown").hover(
function(){ if (!window.IsTouchDevice) $(this).addClass('open'); },
function(){ if (!window.IsTouchDevice) $(this).removeClass('open'); }
);
});
Thanks. Will look into it.
for the fixedheader layout the dropdown function should have a little delay
$(function() {
window.IsTouchDevice = false;
window.addEventListener('touchstart', function onFirstTouch() {
window.IsTouchDevice = true;
window.removeEventListener('touchstart', onFirstTouch, false);
}, false);
$('ul.navbar-nav li.dropdown').hover(function() {
if (!window.IsTouchDevice)
$(this).find('.dropdown-menu').stop(true, true).delay(50).fadeIn(200);
}, function() {
if (!window.IsTouchDevice)
$(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(200);
});
});