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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
odoo.define('website_sale.utils', function (require) {
'use strict';
function animateClone($cart, $elem, offsetTop, offsetLeft) {
$cart.find('.o_animate_blink').addClass('o_red_highlight o_shadow_animation').delay(500).queue(function () {
$(this).removeClass("o_shadow_animation").dequeue();
}).delay(2000).queue(function () {
$(this).removeClass("o_red_highlight").dequeue();
});
return new Promise(function (resolve, reject) {
var $imgtodrag = $elem.find('img').eq(0);
if ($imgtodrag.length) {
var $imgclone = $imgtodrag.clone()
.offset({
top: $imgtodrag.offset().top,
left: $imgtodrag.offset().left
})
.addClass('o_website_sale_animate')
.appendTo(document.body)
.animate({
top: $cart.offset().top + offsetTop,
left: $cart.offset().left + offsetLeft,
width: 75,
height: 75,
}, 1000, 'easeInOutExpo');
$imgclone.animate({
width: 0,
height: 0,
}, function () {
resolve();
$(this).detach();
});
} else {
resolve();
}
});
}
/**
* Updates both navbar cart
* @param {Object} data
*/
function updateCartNavBar(data) {
var $qtyNavBar = $(".my_cart_quantity");
_.each($qtyNavBar, function (qty) {
var $qty = $(qty);
$qty.parents('li:first').removeClass('d-none');
$qty.html(data.cart_quantity).hide().fadeIn(600);
});
$(".js_cart_lines").first().before(data['website_sale.cart_lines']).end().remove();
$(".js_cart_summary").first().before(data['website_sale.short_cart_summary']).end().remove();
}
return {
animateClone: animateClone,
updateCartNavBar: updateCartNavBar,
};
});
|