[-] MO : fixed javascript bug on mouse event

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@12558 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
aFolletete committed 2012-01-19 14:09:12 +00:00
1 parent 6806cdeab3
commit 41a0711869
1 file changed
+29 -3
+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);
}); });
}); });