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