PageSourceSearch

https://giant.sg/themes/giant_v3/js/custom.js?20250611

js giant.sg collected 2026-10-02 06:36:51 UTC 127,016 bytes, 3,429 lines download raw bytes

1$.pnotify.defaults.styling = "jqueryui";
2$.pnotify.defaults.history = false;
3var current_page_url = window.location.href;
4
5var delay = (function () {
6    var timer = 0;
7    return function (callback, ms) {
8        clearTimeout(timer);
9        timer = setTimeout(callback, ms);
10    };
11})();
12
13(function ($) {
14    "use strict";
15    /**
16     * Created by Rizky
17     * JQuery plugin to display alert box that using fancy box
18     * @param message
19     * @param options
20     */
21    $.alert = function (title, message, options) {
22        var settings = $.extend(
23            {
24                btnOkLabel: "OK",
25            },
26            options
27        );
28
29        var html = $("<div/>").addClass("subscription-success-container");
30        // var btn_close = $('<button class="btn btn-danger btn-close-fancybox"><i class="fa fa-times"></i></button>').on('click', function () {
31        // 	$.fancybox.close();
32        // })
33        // html.append(btn_close);
34        var form = $("<div/>").addClass("content");
35        if (title != "") {
36            form.append('<h5 style="margin-bottom: 20px;">' + title + "</h5>");
37        }
38
39        form.append('<div class="description">' + message + "</div>");
40
41        // Element for button ok and bind it
42        var btn_ok = $('<button class="btn btn-primary"/>')
43            .html(
44                '<span class="display-static hvr-underline-from-center">' +
45                    settings.btnOkLabel +
46                    "</span>"
47            )
48            .on("click", function () {
49                $.fancybox.close();
50            });
51
52        var btn_container = $('<div style="margin-top: 20px;"/>');
53        btn_container.append(btn_ok);
54        form.append(btn_container);
55        html.append(form);
56
57        // Register the html to fancybox
58        $.fancybox.open({
59            content: html,
60            maxWidth: 400,
61            maxHeight: 600,
62            fitToView: true,
63            width: "90%",
64            height: "90%",
65            autoSize: true,
66            closeClick: false,
67            openEffect: "none",
68            closeEffect: "none",
69            wrapCSS: "pop-up-message",
70            tpl: {
71                closeBtn:
72                    '<a title="Close" class="fancybox-item fancybox-close myClose" href="javascript:;"></a>',
73            },
74        });
75    };
76
77    /**
78     * JQuery plugin function to display confirm modal that using fancy box
79     * @param message
80     * @param success_callback
81     */
82    $.confirm = function (message, success_callback, options) {
83        var settings = $.extend(
84            {
85                btnYesLabel: "YES",
86                btnNoLabel: "NO",
87                cancelCallback: null,
88            },
89            options
90        );
91
92        var html = $("<div/>").addClass("dialog-confirm");
93        var btn_close = $(
94            '<button class="btn btn-danger btn-close-fancybox"><i class="fa fa-times"></i></button>'
95        ).on("click", function () {
96            $.fancybox.close();
97        });
98
99        html.append(btn_close);
100        var form = $("<div/>").addClass("form");
101        form.append(
102            '<div class="form-input"><div class="form-label">' +
103                message +
104                "</div></div>"
105        );
106
107        // Element for button yes and bind it
108        var btn_yes = $('<button class="btn btn-danger"/>')
109            .html(settings.btnYesLabel)
110            .on("click", function () {
111                $.fancybox.close();
112                if (typeof success_callback == "function") {
113                    success_callback();
114                }
115            });
116
117        // Element for button no and bind it
118        var btn_no = $('<button class="btn btn-default"/>')
119            .html(settings.btnNoLabel)
120            .on("click", function () {
121                $.fancybox.close();
122                if (typeof settings.cancelCallback == "function") {
123                    settings.cancelCallback();
124                }
125            });
126
127        var btn_container = $('<div class="button-container"/>');
128        btn_container.append(btn_yes);
129        btn_container.append(btn_no);
130
131        form.append(btn_container);
132        html.append(form);
133
134        // Register the html to fancybox
135        $.fancybox.open({
136            content: html,
137            width: 500,
138            height: 150,
139            autoSize: false,
140            closeBtn: false,
141        });
142    };
143})(jQuery);
144
145(function ($) {
146    /**
147     * JQuery plugin to marquee notification block
148     * @param message
149     * @param options
150     */
151    $.fn.textWidth = function () {
152        var calc = '<span style="display:none">' + $(this).text() + "</span>";
153        $("body").append(calc);
154        var width = $("body").find("span:last").width();
155        $("body").find("span:last").remove();
156        return width;
157    };
158    $.fn.marquee = function (args) {
159        var that = $(this);
160        var textWidth = that.textWidth(),
161            offset = that.width(),
162            width = offset,
163            css = {
164                "text-indent": that.css("text-indent"),
165                overflow: that.css("overflow"),
166                "white-space": that.css("white-space"),
167            },
168            marqueeCss = {
169                "text-indent": width,
170                overflow: "hidden",
171                "white-space": "nowrap",
172            },
173            args = $.extend(
174                true,
175                { count: -1, speed: 1e1, leftToRight: false },
176                args
177            ),
178            i = 0,
179            stop = textWidth * -1,
180            dfd = $.Deferred();
181
182        function go() {
183            if (!that.length) return dfd.reject();
184            if (Math.round(width) == Math.round(stop)) {
185                i++;
186                if (i == args.count) {
187                    that.css(css);
188                    return dfd.resolve();
189                }
190                if (args.leftToRight) {
191                    width = textWidth * -1;
192                } else {
193                    width = offset;
194                }
195            }
196            that.css("text-indent", width + "px");
197            if (args.leftToRight) {
198                width++;
199            } else {
200                width--;
201            }
202            setTimeout(go, args.speed);
203        }
204        if (args.leftToRight) {
205            width = textWidth * -1;
206            width++;
207            stop = offset;
208        } else {
209            width--;
210        }
211        that.css(marqueeCss);
212        go();
213        return dfd.promise();
214    };
215})(jQuery);
216
217$(document).ajaxStop(function () {
218    $("img.lazyload").lazy({
219        // called after an element was successfully handled
220        afterLoad: function (element) {
221            var imageSrc = element.removeClass("full-width-image");
222        },
223    });
224    init_product_lightbox();
225});
226
227$(function () {
228    if (lazyload_image) {
229        // $('img.lazyload').unveil();
230        $("img.lazyload").lazy({
231            // called after an element was successfully handled
232            afterLoad: function (element) {
233                var imageSrc = element.removeClass("full-width-image");
234            },
235        });
236    }
237    if (lazyload_content) {
238        $("[data-loader=ajax]").lazy({
239            // called after an element was successfully handled
240            afterLoad: function (element) {
241                var imageSrc = element.removeClass("full-width-image");
242            },
243        });
244    }
245
246    $.blockUI.defaults.css = {};
247
248    $.blockUI.defaults.message = '<div class="element-loading"></div>';
249
250    $.blockUI.defaults.overlayCSS = {
251        backgroundColor: "#fff",
252        opacity: 0.6,
253        cursor: "wait",
254    };
255
256    reserve_slot.init();
257
258    $(".alert-error").addClass("alert-danger");
259
260    // $('.homeslider .bx-pager-item a').hover(function () {
261    // 	$(this).click();
262    // });
263
264    /* Function to delay click of tabbed category section to make it smoother */
265    $(
266        "[data-toggle=dropdown], .category-featured .nav-menu-red .navbar-nav li a, .dare-compare .nav-tab li a"
267    ).hover(function () {
268        var width = $(window).width();
269        var obj = this;
270        setTimeout(function () {
271            // if(width > 992) {
272            obj.click();
273            // }
274        }, 100);
275    });
276
277    $("#logout_impersonate").click(function (e) {
278        var href = $(this).attr("href");
279        if (!confirm("Are you sure you want to quit Manual Order session?")) {
280            return false;
281        }
282        $.ajax({
283            url: site_config.base_path + "logout",
284            dataType: "GET",
285            success: function (data) {
286                window.location.href = href;
287            },
288        });
289    });
290
291    $(
292        ".category-featured:not(.dare-compare) .product-list li .right-block"
293    ).click(function (e) {
294        e.preventDefault();
295        $(this).find(".add-to-cart").click();
296    });
297
298    $(".btn.add-cart");
299});
300
301function replaceUrlParam(url, paramName, paramValue) {
302    if (paramValue == null) paramValue = "";
303    url = url.replace("?name=", "");
304
305    var pattern = new RegExp("\\b(" + paramName + "=).*?(&|$)");
306    if (url.search(pattern) >= 0) {
307        return url.replace(pattern, "$1" + paramValue + "$2");
308    }
309    return (
310        url + (url.indexOf("?") > 0 ? "&" : "?") + paramName + "=" + paramValue
311    );
312}
313
314function dark_key(e) {
315    //console.log(arguments);
316    if (e.keyCode == 32) dark_uncover();
317}
318function dark_cover() {
319    $.blockUI();
320    // $('.element-loading').css('display', 'block');
321    // $('#loadingAddCart').css('visibility', 'visible');
322    // $('#loadingAddCart').css('display', '-webkit-inline-box');
323}
324
325function dark_uncover() {
326    $.unblockUI();
327    // $('.element-loading').css('display', 'none');
328    // $('#loadingAddCart').css('visibility', 'hidden');
329    // $('#loadingAddCart').css('display', 'none');
330}
331
332// Global Notification
333function show_notif(msg, type, callback) {
334    if (typeof type === "undefined") {
335        type = "default";
336    }
337    var text_class = "";
338
339    switch (type) {
340        case "error":
341            text_class = "text-danger";
342            break;
343        case "info":
344            text_class = "text-info";
345            break;
346        case "warning":
347            text_class = "text-warning";
348            break;
349        case "success":
350            text_class = "text-success";
351            break;
352        case "black":
353            text_class = "text-bold";
354            break;
355        case "primary":
356            text_class = "text-primary";
357            break;
358    }
359    msg = '<div class="' + text_class + '">' + msg + "</div>";
360
361    if (jQuery.isFunction(callback)) {
362        bootbox.alert(msg, callback);
363    } else {
364        bootbox.alert(msg);
365    }
366}
367function show_pnotify(text) {
368    var _text = text;
369    $.pnotify({
370        text: _text,
371        icon: false,
372        delay: 3000,
373        closer: false,
374        sticker: false,
375        addclass: "pnotify-white-background pnotify-card",
376        width: "300px",
377        before_open: function (pnotify) {
378            pnotify.css({
379                top: $("#header").height() / 2 + 150,
380                right:
381                    Math.floor(
382                        (document.body.clientWidth - $(".container").width()) /
383                            2
384                    ) - 16,
385            });
386        },
387    });
388}
389// Handle old notification
390function show_topstack_notif(type, msg) {
391    show_notif(msg, type);
392    // $.alert('', msg, '');
393}
394
395function show_alert_error(msg) {
396    show_notif(msg, "error");
397    // $.alert('', msg, '');
398}
399
400function capitalize_words(str) {
401    return str.replace(/\w\S*/g, function (txt) {
402        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
403    });
404}
405
406// User related functions
407function doLogout() {
408    reserve_slot.clearReversedSlot();
409    location.href = site_config.base_path + "logout";
410}
411
412// Reserve slot
413var reserve_slot = {
414    interval: null,
415    init: function () {
416        if (this.interval !== null) {
417            clearInterval(this.interval);
418        }
419        if (this.isReservedSlotExist()) {
420            if (this.isReservedSlotExpired()) {
421                this.doExpiredSlotJob();
422                return;
423            }
424            this.setUpPeriodicallyExpiredCheck();
425        }
426    },
427    isReservedSlotExist: function () {
428        if (
429            typeof $.cookie("reserved_slot") !== "undefined" &&
430            typeof $.cookie("reserved_expired") !== "undefined"
431        ) {
432            return true;
433        } else {
434            return false;
435        }
436    },
437    setUpPeriodicallyExpiredCheck: function () {
438        var that = this;
439        this.interval = setInterval(function () {
440            that.onIntervalTime();
441        }, 2000);
442    },
443    onIntervalTime: function () {
444        if (this.isReservedSlotExpired()) {
445            if (site_config.checkout_page && this.isReservedSlotExist()) {
446                this.extendSlot();
447            } else {
448                this.doExpiredSlotJob();
449            }
450            return;
451        }
452        if (this.isReservedSlotAlmostExpired()) {
453            if (site_config.checkout_page && this.isReservedSlotExist()) {
454                this.extendSlot();
455            } else {
456                this.doAlmostExpiredSlotJob();
457            }
458        }
459    },
460    extendSlot: function () {
461        var reserve_slot = $.cookie("reserved_slot");
462        var reserve_postal = $.cookie("reserved_postal");
463        var post_url = site_config.base_path + "checkout/cart/reserveTimeslot";
464        $.post(
465            post_url,
466            {
467                timeslot: reserve_slot,
468                postal: reserve_postal,
469            },
470            function (data) {
471                obj = JSON.parse(data);
472                if (obj.valid) {
473                    reserve_slot.init();
474                    if (
475                        typeof normal_delivery_slot == "object" &&
476                        typeof checkout_cart == "object"
477                    ) {
478                        normal_delivery_slot.get_delivery_timeslot(
479                            checkout_cart.getActiveAddressPostalCode()
480                        );
481                    }
482                }
483            }
484        );
485    },
486    isReservedSlotExpired: function () {
487        if (typeof $.cookie("reserved_expired") !== "undefined") {
488            expired_timestamp = parseInt($.cookie("reserved_expired"));
489            //expired_timestamp = parseInt(ServerDate.now()) / 1000 | 0;
490            server_timestamp = (parseInt(ServerDate.now()) / 1000) | 0;
491            if (expired_timestamp <= server_timestamp) {
492                return true;
493            } else {
494                return false;
495            }
496        }
497
498        return true;
499    },
500    isReservedSlotAlmostExpired: function () {
501        if (
502            typeof $.cookie("reserved_expired") !== "undefined" &&
503            typeof $.cookie("reserved_expired_notify") === "undefined"
504        ) {
505            expired_timestamp =
506                parseInt($.cookie("reserved_expired")) -
507                60 * parseInt(site_config.minutes_extend_message_display);
508            server_timestamp = (parseInt(ServerDate.now()) / 1000) | 0;
509            if (expired_timestamp <= server_timestamp) {
510                return true;
511            } else {
512                return false;
513            }
514        }
515        return false;
516    },
517    clearReversedSlot: function () {
518        $.removeCookie("reserved_slot", { path: "/" });
519        $.removeCookie("reserved_expired", { path: "/" });
520        $.removeCookie("reserved_expired_notify", { path: "/" });
521        window.localStorage.clear();
522        $(".text-reserve i").html($(".text-reserve i").data("original-text"));
523        $(".text-reserve b").html($(".text-reserve b").data("original-text"));
524        var post_url = site_config.base_path + "checkout/cart/reserveTimeslot";
525        $.post(post_url, {
526            method: "clear",
527        });
528        if (this.interval !== null) {
529            clearInterval(this.interval);
530        }
531    },
532    doExpiredSlotJob: function () {
533        if (typeof $.cookie("reserved_postal") !== "undefined") {
534            var postalnum = $.cookie("reserved_postal").toString();
535        }
536        enabledeliveryslot = "yes";
537        var box = bootbox.dialog({
538            message:
539                "Your Delivery Slot reservation session has ended. Click Reserve to select your Delivery Slot.",
540            title: "",
541            className: "reserve-delivery-expired-dialog bootbox-confirm",
542            buttons: {
543                cancel: {
544                    label: "Cancel",
545                    size: "large",
546                    className: "btn-warning",
547                    callback: function () {
548                        box.modal("hide");
549                    },
550                },
551                confirm: {
552                    label: "Reserve",
553                    size: "large",
554                    className: "btn-primary",
555                    callback: function () {
556                        box.modal("hide");
557                        if (is_mobile_view) {
558                            checkDelivery(postalnum, enabledeliveryslot);
559                        } else {
560                            checkDeliveryDesktop(postalnum, enabledeliveryslot);
561                        }
562                    },
563                },
564            },
565        });
566        if (this.interval !== null) {
567            clearInterval(this.interval);
568        }
569        this.clearReversedSlot();
570    },
571    doAlmostExpiredSlotJob: function () {
572        if (typeof $.cookie("reserved_postal") !== "undefined") {
573            var postalnum = $.cookie("reserved_postal").toString();
574        }
575        enabledeliveryslot = "yes";
576        $.cookie("reserved_expired_notify", "1", { expires: 1, path: "/" });
577        var box = bootbox.dialog({
578            message:
579                "Your Delivery Slot reservation time is almost end. Click Reserve button to extend",
580            title: "",
581            className: "reserve-delivery-almost-end-dialog bootbox-confirm",
582            buttons: {
583                cancel: {
584                    label: "Cancel",
585                    size: "large",
586                    className: "btn-warning",
587                    callback: function () {
588                        box.modal("hide");
589                    },
590                },
591                confirm: {
592                    label: "Reserve",
593                    size: "large",
594                    className: "btn-primary",
595                    callback: function () {
596                        box.modal("hide");
597                        if (typeof doReserveTimeslot == "function") {
598                            doReserveTimeslot();
599                        } else {
600                            if (is_mobile_view) {
601                                checkDelivery(postalnum, enabledeliveryslot);
602                            } else {
603                                checkDeliveryDesktop(
604                                    postalnum,
605                                    enabledeliveryslot
606                                );
607                            }
608                        }
609                    },
610                },
611            },
612        });
613    },
614};
615
616// Multiple Search
617$(function () {
618    // Open multiple search
619    $("#searchbox").on("click", function (e) {
620        // $('#multiple-search').show();
621    });
622
623    // Close multiple search
624    $(".close-multiple-search").on("click", function (e) {
625        // $('#multiple-search').hide();
626    });
627
628    $("#searchbox").on("keyup", function (e) {
629        var searchValue = $(this).val();
630        if (searchValue == "") {
631            $(".searchform-suggestion").hide();
632            $(".searchform-suggestion-see-all").hide();
633        }
634        delay(function () {
635            //ajaxSuggestions(searchValue, $('#searchform-suggestion'));
636        }, 500);
637
638        /*
639		setTimeout(function () {
640			ajaxSuggestions(searchValue, $('#searchform-suggestion'));
641		}, 500);
642		*/
643    });
644
645    $(".floating-form").on("keyup", "#searchbox", function (e) {
646        var searchValue = $(this).val();
647        delay(function () {
648            //ajaxSuggestions(searchValue, $('.floating-form').find('#searchform-suggestion'));
649        }, 500);
650    });
651
652    $("#searchbox-mobile").on("keyup", function (e) {
653        var searchValue = $(this).val();
654        delay(function () {
655            //ajaxSuggestions(searchValue, $('.floating-form').find('#searchform-suggestion'));
656        }, 500);
657    });
658    $("#searchbox2-mobile").on("focus", function (e) {
659        if($(window).width() < 768){
660            $(this).closest('.dropdown-menu-search').find('.search-suggestion').css('max-height','50vh');
661        }
662    });
663    $("#searchbox2-mobile").on("focusout", function (e) {
664        if($(window).width() < 768){
665            $(this).closest('.dropdown-menu-search').find('.search-suggestion').css('max-height','none');
666        }
667    });
668
669    // open multiple search box
670    $("#open-multiple-search").on("click", function () {
671        $(".multiplesearch-box").show();
672        $(this).parents(".search-suggestion").hide();
673    });
674
675    // close mutilpe search box
676    $("#close-multiplesearch-box").on("click", function () {
677        $(".multiplesearch-box").hide();
678        $(".search-suggestion").show();
679    });
680
681    $("#btn-basic-search").on("click", function () {
682        if ($("#searchbox").val() != "") {
683            $("#basic-search-form").submit();
684        }
685    });
686    $("#btn-basic-search-mobile").on("click", function () {
687        if ($("#searchbox-mobile").val() != "") {
688            $("#basic-search-form-mobile").submit();
689        }
690    });
691
692    $("#btn-advanced-search").on("click", function () {
693        if ($("#txtkeyword").val() != "") {
694            $("#advanced-search-form").submit();
695        }
696    });
697    $("#btn-advanced-search-mobile").on("click", function () {
698        if ($("#txtkeyword-mobile").val() != "") {
699            $("#advanced-search-form-mobile").submit();
700        }
701    });
702});
703
704function showMultiplesearchbox() {
705    $(".multiplesearch-box").show();
706    $("#multiple-search").hide();
707}
708
709var search_request = null;
710function ajaxSuggestions(searchValue, suggestionElm) {
711    if (searchValue.length >= 3) {
712        var strHtml = "";
713        var post_url = base + "catalog/product/suggestions";
714
715        search_request = $.ajax({
716            type: "POST",
717            data: { keywords: searchValue },
718            url: post_url,
719            beforeSend: function () {
720                $(".search-loader").show();
721                if (search_request != null) {
722                    search_request.abort();
723                }
724            },
725            success: function (data) {
726                obj = JSON.parse(data);
727                console.log(obj);
728                if (isNaN(obj)) {
729                    strHtml = "<ul class='list-suggestion product-suggestion'>";
730                    if ($(obj.product_suggestion).size() > 0) {
731                        var ctr = 0;
732                        for (i in obj.product_suggestion) {
733                            if (ctr <= 5) {
734                                var tmp_name = obj.product_suggestion[i].name;
735                                var pattern = new RegExp(
736                                    "(" + searchValue + ")",
737                                    "gi"
738                                );
739                                var start_pos = tmp_name
740                                    .toLowerCase()
741                                    .indexOf(searchValue.toLowerCase());
742                                var tmp_search_value = tmp_name.substring(
743                                    start_pos,
744                                    start_pos + searchValue.length
745                                );
746
747                                tmp_name = tmp_name.replace(
748                                    pattern,
749                                    '<span class="highlight">' +
750                                        tmp_search_value +
751                                        "</span>"
752                                );
753
754                                strHtml += "<li>";
755
756                                strHtml += "<div class='suggested-product'>";
757                                strHtml +=
758                                    "<div class='search-product-image'><img src='" +
759                                    obj.product_suggestion[i].image +
760                                    "' /></div>";
761                                strHtml +=
762                                    "<div class='search-product-name'><a href='" +
763                                    base +
764                                    "product/" +
765                                    obj.product_suggestion[i].slug +
766                                    "'>" +
767                                    obj.product_suggestion[i].brand +
768                                    " " +
769                                    tmp_name +
770                                    "</a></div>";
771                                strHtml +=
772                                    "<div class='search-product-size'>" +
773                                    obj.product_suggestion[i].size +
774                                    "</div>";
775                                strHtml +=
776                                    "<div class='search-product-price'><p class='item-price'>";
777                                if (
778                                    obj.product_suggestion[i].price_class ==
779                                    "price-off"
780                                ) {
781                                    strHtml +=
782                                        '<span class="promo-price ' +
783                                        obj.product_suggestion[i].price_class +
784                                        '">' +
785                                        obj.product_suggestion[i].promoPrice +
786                                        "</span>";
787                                }
788                                strHtml +=
789                                    '<span class="original-price ' +
790                                    obj.product_suggestion[i].price_class +
791                                    '">' +
792                                    obj.product_suggestion[i].normal_price +
793                                    "</span>";
794                                if (
795                                    obj.product_suggestion[i].price_class ==
796                                    "price-off-qty"
797                                ) {
798                                    strHtml +=
799                                        '<span class="promo-price ' +
800                                        obj.product_suggestion[i].price_class +
801                                        '">' +
802                                        obj.product_suggestion[i].promoPrice +
803                                        "</span>";
804                                }
805                                strHtml += "</p></div>";
806                                strHtml += "<div class='clearfix'></div>";
807                                strHtml += "</div>";
808
809                                strHtml += "</li>";
810                            }
811                            ctr += 1;
812                        }
813                    } else {
814                        strHtml += "<li>No product found.</li>";
815                    }
816                    strHtml += "</ul>";
817                    strParent = "";
818                    if ($(obj.category_suggestion).size() > 0) {
819                        strHtml +=
820                            "<ul class='list-suggestion categorylist-suggestion'>";
821                        for (i in obj.category_suggestion) {
822                            strHtml += "<li>";
823                            strParent = "";
824                            if (obj.category_suggestion[i].is_department) {
825                                strParent = "";
826                            } else {
827                                strParent =
828                                    obj.category_suggestion[i].department.slug +
829                                    "/";
830                            }
831
832                            var tmp_name = obj.category_suggestion[i].name;
833                            var pattern = new RegExp(
834                                "(" + searchValue + ")",
835                                "gi"
836                            );
837                            var start_pos = tmp_name
838                                .toLowerCase()
839                                .indexOf(searchValue.toLowerCase());
840                            var tmp_search_value = tmp_name.substring(
841                                start_pos,
842                                start_pos + searchValue.length
843                            );
844
845                            tmp_name = tmp_name.replace(
846                                pattern,
847                                '<span class="highlight">' +
848                                    tmp_search_value +
849                                    "</span>"
850                            );
851
852                            strHtml +=
853                                "<a href='" +
854                                base +
855                                "catalog/" +
856                                strParent +
857                                obj.category_suggestion[i].slug +
858                                "'>" +
859                                tmp_name +
860                                "</a>";
861                            strHtml += "</li>";
862                        }
863                        strHtml += "</ul>";
864                    }
865                    if ($(obj.category_alias_suggestion).size() > 0) {
866                        strHtml +=
867                            "<ul class='list-suggestion categorylist-suggestion'>";
868                        strHtml +=
869                            "<li class='lookingfor'>Are you looking for ...</li>";
870                        for (i in obj.category_alias_suggestion) {
871                            //console.log(obj.category_alias_suggestion[i]);
872                            strHtml += "<li>";
873          
873                  strParent = "";
874                            if (
875                                obj.category_alias_suggestion[i].is_department
876                            ) {
877                                strParent = "";
878                            } else {
879                                strParent =
880                                    obj.category_alias_suggestion[i].department
881                                        .slug + "/";
882                            }
883
884                            var tmp_name =
885                                obj.category_alias_suggestion[i].name;
886                            var pattern = new RegExp(
887                                "(" + searchValue + ")",
888                                "gi"
889                            );
890                            var start_pos = tmp_name
891                                .toLowerCase()
892                                .indexOf(searchValue.toLowerCase());
893                            var tmp_search_value = tmp_name.substring(
894                                start_pos,
895                                start_pos + searchValue.length
896                            );
897
898                            tmp_name = tmp_name.replace(
899                                pattern,
900                                '<span class="highlight">' +
901                                    tmp_search_value +
902                                    "</span>"
903                            );
904
905                            strHtml +=
906                                "<a href='" +
907                                base +
908                                "catalog/" +
909                                strParent +
910                                obj.category_alias_suggestion[i].slug +
911                                "'>" +
912                                tmp_name +
913                                "</a>";
914                            strHtml += "</li>";
915                        }
916                        strHtml += "</ul>";
917                    }
918                    var seeAllHtml = "<ul class='searchresults-seeall'>";
919                    // seeAllHtml += "<li><a href='" + base + "search?q=" + searchValue + "'>See all results of " + searchValue + "</a></li>";
920                    seeAllHtml +=
921                        "<li><a href='" +
922                        base +
923                        "search?q=" +
924                        encodeURIComponent(searchValue) +
925                        "'>VIEW ALL RESULTS</a></li>";
926                    seeAllHtml += "</ul>";
927
928                    suggestionElm.html(strHtml);
929                    suggestionElm
930                        .next("#searchform-suggestion-see-all")
931                        .html(seeAllHtml);
932                    // suggestionElm.highlight(searchValue);
933                } else {
934                    suggestionElm.html(
935                        "<ul class='list-suggestion product-suggestion'><li>No matches found.</li></ul>"
936                    );
937                }
938                suggestionElm.show();
939                setTimeout(function () {
940                    if (
941                        suggestionElm
942                            .next("#searchform-suggestion-see-all")
943                            .hasClass("search-suggestion-mobile")
944                    ) {
945                        suggestionElm
946                            .next("#searchform-suggestion-see-all")
947                            .find(".searchresults-seeall")
948                            .css("top", suggestionElm.height() + 50);
949                    } else {
950                        suggestionElm
951                            .next("#searchform-suggestion-see-all")
952                            .find(".searchresults-seeall")
953                            .css("top", suggestionElm.height() + 12);
954                    }
955
956                    suggestionElm.next("#searchform-suggestion-see-all").show();
957                }, 100);
958
959                $(".search-loader").hide();
960            },
961        });
962
963        // $.post(post_url, {keywords: searchValue},
964        // 	function (data) {
965
966        // 	}
967        // );
968    } else {
969        $(".search-loader").hide();
970        suggestionElm.hide();
971        suggestionElm.next("#searchform-suggestion-see-all").hide();
972    }
973}
974
975function changeUrl(page, url) {
976    if (typeof history.pushState != "undefined") {
977        var obj = { Page: page, Url: url };
978        history.pushState(obj, obj.Page, obj.Url);
979    } else {
980        alert("Browser does not support HTML5.");
981    }
982}
983
984$(document).ready(function () {
985    init_fancybox();
986
987    if ($("#product_quick_view").length > 0) {
988        $("#product_quick_view").click();
989    }
990
991    $(document).click(function () {
992        $(".searchform-suggestion").hide();
993        $(".searchform-suggestion-see-all").hide();
994        if ($("body").hasClass("show_menu")) {
995            $(".button_nav").find(".span_wrapper").removeClass("open");
996            $("body").removeClass("show_menu");
997            $("body").enableScroll();
998            $('.left-menu-mobile #shop-leftmenu').css('max-height', '0px');
999        }
1000
1001        $(".floating-form").find("#searchform-suggestion").hide();
1002        $(".floating-form").find("#searchform-suggestion-see-all").hide();
1003    });
1004    $( ".share-btn" ).click(function(e) {
1005        $('.networks-5').not($(this).next( ".networks-5" )).each(function(){
1006           $(this).removeClass("active");
1007           $(this).removeClass('active');
1008       });
1009           $(this).toggleClass('active');
1010          $(this).next( ".networks-5" ).toggleClass( "active" );
1011    });
1012    $("#searchform-suggestion").click(function (e) {
1013        e.stopPropagation();
1014    });
1015
1016    $("#shop-leftmenu").click(function (e) {
1017        e.stopPropagation();
1018    });
1019
1020    $("#shop-leftmenu .expand").click(function (e) {
1021        e.stopPropagation();
1022    });
1023
1024    $(".button_nav").click(function (e) {
1025        e.stopPropagation();
1026    });
1027
1028    $("#searchresults-seeall").click(function (e) {
1029        e.stopPropagation();
1030    });
1031
1032    $(".floating-form")
1033        .find("#searchform-suggestion")
1034        .click(function (e) {
1035            e.stopPropagation();
1036        });
1037
1038    $(".floating-form")
1039        .find("#searchresults-seeall")
1040        .click(function (e) {
1041            e.stopPropagation();
1042        });
1043
1044    $("body").on("click", ".open-product-detail", function (e) {
1045        if (
1046            $(e.target).hasClass("add-cart") ||
1047            $(e.target).hasClass("btn") ||
1048            $(e.target).hasClass("input-individual-quantity") ||
1049            $(e.target).hasClass("btn-add-to-shopping-list") ||
1050            $(e.target).hasClass("product-quick-view") ||
1051            $(e.target).hasClass("to-brand-page")
1052        ) {
1053            if ($(e.target).hasClass("view-product")) {
1054                $(this).find(".product-quick-view").click();
1055            } else {
1056                e.stopPropagation();
1057            }
1058        } else if ($(this).hasClass("open-single-page")) {
1059            window.open($(this).attr("data-url"), "_self");
1060        } else {
1061            if (!$(e.target).hasClass("bell")) {
1062                $(this).find(".product-quick-view").click();
1063            }
1064        }
1065    });
1066
1067    //Init Footer Fancybox
1068    $("#footer_link_new_to").click(function () {
1069        $("#newtogiant-fancybox").click();
1070    });
1071
1072    $("#footer_link_easy_reorder").click(function () {
1073        $("#easyreorder-fancybox").click();
1074    });
1075
1076    if ($(".owl-carousel.use-see-all").length > 0) {
1077        var sliderHeight =
1078            $(".owl-carousel.use-see-all").find("li:first").height() - 10;
1079        $(".owl-carousel.use-see-all")
1080            .find("li.see-all")
1081            .children("a")
1082            .css("height", sliderHeight + "px");
1083    }
1084
1085    $(document).on(
1086        "click",
1087        ".demo-notice-login-logout .close-notice-login-logout",
1088        function () {
1089            var header_height = $(".header-height");
1090            var demo_notice_height = $(this).height();
1091            $(this).parents(".demo-notice-login-logout").slideUp();
1092            if (
1093                $(this)
1094                    .parents(".demo-notice-login-logout")
1095                    .parent()
1096                    .css("display") != "none"
1097            ) {
1098                header_height.animate({
1099                    height: header_height.height() - demo_notice_height + "px",
1100                });
1101            }
1102        }
1103    );
1104
1105    setTimeout(function () {
1106        $(".demo-notice-login-logout .close-notice-login-logout").click();
1107    }, 5000);
1108
1109    $(document).on("keyup", "input.input-alphanumeric", function () {
1110        selected_input_val = $(this).val();
1111        selected_input_val_text = "";
1112        for (i = 0; i < selected_input_val.length; i++) {
1113            selected_input_char = selected_input_val.charCodeAt(i);
1114            if (
1115                (selected_input_char > 47 && selected_input_char < 58) ||
1116                (selected_input_char > 64 && selected_input_char < 91) ||
1117                (selected_input_char > 96 && selected_input_char < 123)
1118            ) {
1119                selected_input_val_text += String.fromCharCode(
1120                    selected_input_char
1121                );
1122            }
1123        }
1124        $(this).val(selected_input_val_text);
1125    });
1126
1127    $(document).on("keyup", "input.input-alphanumeric-space", function () {
1128        selected_input_val = $(this).val();
1129        selected_input_val_text = "";
1130        for (i = 0; i < selected_input_val.length; i++) {
1131            selected_input_char = selected_input_val.charCodeAt(i);
1132            if (
1133                selected_input_char == 32 ||
1134                (selected_input_char > 47 && selected_input_char < 58) ||
1135                (selected_input_char > 64 && selected_input_char < 91) ||
1136                (selected_input_char > 96 && selected_input_char < 123)
1137            ) {
1138                selected_input_val_text += String.fromCharCode(
1139                    selected_input_char
1140                );
1141            }
1142        }
1143        $(this).val(selected_input_val_text);
1144    });
1145
1146    $(document).on("keyup", "input.input-number", function () {
1147        selected_input_val = $(this).val();
1148        selected_input_val_text = "";
1149        for (i = 0; i < selected_input_val.length; i++) {
1150            selected_input_char = selected_input_val.charCodeAt(i);
1151            if (selected_input_char > 47 && selected_input_char < 58) {
1152                selected_input_val_text += String.fromCharCode(
1153                    selected_input_char
1154                );
1155            }
1156        }
1157        $(this).val(selected_input_val_text);
1158    });
1159
1160    $(window).resize(function () {
1161        var width = $(window).width();
1162        var sliderHeight = 0;
1163        if (width <= 480) {
1164            $(".owl-carousel").each(function (index, el) {
1165                sliderHeight = $(this).find("li:first").height();
1166                if (
1167                    $(this).hasClass("use-see-all") &&
1168                    $(this).find("li.see-all").length == 0
1169                ) {
1170                    $(this).trigger("destroy.owl.carousel");
1171                }
1172            });
1173
1174            if (sliderHeight > 0) {
1175                sliderHeight -= 10;
1176            }
1177
1178            $(".owl-carousel").each(function (index, el) {
1179                if (
1180                    $(this).hasClass("use-see-all") &&
1181                    $(this).find("li.see-all").length == 0
1182                ) {
1183                    var url = $(this).parent().data("category-url");
1184                    var config = $(this).data();
1185                    config.loop = false;
1186                    config.nav = true;
1187
1188                    if ($(this).find("li.see-all").length == 0) {
1189                        $(this).append(
1190                            '<li class="visible-xs see-all"><a style="height: ' +
1191                                sliderHeight +
1192                                'px" href="' +
1193                                url +
1194                                '" class="see-all-products"><span>See All&nbsp;></span></a></li>'
1195                        );
1196                    }
1197
1198                    $(this).owlCarousel(config);
1199                }
1200            });
1201        } else {
1202            $(".owl-carousel").each(function (index, el) {
1203                if ($(this).hasClass("use-see-all")) {
1204                    $(this).trigger("destroy.owl.carousel");
1205                }
1206            });
1207
1208            $(".owl-carousel").each(function (index, el) {
1209                if ($(this).hasClass("use-see-all")) {
1210                    var config = $(this).data();
1211                    $(this).find("li.see-all").remove();
1212                    config.loop = true;
1213                    config.nav = true;
1214                    $(this).owlCarousel(config);
1215                }
1216            });
1217        }
1218    });
1219});
1220
1221/**
1222 * Vertically center Bootstrap 3 modals so they aren't always stuck at the top
1223 */
1224$(function () {
1225    function reposition() {
1226        var modal = $(this),
1227            dialog = modal.find(".modal-dialog");
1228        modal.css("display", "block");
1229
1230        // Dividing by two centers the modal exactly, but dividing by three
1231        // or four works better for larger screens.
1232        dialog.css(
1233            "margin-top",
1234            Math.max(0, ($(window).height() - dialog.height()) / 2)
1235        );
1236    }
1237
1238    // Reposition when a modal is showing
1239    $(document).on("show.bs.modal", ".modal", reposition);
1240
1241    // Reposition when the window is resized
1242    $(window).on("resize", function () {
1243        $(".modal:visible").each(reposition);
1244    });
1245});
1246
1247function init_fancybox() {
1248    $(".various").fancybox({
1249        maxWidth: 800,
1250        maxHeight: 600,
1251        fitToView: true,
1252        width: "100%",
1253        height: "100%",
1254        autoSize: true,
1255        closeClick: false,
1256        openEffect: "none",
1257        closeEffect: "none",
1258    });
1259
1260    $("a.fancybox").fancybox({
1261        maxWidth: 1170,
1262        maxHeight: 600,
1263        fitToView: true,
1264        width: "100%",
1265        height: "100%",
1266        autoSize: true,
1267        closeClick: false,
1268        openEffect: "fade",
1269        closeEffect: "fade",
1270        nextEffect: "fade",
1271        prevEffect: "fade",
1272        helpers: {
1273            title: {
1274                type: "outside",
1275            },
1276        },
1277    });
1278}
1279
1280function send_data_to_ga(path, product_data) {
1281    if (path == "") {
1282        path = window.location.pathname;
1283    }
1284
1285    var ga = window[window["GoogleAnalyticsObject"] || "ga"];
1286    if (typeof ga == "function") {
1287        // call ga object here
1288        ga("ec:addProduct", product_data);
1289        ga("ec:setAction", "detail");
1290        ga("set", "page", path);
1291        ga("send", "pageview");
1292    }
1293}
1294
1295function init_product_lightbox() {
1296    var product_id = 0;
1297    var product_type = "";
1298    var previousLink = current_page_url;
1299    $(".product-quick-view").each(function () {
1300        if (typeof $(this).data("fancybox-ready") == "undefined") {
1301            $(this).data("fancybox-ready", 1);
1302            var product_id = $(this).data("product-id");
1303            var product_type = $(this).data("product-type");
1304
1305            var quickViewPath = $(this).data("quick-view-path");
1306            var product_name = decodeURIComponent(
1307                ($(this).data("product-name") + "").replace(/\+/g, "%20")
1308            );
1309            var sku = $(this).data("product-sku");
1310            var size = $(this).data("product-size");
1311            var brand = $(this).data("product-brand");
1312            var brand_url = $(this).data("product-brand-url");
1313            var extra_note = $(this).data("extra-note");
1314            var parent_page = $(this).data("parent-page");
1315
1316            $(this).fancybox({
1317                maxWidth: 800,
1318                maxHeight: 600,
1319                padding: 0,
1320                fitToView: true,
1321                width: "90%",
1322                height: "90%",
1323                autoSize: false,
1324                closeClick: false,
1325                openEffect: "none",
1326                closeEffect: "none",
1327                touch: false,
1328                thumbs: {
1329                    autoStart: true,
1330                },
1331                mobile: {
1332                    thumbs: false,
1333                },
1334                tpl: {
1335                    closeBtn:
1336                        '<a title="Close" class="fancybox-item fancybox-close close-login" href="javascript:;"></a>',
1337                },
1338                baseClass: "product-lightbox2",
1339                onInit: function () {
1340                    if ($(".product-lightbox2").length > 1) {
1341                        $(".product-lightbox2:first")
1342                            .find(".fancybox-close-small")
1343                            .click();
1344                    }
1345
1346                    if ($("#product_quick_view").length > 0) {
1347                        $("#product_quick_view").remove();
1348                    }
1349
1350                    if ($(".zoomContainer").length > 0) {
1351                        $(".zoomContainer").remove();
1352                    }
1353                },
1354                beforeLoad: function () {
1355                    if (
1356                        typeof parent_page != "undefined" &&
1357                        parent_page == "home"
1358                    ) {
1359                        previousLink = base;
1360                    }
1361                    // previousLink = window.location.pathname;
1362                },
1363                afterShow: function () {
1364                    if ($("#product_quick_view").length > 0) {
1365                        $("#product_quick_view").remove();
1366                    }
1367
1368                    $(".product-lightbox2")
1369                        .find(".product-size")
1370                        .css("display", "none");
1371                    $(".product-lightbox2")
1372                        .find(".product-name")
1373                        .html(product_name);
1374                    $(".product-lightbox2").find(".product-size").html(size);
1375                    $(".product-lightbox2")
1376                        .find(".product-brand")
1377                        .children("a")
1378                        .html(brand);
1379                    $(".product-lightbox2")
1380                        .find(".product-brand")
1381                        .children("a")
1382                        .attr("href", brand_url);
1383                    $(".product-lightbox2")
1384                        .find(".btn-add-to-shopping-list")
1385                        .data("product-id", product_id);
1386                    $(".product-lightbox2")
1387                        .find("#product_sku")
1388                        .find("#data-sku")
1389                        .html(sku);
1390
1391                    // load product images
1392                    var loadProductImageUrl =
1393                        base + "productlightbox/getproductimage";
1394                    $.post(
1395                        loadProductImageUrl,
1396                        { product_id: product_id },
1397                        function (result) {
1398                            result = $.parseJSON(result);
1399                            // display product image
1400                            setProductImage(result);
1401
1402                            // load product information
1403                            var loadProductInfoUrl =
1404                                base + "productlightbox/getproductinfo";
1405                            $.post(
1406                                loadProductInfoUrl,
1407                                { product_id: product_id },
1408                                function (result) {
1409                                    result = $.parseJSON(result);
1410                                    $(".product-lightbox2")
1411                                        .find("#product_sku")
1412                                        .find("p")
1413                                        .append(result.brand_blurb);
1414
1415                                    $(".product-lightbox2")
1416                                        .find("#product_extra_note")
1417                                        .html(
1418                                            '<div class="content_info extra_note">' +
1419                                                extra_note +
1420                                                "</div>"
1421                                        );
1422                                    $(".product-lightbox2")
1423                                        .find("#product_price_block")
1424                                        .html(result.product_price);
1425                                    $(".product-lightbox2")
1426                                        .find(".btn-add-to-shopping-list")
1427                                        .removeClass("red");
1428                                    $(".product-lightbox2")
1429                                        .find(".btn-add-to-shopping-list")
1430                                        .addClass(result.favourite_class);
1431                                    $(".product-lightbox2")
1432                                        .find(".btn-add-to-shopping-list a")
1433                                        .html(result.favourite_text);
1434
1435                                    var display_size = true;
1436                                    $(".product-lightbox2")
1437                                        .find("#product_price_block")
1438                                        .find(".content_info")
1439                                        .each(function () {
1440                                            if (
1441                                                $(this).find("span").length > 0
1442                                            ) {
1443                                                display_size = false;
1444                                            } else {
1445                                                $(this).addClass("hidden");
1446                                            }
1447                                        });
1448
1449                                    if (display_size) {
1450                                        $(".product-lightbox2")
1451                                            .find(".product-size")
1452                                            .css("display", "block");
1453                                    }
1454
1455                                    var raw_product_price = $(
1456                                        ".product-lightbox2"
1457                                    )
1458                                        .find("#product_price_block")
1459                                        .find(".product-price")
1460                                        .attr("data-price");
1461
1462                                    var ga_product_data = {
1463                                        id: sku,
1464                                        name: product_name,
1465                                        brand: brand,
1466                                        price: raw_product_price,
1467                                    };
1468
1469                                    send_data_to_ga(
1470                                        quickViewPath,
1471                                        ga_product_data
1472                                    );
1473
1474                                    if (
1475                                        result.product_type == "Bundle" &&
1476                                        result.bundle_product != ""
1477                                    ) {
1478                                        $(".product-lightbox2")
1479                                            .find("#bundle_product")
1480                                            .html(result.bundle_product);
1481                                        initBundleItem();
1482                                        calculateAdditionalPrice();
1483                                    }
1484
1485                                    /* For configurable product */
1486                                    if (
1487                                        $(".product-lightbox2").find("#indexId")
1488                                            .length > 0
1489                                    ) {
1490                                        var optionSelected = $(
1491                                            ".product-lightbox2"
1492                                        ).find("#indexId>option:selected");
1493                                        if (
1494                                            optionSelected.data(
1495                                                "promo-price"
1496                                            ) != "$0.00"
1497                                        ) {
1498                                            if (
1499                                                $(".product-lightbox2").find(
1500                                                    ".old-price"
1501                                                ).length < 1
1502                                            ) {
1503                                                $(".product-lightbox2")
1504                                                    .find(".content_price")
1505                                                    .append(
1506                                                        '<span class="price old-price hidden"></span>'
1507                                                    );
1508                                            }
1509
1510                                            $(".product-lightbox2")
1511                                                .find(".old-price")
1512                                                .html(
1513                                                    optionSelected.data("price")
1514                                                );
1515                                            $(".product-lightbox2")
1516                                                .find(".product-price")
1517                                                .html(
1518                                                    optionSelected.data(
1519                                                        "promo-price"
1520                                                    )
1521                                                );
1522                                            $(".product-lightbox2")
1523                                                .find(".old-price")
1524                                                .removeClass("hidden");
1525
1526                                            if (
1527                                                optionSelected.data(
1528                                                    "discount-label"
1529                                                ) != ""
1530                                            ) {
1531                                                var tmp_discount_label = optionSelected.data(
1532                                                    "discount-label"
1533                                                );
1534                                                $(".product-lightbox2")
1535                                                    .find("#price_discount")
1536                                                    .removeClass("hidden");
1537                                                $(".product-lightbox2")
1538                                                    .find("#price_discount")
1539                                                    .html(tmp_discount_label);
1540
1541                                                if (
1542                                                    tmp_discount_label
1543                                                        .toLowerCase()
1544                                                        .indexOf("buy") >= 0
1545                                                ) {
1546                                                    $(".product-lightbox2")
1547                                                        .find("#price_discount")
1548                                                        .addClass("blue");
1549                                                } else {
1550                                                    $(".product-lightbox2")
1551                                                        .find("#price_discount")
1552                                                        .removeClass("blue");
1553                                                }
1554                                            }
1555                                        } else {
1556                                            $(".product-lightbox2")
1557                                                .find(".product-price")
1558                                                .html(
1559                                                    optionSelected.data("price")
1560                                                );
1561                                            if (
1562                                                $(".product-lightbox2").find(
1563                                                    ".old-price"
1564                                                ).length > 0
1565                                            ) {
1566                                                $(".product-lightbox2")
1567                                                    .find(".old-price")
1568                                                    .addClass("hidden");
1569                                            }
1570                                        }
1571
1572                                        $(".product-lightbox2")
1573                                            .find(".btn-add-to-cart")
1574                                            .data(
1575                                                "product-id",
1576                                                $(".product-lightbox2")
1577                                                    .find("#indexId")
1578                                                    .val()
1579                                            );
1580
1581                                        updateOptionAjax(optionSelected.val());
1582                                        calculatePrice(optionSelected.val());
1583                                    }
1584
1585                                    $('[data-toggle="tooltip"]').tooltip({
1586                                        sanitize: false,
1587                                        sanitizeFn: null,
1588                                    });
1589                                }
1590                            );
1591                        }
1592                    );
1593
1594                    // load add to cart button
1595                    var loadAddToCartUrl =
1596                        base + "productlightbox/getaddtocart";
1597                    $.post(
1598                        loadAddToCartUrl,
1599                        { product_id: product_id },
1600                        function (result) {
1601                            result = $.parseJSON(result);
1602                            if (result.discount_label != "") {
1603                                $(".product-lightbox2")
1604                                    .find("#price_discount")
1605                                    .html(result.discount_label);
1606                                $(".product-lightbox2")
1607                                    .find("#price_discount")
1608                                    .removeClass("hidden");
1609                                if (
1610                                    result.discount_label
1611                                        .toLowerCase()
1612                                        .indexOf("buy") >= 0
1613                                ) {
1614                                    $(".product-lightbox2")
1615                                        .find("#price_discount")
1616                                        .addClass("blue");
1617                                } else {
1618                                    $(".product-lightbox2")
1619                                        .find("#price_discount")
1620                                        .removeClass("blue");
1621                                }
1622                            }
1623
1624                            if (result.show_rating == "yes") {
1625                                $(".product-lightbox2")
1626                                    .find(".rating-star-md")
1627                                    .html(result.product_rating);
1628                                $(".product-lightbox2")
1629                                    .find(".rating-star-md")
1630                                    .removeClass("hidden");
1631                            }
1632
1633                            if (result.product_label != "") {
1634                                $(".product-lightbox2")
1635                                    .find(".individual-product.label")
1636                                    .html(result.product_label);
1637                                $(".product-lightbox2")
1638                                    .find(".individual-product.label")
1639                                    .removeClass("hidden");
1640                            }
1641
1642                            if (result.stamps_info != "") {
1643                                $(".product-lightbox2")
1644                                    .find("#stamps_block")
1645                                    .html(result.stamps_info);
1646                            }
1647
1648                            if (result.product_description != "") {
1649                                $(".product-lightbox2")
1650                                    .find("#description_block")
1651                                    .html(result.product_description);
1652                            } else {
1653                                $(".product-lightbox2")
1654                                    .find("#description_block")
1655                                    .html("");
1656                            }
1657
1658                            if (result.full_description != "") {
1659                                $(".product-lightbox2")
1660                                    .find("#product_full_description")
1661                                    .addClass("col-xs-12");
1662                            }
1663
1664                            $(".product-lightbox2")
1665                                .find("#product_full_description")
1666                                .html(result.full_description);
1667
1668                            $(".product-lightbox2")
1669                                .find("#cart-block")
1670                                .html(result.add_to_cart);
1671                            $(".product-lightbox2")
1672                                .find("#price-alert-block")
1673                                .html(result.price_alert);
1674                        }
1675                    );
1676
1677                    // load product custom options
1678                    var loadProductCustomOptionsUrl =
1679                        base + "productlightbox/getproductcustomoptions";
1680                    $.post(
1681                        loadProductCustomOptionsUrl,
1682                        { product_id: product_id },
1683                        function (result) {
1684                            result = $.parseJSON(result);
1685                            if (result.custom_options != "") {
1686                                $("#has-option").show();
1687                            }
1688                            $(".product-lightbox2")
1689                                .find("#custom_options_block")
1690                                .html(result.custom_options);
1691                        }
1692                    );
1693
1694                    // load rating & review
1695                    var loadProductRatingUrl =
1696                        base + "productlightbox/getproductrating";
1697                    $.post(
1698                        loadProductRatingUrl,
1699                        { product_id: product_id },
1700                        function (result) {
1701                            result = $.parseJSON(result);
1702                            $(".product-lightbox2")
1703                                .find("#product_rating_block")
1704                                .html(result.product_rating);
1705                        }
1706                    );
1707
1708                    // load related product
1709                    var loadRelatedProductUrl =
1710                        base + "productlightbox/getrelatedproduct";
1711                    $.post(
1712                        loadRelatedProductUrl,
1713                        { product_id: product_id },
1714                        function (result) {
1715                            result = $.parseJSON(result);
1716                            $(".product-lightbox2")
1717                                .find("#related_product_block")
1718                                .html(result.related_product);
1719
1720                            $(".product-lightbox2 #related_product_block")
1721                                .find(".owl-carousel")
1722                                .each(function (index, el) {
1723                                    var config = $(this).data();
1724                                    config.navText = [
1725                                        '<i class="fa fa-angle-left"></i>',
1726                                        '<i class="fa fa-angle-right"></i>',
1727                                    ];
1728                                    config.smartSpeed = "300";
1729                                    if ($(this).hasClass("owl-style2")) {
1730                                        config.animateOut = "fadeOut";
1731                                        config.animateIn = "fadeIn";
1732                                    }
1733
1734                                    config.callbacks = true;
1735                                    var owl = $(this);
1736                                    owl.on(
1737                                        "initialized.owl.carousel",
1738                                        function (event) {
1739                                            // console.log('carousel loaded!');
1740                                            setTimeout(function () {
1741                                                $(
1742                                                    ".product-lightbox2 #related_product_block"
1743                                                )
1744                                                    .find("img.lazyload")
1745                                                    .lazy({
1746                                                        // called after an element was successfully handled
1747                                                        afterLoad: function (
1748                                                            element
1749                                                        ) {
1750                                                            var imageSrc = element.removeClass(
1751                                                                "full-width-image"
1752                                                            );
1753                                                        },
1754                                                    });
1755                                                console.log(
1756                                                    "carousel lazy image loaded!"
1757                                                );
1758                                            }, 200);
1759                                        }
1760                                    );
1761
1762                                    owl.owlCarousel(config);
1763
1764                                    owl.on("changed.owl.carousel", function (
1765                                        event
1766                                    ) {
1767                                        $(
1768                                            ".product-lightbox2 #related_product_block"
1769                                        )
1770                                            .find("img.lazyload")
1771                                            .lazy({
1772                                                // called after an element was successfully handled
1773                                                afterLoad: function (element) {
1774                                                    var imageSrc = element.removeClass(
1775                                                        "full-width-image"
1776                                                    );
1777                                                },
1778                                            });
1779                                    });
1780                                });
1781                        }
1782                    );
1783
1784                    if (typeof quickViewPath != "undefined") {
1785                        changeUrl("", quickViewPath);
1786                    }
1787
1788                    $(".product-lightbox2").find("#cart-block").popover({
1789                        html: true,
1790                        trigger: "manual",
1791                        placement: "top",
1792                    });
1793
1794                    $(".product-lightbox2")
1795                        .find(".btn-notify-me")
1796                        .each(function () {
1797                            var tmp = $(this).attr("href");
1798                            tmp += "&callback=" + previousLink;
1799                            $(this).attr("href", tmp);
1800                        });
1801                },
1802                afterClose: function () {
1803                    if (previousLink != "") {
1804                        if (previousLink == window.location.pathname) {
1805                            changeUrl("", "/");
1806                        } else {
1807                            changeUrl("", previousLink);
1808                        }
1809                    }
1810
1811                    $(".zoomContainer").remove();
1812                    $(".fancybox-overlay").remove();
1813                },
1814            });
1815        }
1816    });
1817
1818    setTimeout(function () {
1819        if ($("#product_quick_view").length > 0) {
1820            $("#product_quick_view").click();
1821        }
1822    }, 300);
1823}
1824
1825function setProductImage(result) {
1826    var nums_image = 0;
1827    var first_image = "";
1828    var loop_image = false;
1829    var use_pager = false;
1830
1831    if (result.product_type == "Configurable") {
1832        $.each(result.image_gallery, function (key, value) {
1833            nums_image++;
1834            if (first_image == "") {
1835                first_image = key;
1836            }
1837        });
1838    } else {
1839        nums_image = result.image_gallery.length;
1840    }
1841
1842    if (nums_image > 2) {
1843        loop_image = true;
1844    }
1845
1846    if (nums_image > 1) {
1847        use_pager = true;
1848    }
1849
1850    var main_image = "";
1851    var product_image_gallery =
1852        "<ul class='product-list images-slider' data-margin='5' data-dots='0' data-loop='" +
1853        loop_image +
1854        '\' data-nav=\'1\' data-autoplayTimeout=\'1000\' data-autoplayHoverPause=\'1\' data-responsive=\'{"0":{"items":2},"375":{"items":2},"480":{"items":2},"767":{"items":4},"768":{"items":3},"991":{"items":3},"1199":{"items":3},"1200":{"items":3},"1366":{"items":3},"1920":{"items":3}}\'>';
1855
1856    if (nums_image > 1) {
1857        var main_image_gallery = "<ul class='main-images-slider touch-active'>";
1858    } else {
1859        var main_image_gallery = "<ul class='main-images-slider no-touch'>";
1860    }
1861    if (result.product_type == "Configurable") {
1862        // generate main image
1863        main_image =
1864            "<img src='" +
1865            result.original_image[first_image] +
1866            "' class='product-img' data-zoom-image='" +
1867            result.original_image[first_image] +
1868            "' />";
1869
1870        // set product image gallery
1871        var index = 0;
1872        $.each(result.image_gallery, function (key, value) {
1873            product_image_gallery +=
1874                "<li class='image-thumb' id='image-" + index + "'>";
1875            product_image_gallery +=
1876                "<img src='" +
1877                value +
1878                "' class='product-img' data-original-url='" +
1879                result.original_image[key] +
1880                "' />";
1881            product_image_gallery += "</li>";
1882
1883            main_image_gallery += "<li>";
1884            main_image_gallery +=
1885                "<img src='" + result.original_image[key] + "' class='' />";
1886            main_image_gallery += "</li>";
1887
1888            index++;
1889        });
1890        product_image_gallery += "</ul>";
1891
1892        // load product options for configurable product
1893        setProductOptions(result);
1894    } else {
1895        // set product main image
1896        main_image =
1897            "<img src='" +
1898            result.original_image[0] +
1899            "' class='product-img' data-zoom-image='" +
1900            result.original_image[0] +
1901            "' />";
1902
1903        // set product image gallery
1904        $.each(result.image_gallery, function (key, value) {
1905            product_image_gallery += "<li class='image-thumb'>";
1906            product_image_gallery +=
1907                "<img src='" +
1908                value +
1909                "' class='product-img' data-original-url='" +
1910                result.original_image[key] +
1911                "' />";
1912            product_image_gallery += "</li>";
1913
1914            main_image_gallery += "<li>";
1915            main_image_gallery +=
1916                "<img src='" + result.original_image[key] + "' class='' />";
1917            main_image_gallery += "</li>";
1918        });
1919
1920        product_image_gallery += "</ul>";
1921        main_image_gallery += "</ul>";
1922        $(".product-lightbox2").find("#product_options").html("");
1923    }
1924
1925    $(".product-lightbox2").find("#selected_image_lightbox").html(main_image);
1926    $(".product-lightbox2")
1927        .find("#product_image_gallery")
1928        .html(product_image_gallery);
1929
1930    // main image for mobile
1931    $(".product-lightbox2")
1932        .find("#selected_image_lightbox_xs")
1933        .html(main_image_gallery);
1934
1935    window_width = $(window).width();
1936    var elevate_config = {
1937        zoomType: "inner",
1938        cursor: "crosshair",
1939        zoomWindowFadeIn: 500,
1940        zoomWindowFadeOut: 750,
1941    };
1942
1943    if (window_width > 767) {
1944        $("#selected_image_lightbox")
1945            .children("img")
1946            .elevateZoom(elevate_config);
1947    }
1948
1949    $(".product-lightbox2").find(".images-slider").bxSlider({
1950        mode: "vertical",
1951        minSlides: 3,
1952        maxSlides: 3,
1953        slideMargin: 10,
1954        infiniteLoop: false,
1955        pager: false,
1956        prevText: '<i class="fa fa-angle-up"></i>',
1957        nextText: '<i class="fa fa-angle-down"></i>',
1958    });
1959
1960    $(".product-lightbox2").find(".main-images-slider.touch-active").bxSlider({
1961        // mode: 'vertical',
1962        minSlides: 1,
1963        maxSlides: 1,
1964        // slideMargin: 10,
1965        infiniteLoop: false,
1966        pager: use_pager,
1967        controls: false,
1968    });
1969    $(".product-lightbox2").find(".main-images-slider.no-touch").bxSlider({
1970        // mode: 'vertical',
1971        minSlides: 1,
1972        maxSlides: 1,
1973        // slideMargin: 10,
1974        infiniteLoop: false,
1975        pager: use_pager,
1976        controls: false,
1977        touchEnabled: false,
1978    });
1979
1980    // $('.product-lightbox2').find('.owl-carousel').each(function (index, el) {
1981    // 	var config = $(this).data();
1982    // 	config.navText = ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>'];
1983    // 	config.smartSpeed = "300";
1984    // 	if ($(this).hasClass('owl-style2')) {
1985    // 		config.animateOut = "fadeOut";
1986    // 		config.animateIn = "fadeIn";
1987    // 	}
1988
1989    // 	$(this).owlCarousel(config);
1990    // });
1991
1992    $("#product_image_gallery")
1993        .find(".owl-stage")
1994        .find(".active")
1995        .each(function (index) {
1996            if (index == 0) {
1997                $(this).children("li").addClass("border-green");
1998            }
1999        });
2000}
2001
2002function setProductOptions(result) {
2003    if (result.product_type == "Configurable" && result.hasChildActive) {
2004        var product_options = "";
2005        product_options += '<div class="row">';
2006        product_options += '<div class="col-12">';
2007        product_options += "<div>Select Product</div>";
2008        product_options +=
2009            '<select id="indexId" name="indexId" class="input form-control">';
2010        product_options +=
2011            '<option value="" selected disabled>- Please Select -</option>';
2012        $.each(result.dropdown, function (key, value) {
2013            var index = 0;
2014            var counter = 0;
2015
2016            $.each(result.image_gallery, function (k, v) {
2017                if (k == value["img_key"]) {
2018                    counter = index;
2019                }
2020
2021                index++;
2022            });
2023
2024            if (value["status"] == "Enabled") {
2025                var sku = value["sku"];
2026                var price = value["price"];
2027                var promo_price = value["promoprice"];
2028                var id = value["id"];
2029                var availability = value["availability"];
2030                var status = value["status"];
2031                var discount_label = value["discount_label"];
2032                var product_info = value["product_info"];
2033
2034                product_options +=
2035                    "<option " +
2036                    product_info +
2037                    ' imageIndex="image-' +
2038                    counter +
2039                    '" data-sku="' +
2040                    sku +
2041                    '" data-price="' +
2042                    price +
2043                    '" data-promo-price="' +
2044                    promo_price +
2045                    '" value="' +
2046                    id +
2047                    '" data-availability="' +
2048                    availability +
2049                    '" data-status="' +
2050                    status +
2051                    '" data-discount-label="' +
2052                    discount_label +
2053                    '">' +
2054                    value["name"] +
2055                    "</option>";
2056            }
2057        });
2058
2059        product_options += "</select>";
2060        product_options += "<hr />";
2061        product_options += "</div>";
2062        product_options += "</div>";
2063
2064        $(".product-lightbox2").find("#product_options").html(product_options);
2065    } else {
2066        $(".product-lightbox2").find("#product_options").html("");
2067    }
2068}
2069
2070function stopEventPropagation(e) {
2071    if (!e) e = window.event;
2072
2073    // IE9 & Other Browsers
2074    if (e.stopPropagation) {
2075        e.stopPropagation();
2076    }
2077    // IE8 and Lower
2078    else {
2079        e.cancelBubble = true;
2080    }
2081}
2082
2083function openLogin() {
2084    $("a.login-popup").trigger("click");
2085}
2086
2087$.fn.disableScroll = function () {
2088    window.oldScrollPos = $(window).scrollTop();
2089
2090    $(window).on("scroll.scrolldisabler", function (event) {
2091        $(window).scrollTop(window.oldScrollPos);
2092        event.preventDefault();
2093    });
2094};
2095
2096$.fn.enableScroll = function () {
2097    $(window).off("scroll.scrolldisabler");
2098};
2099
2100/*Search Articles*/
2101$("#search_article").on("keyup", function (e) {
2102    var searchValue = $(this).val();
2103    var searchCategory = $("#article_topic").val();
2104    delay(function () {
2105        ajaxSearchArticles(searchValue, searchCategory);
2106    }, 500);
2107
2108    /*
2109	setTimeout(function () {
2110		ajaxSuggestions(searchValue, $('#searchform-suggestion'));
2111	}, 500);
2112	*/
2113});
2114$("#article_topic").on("change", function (e) {
2115    var searchValue = $("#search_article").val();
2116    var searchCategory = $(this).val();
2117    delay(function () {
2118        ajaxSearchArticles(searchValue, searchCategory);
2119    }, 500);
2120});
2121function ajaxSearchArticles(searchValue, searchCategory) {
2122    var ajaxRequest = "?";
2123    if (searchValue != "") {
2124        ajaxRequest += "q=" + searchValue;
2125    } else {
2126        ajaxRequest += "q=";
2127    }
2128    if (searchCategory != "") {
2129        ajaxRequest += "&cat=" + searchCategory;
2130    } else {
2131        ajaxRequest += "&cat=";
2132    }
2133
2134    $.fn.yiiListView.update("article_list", {
2135        data: ajaxRequest,
2136    });
2137}
2138/*END Search Articles*/
2139
2140/*ACCORDION*/
2141
2142$(".accordion_title").on("click", function () {
2143    if ($(this).closest(".accordion_box").hasClass("active")) {
2144        $(this).closest(".accordion_box").removeClass("active");
2145    } else {
2146        $(this).closest(".accordion_box").addClass("active");
2147    }
2148});
2149$(function () {
2150    $(window).scroll(function () {
2151        var aTop = $("#header").height();
2152        if ($(this).scrollTop() >= aTop) {
2153            $("body").addClass("menu-scroll");
2154            // instead of alert you can use to show your ad
2155            // something like $('#footAd').slideup();
2156        } else {
2157            $("body").removeClass("menu-scroll");
2158        }
2159    });
2160});
2161
2162$(".menu_on_mobile").on("click", function () {
2163    if ($(this).hasClass("show")) {
2164        $(this).removeClass("show");
2165    } else {
2166        $(this).addClass("show");
2167    }
2168});
2169
2170$(".dropdown-left-menu .expand").on("click", function () {
2171    if ($(this).parent().hasClass("show")) {
2172        $(this).parent().removeClass("show");
2173    } else {
2174        $(this).parent().addClass("show");
2175    }
2176});
2177$(".main-navbar .nav-link").on("click", function () {
2178    if ($("body").hasClass("show_menu")) {
2179        $(".button_nav").find(".span_wrapper").removeClass("open");
2180        $("body").removeClass("show_menu");
2181        $("body").enableScroll();
2182        $('.left-menu-mobile #shop-leftmenu').css('max-height', '0px');
2183    }
2184});
2185$(".top_header .search_top").on("focus", function () {
2186    if ($("body").hasClass("show_menu")) {
2187        $(".button_nav").find(".span_wrapper").removeClass("open");
2188        $("body").removeClass("show_menu");
2189        $("body").enableScroll();
2190        $('.left-menu-mobile #shop-leftmenu').css('max-height', '0px');
2191    }
2192});
2193$(".top_header .search_top").on("keyup", function () {
2194    if ($("body").hasClass("show_menu")) {
2195        $(".button_nav").find(".span_wrapper").removeClass("open");
2196        $("body").removeClass("show_menu");
2197        $("body").enableScroll();
2198        $('.left-menu-mobile #shop-leftmenu').css('max-height', '0px');
2199    }
2200    if ($(this).val() != "") {
2201        $(".top_header .search_top").css("width", "200px");
2202    } else {
2203        $(".top_header .search_top").css("width", "70px");
2204    }
2205});
2206
2207if($(".sms-checkbox-wrapper .sms-check").length > 0){
2208    var newsletter_checked = $(".sms-checkbox-wrapper .sms-check").prop('checked');
2209    if(newsletter_checked == true){
2210        $(".sms-checkbox-wrapper .sms-check").closest('.widget_dynamic_list-newsletter-subscription').find('.form-input-phone').slideDown();
2211    }else{
2212        $(".sms-checkbox-wrapper .sms-check").closest('.widget_dynamic_list-newsletter-subscription').find('.form-input-phone').slideUp();
2213    }
2214}
2215
2216$(".sms-checkbox-wrapper .sms-check").on("change", function () {
2217    var checked = $(this).prop('checked');
2218    if(checked == true){
2219        $(this).closest('.widget_dynamic_list-newsletter-subscription').find('.form-input-phone').slideDown();
2220    }else{
2221        $(this).closest('.widget_dynamic_list-newsletter-subscription').find('.form-input-phone').slideUp();
2222    }
2223});
2224
2225$("#newsletter_subscription_form").submit(function (e) {
2226    e.preventDefault();
2227    var _email = $("#Subscription_subscription_email").val();
2228    var _phone = $("#Subscription_subscription_phone").val();
2229    var _phone_validation = true;
2230    if($(this).find('#sms-check').is(':checked') && _phone == ""){
2231        _phone_validation = false;
2232    }
2233    if (_email != "" && _phone_validation) {
2234        $(this).parent().find(".subscribe_error.error_invalid").hide();
2235        var that = this;
2236        $.post(
2237            site_config.base_path + "subscription/default/validateemail",
2238            { email: _email, phone: _phone },
2239            function (data) {
2240                if (data.error_message != undefined) {
2241                    $(that)
2242                        .parent()
2243                        .find(".subscribe_error.error_invalid")
2244                        .html(data.error_message);
2245                }
2246                if (data.valid == 1) {
2247                    $("#subscription_email_hidden").val(_email);
2248                    // $(".btn-subscription").click();
2249                    // views/layouts/html/popup_subscribe.php
2250                    // previously it show popup to fill name, but now it skipped
2251                    $(that).unbind("submit").submit();
2252                } else {
2253                    $(that).unbind('submit').submit();
2254                    //$(that)
2255                    //    .parent()
2256                    //    .find(".subscribe_error.error_invalid")
2257                    //    .show();
2258                }
2259            },
2260            "json"
2261        );
2262    } else {
2263        $(this).parent().find('.phone-number').hide();
2264        $(this).parent().find(".subscribe_error.error_invalid").show();
2265        if(!_phone_validation){
2266            $(this).parent().find('.phone-number').show();
2267        }
2268    }
2269});
2270
2271window.onresize = function (event) {
2272    adjustHeight();
2273    if($(".sms-checkbox-wrapper .sms-check").length > 0){
2274        var newsletter_checked = $(".sms-checkbox-wrapper .sms-check").prop('checked');
2275        if(newsletter_checked == true){
2276            $(".sms-checkbox-wrapper .sms-check").closest('.widget_dynamic_list-newsletter-subscription').find('.form-input-phone').slideDown();
2277        }else{
2278            $(".sms-checkbox-wrapper .sms-check").closest('.widget_dynamic_list-newsletter-subscription').find('.form-input-phone .input-phone').val('');
2279            $(".sms-checkbox-wrapper .sms-check").closest('.widget_dynamic_list-newsletter-subscription').find('.form-input-phone').slideUp();
2280        }
2281    }
2282};
2283/* ---------------------------------------------
2284Set Height header height
2285--------------------------------------------- */
2286var headerheight;
2287function adjustHeight() {
2288    headerheight = $("#header").height();
2289    searchposition =
2290        $(".main-navbar").height() + $(".header_notification_wrapper").height();
2291    $(".header_height").height(headerheight);
2292}
2293
2294adjustHeight();
2295$(window).on("load", function () {
2296    adjustHeight();
2297});
2298
2299if ($(".header_notification .slick_item").length > 0) {
2300    if ($(window).width() < 992) {
2301        $(".header_notification").slick({
2302            slidesToShow: 1,
2303            autoplay: false,
2304            arrows: false,
2305            dot: false,
2306            vertical: true,
2307            autoplaySpeed: 7000,
2308        });
2309    } else {
2310        $(".header_notification").slick({
2311            slidesToShow: 1,
2312            autoplay: true,
2313            arrows: false,
2314            dot: false,
2315            vertical: true,
2316            autoplaySpeed: 5000,
2317        });
2318    }
2319}
2320
2321var hide_notification = null;
2322if ($.cookie("hide_notification") !== undefined) {
2323    hide_notification = $.cookie("hide_notification");
2324}
2325if (hide_notification == 1) {
2326    $(".header_notification_wrapper").hide();
2327    $("body").removeClass("with_top_notif");
2328} else {
2329    if (!$("body").hasClass("with_top_notif")) {
2330        $(".header_notification_wrapper").show("slow", function () {
2331            $("body").addClass("with_top_notif");
2332            adjustHeight();
2333        });
2334    }
2335}
2336
2337function validateEmail(email) {
2338    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
2339    return re.test(email);
2340}
2341
2342function topNotifClose() {
2343    $.cookie("hide_notification", 1);
2344    $(".header_notification_wrapper").hide();
2345    $("body").removeClass("with_top_notif");
2346    adjustHeight();
2347}
2348
2349var classname = document.getElementsByClassName("bst-carousel");
2350for (var i = 0; i < classname.length; i++) {
2351    classname[i].addEventListener("touchstart", handleTouchStart, false);
2352    classname[i].addEventListener("touchmove", handleTouchMove, false);
2353}
2354
2355var xDown = null;
2356var yDown = null;
2357
2358function getTouches(evt) {
2359    return (
2360        evt.touches || // browser API
2361        evt.originalEvent.touches
2362    ); // jQuery
2363}
2364
2365function handleTouchStart(evt) {
2366    const firstTouch = getTouches(evt)[0];
2367    xDown = firstTouch.clientX;
2368    yDown = firstTouch.clientY;
2369}
2370
2371function handleTouchMove(evt) {
2372    if (!xDown || !yDown) {
2373        return;
2374    }
2375
2376    var xUp = evt.touches[0].clientX;
2377    var yUp = evt.touches[0].clientY;
2378
2379    var xDiff = xDown - xUp;
2380    var yDiff = yDown - yUp;
2381    if (Math.abs(xDiff) > Math.abs(yDiff)) {
2382        /*most significant*/
2383        if (xDiff > 0) {
2384            $(this).carousel("next");
2385            /* left swipe */
2386        } else {
2387            $(this).carousel("prev");
2388            /* right swipe */
2389        }
2390    } else {
2391        if (yDiff > 0) {
2392            /* up swipe */
2393        } else {
2394            /* down swipe */
2395        }
2396    }
2397    /* reset values */
2398    xDown = null;
2399    yDown = null;
2400}
2401
2402$(function () {
2403    // whenever we hover over a menu item that has a submenu
2404    $("#shop-leftmenu li.dropdown").on("mouseover", function () {
2405        var $menuItem = $(this),
2406            $submenuWrapper = $("> .layer", $menuItem);
2407        // grab the menu item's position relative to its positioned parent
2408        var menuItemPos = $menuItem.position();
2409        var spaceMenuBottom = $("#shop-leftmenu").height() - menuItemPos.top;
2410        if ($submenuWrapper.height() > spaceMenuBottom) {
2411            // place the submenu in the correct position relevant to the menu item
2412            var l = $submenuWrapper.find(".layer-wrapper .layer-content li")
2413                .length;
2414            var h = $submenuWrapper
2415                .find(".layer-wrapper .layer-content")
2416                .height();
2417            var top = menuItemPos.top;
2418            if (spaceMenuBottom <= 280) {
2419                h = 280;
2420                top = "auto";
2421            }
2422            $submenuWrapper.css({
2423                top: top,
2424                bottom: 30,
2425                "max-height": h + "px",
2426            });
2427        } else {
2428            // place the submenu in the correct position relevant to the menu item
2429            $submenuWrapper.css({
2430                top: menuItemPos.top,
2431                bottom: "auto",
2432            });
2433        }
2434    });
2435});
2436
2437$(document).ready(function () {
2438    if ($(window).width() < 992) {
2439        if ($(".widget_block_tabs_wrapper").length > 0) {
2440            var nav_tabs = $(".widget_block_tabs_wrapper")
2441                .find(".navbar_block_tabs")
2442                .html();
2443            $(".widget_block_tabs_wrapper").find(".navbar_block_tabs").remove();
2444            var menu_tabs =
2445                '<div class="mobile_tabs_wrapper"><ul role="tablist" data-type="widget_dynamic_list_block_tabs_ul" class="nav navbar_block_tabs">' +
2446                nav_tabs +
2447                "</ul></div>";
2448            $(".navbar_block_tabs_wrapper").prepend(menu_tabs);
2449            // $('.navbar_block_tabs_wrapper').html(menu_tabs + $(".navbar_block_tabs_wrapper").html());
2450        }
2451    }
2452    $(".popup-link").fancybox({
2453        maxWidth: 400,
2454        maxHeight: 600,
2455        fitToView: true,
2456        width: "90%",
2457        height: "90%",
2458        autoSize: true,
2459        closeClick: false,
2460        openEffect: "none",
2461        closeEffect: "none",
2462        touch: false,
2463        tpl: {
2464            closeBtn:
2465                '<a title="Close" class="fancybox-item fancybox-close myClose" href="javascript:;"></a>',
2466        },
2467        afterShow: function () {
2468            if (typeof callbackPopuplink == "function") {
2469                callbackPopuplink();
2470            }
2471        },
2472    });
2473    setTimeout(function () {
2474        resizeFloatingElement();
2475    }, 3000);
2476
2477    if ($(window).width() < 992) {
2478        if ($(".header_notification .slick_item").length == 1) {
2479            $(".slick_item .slick_item_text a:first-child").marquee({
2480                count: -1,
2481                speed: 10,
2482            });
2483        } else {
2484            $(".slick_item .slick_item_text a:first-child")
2485                .marquee({ count: 1, speed: 10 })
2486                .done(function () {
2487                    $(".header_notification").slick("slickNext");
2488                });
2489            $(".header_notification").on("beforeChange", function (
2490                event,
2491                slick,
2492                currentSlide,
2493                nextSlide
2494            ) {
2495                $(".slick_item .slick_item_text a")
2496                    .marquee({ count: 1, speed: 10 })
2497                    .done(function () {
2498                        $(".header_notification").slick("slickNext");
2499                    });
2500            });
2501        }
2502    }
2503});
2504
2505$(window).on("resize", function () {
2506    var win = $(this); //this = window
2507
2508    if (win < 992) {
2509        if ($(".widget_block_tabs_wrapper").length > 0) {
2510            var nav_tabs = $(".widget_block_tabs_wrapper")
2511                .find(".navbar_block_tabs")
2512                .html();
2513            $(".widget_block_tabs_wrapper").find(".navbar_block_tabs").remove();
2514            var menu_tabs =
2515                '<div class="mobile_tabs_wrapper"><ul role="tablist" data-type="widget_dynamic_list_block_tabs_ul" class="nav navbar_block_tabs">' +
2516                nav_tabs +
2517                "</ul></div>";
2518            $(".navbar_block_tabs_wrapper").prepend(menu_tabs);
2519            // $('.navbar_block_tabs_wrapper').html(menu_tabs + $(".navbar_block_tabs_wrapper").html());
2520        }
2521    }
2522});
2523
2524var block_current_view = "desktop";
2525var block_mobile_content = [];
2526var block_desktop_content = [];
2527if ($(window).width() < 992) {
2528    block_current_view = "mobile";
2529} else {
2530    block_current_view = "desktop";
2531}
2532$(".static-block").each(function (index) {
2533    block_mobile_content[index] = $(this).find(".static-content-mobile");
2534    block_desktop_content[index] = $(this).find(".static-content-desktop");
2535
2536    if (block_current_view == "mobile") {
2537        block_desktop_content[index].detach();
2538        block_mobile_content[index].appendTo($(this));
2539    } else {
2540        block_mobile_content[index].detach();
2541        block_desktop_content[index].appendTo($(this));
2542    }
2543});
2544
2545var width = $(window).width();
2546$(window).resize(function () {
2547    if ($(window).width() != width) {
2548        if ($(".jqvsiv_reset").length > 0) {
2549            $(".jqvsiv_reset").click();
2550        }
2551        var win = $(this); //this = window
2552        width = $(window).width();
2553        $(".static-block").each(function (index) {
2554            console.log(index);
2555            if (win.width() < 992 && block_current_view == "desktop") {
2556                block_desktop_content[index].detach();
2557                $(this).append(block_mobile_content[index]);
2558                block_current_view = "mobile";
2559            } else if (win.width() >= 992 && block_current_view == "mobile") {
2560                block_mobile_content[index].detach();
2561                $(this).append(block_desktop_content[index]);
2562                block_current_view = "desktop";
2563            }
2564        });
2565    }
2566    resizeFloatingElement();
2567});
2568
2569$(".overlay_img_filter_1").each(function (index, element) {
2570    $(element).wrap("<div class='overlay_img_filter_1_wrapper'></div>");
2571});
2572
2573function resizeFloatingElement() {
2574    if ($(".widget_dynamic_list_product_left").length > 0) {
2575        const floatingelement = $(".floating_element");
2576        const h_img =
2577            floatingelement.parent().find("img").height() > 0
2578                ? floatingelement.parent().find("img").height()
2579                : 0;
2580        const h_floating =
2581            floatingelement
2582                .parents(".widget_dynamic_list_product_left")
2583                .height() > 0
2584                ? floatingelement
2585                      .parents(".widget_dynamic_list_product_left")
2586                      .height()
2587                : 1;
2588        const font = (h_img / h_floating) * 100;
2589        floatingelement.css("font-size", font + "%");
2590        const floatingbutton = $(".floating_button");
2591        floatingbutton.css("font-size", font + "%");
2592    }
2593}
2594
2595if (
2596    navigator.appName == "Microsoft Internet Explorer" ||
2597    !!(
2598        navigator.userAgent.match(/Trident/) ||
2599        navigator.userAgent.match(/rv:11/)
2600    ) ||
2601    (typeof $.browser !== "undefined" && $.browser.msie == 1)
2602) {
2603    changeImageableItem();
2604}
2605if (
2606    /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
2607        navigator.userAgent
2608    )
2609) {
2610    changeImageableItem();
2611}
2612function changeImageableItem() {
2613    $(".imageable_item").each(function () {
2614        var $container = $(this),
2615            imgUrl = $container.find("img").prop("src");
2616        imgUrl = imgUrl.replaceAll("(", "%28");
2617        imgUrl = imgUrl.replaceAll(")", "%29");
2618        if (imgUrl) {
2619            $container
2620                .css("background-image", "url(" + imgUrl + ")")
2621                .addClass("compact-object-fit");
2622        }
2623    });
2624}
2625
2626/** FOR PAGE BUILDER CAROUSEL**/
2627$(".static_page_desktop .bst-carousel-text .item").each(function () {
2628    var d = new Date();
2629    var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2630    var today = new Date(utc + 3600000 * 8);
2631    var todaydate =
2632        today.getFullYear() +
2633        "-" +
2634        (today.getMonth() + 1) +
2635        "-" +
2636        today.getDate();
2637    var startDate = $(this).attr("data-start");
2638    var endDate = $(this).attr("data-end");
2639    var startTime = $(this).attr("data-start-time");
2640    var endTime = $(this).attr("data-end-time");
2641    if (startTime == undefined) {
2642        startTime = "00:00:00";
2643    }
2644    if (endTime == undefined) {
2645        endTime = "00:00:00";
2646    }
2647    var fullstart = startDate + " " + startTime;
2648    var start = new Date(fullstart.replace(/-/g, "/"));
2649    var fullend = endDate + " " + endTime;
2650    var end = new Date(fullend.replace(/-/g, "/"));
2651    if (today < start) {
2652        $(
2653            ".static_page_desktop .bst-carousel-text .carousel-indicators li:last-child"
2654        ).remove();
2655        $(this).remove();
2656    }
2657    if (today > end) {
2658        $(this).remove();
2659        $(
2660            ".static_page_desktop .bst-carousel-text .carousel-indicators li:last-child"
2661        ).remove();
2662    }
2663});
2664$(".static_page_desktop .bst-carousel .item").each(function () {
2665    var d = new Date();
2666    var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2667    var today = new Date(utc + 3600000 * 8);
2668    var todaydate =
2669        today.getFullYear() +
2670        "-" +
2671        (today.getMonth() + 1) +
2672        "-" +
2673        today.getDate();
2674    var startDate = $(this).children().attr("data-start");
2675    var endDate = $(this).children().attr("data-end");
2676    var startTime = $(this).children().attr("data-start-time");
2677    var endTime = $(this).children().attr("data-end-time");
2678    if (startTime == undefined) {
2679        startTime = "00:00:00";
2680    }
2681    if (endTime == undefined) {
2682        endTime = "00:00:00";
2683    }
2684    var fullstart = startDate + " " + startTime;
2685    var start = new Date(fullstart.replace(/-/g, "/"));
2686    var fullend = endDate + " " + endTime;
2687    var end = new Date(fullend.replace(/-/g, "/"));
2688    if (today < start) {
2689        $(
2690            ".static_page_desktop .bst-carousel .carousel-indicators li:last-child"
2691        ).remove();
2692        $(this).remove();
2693    }
2694    if (today > end) {
2695        $(this).remove();
2696        $(
2697            ".static_page_desktop .bst-carousel .carousel-indicators li:last-child"
2698        ).remove();
2699    }
2700});
2701$(".static_page_desktop .bst-carousel .item").first().addClass("active");
2702if ($(".static_page_desktop .bst-carousel .item").length <= 1) {
2703    $(".static_page_desktop .carousel-control").hide();
2704}
2705
2706$(".static_page_mobile .bst-carousel-text .item").each(function () {
2707    var d = new Date();
2708    var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2709    var today = new Date(utc + 3600000 * 8);
2710    var todaydate =
2711        today.getFullYear() +
2712        "-" +
2713        (today.getMonth() + 1) +
2714        "-" +
2715        today.getDate();
2716    var startDate = $(this).attr("data-start");
2717    var endDate = $(this).attr("data-end");
2718    var startTime = $(this).attr("data-start-time");
2719    var endTime = $(this).attr("data-end-time");
2720    if (startTime == undefined) {
2721        startTime = "00:00:00";
2722    }
2723    if (endTime == undefined) {
2724        endTime = "00:00:00";
2725    }
2726    var fullstart = startDate + " " + startTime;
2727    var start = new Date(fullstart.replace(/-/g, "/"));
2728    var fullend = endDate + " " + endTime;
2729    var end = new Date(fullend.replace(/-/g, "/"));
2730    if (today < start) {
2731        $(
2732            ".static_page_mobile .bst-carousel-text .carousel-indicators li:last-child"
2733        ).remove();
2734        $(this).remove();
2735    }
2736    if (today > end) {
2737        $(this).remove();
2738        $(
2739            ".static_page_mobile .bst-carousel-text .carousel-indicators li:last-child"
2740        ).remove();
2741    }
2742});
2743$(".static_page_mobile .bst-carousel .item").each(function () {
2744    var d = new Date();
2745    var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2746    var today = new Date(utc + 3600000 * 8);
2747    var todaydate =
2748        today.getFullYear() +
2749        "-" +
2750        (today.getMonth() + 1) +
2751        "-" +
2752        today.getDate();
2753    var startDate = $(this).children().attr("data-start");
2754    var endDate = $(this).children().attr("data-end");
2755    var startTime = $(this).children().attr("data-start-time");
2756    var endTime = $(this).children().attr("data-end-time");
2757    if (startTime == undefined) {
2758        startTime = "00:00:00";
2759    }
2760    if (endTime == undefined) {
2761        endTime = "00:00:00";
2762    }
2763    var fullstart = startDate + " " + startTime;
2764    var start = new Date(fullstart.replace(/-/g, "/"));
2765    var fullend = endDate + " " + endTime;
2766    var end = new Date(fullend.replace(/-/g, "/"));
2767    if (today < start) {
2768        $(
2769            ".static_page_mobile .bst-carousel .carousel-indicators li:last-child"
2770        ).remove();
2771        $(this).remove();
2772    }
2773    if (today > end) {
2774        $(this).remove();
2775        $(
2776            ".static_page_mobile .bst-carousel .carousel-indicators li:last-child"
2777        ).remove();
2778    }
2779});
2780$(".static_page_mobile .bst-carousel .item").first().addClass("active");
2781if ($(".static_page_mobile .bst-carousel .item").length <= 1) {
2782    $(".static_page_mobile .carousel-control").hide();
2783}
2784/** END FOR PAGE BUILDER CAROUSEL**/
2785
2786/** PAGE BUILDER BLOCK CONTENT**/
2787$(".widget_dynamic_list_block_content").each(function () {
2788    var d = new Date();
2789    var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2790    var today = new Date(utc + 3600000 * 8);
2791    var todaydate =
2792        today.getFullYear() +
2793        "-" +
2794        (today.getMonth() + 1) +
2795        "-" +
2796        today.getDate();
2797    var startDate = $(this).attr("data-start");
2798    var endDate = $(this).attr("data-end");
2799    var startTime = $(this).attr("data-start-time");
2800    var endTime = $(this).attr("data-end-time");
2801    if (startTime == undefined) {
2802        startTime = "00:00:00";
2803    }
2804    if (endTime == undefined) {
2805        endTime = "00:00:00";
2806    }
2807    var fullstart = startDate + " " + startTime;
2808    var start = new Date(fullstart.replace(/-/g, "/"));
2809    var fullend = endDate + " " + endTime;
2810    var end = new Date(fullend.replace(/-/g, "/"));
2811    if (today < start) {
2812        $(this).hide();
2813    }
2814    if (today > end) {
2815        $(this).hide();
2816    }
2817});
2818/** END PAGE BUILDER BLOCK CONTENT**/
2819
2820/** FOR PAGE BUILDER */
2821$(".image-popup-button").on("click", function () {
2822    var selector = "";
2823    var display = "desktop";
2824    if ($(window).width() < 992) {
2825        display = "mobile";
2826    }
2827    if (
2828        $(
2829            ".static-block-page-" +
2830                display +
2831                " ." +
2832                $(this).parents(".widget_custom_image_wrapper").attr("id") +
2833                "-popup"
2834        ).length > 0
2835    ) {
2836        selector =
2837            ".static-block-page-" +
2838            display +
2839            " ." +
2840            $(this).parents(".widget_custom_image_wrapper").attr("id") +
2841            "-popup";
2842    } else {
2843        selector =
2844            "." +
2845            $(this).parents(".widget_custom_image_wrapper").attr("id") +
2846            "-popup";
2847    }
2848    $.fancybox.open({
2849        src: selector,
2850        type: "inline",
2851    });
2852});
2853$(".block-popup-button").on("click", function () {
2854    var selector = "";
2855    var display = "desktop";
2856    if ($(window).width() < 992) {
2857        display = "mobile";
2858    }
2859    if (
2860        $(
2861            ".static-block-page-" +
2862                display +
2863                " ." +
2864                $(this).attr("id") +
2865                "-popup"
2866        ).length > 0
2867    ) {
2868        selector =
2869            ".static-block-page-" +
2870            display +
2871            " ." +
2872            $(this).attr("id") +
2873            "-popup";
2874    } else {
2875        selector = "." + $(this).attr("id") + "-popup";
2876    }
2877
2878    $.fancybox.open({
2879        src: selector + ":first",
2880        type: "inline",
2881    });
2882});
2883
2884carouselChildDateCheck();
2885blockChildDateCheck();
2886
2887function carouselChildDateCheck() {
2888    $(".bst-carousel-text .item").each(function () {
2889        var num = $(this)
2890            .find(".text-carousel-child")
2891            .map(function () {
2892                var selectiondate = startendDate($(this));
2893                var d = new Date();
2894                var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2895                var today = new Date(utc + 3600000 * 8);
2896                if (
2897                    (today < selectiondate.start &&
2898                        !isNaN(selectiondate.start)) ||
2899                    (today > selectiondate.end && !isNaN(selectiondate.end))
2900                ) {
2901                    var fullstart = "1970/01/01 00:00:00";
2902                    var start = new Date(fullstart.replace(/-/g, "/"));
2903                    return start;
2904                }
2905                return selectiondate.start;
2906            })
2907            .get(); //get all data values in an array
2908        var highest = new Date(Math.max.apply(Math, num)); //find the highest value from them
2909
2910        if ($(this).find(".text-carousel-child").length > 1) {
2911            $(this)
2912                .find(".text-carousel-child")
2913                .filter(function () {
2914                    var selectiondate = startendDate($(this));
2915                    var d = new Date();
2916                    var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2917                    var today = new Date(utc + 3600000 * 8);
2918                    return (
2919                        selectiondate.start < highest ||
2920                        today < selectiondate.start ||
2921                        today > selectiondate.end
2922                    ); //return the highest div
2923                })
2924                .remove(); //append to that div
2925        }
2926    });
2927}
2928function blockChildDateCheck() {
2929    $(
2930        ".widget_dynamic_list_block_content .widget_dynamic_list_content_item"
2931    ).each(function () {
2932        var num = $(this)
2933            .find(".whatshot_box")
2934            .map(function () {
2935                var selectiondate = startendDate($(this));
2936                var d = new Date();
2937                var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2938                var today = new Date(utc + 3600000 * 8);
2939                if (
2940                    (today < selectiondate.start &&
2941                        !isNaN(selectiondate.start)) ||
2942                    (today > selectiondate.end && !isNaN(selectiondate.end))
2943                ) {
2944                    var fullstart = "1970/01/01 00:00:00";
2945                    var start = new Date(fullstart.replace(/-/g, "/"));
2946                    return start;
2947                }
2948                return selectiondate.start;
2949            })
2950            .get(); //get all data values in an array
2951        var highest = new Date(Math.max.apply(Math, num)); //find the highest value from them
2952
2953        if ($(this).find(".whatshot_box").length >= 1) {
2954            $(this)
2955                .find(".whatshot_box")
2956                .filter(function () {
2957                    var selectiondate = startendDate($(this));
2958                    var d = new Date();
2959                    var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2960                    var today = new Date(utc + 3600000 * 8);
2961                    return (
2962                        selectiondate.start < highest ||
2963                        today < selectiondate.start ||
2964                        today > selectiondate.end
2965                    ); //return the highest div
2966                })
2967                .remove(); //append to that div
2968            if($(this).find('.whatshot_box').length <= 0){
2969                $(this).remove();
2970            }
2971        }
2972    });
2973}
2974function sameDay(d1, d2) {
2975    return (
2976        d1.getFullYear() === d2.getFullYear() &&
2977        d1.getMonth() === d2.getMonth() &&
2978        d1.getDate() === d2.getDate()
2979    );
2980}
2981function startendDate(d1) {
2982    var d = new Date();
2983    var utc = d.getTime() + d.getTimezoneOffset() * 60000;
2984    var today = new Date(utc + 3600000 * 8);
2985    var todaydate =
2986        today.getFullYear() +
2987        "-" +
2988        (today.getMonth() + 1) +
2989        "-" +
2990        today.getDate();
2991    var startDate = d1.attr("data-start");
2992    var endDate = d1.attr("data-end");
2993    var startTime = d1.attr("data-start-time");
2994    var endTime = d1.attr("data-end-time");
2995    if (startDate == undefined) {
2996        startDate = "01/01/1970";
2997    }
2998    if (startTime == undefined) {
2999        startTime = "00:00:00";
3000    }
3001    if (endTime == undefined) {
3002        endTime = "00:00:00";
3003    }
3004    var fullstart = startDate + " " + startTime;
3005    var start = new Date(fullstart.replace(/-/g, "/"));
3006    var fullend = endDate + " " + endTime;
3007    var end = new Date(fullend.replace(/-/g, "/"));
3008    return {
3009        start: start,
3010        end: end,
3011    };
3012}
3013/** END FOR PAGE BUILDER */
3014
3015$(window).resize(function () {
3016    /** FOR PAGE BUILDER */
3017    $(".image-popup-button").on("click", function () {
3018        $.fancybox.close();
3019        var selector = "";
3020        var display = "desktop";
3021        if ($(window).width() < 992) {
3022            display = "mobile";
3023        }
3024        if (
3025            $(
3026                ".static-block-page-" +
3027                    display +
3028                    " ." +
3029                    $(this).parents(".widget_custom_image_wrapper").attr("id") +
3030                    "-popup"
3031            ).length > 0
3032        ) {
3033            selector =
3034                ".static-block-page-" +
3035                display +
3036                " ." +
3037                $(this).parents(".widget_custom_image_wrapper").attr("id") +
3038                "-popup";
3039        } else {
3040            selector =
3041                "." +
3042                $(this).parents(".widget_custom_image_wrapper").attr("id") +
3043                "-popup";
3044        }
3045        $.fancybox.open({
3046            src: selector,
3047            type: "inline",
3048        });
3049    });
3050    $(".block-popup-button").on("click", function () {
3051        $.fancybox.close();
3052        var selector = "";
3053        var display = "desktop";
3054        if ($(window).width() < 992) {
3055            display = "mobile";
3056        }
3057        if (
3058            $(
3059                ".static-block-page-" +
3060                    display +
3061                    " ." +
3062                    $(this).attr("id") +
3063                    "-popup"
3064            ).length > 0
3065        ) {
3066            selector =
3067                ".static-block-page-" +
3068                display +
3069                " ." +
3070                $(this).attr("id") +
3071                "-popup";
3072        } else {
3073            selector = "." + $(this).attr("id") + "-popup";
3074        }
3075
3076        $.fancybox.open({
3077            src: selector + ":first",
3078            type: "inline",
3079        });
3080    });
3081    /** END FOR PAGE BUILDER */
3082});
3083
3084$('.lightslider').each(function(index, element) { 
3085    if(!$(this).parent().hasClass('lSSlideWrapper')){
3086        if($(this).first().find('li').length > 0){
3087            $('.lightslider li').each(function(index, element) { 
3088                $(this).attr('data-thumb',$(this).find('img').attr('src'));
3089            });
3090        }
3091        var gallery_thumb = true;
3092        var gallery_loop = false;
3093        var gallery_autoplay = false;
3094        var gallery_arrow = false;
3095        var gallery_speed = 5000;
3096        if($(this).closest('.widget_gallery').length > 0){
3097            gallery_thumb = ($(this).closest('.widget_gallery').attr('data-thumbnail') !== undefined) ? $(this).closest('.widget_gallery').attr('data-thumbnail') : true;
3098            gallery_autoplay = ($(this).closest('.widget_gallery').attr('data-autoplay') !== undefined) ? $(this).closest('.widget_gallery').attr('data-autoplay') : false;
3099            gallery_arrow = ($(this).closest('.widget_gallery').attr('data-arrow') !== undefined) ? $(this).closest('.widget_gallery').attr('data-arrow') : true;
3100            gallery_speed = ($(this).closest('.widget_gallery').attr('data-pause') !== undefined) ? $(this).closest('.widget_gallery').attr('data-pause') : 5000;
3101        }
3102        var lightslider = $(this).first().lightSlider({
3103            gallery: (gallery_thumb == 'true') ? true : false,
3104            item: 1,
3105            loop: (gallery_loop == 'true') ? true : false,
3106            slideMargin: 0,
3107            thumbItem: 4,
3108            thumbMargin: 15,
3109            galleryMargin: 25,
3110            pause: gallery_speed,
3111            controls: (gallery_arrow == 'true') ? true : false,
3112            auto: (gallery_autoplay == 'true') ? true : false,
3113            onAfterSlide: function($el, scene){
3114                if($(window).width() < 992){
3115                    var leftPos = $el.closest('.lSSlideOuter').find('.lSPager .active').position().left;
3116                    var scrollPos = $el.closest('.lSSlideOuter').find('.lSPager .active').offset().left + $el.closest('.lSSlideOuter').find('.lSPager .active').outerWidth(true)/2 + $el.closest('.lSSlideOuter').find('.lSPager').scrollLeft() - $el.closest('.lSSlideOuter').find('.lSPager').width()/2;
3117                    $el.closest('.lSSlideOuter').find('.lSPager').animate({
3118                        scrollLeft: scrollPos
3119                    }, 500);
3120                }
3121            }
3122        });
3123    }
3124});
3125
3126$(".aia-popover-product").popover({
3127    trigger: "hover",
3128    html: true,
3129    template:
3130        '<div class="popover aia-popover-product-tooltip" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>',
3131});
3132
3133
3134var x, i, j, l, ll, selElmnt, a, b, c,prevSel;
3135/* Look for any elements with the class "custom-select-wap": */
3136x = document.getElementsByClassName("custom-select-wrap");
3137l = x.length;
3138for (i = 0; i < l; i++) {
3139  selElmnt = x[i].getElementsByTagName("select")[0];
3140  ll = selElmnt.length;
3141  /* For each element, create a new DIV that will act as the selected item: */
3142  a = document.createElement("DIV");
3143  a.setAttribute("class", "select-selected");
3144  a.innerHTML = selElmnt.options[selElmnt.selectedIndex].innerHTML;
3145  x[i].appendChild(a);
3146  /* For each element, create a new DIV that will contain the option list: */
3147  b = document.createElement("DIV");
3148  b.setAttribute("class", "select-items select-hide");
3149  for (j = 1; j < ll; j++) {
3150    /* For each option in the original select element,
3151    create a new DIV that will act as an option item: */
3152    c = document.createElement("DIV");
3153    c.innerHTML = selElmnt.options[j].innerHTML;
3154    c.addEventListener("click", function(e) {
3155        /* When an item is clicked, update the original select box,
3156        and the selected item: */
3157        var y, i, k, s, h, sl, yl;
3158        s = this.parentNode.parentNode.getElementsByTagName("select")[0];
3159        sl = s.length;
3160        h = this.parentNode.previousSibling;
3161        prevSel = $(selElmnt).val();
3162        for (i = 0; i < sl; i++) {
3163          if (s.options[i].innerHTML == this.innerHTML) {
3164            s.selectedIndex = i;
3165            h.innerHTML = this.innerHTML;
3166            y = this.parentNode.getElementsByClassName("same-as-selected");
3167            yl = y.length;
3168            for (k = 0; k < yl; k++) {
3169              y[k].removeAttribute("class");
3170            }
3171            this.setAttribute("class", "same-as-selected");
3172            break;
3173          }
3174        }
3175        h.click();
3176    });
3177    b.appendChild(c);
3178  }
3179  x[i].appendChild(b);
3180  a.addEventListener("click", function(e) {
3181    /* When the select box is clicked, close any other select boxes,
3182    and open/close the current select box: */
3183    e.stopPropagation();
3184    closeAllSelect(this);
3185    if(prevSel == undefined){
3186        prevSel = '';
3187    }
3188    if(($(selElmnt).val() != prevSel)){
3189        $(selElmnt).trigger('change');
3190        prevSel = $(selElmnt).val();
3191    }
3192    this.nextSibling.classList.toggle("select-hide");
3193    this.classList.toggle("select-arrow-active");
3194  });
3195}
3196
3197function closeAllSelect(elmnt) {
3198  /* A function that will close all select boxes in the document,
3199  except the current select box: */
3200  var x, y, i, xl, yl, arrNo = [];
3201  x = document.getElementsByClassName("select-items");
3202  y = document.getElementsByClassName("select-selected");
3203  xl = x.length;
3204  yl = y.length;
3205  for (i = 0; i < yl; i++) {
3206    if (elmnt == y[i]) {
3207      arrNo.push(i)
3208    } else {
3209      y[i].classList.remove("select-arrow-active");
3210    }
3211  }
3212  for (i = 0; i < xl; i++) {
3213    if (arrNo.indexOf(i)) {
3214      x[i].classList.add("select-hide");
3215    }
3216  }
3217}
3218
3219
3220function eventAnalyticsGA(params){
3221    if (typeof  ga == 'function') {
3222        ga(
3223            'send',
3224            'event',
3225            (typeof params['eventCategory'] !== 'undefined') ? params['eventCategory'] : 'UX',
3226            (typeof params['eventAction'] !== 'undefined') ? params['eventAction'] : 'click',
3227            (typeof params['eventLabel'] !== 'undefined') ? params['eventLabel'] : 'page'
3228        );
3229    }
3230}
3231/* If the user clicks anywhere outside the select box,
3232then close all select boxes: */
3233document.addEventListener("click", closeAllSelect);
3234
3235
3236var url = document.location.toString();
3237$(document).ready(function () {
3238    if($('.navbar_block_tabs').length > 0){
3239        $('.block_tab_container').find('.block_tab_content.active').addClass('show');
3240        $('.navbar_block_tabs').find('li.active').removeClass('active');
3241        $('.navbar_block_tabs').find('a.active').removeClass('active');
3242        $('.navbar_block_tabs li:first-child').find('a').addClass('active');
3243    }
3244    var url_tab = url.split('tab=')[1];
3245    var tab_name = url.split('tab=')[1];
3246    if(url_tab !== undefined && url_tab.indexOf("&") > 0){
3247        tab_name = url_tab.substring(0, url_tab.indexOf("&"));
3248    }
3249    if (url.match('tab=') && ($('.navbar_block_tabs').length > 0)) {
3250        $('.navbar_block_tabs li[id="' + tab_name + '"] a').click();
3251        setTimeout(function() {
3252            $('body').removeClass('--widget-tabs-preload');
3253        }, 100);
3254    }else if (url.match('tab=')){
3255         $('body').removeClass('--widget-tabs-preload');
3256    }
3257
3258    if (url.match('/#cn') && $(".switch-lang[data-lang=cn]").length>0){
3259        $(".switch-lang[data-lang=cn]").click();
3260    }
3261    if (url.match('mobileapp=1')){
3262        $("a[data-href]").each(function(){
3263            if(($(this).attr('data-href') != 'null') && ($(this).attr('data-href') != 'undefined') && ($(this).attr('data-href') != '')){
3264                var deeplink = $(this).attr('data-href');
3265                $(this).attr('href',deeplink);
3266            }
3267        });
3268    }
3269
3270    $(".widget_dynamic_list_home_product").each(function(){
3271        if($(window).width() > 992){
3272            if($(this).find('.widget_dynamic_list_product_right').find('.widget_dynamic_list_product_item').length <= 5){
3273                $('.widget_home_product_arrow_wrapper').hide();
3274             }else{
3275                 $('.widget_home_product_arrow_wrapper').show();
3276             }
3277        }
3278    });
3279    $(".widget_dynamic_list_product_item").each(function(){
3280        if(($(this).find('.product_box').length <= 0) && (!$(this).hasClass('col_product_view_more'))){
3281            $(this).remove();
3282        }
3283    });
3284});
3285
3286
3287
3288/*Add scrollable function on home product widget*/
3289
3290$(".btn-home-product-prev").click(function (e) {
3291    var space = 19;
3292    var total_product = $(this).parents('.widget_dynamic_list_product_right').find('.widget_dynamic_list_product_item').length;
3293	var product_box_width = $(this).parents('.widget_dynamic_list_product_right').find('.widget_dynamic_list_product_item').width();
3294    var row_width = (product_box_width) * total_product;
3295    var pos = $(this).parents('.widget_dynamic_list_product_right').find('.product_item_row').scrollLeft() - 20 -  product_box_width;
3296    if(total_product > 10){
3297        pos = $(this).parents('.widget_dynamic_list_product_right').find('.product_item_row').scrollLeft() - ((space +  product_box_width) * 5);
3298    }
3299    $(this).parents('.widget_dynamic_list_product_right').find('.product_item_row').animate({
3300        scrollLeft: pos
3301    }, "fast");
3302    if(pos < 0){
3303        $(this).parent().find('.btn-home-product-prev').hide();
3304    }
3305    if(pos >= (row_width - product_box_width)){
3306        $(this).parent().find('.btn-home-product-next').hide();
3307    }else{
3308        $(this).parent().find('.btn-home-product-next').show();
3309    }
3310});
3311
3312$(".btn-home-product-next").click(function (e) {
3313    var space = 19;
3314    var total_product = $(this).parents('.widget_dynamic_list_product_right').find('.widget_dynamic_list_product_item').length;
3315    var product_box_width = $(this).parents('.widget_dynamic_list_product_right').find('.widget_dynamic_list_product_item').width();
3316    var row_width = (product_box_width) * total_product;
3317    var pos = $(this).parents('.widget_dynamic_list_product_right').find('.product_item_row').scrollLeft() + 20 + (product_box_width);
3318    if(total_product > 10){
3319        pos = $(this).parents('.widget_dynamic_list_product_right').find('.product_item_row').scrollLeft() + ((space + product_box_width) * 5);
3320    }
3321    $(this).parents('.widget_dynamic_list_product_right').find('.product_item_row').animate({
3322        scrollLeft: pos
3323    }, "fast");
3324    if(pos > 0){
3325        $(this).parent().find('.btn-home-product-prev').show();
3326    }
3327    if(total_product <= 10){
3328        if(pos >= (row_width - ((product_box_width + 20) * 5))){
3329            $(this).parent().find('.btn-home-product-next').hide();
3330        }
3331    }else{
3332        if(pos >= (row_width - product_box_width - 20)){
3333            $(this).parent().find('.btn-home-product-next').hide();
3334        }
3335    }
3336});
3337
3338$(document).on("click", ".instagram_feed .instagram-child-image img", function (e) {
3339    e.preventDefault();
3340    var href = $(this).closest('a').attr('href');
3341    window.open(href,'_system');
3342})
3343
3344
3345
3346//INSTAGRAM FEED
3347$(window).on('load', function () {
3348    $.instagramFeed({
3349        'username': 'giantsingapore',
3350        'display_profile': false,
3351        'display_igtv': false,
3352        'display_gallery': true,
3353        'items': 8,
3354        'margin': 0,
3355        'styling': false,
3356        'callback': function (data) {
3357
3358            if (data !== undefined && data.edge_owner_to_timeline_media.edges !== undefined) {
3359                if (window_width > 992) {
3360                    var html_content = '<div class="instagram_wrapper">';
3361                } else {
3362                    var html_content = '<div class="instagram_wrapper">';
3363                }
3364                var itemdata = data.edge_owner_to_timeline_media.edges;
3365                console.log('Data:', data);
3366                if (window_width > 992) {
3367                    html_content += '<div class="row no-gutters instagram_gallery">';
3368                } else {
3369                    html_content += '<div class=" instagram_gallery instagram-child-image owl-carousel owl-instagram">';
3370                }
3371                $.each(itemdata, function (index, value) {
3372                    console.log('Index:', index);
3373                    if (index < 8) {
3374
3375                        if (window_width > 992) {
3376                            html_content += '<div class="col-lg-3 col-md-3">';
3377                        } else {
3378                            html_content += '<div class="item">';
3379                        }
3380                        html_content += '<a href="https://www.instagram.com/p/' + value.node.shortcode + '" target="_blank">';
3381                        html_content += '<img src="' + value.node.display_url + '">';
3382                        html_content += '</a>';
3383                        html_content += '</div>';
3384                    } else {
3385                        return false;
3386                    }
3387                });
3388                html_content += '</div>';
3389                html_content += '</div>';
3390                $('.instagram_feed').html(html_content);
3391                if (window_width <= 992) {
3392                    var owl_instagram = $('.owl-instagram').owlCarousel({
3393                        items: 5,
3394                        lazyLoad: true,
3395                        loop: true,
3396                        dots: false,
3397                        margin: 0,
3398                        nav: true,
3399                        autoplay: true,
3400                        autoplayTimeout: 5000,
3401                        margin: 10,
3402                        navText: [`<div class="instagram-slider-nav instagram-slider-nav-prev"><svg viewBox="4 0 8 16" width="12" height="16" class="eapps-instagram-feed-posts-slider-nav-icon">
3403    <path d="M4.3,8.7l6,5.9c0.4,0.4,1.1,0.4,1.5,0c0.4-0.4,0.4-1.1,0-1.5L6.5,8l5.2-5.2c0.4-0.4,0.4-1.1,0-1.5
3404    c-0.4-0.4-1.1-0.4-1.5,0l-6,6C3.9,7.7,3.9,8.3,4.3,8.7z"></path>
3405    </svg></div>`, `<div class="instagram-slider-nav instagram-slider-nav-next"><svg viewBox="4 0 8 16" width="12" height="16" class="eapps-instagram-feed-posts-slider-nav-icon">
3406    <path d="M11.7,7.3l-6-5.9c-0.4-0.4-1.1-0.4-1.5,0c-0.4,0.4-0.4,1.1,0,1.5L9.5,8l-5.2,5.2
3407    c-0.4,0.4-0.4,1.1,0,1.5c0.4,0.4,1.1,0.4,1.5,0l6-6C12.1,8.3,12.1,7.7,11.7,7.3z"></path>
3408    </svg></div>`],
3409                        responsive: {
3410                            0: {
3411                                items: 1
3412                            },
3413                            480: {
3414                                items: 1
3415                            },
3416                            768: {
3417                                items: 4
3418                            }
3419                        }
3420                    });
3421                    owl_instagram.on('changed.owl.carousel', function (e) {
3422                        owl_instagram.trigger('stop.owl.autoplay');
3423                        owl_instagram.trigger('play.owl.autoplay');
3424                    });
3425                }
3426            }
3427        }
3428    });
3429});

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.