PageSourceSearch

https://montagut.com/modules/pscartdropdown/views/js/pscartdropdown_header.js

js montagut.com collected 2026-10-08 01:33:23 UTC 6,467 bytes, 160 lines download raw bytes

1/**
2 * Copyright since 2007 PrestaShop SA and Contributors
3 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
4 *
5 * NOTICE OF LICENSE
6 *
7 * This source file is subject to the Academic Free License version 3.0
8 * that is bundled with this package in the file LICENSE.md.
9 * It is also available through the world-wide-web at this URL:
10 * https://opensource.org/licenses/AFL-3.0
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to [email protected] so we can send you a copy immediately.
14 *
15 * @author    PrestaShop SA and Contributors <[email protected]>
16 * @copyright Since 2007 PrestaShop SA and Contributors
17 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
18 */
19$(document).ready(function() {
20    if (isMobileCartDropdown == 0 && document.body.clientWidth > 640) {
21        $("#pscarthover_shoppingcart").appendTo("#_desktop_cart");
22    }
23    let cart_block = new HoverWatcher('#header .blockcart');
24    let shopping_cart = new HoverWatcher('#pscarthover_shoppingcart');
25    let shop_block = new HoverWatcher('#wrapper');
26    let clicked = false;
27    let clickedqty = false;
28    let nbProducts = 0;
29
30    $(document).on('touchend', '#close_cartdropdown_mobile', function() {
31        $("#pscarthover_shoppingcart").slideUp(500);
32    });
33    if (isMobileCartDropdown == 1 && CheckBoxMobile == 1) {
34        $(document).on('touchend', '.blockcart', function(event) {
35            event.preventDefault();
36            $("#pscarthover_shoppingcart").slideDown(500);
37        });
38    }
39
40    $(document).on('click', '.remove-from-cart', function() {
41        let id_product = $(this).attr('data-id-product');
42        clicked = true;
43        $('.cart-item-' + id_product).fadeTo("slow", 0.00, function() {
44            $(this).slideUp(500, function() {
45                $(this).remove();
46            });
47        });
48    });
49    if (isMobileCartDropdown == 0) {
50        $(document).on('click', '.js-decrease-product-quantity', function() {
51            let qty = $(this).parent().parent().find('.js-cart-line-product-quantity').attr('value');
52            if (qty == "1") {
53                let id_product = $(this).parent().parent().find('.js-cart-line-product-quantity').attr('data-product-id');
54                $('.cart-item-' + id_product).fadeTo("slow", 0.00, function() {
55                    $(this).slideUp(500, function() {
56                        $(this).remove();
57                    });
58                });
59            }
60            clickedqty = true;
61        });
62    }
63    if (isMobileCartDropdown == 0) {
64        $(document).on('mouseover', '.blockcart', function() {
65            if (nbProducts || prestashop.cart.products_count)
66            $("#pscarthover_shoppingcart").not(":animated").slideDown(500);
67        });
68        $(document).on('mouseleave', '.blockcart', function() {
69            setTimeout(function() {
70                if (!shopping_cart.isHoveringOver() && !cart_block.isHoveringOver())
71                $("#pscarthover_shoppingcart").not(":animated").slideUp(500);
72            }, 400);
73        });
74
75        $("#pscarthover_shoppingcart").hover(
76            function() {},
77            function() {
78                setTimeout(function() {
79                    if (!shopping_cart.isHoveringOver() && !cart_block.isHoveringOver() || prestashop.cart.products_count < 0)
80                    $("#pscarthover_shoppingcart").slideUp(900);
81                }, 400);
82            }
83        );
84    }
85
86    prestashop.on(
87        'updateCart',
88        function(event) {
89            prestashop.cart = event.reason.cart;
90            let getCartViewUrl = $('.js-cartdrop').data('refresh-url');
91            if (!getCartViewUrl) {
92                return;
93            }
94            let requestData = {};
95            if (event && event.reason) {
96                requestData = {
97                    id_product_attribute: event.reason.idProductAttribute,
98                    id_product: event.reason.idProduct
99                };
100            }
101            $.post(getCartViewUrl, requestData).then((resp) => {
102                nbProducts = resp.nbProducts;
103                //if product is deleted add 1 sec delay
104                if (clicked == true || clickedqty == true) {
105                    setTimeout(function() {
106                        $('.cartdrop-detailed-totals').replaceWith(resp.cartdrop_detailed_totals);
107                        $('.cartdrop-detailed-actions').replaceWith(resp.cartdrop_detailed_actions);
108                        $('.cartdrop-overview').replaceWith(resp.cartdrop_detailed);
109                        $('#product_customization_id').val(0);
110                        $('.js-cart-line-product-quantity').each((index, input) => {
111                            let $input = $(input);
112                            $input.attr('value', $input.val());
113                        });
114                        prestashop.emit('updatedCart', {
115                            eventType: 'updateCart',
116                            resp: resp
117                        });
118                    }, 900)
119                    clicked = false;
120                    clickedqty = false;
121                } else {
122                    $('.cartdrop-detailed-totals').replaceWith(resp.cartdrop_detailed_totals);
123                    $('.cartdrop-detailed-actions').replaceWith(resp.cartdrop_detailed_actions);
124                    $('.cartdrop-overview').replaceWith(resp.cartdrop_detailed);
125
126                    $('#product_customization_id').val(0);
127
128                    $('.js-cart-line-product-quantity').each((index, input) => {
129                        let $input = $(input);
130                        $input.attr('value', $input.val());
131                    });
132                    prestashop.emit('updatedCart', {
133                        eventType: 'updateCart',
134                        resp: resp
135                    });
136                }
137            }).fail((resp) => {
138                prestashop.emit('handleError', {
139                    eventType: 'updateCart',
140                    resp: resp
141                })
142            });
143        }
144    );
145});
146
147function HoverWatcher(selector) {
148    this.hovering = false;
149    let self = this;
150
151    this.isHoveringOver = function() {
152        return self.hovering;
153    }
154
155    $(selector).hover(function() {
156        self.hovering = true;
157    }, function() {
158        self.hovering = false;
159    })
160}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.