1axios.defaults.showLoader = true; 2 3var vm = new Vue({ 4 el: '#app', 5 data: function () { 6 return { 7 show: false, 8 hover: false, 9 darkMode: false, 10 active: false, 11 NextDropdownVisible: false, 12 value: 5, 13 flycartfirstload: true, 14 PopupAddToCartVueModal: null, 15 PopupQuickViewVueModal: null, 16 index: null, 17 RelatedProducts: null, 18 compareproducts: null, 19 compareProductsQty: 0, 20 loader: false, 21 } 22 }, 23 props: { 24 flycart: null, 25 flycartitems: null, 26 flycartindicator: undefined, 27 flywish: null, 28 wishlistitems: null, 29 wishindicator: undefined, 30 UpdatedShoppingCartItemId: null, 31 }, 32 mounted: function () { 33 if (localStorage.fluid == "true") this.fluid = "fluid"; 34 if (localStorage.fluid == "fluid") this.fluid = "fluid"; 35 if (localStorage.fluid == "") this.fluid = "false"; 36 if (localStorage.darkMode == "true") this.darkMode = true; 37 this.wishindicator = parseInt(this.$refs.wishlistQty.innerText); 38 this.updateCompareProductsQty(); 39 this.backToTop(); 40 }, 41 watch: { 42 fluid: function (newName) { 43 localStorage.fluid = newName; 44 }, 45 darkMode: function (newValue) { 46 localStorage.darkMode = newValue; 47 }, 48 PopupQuickViewVueModal: function () { 49 vm.getLinkedProductsQV(vm.PopupQuickViewVueModal.Id); 50 } 51 }, 52 created: function () { 53 axios.interceptors.request.use( 54 config => { 55 if (config.showLoader) { 56 document.getElementById("app").setAttribute("v-cloak", true); 57 var element = document.querySelector(".page-loader-container"); 58 element.classList.add("axios-request"); 59 } 60 return config; 61 }, 62 error => { 63 if (error.config.showLoader) { 64 document.getElementById("app").removeAttribute("v-cloak"); 65 } 66 return Promise.reject(error); 67 } 68 ); 69 axios.interceptors.response.use( 70 response => { 71 if (response.config.showLoader) { 72 document.getElementById("app").removeAttribute("v-cloak"); 73 } 74 75 return response; 76 }, 77 error => { 78 let response = error.response; 79 80 if (response.config.showLoader) { 81 document.getElementById("app").removeAttribute("v-cloak"); 82 } 83 84 return Promise.reject(error); 85 } 86 ) 87 }, 88 methods: { 89 backToTop() { 90 if (!document.querySelector('.up-btn')) { 91 const upBtn = document.createElement('div'); 92 const upBtnContent = document.createElement('div'); 93 94 upBtn.classList.add('up-btn', 'up-btn__hide'); 95 96 function showBtn(num) { 97 if (document.documentElement.scrollTop >= num) { 98 upBtn.classList.remove('up-btn__hide'); 99 } else { 100 upBtn.classList.add('up-btn__hide'); 101 } 102 } 103 104 document.body.append(upBtn); 105 upBtn.append(upBtnContent) 106 window.addEventListener('scroll', () => { 107 showBtn(400); 108 }); 109 110 upBtn.addEventListener('click', () => { 111 window.scrollTo({ 112 top: 0, 113 behavior: "smooth" 114 }); 115 }); 116 } 117 }, 118 newsletterBox(AllowToUnsubscribe, url) { 119 let subscribe; 120 if (AllowToUnsubscribe) { 121 subscribe = this.$refs.newsletterSubscribe.checked 122 } else { 123 subscribe = true 124 } 125 var postData = { 126 subscribe: subscribe, 127 email: document.getElementById("newsletter-email").value 128 }; 129 axios({ 130 url: url, 131 params: postData, 132 method: 'post', 133 }).then(function (response) { 134 let result = response.data.Result; 135 let resultCategory = response.data.ResultCategory; 136 let showCategories = response.data.Showcategories; 137 let success = response.data.Success; 138 let variant; 139 140 if (success) { 141 variant = "info"; 142 } else { 143 variant = "danger"; 144 } 145 146 vm.$bvToast.toast(result, { 147 variant: variant, 148 autoHideDelay: 3500, 149 solid: true, 150 }); 151 152 if (showCategories) { 153 vm.displayPopup(resultCategory, 'ModalNewsletterCategory'); 154 } 155 156 }); 157 }, 158 newsletterSubscribeCategory(url) { 159 let form = document.getElementById('newsletter-category-method-form'); 160 let data = new FormData(form); 161 axios({ 162 url: url, 163 method: 'post', 164 data: data, 165 }).then(function (response) { 166 if (!response.data.Success) { 167 alert(response.data.Message); 168 } 169 }).catch(function (error) { 170 alert(error); 171 }) 172 }, 173 getPrivacyPreference(href) { 174 axios({ 175 url: href, 176 method: 'get', 177 }).then(function (response) { 178 vm.displayPopup(response.data.html, 'ModalPrivacyPreference') 179 }).catch(function (error) { 180 alert(error); 181 }); 182 }, 183 savePrivacyPreference(href) { 184 let form = document.getElementById('frmPrivacyPreference'); 185 let data = new FormData(form); 186 axios({ 187 url: href, 188 method: 'post', 189 data: data 190 }).catch(function (error) { 191 alert(error); 192 }); 193 }, 194 displayPopup(html, el) { 195 new Vue({ 196 el: '#' + el, 197 data: { 198 template: null, 199 }, 200 render: function (createElement) { 201 if (!this.template) { 202 return createElement('b-overlay', { 203 attrs: { 204 show: 'true' 205 } 206 }); 207 } else { 208 return this.template(); 209 } 210 }, 211 methods: { 212 showModal: function () { 213 this.$refs[el].show() 214 } 215 }, 216 mounted: function () { 217 var self = this; 218 self.template = Vue.compile(html).render; 219 this.darkMode = vm.darkMode; 220 }, 221 updated: function () { 222 this.showModal(); 223 } 224 }); 225 }, 226 displayBarNotification(message, url, messagetype, timeout) { 227 var variant; 228 229 if (messagetype == 'error') { 230 variant = "danger"; 231 } else { 232 variant = "info"; 233 } 234 235 this.$bvToast.toast(message, { 236 title: messagetype, 237 variant: variant, 238 href: url, 239 autoHideDelay: timeout, 240 solid: true 241 }) 242 },
243 deletecartitem: function (href) { 244 axios({ 245 method: "post", 246 baseURL: href 247 }).then(function (response) { 248 const newfly = response.data.sidebarshoppingcartmodel; 249 vm.flycart = newfly; 250 vm.flycartitems = newfly.Items; 251 vm.flycartindicator = newfly.TotalProducts; 252 }).catch(function (error) { 253 alert(error); 254 }); 255 return false; 256 }, 257 updateCompareProductsQty: function () { 258 const cookie = AxiosCart.getCookie('Grand.CompareProduct'); 259 if (cookie !== '') { 260 const qty = cookie.split('|').filter(Boolean).length; 261 this.compareProductsQty = qty; 262 } else { 263 this.compareProductsQty = 0; 264 } 265 }, 266 updateSidebarShoppingCart: function (url) { 267 axios({ 268 baseURL: url, 269 method: 'get', 270 data: null, 271 headers: { 272 'Accept': 'application/json', 273 'Content-Type': 'application/json' 274 }, 275 showLoader: false 276 }).then(response => ( 277 this.flycart = response.data, 278 this.flycartitems = response.data.Items, 279 this.flycartindicator = response.data.TotalProducts, 280 this.flycartfirstload = false 281 )) 282 }, 283 updateWishlist: function (url) { 284 axios({ 285 baseURL: url, 286 method: 'get', 287 data: null, 288 headers: { 289 'Accept': 'application/json', 290 'Content-Type': 'application/json', 291 }, 292 showLoader: false 293 }).then(response => ( 294 this.loader = false, 295 this.flywish = response.data, 296 this.wishlistitems = response.data.Items, 297 this.wishindicator = response.data.Items.length 298 )) 299 }, 300 getCompareList: function (url) { 301 this.loader = true; 302 axios({ 303 baseURL: url, 304 method: 'get', 305 params: { 306 t: new Date().getTime() 307 }, 308 data: null, 309 headers: { 310 'Accept': 'application/json', 311 'Content-Type': 'application/json' 312 }, 313 showLoader: false 314 }).then(response => { 315 this.loader = false;
316 this.compareproducts = response.data 317 }) 318 }, 319 removeFromCompareList: function (product, index) { 320 if (product !== undefined) { 321 const compareList = AxiosCart.getCookie('Grand.CompareProduct'); 322 const newCompareList = compareList.replace(product, ''); 323 AxiosCart.setCookie('Grand.CompareProduct', newCompareList); 324 vm.compareproducts.Products.splice(index, 1); 325 } else { 326 AxiosCart.setCookie('Grand.CompareProduct', ''); 327 vm.compareproducts.Products.splice(0); 328 } 329 this.updateCompareProductsQty(); 330 }, 331 showModalOutOfStock: function () { 332 this.$refs['out-of-stock'].show() 333 }, 334 productImage: function (event) { 335 var Imagesrc = event.target.parentElement.getAttribute('data-href'); 336 function collectionHas(a, b) { 337 for (var i = 0, len = a.length; i < len; i++) { 338 if (a[i] == b) return true; 339 } 340 return false; 341 } 342 function findParentBySelector(elm, selector) { 343 var all = document.querySelectorAll(selector); 344 var cur = elm.parentNode; 345 while (cur && !collectionHas(all, cur)) { 346 cur = cur.parentNode; 347 } 348 return cur; 349 } 350 351 var yourElm = event.target 352 var selector = ".product-box"; 353 var parent = findParentBySelector(yourElm, selector); 354 var Image = parent.querySelectorAll(".main-product-img")[0]; 355 Image.setAttribute('src', Imagesrc); 356 }, 357 formSubmit() { 358 vm.$refs.form.submit(); 359 }, 360 formSubmitParam(e, observer) { 361 if (e && observer) { 362 observer.validate().then(success => { 363 if (!success) { 364 return 365 } else { 366 var submitter = e.target.querySelector('[type="submit"]'); 367 eval(submitter.dataset.form) 368 } 369 }); 370 } 371 }, 372 isMobile: function () { 373 return (typeof window.orientation !== "undefined") || (navigator.userAgent.indexOf('IEMobile') !== -1); 374 }, 375 attrchange: function (productId, loadPicture) { 376 var form = document.getElementById('product-details-form'); 377 var data = new FormData(form); 378 var pId; 379 380 if (vm.PopupQuickViewVueModal.ProductBundleModels.length > 0) { 381 pId = vm.PopupQuickViewVueModal.Id; 382 } else { 383 pId = productId; 384 } 385 var isDraftMode = false; 386 var pageUrl = new URL(window.location.href); 387 if (pageUrl.searchParams.has('revId')) { 388 isDraftMode = true; 389 } 390 391 axios({ 392 url: '/product/productdetails_attributechange?productId=' + pId + '&loadPicture=' + loadPicture + '&isDraftMode=' + isDraftMode, 393 data: data, 394 method: 'post', 395 params: { product: pId }, 396 }).then(function (response) { 397 if (vm.PopupQuickViewVueModal.ProductBundleModels.length > 0) { 398 if (response.data.price) { 399 vm.PopupQuickViewVueModal.ProductPrice.Price = response.data.price; 400 } 401 } else { 402 if (response.data.price) { 403 if (vm.PopupQuickViewVueModal.ProductType == 0) { 404 if(vm.PopupQuickViewVueModal.ProductPrice.PriceWithDiscount!=null) 405 vm.PopupQuickViewVueModal.ProductPrice.PriceWithDiscount = response.data.price; 406 else 407 vm.PopupQuickViewVueModal.ProductPrice.Price = response.data.price; 408 } else { 409 vm.PopupQuickViewVueModal.AssociatedProducts.find(x => x.Id === pId).ProductPrice.Price = response.data.price; 410 } 411 } 412 if (response.data.sku) { 413 vm.PopupQuickViewVueModal.Sku = response.data.sku; 414 } 415 if (response.data.mpn) { 416 vm.PopupQuickViewVueModal.Mpn = response.data.mpn; 417 } 418 if (response.data.gtin) { 419 vm.PopupQuickViewVueModal.Gtin = response.data.gtin; 420 } 421 if (response.data.stockAvailability) { 422 vm.PopupQuickViewVueModal.StockAvailability = response.data.stockAvailability; 423 } 424 if (response.data.enabledattributemappingids) { 425 for (var i = 0; i < response.data.enabledattributemappingids.length; i++) { 426 document.querySelector('#product_attribute_label_' + response.data.enabledattributemappingids[i]).style.display = "table-cell"; 427 document.querySelector('#product_attribute_input_' + response.data.enabledattributemappingids[i]).style.display = "table-cell"; 428 } 429 } 430 if (response.data.disabledattributemappingids) { 431 for (var i = 0; i < response.data.disabledattributemappingids.length; i++) { 432 document.querySelector('#product_attribute_label_' + response.data.disabledattributemappingids[i]).style.display = "none"; 433 document.querySelector('#product_attribute_input_' + response.data.disabledattributemappingids[i]).style.display = "none"; 434 } 435 } 436 /*if (response.data.notAvailableAttributeMappingids) { 437 document.querySelectorAll('[data-disable]').forEach((element) => element.disabled = false); 438 for (var i = 0; i < response.data.notAvailableAttributeMappingids.length; i++) { 439 if (document.querySelectorAll("[data-disable='" + response.data.notAvailableAttributeMappingids[i] + "']").length > 0) { 440 document.querySelectorAll("[data-disable='" + response.data.notAvailableAttributeMappingids[i] + "']")[0].disabled = true; 441 } 442 } 443 }*/ 444 if (response.data.pictureDefaultSizeUrl !== null) { 445 vm.PopupQuickViewVueModal.DefaultPictureModel.ImageUrl = response.data.pictureDefaultSizeUrl; 446 } 447 } 448 }); 449 }, 450 uploadFile: function (e) { 451 var formData = new FormData(); 452 var imagefile = e; 453 var url = imagefile.getAttribute('data-url'); 454 formData.append("image", qqfile.files[0]); 455 axios.post(url, formData, { 456 headers: { 457 'Content-Type': 'multipart/form-data' 458 } 459 }).then(function (response) { 460 if (response.data.success) { 461 var message = response.data.message; 462 var downloadGuid = response.data.downloadGuid; 463 var downloadUrl = response.data.downloadUrl; 464 var downloadBtn = document.querySelector('.download-file'); 465 var messageContainer = document.getElementById('download-message'); 466 467 e.setAttribute('qq-button-id', downloadGuid); 468 document.querySelector('.hidden-upload-input').value = downloadGuid; 469 470 messageContainer.style.display = "block"; 471 messageContainer.classList.remove('alert-danger'); 472 messageContainer.classList.add('alert-info'); 473 messageContainer.innerText = message; 474 475 downloadBtn.style.display = "block"; 476 downloadBtn.children[0].setAttribute('href', downloadUrl); 477 478 } else { 479 var message = response.data.message; 480 var messageContainer = document.getElementById('download-message'); 481 messageContainer.style.display = "block"; 482 messageContainer.classList.remove('alert-info'); 483 messageContainer.classList.add('alert-danger'); 484 messageContainer.innerText = message; 485 } 486 }) 487 }, 488 initReservationQV: function () { 489 if (vm.PopupQuickViewVueModal !== null && vm.PopupQuickViewVueModal.ProductType == 20) { 490 var productId = vm.PopupQuickViewVueModal.Id; 491 var fullDate = vm.PopupQuickViewVueModal.ReservationFullDate; 492 var year = vm.PopupQuickViewVueModal.ReservationYear;
493 var month = vm.PopupQuickViewVueModal.ReservationMonth; 494 Reservation.init(fullDate, year, month, "No available reservations", "/Product/GetDatesForMonth", productId, "/product/productdetails_attributechange?productId=" + productId); 495 } 496 }, 497 getLinkedProductsQV: function (id) { 498 axios({ 499 url: '/Product/RelatedProducts', 500 method: 'get', 501 params: { "productId": id }, 502 headers: { 503 'Accept': 'application/json', 504 'Content-Type': 'application/json' 505 } 506 }).then(function (response) { 507 vm.RelatedProducts = response.data; 508 }); 509 }, 510 warehouse_change_handler(id, url) { 511 var data = new FormData(); 512 data.append('warehouseId', document.getElementById('WarehouseId').value); 513 data.append('productId', id); 514 axios({ 515 url: url, 516 data: data, 517 method: 'post' 518 }).then(function (response) { 519 if (response.data.stockAvailability) { 520 vm.PopupQuickViewVueModal.StockAvailability = response.data.stockAvailability; 521 } 522 }) 523 }, 524 formatDate(date) { 525 var d = new Date(date), 526 month = '' + (d.getMonth() + 1), 527 day = '' + d.getDate(), 528 year = d.getFullYear(); 529 530 if (month.length < 2) 531 month = '0' + month; 532 if (day.length < 2) 533 day = '0' + day; 534 535 return [month, day, year].join('/'); 536 }, 537 QuickViewShown: function () { 538 if (vm.PopupQuickViewVueModal.ProductAttributes.length > 0) { 539 vm.attrchange(vm.PopupQuickViewVueModal.Id, true) 540 } else { 541 var bundleProducts = vm.PopupQuickViewVueModal.ProductBundleModels; 542 if (bundleProducts.length > 0) { 543 vm.attrchange(vm.PopupQuickViewVueModal.Id, true) 544 } 545 } 546 if (vm.PopupQuickViewVueModal.ProductType == 20) { 547 var StartDate; 548 var EndDate; 549 if (vm.PopupQuickViewVueModal.IntervalUnit == 10) { 550 if (vm.PopupQuickViewVueModal.RentalStartDateUtc !== null) { 551 StartDate = this.formatDate(vm.PopupQuickViewVueModal.RentalStartDateUtc); 552 vm.PopupQuickViewVueModal.RentalStartDateUtc = StartDate; 553 } 554 if (vm.PopupQuickViewVueModal.RentalEndDateUtc !== null) { 555 EndDate = this.formatDate(vm.PopupQuickViewVueModal.RentalEndDateUtc); 556 vm.PopupQuickViewVueModal.RentalEndDateUtc = EndDate; 557 } 558 } else { 559 if (vm.PopupQuickViewVueModal.RentalStartDateUtc !== null) { 560 vm.PopupQuickViewVueModal.RentalStartDateUtc = this.formatDate(vm.PopupQuickViewVueModal.RentalStartDateUtc); 561 } else { 562 vm.PopupQuickViewVueModal.RentalStartDateUtc = null; 563 } 564 } 565 } 566 }, 567 568 }, 569});
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.