1$('body').on("click", ".sf_promo-product-single__btn-qty-adjust", function(event) { 2 event.stopImmediatePropagation(); 3 var $button = $(this); 4 var oldValue = $button.parent().find("input.sf_promo-quantity-input").val(); 5 6 if ($button.attr('data-adjust') == 1) { 7 var newVal = parseFloat(oldValue) + 1; 8 } else { 9 // Don't allow decrementing below zero 10 if (oldValue > 1) { 11 var newVal = parseFloat(oldValue) - 1; 12 } else { 13 newVal = 1; 14 } 15 } 16 17 $button.parent().find("input.sf_promo-quantity-input").val(newVal).change(); 18 19}); 20 21function expandPromoSection() { 22 var element = document.getElementById("promotion-section") 23 var expand_btn = document.getElementById("view-more-promotion") 24 25 26 element.classList.remove("sf_promo-container-white-gradient","sf_promo-container-height-opacity"); 27 expand_btn.classList.add("hide"); 28} 29 30function promoScrollToView(id) { 31 var element = document.getElementById('sf_promo-'+id); 32 if(element) element.scrollIntoView(); 33} 34 35function promo_checkbox_onChange(checkbox, product_id, promotion_id) { 36 37 // Delay for IOS mobile 38 setTimeout(function() { 39 if($("#sf_promo-"+promotion_id+" #sf_promo-product-"+product_id + " .sf_promo-prod-checkbox").is(':checked')){ 40 41 $("#sf_promo-"+promotion_id+" #sf_promo-product-"+product_id).addClass("is-selected"); 42 $("#sf_promo-"+promotion_id+" #sf_promo-product-"+product_id + " .sf_promo-variant_hidden_input").attr({'name':"promo_variant"}); 43 $("#sf_promo-"+promotion_id+" #sf_promo-product-"+product_id + " .sf_promo-quantity-selector").attr({'name':"promo_qty",'required':true}); 44 }else{ 45 46 $("#sf_promo-"+promotion_id+" #sf_promo-product-"+product_id).removeClass("is-selected"); 47 $("#sf_promo-"+promotion_id+" #sf_promo-product-"+product_id + " .sf_promo-variant_hidden_input").removeAttr('name'); 48 $("#sf_promo-"+promotion_id+" #sf_promo-product-"+product_id + " .sf_promo-quantity-selector").removeAttr('name required'); 49 } 50 },150); 51 52}; 53 54$("body").on("change", ".sf_promo-prod-checkbox", function(event){ 55 event.stopImmediatePropagation(); 56 promo_checkbox_onChange($(this),$(this).attr("data-product-id"),$(this).attr("data-promotion-id")) 57}); 58 59$("body").on("change",".sf_promo-variant-select",function(event){ 60 event.stopImmediatePropagation(); 61 promoVariantDetailUpdate($(this)) 62 63}); 64 65function promoVariantDetailInitial(){ 66 $("body").find(".sf_promo-variant-select").each(function(){ 67 if(!$(this).attr('is-initial')){ 68 promoVariantDetailUpdate($(this),true) 69 $(this).attr('is-initial',true) 70 } 71 }) 72} 73 74function promoVariantDetailUpdate(el,initial = false){ 75 var this_variant_id = $('option:selected', el).val(), 76 this_variant_price = $('option:selected', el).attr('data-price'), 77 this_variant_compare_price = $('option:selected', el).attr('data-compare_at_price'), 78 this_variant_img = $('option:selected', el).attr('data-varaint-img'), 79 this_promotion_id = $('option:selected', el).attr('data-promotion-id'), 80 this_product_id = $('option:selected', el).attr('data-product-id'), 81 this_variant_inventory = $('option:selected', el).attr('data-quantity'), 82 this_variant_available = $('option:selected', el).attr('data-available'), 83 this_variant_img_url = 'https://s3.ap-southeast-1.amazonaws.com/eesb.public/images/products/no_image.png', 84 primary_product = $(el).attr('data-primary-product') != undefined ? true : false; 85 86 var allCookies = document.cookie.split(";"), 87 cookies = {}; 88 for (var i=0; i<allCookies.length; i++){ 89 var pair = allCookies[i].split("="); 90 cookies[(pair[0]+'').trim()] = unescape(pair[1]); 91 } 92 if (cookies['currency'] != undefined) selectedCurrency = cookies['currency'] 93 94 95 if(this_variant_img != null && this_variant_img != '' ) { 96 this_variant_img_url = this_variant_img 97 $("#sf_promo-"+this_promotion_id+" #sf_promo-product-"+this_product_id + " .sf_promo-product-image").attr('src',this_variant_img_url); 98 } 99 100 $("#sf_promo-"+this_promotion_id+" #sf_promo-product-"+this_product_id + " .sf_promo-variant_hidden_input").attr({'value':this_variant_id}); 101 102 $("body").find("#sf_promo-"+this_promotion_id+" #sf_promo-product-"+this_product_id + " .sf_promo-product-discounted-price").html(promoformatMoney(this_variant_price,shop_money_format) ); 103 $("body").find("#sf_promo-"+this_promotion_id+" #sf_promo-product-"+this_product_id + " .sf_promo-product-original-price").html(promoformatMoney(this_variant_compare_price,shop_money_format) ); 104 105 if(!initial) $("#sf_promo-"+this_promotion_id+" #sf_promo-product-"+this_product_id + " .sf_promo-prod-checkbox").prop('checked',true).change(); 106 107 sf_promoCheckInventory(this_product_id, this_variant_inventory, this_variant_available, this_variant_price, primary_product); 108 109 if(window.Currency != undefined) Currency.convertAll(shopCurrency, selectedCurrency); 110 if(window.EasyStore != undefined && window.EasyStore.Currencies != undefined) EasyStore.Currencies.convertAll() 111 112 113} 114 115function sf_promoCheckInventory(id, inventory, available, price, primary_product){ 116 // console.log("check inventory",id, inventory, available); 117 if((available == false) || (price <= 0 && primary_product)){ 118 $("#sf_promo-product-"+id + " .sf_promo-prod-checkbox").prop('checked',fal
118se).change(); 119 $("#sf_promo-product-"+id + " .sf_promo-prod-checkbox").prop('disabled',true); 120 $("#sf_promo-product-"+id + " .sf_promo-qty-adjust input").prop('disabled',true); 121 $("#sf_promo-product-"+id + " .sf_promo-qty-adjust").addClass('hide'); 122 $("#sf_promo-product-"+id + " .entitled-label").addClass('hide'); 123 if(inventory == 0 || inventory != null || inventory != '') $("#sf_promo-product-"+id + " .sold-out-text").removeClass('hide'); 124 } 125 else{ 126 $("#sf_promo-product-"+id + " .sf_promo-qty-adjust").removeClass('hide'); 127 $("#sf_promo-product-"+id + " .sold-out-text").addClass('hide'); 128 $("#sf_promo-product-"+id + " .sf_promo-qty-adjust input").prop('disabled',false); 129 $("#sf_promo-product-"+id + " .sf_promo-prod-checkbox").prop('disabled',false); 130 } 131 132 if(inventory == null && inventory != 0){ 133 $("#sf_promo-product-"+id + " .sf_promo-qty-adjust input").prop('max',''); 134 }else if(available && inventory > 0){ 135 $("#sf_promo-product-"+id + " .sf_promo-qty-adjust input").prop('max',inventory); 136 } 137 138} 139 140$("body").on("input change",".sf_promo-quantity-input",function(event){ 141 event.stopImmediatePropagation(); 142 143 $("#sf_promo-product-"+$(this).attr("data-product-id") + " .sf_promo-prod-checkbox").prop('checked',true).change(); 144}); 145 146$("body").on("submit", ".sf_promo-form", function(event){ 147 event.preventDefault(); 148 event.stopImmediatePropagation(); 149 var countCheckedCheckboxes = $(this).find('input.sf_promo-prod-checkbox').filter(':checked').length; 150 151 if(countCheckedCheckboxes > 0){ 152 $(this).find('button[type=submit]').addClass('btn--loading') 153 var form_template = $(this).attr('data-template') 154 155 var id = $(this).find('input[name="promo_variant"]'), 156 input_quantity = $(this).find('input[name="promo_qty"]'), 157 id_ar = [], 158 qty_ar = [] 159 160 $.each(id, function( index, b ) { 161 id_ar.push($(b).val()) 162 }) 163 164 $.each(input_quantity, function( index, b ) { 165 qty_ar.push($(b).val()) 166 }) 167 168 let this_form = $(this) 169 170 $.ajax({ 171 type: "POST", 172 dataType: 'json', 173 url: "/cart/add", 174 data:{ 175 id: id_ar, 176 quantity: qty_ar, 177 _token: $('#app__product_promotionDialog-token').val(), 178 promotion_id: $(this).attr("data-promotion-id"), 179 }, 180 success: function(response){ 181 var cartCount = $('.cart-count') 182 cartCount.text(response.item_count); 183 $('.hidden-count').removeClass('hidden-count'); 184 185 if(window.theme != undefined && window.theme.fetchCartDrawer != undefined) theme.fetchCartDrawer() 186 if(document.querySelector('cart-notification')) document.querySelector('cart-notification').renderContents(response) 187 if(response.cart_content && document.querySelector('#cart-template')) document.querySelector('#cart-template').innerHTML = response.cart_content 188 189 if (window.checkProductProperties !== undefined){ 190 window.checkProductProperties(); 191 } 192 193 }, 194 error: function(xhr){ 195 console.log('error',xhr); 196 var data = eval('(' + xhr.responseText + ')'); 197 var response = data.description; 198 }, 199 complete: function(xhr){ 200 this_form.find('button[type=submit]').removeClass('btn--loading') 201 } 202 }); 203 } 204}); 205 206promoformatMoney = function(t, e) { 207 function n(t, e) { 208 return "undefined" == typeof t ? e : t 209 } 210 211 function r(t, e, r, i) { 212 if (e = n(e, 2), r = n(r, ","), i = n(i, "."), isNaN(t) || null == t) return 0; 213 t = (t / 100).toFixed(e); 214 var o = t.split("."), 215 a = o[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + r), 216 s = o[1] ? i + o[1] : ""; 217 return a + s 218 } 219 "string" == typeof t && (t = t.replace(".", "")) && (t = t.replace(",", "")); 220 var i = "", 221 o = /\{\{\s*(\w+)\s*\}\}/, 222 a = e || this.money_format; 223 switch (a.match(o)[1]) { 224 case "amount": 225 i = r(t, 2); 226 break; 227 case "amount_no_decimals": 228 i = r(t, 0); 229 break; 230 case "amount_with_comma_separator": 231 i = r(t, 2, ".", ","); 232 break; 233 case "amount_no_decimals_with_comma_separator": 234 i = r(t, 0, ".", ","); 235 break; 236 case "amount_no_decimals_with_space_separator": 237 i = r(t, 0, " ") 238 } 239 return a.replace(o, i) 240}
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.