<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/*
** nopCommerce ajax cart implementation
*/


var AjaxCart = {
    loadWaiting: false,
    usepopupnotifications: false,
    topcartselector: '',
    topwishlistselector: '',
    flyoutcartselector: '',

    init: function (usepopupnotifications, topcartselector, topwishlistselector, flyoutcartselector) {
        this.loadWaiting = false;
        this.usepopupnotifications = usepopupnotifications;
        this.topcartselector = topcartselector;
        this.topwishlistselector = topwishlistselector;
        this.flyoutcartselector = flyoutcartselector;
    },

    setLoadWaiting: function (display) {
        displayAjaxLoading(display);
        this.loadWaiting = display;
    },

    //add a product to the cart/wishlist from the catalog pages
    addproducttocart_catalog: function (urladd) {
        if (this.loadWaiting != false) {
            return;
        }
        this.setLoadWaiting(true);

        $.ajax({
            cache: false,
            url: urladd,
            type: 'post',
            success: this.success_process,
            complete: this.resetLoadWaiting,
            error: this.ajaxFailure
        });
    },

    //add a product to the cart/wishlist from the product details page
    addproducttocart_details: function (urladd, formselector) {
        if (this.loadWaiting != false) {
            return;
        }
        this.setLoadWaiting(true);

        $.ajax({
            cache: false,
            url: urladd,
            data: $(formselector).serialize(),
            type: 'post',
            success: this.success_process,
            complete: this.resetLoadWaiting,
            error: this.ajaxFailure
        });
    },

    //add a product to compare list
    addproducttocomparelist: function (urladd) {
        if (this.loadWaiting != false) {
            return;
        }
        this.setLoadWaiting(true);

        $.ajax({
            cache: false,
            url: urladd,
            type: 'post',
            success: this.success_process,
            complete: this.resetLoadWaiting,
            error: this.ajaxFailure
        });
    },

    success_process: function (response) {
        if (response.updatetopcartsectionhtml) {
            var count = response.updatetopcartsectionhtml.match(/[\d\.]+/g);            
            $(AjaxCart.topcartselector).html(count);
            $("#menu-shopping-bag-qty").html(count);
            
        }
        
        if (response.updatetopwishlistsectionhtml) {            
            var count = response.updatetopwishlistsectionhtml.match(/[\d\.]+/g);
            $(AjaxCart.topwishlistselector).html(count);
        }

        //alert(response.updateflyoutcartsectionhtml);
        if (response.updateflyoutcartsectionhtml) {
            if ($(AjaxCart.flyoutcartselector).length) { //
                $(AjaxCart.flyoutcartselector).replaceWith(response.updateflyoutcartsectionhtml);
            } else {
                $("#three_step_checkout").replaceWith(response.updateflyoutcartsectionhtml);
            }
        }
        if (response.message) {
            //display notification
            if (response.success == true) {
                if (response.updatetopcartsectionhtml) {
                    if (window.matchMedia('(max-width: 480px)').matches) {
                        displayBarNotification(response.message, 'success', 5000);
                    } else {
                        $(".minicart__popup js-shoppingBag").hide();
                        $.fancybox({
                            'type': 'ajax',
                            'href': '/ShoppingCart'
                        });
                    }
                }
                if (AjaxCart.usepopupnotifications == true) {
                    displayPopupNotification(response.message, 'success', true);                 
                }
            }
            else {
                //error
                if (AjaxCart.usepopupnotifications == true) {
                    displayPopupNotification(response.message, 'error', true);
                }
                else {
                    //no timeout for errors
                    displayBarNotification(response.message, 'error', 5000);
                }
            }
            return false;
        }
        if (response.redirect) {
            location.href = response.redirect;
            return true;
        }
        return false;
    },

    resetLoadWaiting: function () {
        AjaxCart.setLoadWaiting(false);
    },

    ajaxFailure: function () {
        alert('Failed to add the product. Please refresh the page and try one more time.');
    }
};</pre></body></html>