-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuyButtonEvents.js
More file actions
36 lines (35 loc) · 1.52 KB
/
Copy pathbuyButtonEvents.js
File metadata and controls
36 lines (35 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
jQuery(document).ready(function($){
var buttonEvents = {
mouseenter: function(){
$(this).stop().animate({color:"white", backgroundColor:"#dd7755", borderColor: "#dd7755"}, 300);
},
mouseleave: function(){
$(this).stop().animate({color:"#dd7755", backgroundColor:"white", borderColor: "#dd7755"}, 300);
},
click: function(){
function leave(){
$(this).delay(300).animate({color:"#dd7755", backgroundColor:"white", borderColor: "#dd7755"}, 300);
}
if (this.id){
Ajax("POST", '/LAB3/ShoppingServlet', { id: this.id}, {}, function(returnedData){
console.log("Shopping Cart Size: " + returnedData);
document.location.href = "/LAB3/cart";
});
};
$(this).stop().unbind("mouseenter", buttonEvents.mouseenter)
.unbind("mouseleave", buttonEvents.mouseleave)
.mouseleave(leave)
.animate({color:"white", backgroundColor:"red", borderColor: "red"}, {
duration: 300,
complete: function(){
$(this).unbind("mouseleave", leave)
.mouseenter(buttonEvents.mouseenter)
.mouseleave(buttonEvents.mouseleave);
}
});
}
};
$(".buyButton").mouseenter(buttonEvents.mouseenter)
.mouseleave(buttonEvents.mouseleave)
.click(buttonEvents.click);
});