1function floatToString(t, e) { 2 var n = t.toFixed(e).toString(); 3 return n.match(/^\.\d+/) ? "0" + n : n 4} 5"undefined" == typeof window.EasyStore && (window.EasyStore = {}), EasyStore.each = function(t, e) { 6 for (var n = 0; n < t.length; n++) e(t[n], n) 7}, EasyStore.map = function(t, e) { 8 for (var n = [], r = 0; r < t.length; r++) n.push(e(t[r], r)); 9 return n 10}, EasyStore.arrayIncludes = function(t, e) { 11 for (var n = 0; n < t.length; n++) 12 if (t[n] == e) return !0; 13 return !1 14}, EasyStore.uniq = function(t) { 15 for (var e = [], n = 0; n < t.length; n++) EasyStore.arrayIncludes(e, t[n]) || e.push(t[n]); 16 return e 17}, EasyStore.isDefined = function(t) { 18 return "undefined" == typeof t ? !1 : !0 19}, EasyStore.getClass = function(t) { 20 return Object.prototype.toString.call(t).slice(8, -1) 21}, EasyStore.extend = function(t, e) { 22 function n() {} 23 n.prototype = e.prototype, t.prototype = new n, t.prototype.constructor = t, t.baseConstructor = e, t.superClass = e.prototype 24}, EasyStore.locationSearch = function() { 25 return window.location.search 26}, EasyStore.locationHash = function() { 27 return window.location.hash 28}, EasyStore.replaceState = function(t) { 29 window.history.replaceState({}, document.title, t) 30}, EasyStore.urlParam = function(t) { 31 var e = RegExp("[?&]" + t + "=([^&#]*)").exec(EasyStore.locationSearch()); 32 return e && decodeURIComponent(e[1].replace(/\+/g, " ")) 33}, EasyStore.newState = function(t, e) { 34 var n; 35 return n = EasyStore.urlParam(t) ? EasyStore.locationSearch().replace(RegExp("(" + t + "=)[^&#]+"), "$1" + e) : "" === EasyStore.locationSearch() ? "?" + t + "=" + e : EasyStore.locationSearch() + "&" + t + "=" + e, n + EasyStore.locationHash() 36}, EasyStore.setParam = function(t, e) { 37 EasyStore.replaceState(EasyStore.newState(t, e)) 38}, EasyStore.Product = function(t) { 39 EasyStore.isDefined(t) && this.update(t) 40}, EasyStore.Product.prototype.update = function(t) { 41 for (property in t) this[property] = t[property] 42}, EasyStore.Product.prototype.optionNames = function() { 43 return "Array" == EasyStore.getClass(this.options) ? this.options : [] 44}, EasyStore.Product.prototype.optionValues = function(t) { 45 if (!EasyStore.isDefined(this.variants)) return null; 46 var e = EasyStore.map(this.variants, function(e) { 47 var n = "option" + (t + 1); 48 return void 0 == e[n] ? null : e[n] 49 }); 50 return null == e[0] ? null : EasyStore.uniq(e) 51}, EasyStore.Product.prototype.getVariant = function(t) { 52 var e = null; 53 return t.length != this.options.length ? e : (EasyStore.each(this.variants, function(n) { 54 for (var r = !0, i = 0; i < t.length; i++) { 55 var o = "option" + (i + 1); 56 n[o] != t[i] && (r = !1) 57 } 58 return 1 == r ? void(e = n) : void 0 59 }), e) 60}, EasyStore.Product.prototype.getVariantById = function(t) { 61 for (var e = 0; e < this.variants.length; e++) { 62 var n = this.variants[e]; 63 if (t == n.id) return n 64 } 65 return null 66}, EasyStore.money_format = "MYR {{amount}}", EasyStore.formatMoney = function(t, e) { 67 function n(t, e) { 68 return "undefined" == typeof t ? e : t 69 } 70 71 function r(t, e, r, i) { 72 if (e = n(e, 2), r = n(r, ","), i = n(i, "."), isNaN(t) || null == t) return 0; 73 t = (t / 100).toFixed(e); 74 var o = t.split("."), 75 a = o[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + r), 76 s = o[1] ? i + o[1] : ""; 77 return a + s 78 } 79 "string" == typeof t && (t = t.replace(".", "")) && (t = t.replace(",", "")); 80 var i = "", 81 o = /\{\{\s*(\w+)\s*\}\}/, 82 a = e || this.money_format; 83 switch (a.match(o)[1]) { 84 case "amount": 85 i = r(t, 2); 86 break; 87 case "amount_no_decimals": 88 i = r(t, 0); 89 break; 90 case "amount_with_comma_separator": 91 i = r(t, 2, ".", ","); 92 break; 93 case "amount_no_decimals_with_comma_separator": 94 i = r(t, 0, ".", ","); 95 break; 96 case "amount_no_decimals_with_space_separator": 97 i = r(t, 0, " ") 98 } 99 return a.replace(o, i) 100}, EasyStore.OptionSelectors = function(t, e) { 101 return this.selectorDivClass = "selector-wrapper", this.selectorClass = "single-option-selector", this.variantIdFieldIdSuffix = "-variant-id", this.variantIdField = null, this.historyState = null, this.selectors = [], this.domIdPrefix = t, this.product = new EasyStore.Product(e.product), this.onVariantSelected = EasyStore.isDefined(e.onVariantSelected) ? e.onVariantSelected : function() {}, this.replaceSelector(t), this.initDropdown(), e.enableHistoryState && (this.historyState = new EasyStore.OptionSelectors.HistoryState(this)), !0 102}, EasyStore.OptionSelectors.prototype.initDropdown = function() { 103 var t = { 104 initialLoad: !0 105 }, 106 e = this.selectVariantFromDropdown(t); 107 if (!e) { 108 var n = this; 109 setTimeout(function() { 110 n.selectVariantFromParams(t) || n.fireOnChangeForFirstDropdown.call(n, t) 111 }) 112 } 113}, EasyStore.OptionSelectors.prototype.fireOnChangeForFirstDropdown = function(t) { 114 this.selectors[0].element.onchange(t) 115}, EasyStore.OptionSelectors.prototype.selectVariantFromParamsOrDropdown = function(t) { 116 var e = this.selectVariantFromParams(t); 117 e || this.selectVariantFromDropdown(t) 118}, EasyStore.OptionSelectors.prototype.replaceSelector = function(t) { 119 var e = document.getElementById(t), 120 n = e.parentNode; 121 EasyStore.each(this.buildSelectors(), function(t) { 122 n.insertBefore(t, e) 123 }), e.style.display = "none", this.variantIdField = e 124}, EasyStore.OptionSelectors.prototype.selectVariantFromDropdown = function(t) { 125 var e = document.getElementById(this.domIdPrefix).querySelector("[selected]"); 126 if (e || (e = document.getElementById(this.domIdPrefix).querySelector('[selected="selected"]')), !e) return !1; 127 var n = e.value; 128 return this.selectVariant(n, t) 129}, EasyStore.OptionSelectors.prototype.selectVariantFromParams = function(t) { 130 var e = EasyStore.urlParam("variant"); 131 132 133 // console.log('selectVariantFromParams',e, t); 134 135 136 return this.selectVariant(e, t) 137}, EasyStore.OptionSelectors.prototype.selectVariant = function(t, e) { 138 // console.log('selectVariant',t, e); 139 var n = this.product.getVariantById(t); 140 // console.log('this.product.getVariantById(t)',n); 141 142 143 if (null == n) return !1; 144 for (var r = 0; r < this.selectors.length; r++) { 145 var i = this.selectors[r].element, 146 o = i.getAttribute("data-option"), 147 a = n[o]; 148 null != a && this.optionExistInSelect(i, a) && (i.value = a) 149 } 150 151 // console.log('this.selectors[0].element',this.selectors[0].element); 152 153 return "undefined" != typeof jQuery ? jQuery(this.selectors[0].element).trigger("change", e) : this.selectors[0].element.onchange(e), !0 154}, EasyStore.OptionSelectors.prototype.optionExistInSelect = function(t, e) { 155 156 157 158 // console.log('OptionSelectors.prototype.optionExistInSelect',t, e); 159 // console.log('OptionSelectors.prototype.optionExistInSelect',t.childElementCount); 160 // console.log('OptionSelectors.prototype.optionExistInSelect',t.getElementsByTagName('input')[0].value); 161 162 163// 164 for (var n = 0; n < t.childElementCount; n++) 165 if (t.getElementsByTagName('input')[n].value == e) return !0 166}, EasyStore.OptionSelectors.prototype.insertSelectors = function(t, e) { 167 EasyStore.isDefined(e) && this.setMessageElement(e), this.domIdPrefix = "product-" + this.product.id + "-variant-selector"; 168 var n = document.getElementById(t); 169 EasyStore.each(this.buildSelectors(), function(t) { 170 n.appendChild(t) 171 }) 172}, EasyStore.OptionSelectors.prototype.buildSelectors = function() { 173 for (var t = 0; t < this.product.optionNames().length; t++) { 174 var e = new EasyStore.SingleOptionSelector(this, t, this.product.optionNames()[t], this.product.optionValues(t)); 175 e.element.disabled = !1, this.selectors.push(e) 176 } 177 var n = this.selectorDivClass, 178 r = this.product.optionNames(), 179 i = EasyStore.map(this.selectors, function(t) { 180 var e = document.createElement("div"); 181 if (e.setAttribute("class", n), r.length > 1) { 182 var i = document.createElement("label");
183 i.htmlFor = t.element.id, i.innerHTML = t.name, e.appendChild(i) 184 } 185 return e.appendChild(t.element), e 186 }); 187 // console.log('i',i); 188 return i 189}, EasyStore.OptionSelectors.prototype.selectedValues = function() { 190 // console.log('selectedValues selectors',this.selectors[0].element); 191 for (var t = [], e = 0; e < this.selectors.length; e++) { 192 var found_checked = false; 193 for (var n = 0; n < this.selectors[e].element.childElementCount; n++){ 194 if (found_checked) { 195 break; 196 } 197 if(this.selectors[e].element.getElementsByTagName('input')[n].checked){ 198 found_checked = true; 199 var n = this.selectors[e].element.getElementsByTagName('input')[n].value; 200 t.push(n) 201 202 } 203 } 204 } 205 // console.log('prototype.selectedValues',t); 206 return t 207}, EasyStore.OptionSelectors.prototype.updateSelectors = function(t, e) { 208 209 var n = this.selectedValues(), 210 r = this.product.getVariant(n); 211 212 // console.log('updateSelectors',n, r); 213 214 r ? (this.variantIdField.disabled = !1, this.variantIdField.value = r.id, this.variantIdField.dispatchEvent(new Event('change', { bubbles: true }))) : this.variantIdField.disabled = !0, this.onVariantSelected(r, this, e), null != this.historyState && this.historyState.onVariantChange(r, this, e) 215}, EasyStore.OptionSelectorsFromDOM = function(t, e) { 216 var n = e.optionNames || [], 217 r = e.priceFieldExists || !0, 218 i = e.delimiter || "/", 219 o = this.createProductFromSelector(t, n, r, i); 220 e.product = o, EasyStore.OptionSelectorsFromDOM.baseConstructor.call(this, t, e) 221}, EasyStore.extend(EasyStore.OptionSelectorsFromDOM, EasyStore.OptionSelectors), EasyStore.OptionSelectorsFromDOM.prototype.createProductFromSelector = function(t, e, n, r) { 222 if (!EasyStore.isDefined(n)) var n = !0; 223 if (!EasyStore.isDefined(r)) var r = "/"; 224 var i = document.getElementById(t), 225 o = i.childNodes, 226 a = (i.parentNode, e.length), 227 s = []; 228 EasyStore.each(o, function(t, i) { 229 if (1 == t.nodeType && "option" == t.tagName.toLowerCase()) { 230 var o = t.innerHTML.split(new RegExp("\\s*\\" + r + "\\s*")); 231 0 == e.length && (a = o.length - (n ? 1 : 0)); 232 var u = o.slice(0, a), 233 l = n ? o[a] : "", 234 c = (t.getAttribute("value"), { 235 available: t.disabled ? !1 : !0, 236 id: parseFloat(t.value), 237 price: l, 238 option1: u[0], 239 option2: u[1], 240 option3: u[2] 241 }); 242 s.push(c) 243 } 244 }); 245 var u = { 246 variants: s 247 }; 248 if (0 == e.length) { 249 u.options = []; 250 for (var l = 0; a > l; l++) u.options[l] = "option " + (l + 1) 251 } else u.options = e; 252 return u 253}, EasyStore.SingleOptionSelector = function(t, e, n, r) { 254 255 this.multiSelector = t, this.values = r, this.index = e, this.name = n, this.element = document.createElement("fieldset"); 256 let first_available_variant = this.multiSelector.product.first_available_variant || null, 257 product_options = this.multiSelector.product.options, 258 product_variants = this.multiSelector.product.variants; 259 260 for (var i = 0; i < r.length; i++) { 261 if(product_options.length > 1 || product_variants[i].is_enabled){ 262 var o = document.createElement("input"); 263 o.setAttribute('type','radio'); 264 o.setAttribute('name',n); 265 o.id = t.domIdPrefix + "-option-"+e+"tag-" + i; 266 if((first_available_variant == null && i == 0) || (first_available_variant != null && first_available_variant.options[this.index] == r[i])){ 267 o.setAttribute('checked','checked'); 268 } 269 o.value = r[i], this.element.appendChild(o); 270 271 this.label = document.createElement("label"); 272 this.label.innerHTML = r[i]; 273 this.label.setAttribute('for',t.domIdPrefix + "-option-"+e+"tag-" + i); 274 this.element.appendChild(this.label); 275 } 276 } 277 this.element.setAttribute('name',n); 278 return this.element.setAttribute("class", this.multiSelector.selectorClass), this.element.setAttribute("data-option", "option" + (e + 1)), this.element.i
278d = t.domIdPrefix + "-option-" + e, this.element.onchange = function(n, r) { 279 // console.log('fieldset onchange',n, r); 280 r = r || {}, t.updateSelectors(e, r) 281 }, !0 282}, EasyStore.Image = { 283 preload: function(t, e) { 284 for (var n = 0; n < t.length; n++) { 285 var r = t[n]; 286 this.loadImage(this.getSizedImageUrl(r, e)) 287 } 288 }, 289 loadImage: function(t) { 290 (new Image).src = t 291 }, 292 switchImage: function(t, e, n) { 293 if (t && e) { 294 var r = this.imageSize(e.src), 295 i = this.getSizedImageUrl(t.src, r); 296 n ? n(i, t, e) : e.src = i 297 } 298 }, 299 imageSize: function(t) { 300 var e = t.match(/_(1024x1024|2048x2048|pico|icon|thumb|small|compact|medium|large|grande)\./); 301 return null != e ? e[1] : null 302 }, 303 getSizedImageUrl: function(t, e) { 304 if (null == e) return t; 305 if ("master" == e) return this.removeProtocol(t); 306 var n = t.match(/\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?$/i); 307 if (null != n) { 308 var r = t.split(n[0]), 309 i = n[0]; 310 return this.removeProtocol(r[0] + "_" + e + i) 311 } 312 return null 313 }, 314 removeProtocol: function(t) { 315 return t.replace(/http(s)?:/, "") 316 } 317}, EasyStore.OptionSelectors.HistoryState = function(t) { 318 this.browserSupports() && this.register(t) 319}, EasyStore.OptionSelectors.HistoryState.prototype.register = function(t) { 320 window.addEventListener("popstate", function(e) { 321 t.selectVariantFromParamsOrDropdown({ 322 popStateCall: !0 323 }) 324 }) 325}, EasyStore.OptionSelectors.HistoryState.prototype.onVariantChange = function(t, e, n) { 326 this.browserSupports() && (!t || n.initialLoad || n.popStateCall || EasyStore.setParam("variant", t.id)) 327}, EasyStore.OptionSelectors.HistoryState.prototype.browserSupports = function() { 328 return window.history && window.history.replaceState 329};
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.