[-] MO : fixed javascript bug on mouse event

This commit is contained in:
aFolletete
2012-01-19 14:09:12 +00:00
parent 585b670df3
commit 47db45fbd9
+29 -3
View File
@@ -618,6 +618,20 @@ var ajaxCart = {
} }
}; };
function HoverWatcher(selector){
this.hovering = false;
var self = this;
this.isHoveringOver = function() {
return self.hovering;
}
$(selector).hover(function() {
self.hovering = true;
}, function() {
self.hovering = false;
})
}
//when document is loaded... //when document is loaded...
$(document).ready(function(){ $(document).ready(function(){
@@ -632,12 +646,24 @@ $(document).ready(function(){
ajaxCart.refresh(); ajaxCart.refresh();
/* roll over cart */ /* roll over cart */
$("#shopping_cart").mouseenter(function(){ var cart_block = new HoverWatcher('#cart_block');
var shopping_cart = new HoverWatcher('#shopping_cart');
$("#shopping_cart").hover(function(){
$("#cart_block").stop(true, true).slideDown(450); $("#cart_block").stop(true, true).slideDown(450);
},
function() {
setTimeout(function() {
if (!cart_block.isHoveringOver())
$("#cart_block").stop(true, true).slideUp(450);
}, 200);
}); });
$("#cart_block").mouseleave(function(){ $("#cart_block").hover(function() {}, function(){
$(this).stop(true, true).slideUp(450); setTimeout(function() {
if (!shopping_cart.isHoveringOver())
$("#cart_block").stop(true, true).slideUp(450);
}, 200);
}); });
}); });