1// Vanilla JS 2 3// Tabs 4(() => { 5 const tabs = document.querySelectorAll('.product-details--tabs li a') 6 const panels = document.querySelectorAll('.panel') 7 8 tabs.forEach(tab => tab.addEventListener('click', () => { 9 const activePanel = document.querySelector(`.panel#product-tab--${tab.dataset.tab}`) 10 11 tabs.forEach(tab => tab.classList.remove('active')) 12 tab.classList.add('active') 13 14 panels.forEach(panel => panel.style.display = 'none') 15 activePanel.style.display = 'block' 16 })) 17})() 18 19// JavaScript Document 20$(function () { 21 "use strict"; 22 23 // Lazy Load Images 24 $("img.lazy").lazyload({ 25 effect: "fadeIn", 26 threshold: -100, 27 }); 28 29 // Add to Cart Button Click 30 $("#btnAddCart").click(function (e) { 31 $("#actionRun").val("addToCart"); 32 $("#hidButtonClick").val("Cart"); 33 }); 34 35 // Add to Favs Button Click 36 $("#btnAddFavs").click(function () { 37 $("#actionRun").val("addToFavs"); 38 $("#hidButtonClick").val("Favs"); 39 }); 40 41 $("#reviewLink").click(function () { 42 $("#customer-reviews-tab-button").trigger("click"); 43 return false; 44 }); 45 46 // Attribute Drop Down Change 47 $(".attribute-select").change(function () { 48 $(this).addClass("changed"); 49 var select = $(this); 50 var productId = $("#hidProdId").val(); 51 var postArray = []; 52 53 var attrSelectedCount = 0; 54 $(".attribute-select").each(function () { 55 /*if(!$(this).hasClass("changed")) { 56 //$(this).attr("disabled","disabled"); 57 }*/ 58 var value = $("#" + $(this).attr("id") + " option:selected").val(); 59 var attribute = $(this).data("id"); 60 var placement = $(this).data("order"); 61 postArray.push(attribute + "|" + value); 62 if ($(this).val().length > 0) { 63 attrSelectedCount++; 64 } 65 }); 66 67 var myJsonPostString = JSON.stringify(postArray); 68 var attribute_count = $("#hidAttrCount").val(); 69 $.ajax({ 70 url: "/modules/ecommerce/ajax/filter-product-variants.php", 71 type: "post", 72 data: { 73 prod: productId, 74 attributes: myJsonPostString, 75 max: attribute_count, 76 }, 77 dataType: "json", 78 success: function (data) { 79 if (data.status == "found") { 80 var itemPrice = 81 parseFloat(data["price"]) + parseFloat(data["additionalCost"]); 82 var storePrice = 83 parseFloat(data["storePrice"]) + parseFloat(data["additionalCost"]); 84 var retailPrice = 85 parseFloat(data["retailPrice"]) + 86 parseFloat(data["additionalCost"]); 87 88 if (parseFloat(data["additionalCost"]) > 0) { 89 $("#additionalPriceDiv span.added-cost").html( 90 data["additionalCost"] 91 ); 92 $("#additionalPriceDiv").slideDown(); 93 } else { 94 $("#additionalPriceDiv").fadeOut(function () { 95 $("#additionalPriceDiv span.added-cost").html(); 96 }); 97 } 98 99 $(".product-pricing").slideDown(); 100 $("#product-not-found").slideUp(); 101 $("#btnAddCart").removeClass("disabled").removeAttr("disabled"); 102 103 // Update Sku 104 $("#optionSku").html(" Item #: " + data["sku"]); 105 106 // Update Main Item Price 107 $("#ourPrice").html( 108 "$" + numberWithCommas(parseFloat(itemPrice).toFixed(2)) 109 ); 110 $("#ourPrice").attr("data-price", parseFloat(itemPrice).toFixed(2)); 111 112 // Update Retail Price if it exists 113 if ($("#retailPrice").length > 0) { 114 $("#retailPrice").html( 115 numberWithCommas(parseFloat(retailPrice).toFixed(2)) 116 ); 117 $("#retailPrice").attr( 118 "data-price", 119 parseFloat(retailPrice).toFixed(2) 120 ); 121 } 122 123 // Update Regular Price if it exists 124 if ($("#storePrice").length > 0) { 125 $("#storePrice").html( 126 numberWithCommas(parseFloat(storePrice).toFixed(2)) 127 ); 128 $("#storePrice").attr( 129 "data-price", 130 parseFloat(storePrice).toFixed(2) 131 ); 132 } 133 // Update Item Savings Percentage if it exists 134 if ($("#itemSavings").length > 0) { 135 var savings = Math.round( 136 ((parseFloat(storePrice) - parseFloat(itemPrice)) / 137 parseFloat(storePrice)) * 138 100 139 ); 140 $("#itemSavings").html(savings); 141 $("#itemSavings").attr("data-savings", parseFloat(savings)); 142 } 143 } else if (data.status == "search") { 144 $(".product-pricing").slideDown();
145 $("#product-not-found").slideUp(); 146 $("#btnAddCart").addClass("disabled").attr("disabled", "disabled"); 147 148 $("#additionalPriceDiv").slideUp(function () { 149 // Set Price to original price when the user started 150 $("#ourPrice").html( 151 "$" + 152 numberWithCommas( 153 parseFloat( 154 $("#ourPrice").attr("data-original-price") 155 ).toFixed(2) 156 ) 157 ); 158 $("#ourPrice").attr( 159 "data-price", 160 $("#ourPrice").attr("data-original-price") 161 ); 162 163 // Set Retail Price to original price when the user started 164 if ($("#retailPrice").length > 0) { 165 $("#retailPrice").html( 166 numberWithCommas( 167 parseFloat( 168 $("#retailPrice").attr("data-original-retail") 169 ).toFixed(2) 170 ) 171 ); 172 $("#retailPrice").attr( 173 "data-price", 174 $("#retailPrice").attr("data-original-retail") 175 ); 176 } 177 178 // Set Store Price to original price when the user started 179 if ($("#storePrice").length > 0) { 180 $("#storePrice").html( 181 numberWithCommas( 182 parseFloat($("#storePrice").attr("data-original")).toFixed(2) 183 ) 184 ); 185 $("#storePrice").attr( 186 "data-price", 187 $("#storePrice").attr("data-original") 188 ); 189 } 190 191 // Set Savings Percentage to original percentage when the user started 192 if ($("#itemSavings").length > 0) { 193 $("#itemSavings").html($("#itemSavings").attr("data-original")); 194 $("#itemSavings").attr( 195 "data-savings", 196 $("#itemSavings").attr("data-original") 197 ); 198 } 199 200 $("#additionalPriceDiv span.added-cost").html(); 201 }); 202 } else if (data.status == "invalid") { 203 $("#additionalPriceDiv").slideUp(function () { 204 $("#additionalPriceDiv span.added-cost").html(); 205 $(".product-pricing").slideUp(); 206 $("#product-not-found").slideDown(); 207 $("#btnAddCart").addClass("disabled").attr("disabled", "disabled"); 208 }); 209 } else { 210 $("#additionalPriceDiv").fadeOut(function () { 211 $("#additionalPriceDiv span.added-cost").html(); 212 $(".product-pricing").slideUp(); 213 $("#product-not-found").slideDown(); 214 $("#btnAddCart").addClass("disabled").attr("disabled", "disabled"); 215 }); 216 } 217 }, 218 }); 219 220 if (attrSelectedCount == $(".attribute-select").length) { 221 $("#btnAddCart").attr("data-disabled", "false"); 222 } 223 }); 224 225 $(".btnCartAction").click(function (e) { 226 e.preventDefault(); 227 var myform = "#" + $(this).closest("form").attr("id"); 228 var buttonVal = $(this).val(); 229 $(this).val("Adding ...."); 230 $(this).attr("disabled", "disabled"); 231 $(myform).parsley({ 232 excluded: 233 "input[type=button], input[type=submit], input[type=reset], input[type=hidden], input:hidden, textarea[type=hidden], textarea:hidden", 234 }); 235 if ($(myform).parsley().isValid()) { 236 $.post( 237 "/modules/ecommerce/process.php", 238 $(myform).serialize(), 239 function (data) { 240 if (data.error.length > 0) { 241 alert(data.error); 242 } else { 243 if (data.returnStatus == "UPD" || data.returnStatus == "ADD") { 244 window.location.href = "/" + catalogSlug + "/" + cartSlug; 245 } else if (data.returnStatus == "FAVS") { 246 window.location.href = "/members/wish-list.php"; 247 } else if (data.returnStatus.includes("RELATION") === true) { 248 window.location.href = "/" + catalogSlug + "/" + cartSlug; 249 } else { 250 window.location = data.returnStatus; 251 } 252 } 253 }, 254 "json" 255 ); 256 } else { 257 $(this).val(buttonVal); 258 $(this).removeAttr("disabled"); 259 $("#btnAddCart").attr("data-disabled", "true"); 260 $(myform).parsley().validate(); 261 } 262 }); 263 264 $("form[name='accessoryForm']").submit(function (e) { 265 var form = $(this); 266 /* var btn = $(this).find("input[type=submit]:focus" ); 267 var id = btn.attr('id'); 268 var splitID = id.split('-'); 269 $('#spinner-' + splitID[1] + '').append('<img src="/images/spin.gif" />'); 270 btn.val(''); 271 btn.css('width', '200px'); 272 btn.css('cursor', 'default'); 273 btn.attr('disabled', 'disabled');*/ 274 275 // client-side validation OK. 276 if (!e.isDefaultPrevented()) { 277 $.post( 278 "/modules/ecommerce/process.php", 279 form.serialize(), 280 function (data) { 281 if (data.length > 0) { 282 try { 283 if (data > 0) { 284 $("[data-productId=" + data + "]").hide(); 285 $("#submit-" + data + "").attr("disabled", "disabled"); 286 $("#submit-" + data + "").attr("title", "Item Added to Cart"); 287 $("#submit-" + data + "").val("Item Added to Cart"); 288 $("#submit-" + data + "").addClass("silver"); 289 $("#submit-" + data + "").addClass("addtocart"); 290 $("#submit-" + data + "").removeClass("green"); 291 $("#cartCountWapper").load(location.href + " #cartCount"); 292 //$('#spinner-' + splitID[1] + '').hide(); 293 } 294 } catch (e) { 295 alert(e.message); 296 } 297 } 298 } 299 ); 300 301 // prevent default form submission logic 302 e.preventDefault(); 303 } 304 }); 305}); 306 307function numberWithCommas(x) { 308 return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); 309} 310 311function Alert() { 312 alert( 313 "Disclaimer: You are responsible for the validation and use of the HCPCS information." 314 ); 315} 316 317function flexsliderStart(whichOne) { 318 if (whichOne == "accessories") { 319 $(".accessory-products").flexslider({ 320 animation: "slide", 321 controlNav: true, 322 animationLoop: false, 323 directionNav: false, 324 slideshow: false, 325 minItems: 5, 326 itemWidth: 240, 327 }); 328 } else { 329 return false;
330 } 331}
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.