1(function (window, document, $) { 2 "use strict"; 3 4 if (!$) { 5 return; 6 } 7 8 function initTranslate() { 9 if (!document.querySelector(".gtranslate_wrapper")) { 10 return; 11 } 12 13 window.gtranslateSettings = { 14 default_language: "en", 15 wrapper_selector: ".gtranslate_wrapper", 16 flag_size: 24, 17 switcher_horizontal_position: "right", 18 switcher_vertical_position: "top" 19 }; 20 21 if (!document.querySelector('script[data-gtranslate="1"]')) { 22 var script = document.createElement("script"); 23 script.src = "https://cdn.gtranslate.net/widgets/latest/dwf.js"; 24 script.async = true; 25 script.setAttribute("data-gtranslate", "1"); 26 document.head.appendChild(script); 27 } 28 } 29 30 function syncHeaderState() { 31 var $header = $("#c-header"); 32 if (!$header.length) { 33 return; 34 } 35 36 if ($(window).scrollTop() > 20 || $("body").hasClass("c-open")) { 37 $header.addClass("c-style2"); 38 } else if (!$header.is(":hover")) { 39 $header.removeClass("c-style2"); 40 } 41 } 42 43 function bindHeader() { 44 var $body = $("body"); 45 var $header = $("#c-header"); 46 var $nav = $header.find(".navbar"); 47 48 $(".c-switch").off("click.loadingnav").on("click.loadingnav", function () { 49 $body.toggleClass("c-open"); 50 $nav.removeAttr("id"); 51 $("#js-search-overlay").hide(); 52 $("html").css("overflow", $body.hasClass("c-open") ? "hidden" : ""); 53 syncHeaderState(); 54 }); 55 56 $header.off("mouseenter.loadingnav mouseleave.loadingnav"); 57 $header.on("mouseenter.loadingnav", function () { 58 $header.addClass("c-style2"); 59 }).on("mouseleave.loadingnav", function () { 60 syncHeaderState(); 61 }); 62 63 $(window).off("scroll.loadingnav resize.loadingnav").on("scroll.loadingnav resize.loadingnav", function () { 64 if ($(window).width() > 991) { 65 $body.removeClass("c-open"); 66 $("html").css("overflow", ""); 67 } 68 syncHeaderState(); 69 }); 70 71 $(document).off("click.loadingmobile", ".mobile-navbtn").on("click.loadingmobile", ".mobile-navbtn", function (event) { 72 event.preventDefault(); 73 var $btn = $(this); 74 var $dropdown = $btn.closest("a").next(".dropdown"); 75 var $panel = $dropdown.find(".slide-list, .submen-list").first(); 76 77 if ($btn.hasClass("open")) { 78 $btn.removeClass("open"); 79 $panel.stop(true, true).slideUp(); 80 return; 81 } 82 83 $btn.closest(".nav-item").siblings().find(".mobile-navbtn").removeClass("open"); 84 $btn.closest(".nav-item").siblings().find(".slide-list, .submen-list").stop(true, true).slideUp(); 85 $btn.closest(".nav-item").find(".sub-list").stop(true, true).slideUp(); 86 87 $btn.addClass("open"); 88 $panel.stop(true, true).slideDown(); 89 }); 90 91 $(".slideTxtBox .hd .slide-list li a").off("mouseenter.loadingthumb").on("mouseenter.loadingthumb", function () { 92 var thumbUrl = $(this).attr("data-img"); 93 if (thumbUrl) { 94 $(this).closest(".slideTxtBox").find(".product-box img").attr("src", thumbUrl); 95 } 96 }); 97 98 $(document).off("mouseenter.loadingsublist", ".slideTxtBox .hd .slide-list > li").on("mouseenter.loadingsublist", ".slideTxtBox .hd .slide-list > li", function () { 99 if ($(window).width() > 991) { 100 $(this).children(".sub-list").stop(true, true).slideDown(120); 101 } 102 }); 103 104 $(document).off("mouseleave.loadingsublist", ".slideTxtBox .hd .slide-list > li").on("mouseleave.loadingsublist", ".slideTxtBox .hd .slide-list > li", function () { 105 if ($(window).width() > 991) { 106 $(this).children(".sub-list").stop(true, true).slideUp(120); 107 } 108 }); 109 } 110 111 function bindSearch() {
112 var $overlay = $("#js-search-overlay"); 113 var $nav = $("#c-header .navbar"); 114 115 $(".icosearch").off("click.loadingsearch").on("click.loadingsearch", function () { 116 $nav.attr("id", "showopen"); 117 if ($(window).width() < 768) { 118 $overlay.show(); 119 $("html").css("overflow", "hidden"); 120 } 121 }); 122 123 $(".js-search-btn-close").off("click.loadingsearch").on("click.loadingsearch", function () { 124 $nav.removeAttr("id"); 125 $overlay.hide(); 126 $("html").css("overflow", ""); 127 }); 128 129 $overlay.off("click.loadingsearch").on("click.loadingsearch", function () { 130 $nav.removeAttr("id"); 131 $overlay.hide(); 132 $("html").css("overflow", ""); 133 }); 134 135 $(".search_con2 .search-btn").off("click.loadingsearch").on("click.loadingsearch", function () { 136 var keyword = $.trim($(".search_con2 #q").val()); 137 if (keyword) { 138 window.location.href = "/index.php?f=search&v=index&modelid=1008&keywords=" + encodeURIComponent(keyword); 139 } else { 140 alert("Keywords cannot be empty!"); 141 } 142 }); 143 } 144 145 function bindAside() { 146 function syncAsideState() { 147 var scrollTop = $(window).scrollTop(); 148 var windowHeight = $(window).height(); 149 var documentHeight = $(document).height(); 150 151 if (scrollTop < windowHeight || (scrollTop + windowHeight) >= documentHeight) { 152 $(".additional-features").removeClass("opa-0"); 153 } else { 154 $(".additional-features").addClass("opa-0"); 155 } 156 } 157 158 $(window).off("scroll.loadingaside").on("scroll.loadingaside", syncAsideState); 159 syncAsideState(); 160 161 $(".db").off("click.loadingaside").on("click.loadingaside", function () { 162 $("html,body").animate({ scrollTop: 0 }, 500); 163 }); 164 165 $(".additional-features li").off("mouseenter.loadingaside mouseleave.loadingaside"); 166 $(".additional-features li").on("mouseenter.loadingaside", function () { 167 $(this).find("span,.wechat_code").css({ opacity: "1", display: "block" }); 168 }).on("mouseleave.loadingaside", function () { 169 $(this).find("span,.wechat_code").css({ opacity: "0", display: "none" }); 170 }); 171 } 172 173 function bindNewsletter() { 174 $("#subscribeBtn").off("click.loadingsubscribe").on("click.loadingsubscribe", function () { 175 var $button = $(this); 176 var email = $.trim($("#emailInput").val()); 177 var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; 178 179 if (!emailRegex.test(email)) { 180 alert("Please enter a valid email address."); 181 return; 182 } 183 184 $button.prop("disabled", true); 185 $.ajax({ 186 url: "/index.php?m=newsletter&f=index&v=subscribe", 187 type: "POST", 188 data: { email: email } 189 }).done(function (response) { 190 alert(response); 191 }).fail(function () { 192 alert("Subscribe failed."); 193 }).always(function () { 194 $button.prop("disabled", false); 195 }); 196 }); 197 } 198 199 $(function () { 200 initTranslate(); 201 bindHeader(); 202 bindSearch(); 203 bindAside(); 204 bindNewsletter(); 205 syncHeaderState(); 206 }); 207})(window, document, window.jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.