summaryrefslogtreecommitdiff
path: root/addons/website_sale/static/src/js/website_sale_utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/website_sale/static/src/js/website_sale_utils.js')
-rw-r--r--addons/website_sale/static/src/js/website_sale_utils.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/addons/website_sale/static/src/js/website_sale_utils.js b/addons/website_sale/static/src/js/website_sale_utils.js
index 48fdd981ca9..3b672063551 100644
--- a/addons/website_sale/static/src/js/website_sale_utils.js
+++ b/addons/website_sale/static/src/js/website_sale_utils.js
@@ -1,6 +1,24 @@
odoo.define('website_sale.utils', function (require) {
'use strict';
+/**
+ * Gets the element in the navbar currently displayed.
+ * Depending on the scroll position, it could either be the one in the main
+ * top bar or the one in the affixed navbar.
+ *
+ * @private
+ * @param {string} selector
+ * @returns {jQuery}
+ */
+function getNavBarButton(selector) {
+ var $affixedHeaderButton = $('header.affixed ' + selector);
+ if ($affixedHeaderButton.length) {
+ return $affixedHeaderButton;
+ } else {
+ return $('header ' + selector).first();
+ }
+}
+
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();
@@ -32,7 +50,20 @@ function animateClone($cart, $elem, offsetTop, offsetLeft) {
}
}
+/**
+ * @param {Object} data
+ */
+function updateCartNavBar(data) {
+ var $q = $(".my_cart_quantity");
+ $q.parents('li:first').removeClass('d-none');
+ $q.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,
+ getNavBarButton: getNavBarButton,
+ updateCartNavBar: updateCartNavBar,
};
});