PageSourceSearch

https://the-mattress-company.co.za/wp-content/plugins/envo-ecommerce-pro/js/envo-ecommerce-pro.js?ver=2.2.5

js the-mattress-company.co.za collected 2026-10-02 23:52:21 UTC 13,071 bytes, 356 lines download raw bytes

1(function ($) {
2    'use strict';
3
4    $(window).scroll(function () {
5        var $myDiv = $('body.floating-menu');
6        if ($myDiv.length) {
7            var header = $('.site-header').outerHeight();
8            if ($(document).scrollTop() > (header + 100)) {
9                $('nav#site-navigation').addClass('shrink');
10            } else {
11                $('nav#site-navigation').removeClass('shrink');
12            }
13        }
14    });
15
16    // float cart
17
18    var $myDiv = $('.woo-float-info');
19    if ($myDiv.length) {
20        $(window).scroll(function () {
21            var distanceTop = $('.woocommerce div.product form.cart').offset().top - 60;
22
23            if ($(window).scrollTop() > distanceTop)
24                $myDiv.animate({'bottom': '0'}, 200);
25            else
26                $myDiv.stop(true).animate({'bottom': '-400px'}, 100);
27        });
28
29        $('.woo-float-info .close-me').bind('click', function () {
30            $(this).parent().remove();
31        });
32    }
33    ;
34
35
36    // sticky sidebar
37    $(document).ready(function () {
38        if ($('.sidebar-sticky #sidebar').length > 0) {
39            var $sticky = $('#sidebar');
40            $sticky.hcSticky({
41                stickTo: '.page-area',
42                top: 80,
43                bottomEnd: 25,
44                responsive: {
45                    991: {
46                        disable: true
47                    }
48                }
49            });
50        }
51        if ($('#elementor-sticky-sidebar').length > 0) {
52            var $sticky = $('#elementor-sticky-sidebar');
53            $sticky.hcSticky({
54                stickTo: '.elementor-widget-wrap section',
55                top: 80,
56                bottomEnd: 25,
57                responsive: {
58                    991: {
59                        disable: true
60                    }
61                }
62            });
63        }
64    });
65
66    // return to top button
67    // ===== Scroll to Top ==== 
68    $(window).scroll(function () {
69        if ($(this).scrollTop() >= 50) {        // If page is scrolled more than 50px
70            $('#return-to-top').fadeIn(200);    // Fade in the arrow
71        } else {
72            $('#return-to-top').fadeOut(200);   // Else fade out the arrow
73        }
74    });
75    $('#return-to-top').click(function () {      // When arrow is clicked
76        $('body,html').animate({
77            scrollTop: 0                       // Scroll to top of body
78        }, 500);
79    });
80
81
82    // open middle cart
83    $(document).on('click', '.button.ajax_add_to_cart', function (e) {
84        //e.preventDefault();
85        $('body.open-middle-cart').addClass('product-added-to-cart-middle');
86    });
87    $(document).on('click', '.product-added-to-cart-middle #middle-cart-overlay', function (e) {
88        e.preventDefault();
89        $('body.open-middle-cart').removeClass('product-added-to-cart-middle');
90    });
91    $(document).on('click', '.product-added-to-cart-middle #middle-cart-close', function (e) {
92        e.preventDefault();
93        $('body.open-middle-cart').removeClass('product-added-to-cart-middle');
94    });
95    $(document).on('click', '.button.ajax_add_to_cart', function (e) {
96        //e.preventDefault();
97        $('body.open-head-cart').addClass('product-added-to-cart');
98    });
99    $(document).on('mouseover', '.product-added-to-cart ul.site-header-cart', function (e) {
100        e.preventDefault();
101        $('body.open-head-cart').removeClass('product-added-to-cart');
102    });
103    $(document).ready(function () {
104        // single product ajax add to cart
105        if ($('body.single-ajax-add-to-cart').length > 0 || $('body.woocommerce-lightbox-on').length > 0) {
106            // Ajax add to cart on the product page
107            var $warp_fragment_refresh = {
108                url: wc_cart_fragments_params.wc_ajax_url.toString().replace('%%endpoint%%', 'get_refreshed_fragments'),
109                type: 'POST',
110                success: function (data) {
111                    if (data && data.fragments) {
112
113                        $.each(data.fragments, function (key, value) {
114                            $(key).replaceWith(value);
115                        });
116
117                        $(document.body).trigger('wc_fragments_refreshed');
118                    }
119                }
120            };
121            if ($('body.single-ajax-add-to-cart').length > 0) {
122                $('.entry-summary form.cart').on('submit', function (e)
123                {
124                    e.preventDefault();
125
126                    $('body.open-middle-cart').addClass('product-added-to-cart-middle'); // open middle cart
127                    $('body.open-head-cart').addClass('product-added-to-cart').delay(3000).fadeIn(2200);  // open header cart
128
129                    $('.entry-summary').block({
130                        message: null,
131                        overlayCSS: {
132                            cursor: 'none'
133                        }
134                    });
135
136                    var product_url = window.location,
137                            form = $(this);
138
139                    $.post(product_url, form.serialize() + '&_wp_http_referer=' + product_url, function (result)
140                    {
141                        var cart_dropdown = $('.cart-contents span.count', result),
142                                woocommerce_message = $('.woocommerce-message', result);
143
144                        // update dropdown cart
145                        $('.cart-contents span.count').replaceWith(cart_dropdown);
146
147                        // Show message
148                        $('.type-product').eq(0).before(woocommerce_message);
149
150                        // update fragments
151                        $.ajax($warp_fragment_refresh);
152
153                        $('.entry-summary').unblock();
154
155                    });
156                });
157            }
158            $.quickviewajax = function () {
159                $('.envo-entry-summary form.cart').on('submit', function (e)
160                {
161                    e.preventDefault();
162
163                    $('body.open-middle-cart').addClass('product-added-to-cart-middle'); // open middle cart
164                    $('body.open-head-cart').addClass('product-added-to-cart').delay(3000).fadeIn(2200);  // open header cart
165
166                    $('.envo-entry-summary').block({
167                        message: null,
168                        overlayCSS: {
169                            cursor: 'none'
170                        }
171                    });
172
173                    var product_url = window.location,
174                            form = $(this);
175
176                    $.post(product_url, form.serialize() + '&_wp_http_referer=' + product_url, function (result)
177                    {
178                        var cart_dropdown = $('.cart-contents span.count', result),
179                                woocommerce_message = $('.woocommerce-message', result);
180
181                        // update dropdown cart
182                        $('.cart-contents span.count').replaceWith(cart_dropdown);
183
184                        // Show message
185                        $('.qview_notice').eq(0).before(woocommerce_message);
186
187                        // update fragments
188                        $.ajax($warp_fragment_refresh);
189
190                        $('.envo-entry-summary').unblock();
191
192                    });
193                });
194            }
195            if ($('body.woocommerce-lightbox-on').length > 0) {
196                $.quickviewajax();
197            }
198        }
199    });
200    $(document).ready(function () {
201        if ($('.arhive-product-gallery-image').length) {
202            $("[data-fancybox]").fancybox();
203        }
204    });
205
206    /**
207     * Product Quick View
208     */
209    $(document).ready(function () {
210        if ($('.woocommerce-lightbox-on').length) {
211            $('.product').magnificPopup({
212                type: 'inline',
213                midClick: true,
214                gallery: {
215                    enabled: true
216                },
217                delegate: 'span.envo_ecommerce_pro_preview',
218                removalDelay: 500, //delay removal by X to allow out-animation
219                callbacks: {
220                    beforeOpen: function () {
221                        this.st.mainClass = this.st.el.attr('data-effect');
222                    }
223                },
224                closeOnContentClick: false,
225            });
226
227            /**
228             * product image lightbox
229             */
230
231            $("[data-fancybox]").fancybox();
232        }
233    });
234
235    $(document).ready(function () {
236        // Toggle Nav on Click
237        $('.canvas-toggle-nav').click(function () {
238            if ($('.page-wrap').hasClass('show-canvas-filter')) {
239                // Do things on Nav Close
240                $('.page-wrap').removeClass('show-canvas-filter');
241            } else {
242                // Do things on Nav Open
243                $('.page-wrap').addClass('show-canvas-filter');
244            }
245        });
246    });
247    
248    $(document).ready(function () {
249        // Toggle Nav on Click
250        $('#popuplogin').click(function () {
251            if ($('body').hasClass('show-popup-login')) {
252                // Do things on Nav Close
253                $('body').removeClass('show-popup-login');
254            } else {
255                // Do things on Nav Open
256                $('body').addClass('show-popup-login');
257            }
258        });
259        $('.login-canvas-toggle-nav').click(function () {
260                $('body').removeClass('show-popup-login');
261        });
262    });
263
264
265    $(document).ready(function () {
266        if ($('.woo-infinite-loading').length && $('.woocommerce-pagination a').length) {
267            var $container = $('article .products');
268            $container.infiniteScroll({
269                // options
270                path: '.woocommerce-pagination a',
271                append: 'li.product',
272                history: false,
273                status: '.page-load-status',
274            });
275
276            $container.on('append.infiniteScroll', function (event, response, path, items) {
277                $(items).find('img[srcset]').each(function (i, img) {
278                    img.outerHTML = img.outerHTML;
279                });
280                if ($('.the-countdown').length) {
281                    $(items).find('.the-countdown').countdown();
282                }
283                if ($('.envo_ecommerce_pro_preview').length) {
284                    $(items).find('.envo_ecommerce_pro_preview').magnificPopup({gallery: {enabled: true}});
285                }
286            });
287        }
288    });
289
290    $(document).ready(function () {
291
292        var $search = $('.ajax-search-section');
293
294        function theAjaxSearch(e) {
295
296            var $ajaxurl = $search.find('.the-search-wrap').data('ajaxurl'),
297                    $searchResults = $search.find('.the-search-results'),
298                    $loadingSpinner = $search.find('.the-search-wrap .the-ajax-loading');
299
300            $.ajax({
301                type: 'post',
302                url: $ajaxurl,
303                data: {
304                    action: 'envo_ecommerce_pro_ajax_search',
305                    search: e
306                },
307                beforeSend: function () {
308                    $searchResults.slideUp(200);
309                    setTimeout(function () {
310                        $loadingSpinner.fadeIn(50);
311                    }, 150);
312                },
313                success: function (result) {
314                    if (result === 0 || result == '0') {
315                        result = '';
316                    } else {
317                        $searchResults.html(result);
318                    }
319                },
320                complete: function () {
321                    $loadingSpinner.fadeOut(200);
322                    setTimeout(function () {
323                        $searchResults.slideDown(400).addClass('filled');
324                    }, 200);
325                }
326            });
327
328        }
329
330        $search.find('.the-ajax-search input.field').on('keyup', function () {
331
332            var $searchValue = $(this).val(),
333                    $lastSearchValue = '',
334                    $searchTimer = null;
335
336            clearTimeout($searchTimer);
337
338            if ($lastSearchValue != $.trim($searchValue) && $searchValue.length >= 3) {
339                $searchTimer = setTimeout(function () {
340                    theAjaxSearch($searchValue);
341                }, 400);
342            }
343
344        });
345
346        $(document).on('click', function () {
347            $('.the-search-results.filled').slideUp(200);
348        }).on('click', '.the-ajax-search, .the-search-results', function (e) {
349            e.stopPropagation();
350        }).on('click', '.the-ajax-search', function () {
351            $(this).parent().find('.the-search-results.filled').slideDown(400);
352        });
353
354    });
355
356})(jQuery);

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.