(function() { loadjQuery() .then(() => { var jQInf = jQuery.noConflict(true); initialize(jQInf); }) .catch((error) => console.error("Error loading jQuery:", error)); function loadjQuery() { return new Promise((resolve, reject) => { var loadScript = (src, integrity) => { var script = document.createElement('script'); script.src = src; if (integrity) { script.integrity = integrity; script.crossOrigin = 'anonymous'; } script.onload = () => resolve(window.jQuery); script.onerror = () => { if (src === 'https://code.jquery.com/jquery-3.6.0.min.js') { // Fallback to alternative source loadScript('https://cdn.bootcss.com/jquery/3.1.1/jquery.min.js', 'sha384-3ceskX3iaEnIogmQchP8opvBy3Mi7Ce34nWjpBIwVTHfGYWQS9jwHDVRnpKKHJg7'); } else { reject(new Error('Failed to load jQuery')); } }; document.head.appendChild(script); }; loadScript('https://code.jquery.com/jquery-3.6.0.min.js', 'sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK'); }); } function initialize($) { console.log("%cLoad products while scrolling - Powered by Scrollify", "font-weight: bold; background-color: #fff; color: #000"); console.log("Get it here: https://apps.shopify.com/scrollify-infinite-scroll"); getData($) .then(settings => { var data = JSON.parse(settings.data[0].data); var gif = settings.data[0].customGif; var status = settings.data[0].status; setupPage($, data,gif); }) .catch(error => console.error("Error getting data:", error)); } function getData($) { var infinite = "/apps/infinite"; var cleverlink = Shopify.shop || "shopallthinge.myshopify.com"; return $.ajax({ type: "POST", url: infinite, data: { shop: cleverlink } }); } function setupPage($, data,gif) { // Your code for setting up the page, themes, and listeners // Refactor this part into smaller functions as needed console.log(gif); var status = data.checked; var customgif = gif || 'https://media.tenor.com/uuEPRFM5xdcAAAAi/loader.gif'; if (data.showbutton === "No" || data.showbutton === "1") { loaderMode = 1; } else { loaderMode = 2; } loadMoreBtnText = data.buttonText; oncegoI = false; specialTheme = 0; gsLastUrl = ''; XMLHttpRequest.prototype.gsOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.gsSend = XMLHttpRequest.prototype.send; $(window).ready(function() { if (!oncegoI) { specialTheme = 0; $("body").append(''); if ($(".container-pushy-main").length > 0 && $("#category-sticky-parent").length > 0 && $(".pagination-buttons").length > 0) { $("#category-sticky-parent").after($($(".pagination-buttons").get(0))); } // TESTAMENT if (($("#product-loop .product-index").length > 0) && ($("#product-loop .first").length > 0)) { $("body").append(''); specialTheme = 6; } // VENUE if ($(".o-layout__item").length > 0) { $("body").append(""); } // ENVY if ($("#Collection .indiv-product-wrapper").length > 0) { specialTheme = 9; } // ICON if ($("#bside #product-loop .product").length > 0) { specialTheme = 8; $("body").append(''); } // TURBO if (($(".columns .collection-matrix .one-third").length > 0) || ($(".columns .collection-matrix .four").length > 0) || ($(".columns .collection-matrix .eight").length > 0)) { specialTheme = 2; setInterval(function() { $(".js-forms .viewed").removeClass("viewed"); }, 1000); } // PARALLAX if (($("#shopify-section-collection-template .one-third").length > 0) || ($("#shopify-section-collection-template .four .product_image .image__container").length > 0) || ($("#shopify-section-collection-template .eight .product_image .image__container").length > 0)) { $("html").css("opacity", '1'); $("body").append(""); specialTheme = 2; } // VANTAGE if (($(".product-loop .medium_grid .product-index-inner .box-ratio").length > 0) || ($(".product-loop .large_grid .product-index-inner .box-ratio").length > 0)) { specialTheme = 13; $("body").append(''); } // SPLIT if ($(".site-box-container .box__collection").length > 0) { $("body").append(""); specialTheme = 12; } if (($(".quickshop .quickshop-spinner").length > 0) && ($(".quick-shop-modal-trigger").length > 0)) { specialTheme = 15; } // ATLANTIC if ($(".product-list .product .product-card-figure").length > 0) { specialTheme = 11; } // KINGDOM if (($(".isotope-products .three .grid-item-image").length > 0)) { $("body").append(''); specialTheme = 17; } // SHOWCASE if (($(".wide-container .jiggly-split").length > 0)) { specialTheme = 16; } // CASCADE if (($(".collection-cascade .resp-img-wrapper .resp-img-placeholder").length > 0)) { specialTheme = 18; } if (($('.collection-listing .product-crop-tall .product-list-item figure[data-rimg-template*="shopif"]').length > 0)) { specialTheme = 33; //$("body").append(''); } // COLORS if (($(".col-0 .inner .table .cell").length > 0)) { specialTheme = 21; $("body").append(''); } setInterval(function() { try { $(".lazyloading").each(function() { $(this).removeClass("lazyloading"); $(this).addClass("lazyloaded"); }); } catch (err) {} }, 3000); //console.debug("special theme " + specialTheme); try { $("#bc-sf-filter-top-pagination").remove(); } catch (error) {} if ($(".pagination").length == 2) { $($(".pagination").get(0)).remove(); } gsLastUrl = window.location.href; if (!(window.location.href.indexOf("/products/") > 0)) { setInterval(function() { try { if (gsLastUrl.length > 5 && window.location.href !== gsLastUrl) { var url = window.location.href; if (url.includes("/collections") || url.includes("/search")) { gsLastUrl = url; window.location.reload(); } } } catch (err) {} try { $($('body').get(0)).find("img[src*='loader.gif']").each(function() { if ($(this).hasClass("product_image--current")) { $(this).attr("src", $(this).attr('data-src')); } }); } catch (err) {} }, 1000); } $("body").append(""); oncegoI = true; if ($("#wrapper1 #collection_sorted .product_listing_controls .products_count").length > 0) { specialTheme = 1; } if (specialTheme == 1) { setTimeout(function() { gsscroller = new GSLoader(); }, 1000); } else { gsscroller = new GSLoader(); } } }); paginateSel = null; paginateSelector = ''; collectionParent = ''; collectionPageNr = 1; gsscroller = null; containerPos = 1; productsParentTmp = null; function getUrlParamsGS(prop) { var params = {}; var search = decodeURIComponent(window.location.href.slice(window.location.href.indexOf('?') + 1)); var definitions = search.split('&'); definitions.forEach(function(val, key) { var parts = val.split('=', 2); params[parts[0]] = parts[1]; }); return (prop && prop in params) ? params[prop] : null; } var fixThemeSpecial = function() { if (specialTheme == 6) { var gsProductsPerRow = 0; var gsCntProductsInRow = 0; if ($("#product-loop").find(".desktop-6").length > 0) { gsProductsPerRow = 2; } if ($("#product-loop").find(".desktop-4").length > 0) { gsProductsPerRow = 3; } if ($("#product-loop").find(".desktop-3").length > 0) { gsProductsPerRow = 4; } if ($("#product-loop").find(".desktop-2").length > 0) { gsProductsPerRow = 6; } if ($("#product-loop").find(".desktop-fifth").length > 0) { gsProductsPerRow = 5; } if (gsProductsPerRow == 0) { gsProductsPerRow = 4; } var gsCounterOdds = 1; $("#product-loop .product-index").each(function(index) { var loazyloaders = $(this).find(".lazyloading"); if (loazyloaders.length > 0) { var mainlazyloader = $(loazyloaders.get(0)); mainlazyloader.removeClass("lazyloading"); mainlazyloader.addClass("lazyloaded"); } $(this).removeClass("first"); $(this).removeClass("last"); if (gsCounterOdds == 1) { $(this).addClass("first"); } if (gsCounterOdds == gsProductsPerRow) { $(this).addClass("last"); } if (gsCounterOdds == gsProductsPerRow) { gsCounterOdds = 0; } gsCounterOdds++; }); } if (specialTheme == 16) { colCnt = 1; $(".product-block").each(function(index) { var cardImage = $($(this).find(".lazyloading").get(0)); cardImage.removeClass("lazyloading"); cardImage.addClass("lazyloaded"); var productBlockGS = $(".col-" + colCnt).find(".product-block").get(0); $(productBlockGS).appendTo("#page-content"); colCnt++; if (colCnt == 4) { colCnt = 1; } }); $(".product-list .product-block").each(function(index) { $(this).appendTo("#page-content"); }); colCnt = 1; $(".product-block").each(function(index) { $(".col-" + colCnt).append($(this)); colCnt++; if (colCnt == 4) { colCnt = 1; } }); } if (specialTheme == 17) { try { $(".grid-item").each(function(index) { $(this).addClass("loaded"); }); if (jQuery('.isotope-products').length > 0) { jQuery('.isotope-products').each(function() { window.KINGDOM.Grid.mount(jQuery(this)) }); } } catch (err) {} } if (specialTheme == 18) { try { $("body").append($('script[src*="assets/theme.min.js"]').get(0).outerHTML.replace('defer="defer"', '')); } catch (err) {} } if (specialTheme == 9) { var gsNumberOfColumns = 0 if ($("#Collection").find(".six_columns").length > 0) { gsNumberOfColumns = 6; } if ($("#Collection").find(".five_columns").length > 0) { gsNumberOfColumns = 5; } if ($("#Collection").find(".four_columns").length > 0) { gsNumberOfColumns = 4; } if ($("#Collection").find(".three_columns").length > 0) { gsNumberOfColumns = 3; } if ($("#Collection").find(".two_columns").length > 0) { gsNumberOfColumns = 2; } if (gsNumberOfColumns == 0) { gsNumberOfColumns = 4; } $(".product_clear").remove(); var gsCounterOdds = 1; var gsCounterThree = 1; $("#Collection .indiv-product-wrapper").each(function(index) { $(this).removeClass("alpha"); $(this).removeClass("omega"); $(this).removeClass("even"); $(this).removeClass("odd"); $(this).removeClass("tablet-clear"); $(this).removeClass("mobile-clear"); if (gsCounterOdds == 1) { $(this).addClass("even"); $(this).addClass("tablet-clear"); $(this).addClass("mobile-clear"); } else { $(this).addClass("odd"); } if (gsCounterThree == 1) { $(this).addClass("alpha"); } if (gsCounterThree == gsNumberOfColumns) { $(this).addClass("omega"); $(this).after('
'); } if (gsCounterOdds == 2) { gsCounterOdds = 0; } if (gsCounterThree == gsNumberOfColumns) { gsCounterThree = 0; } gsCounterOdds++; gsCounterThree++; }); } if (specialTheme == 12) { $("#section-collection .site-box").each(function(index) { $(this).addClass("active"); }); } if (specialTheme == 13) { var gsCounterOdds = 1; var gsNumberOfColumns = 0 if ($($(".product-loop").get(0)).find(".desktop-6").length > 0) { gsNumberOfColumns = 2; } if ($($(".product-loop").get(0)).find(".desktop-4").length > 0) { gsNumberOfColumns = 3; } if ($($(".product-loop").get(0)).find(".desktop-3").length > 0) { gsNumberOfColumns = 4; } if (gsNumberOfColumns == 0) { gsNumberOfColumns = 3; } $(".product-loop .product-index").each(function(index) { $(this).removeClass("first"); $(this).removeClass("last"); if (gsCounterOdds == 1) { $(this).addClass("first"); } if (gsCounterOdds == gsNumberOfColumns) { $(this).addClass("last"); } if (gsCounterOdds == gsNumberOfColumns) { gsCounterOdds = 0; } gsCounterOdds++; }); } if (specialTheme == 8) { var gsNumberOfColumns = 0 if ($("#product-loop").find(".desktop-6").length > 0) { gsNumberOfColumns = 2; } if ($("#product-loop").find(".desktop-4").length > 0) { gsNumberOfColumns = 3; } if ($("#product-loop").find(".desktop-3").length > 0) { gsNumberOfColumns = 4; } if (gsNumberOfColumns == 0) { gsNumberOfColumns = 4; } var gsCounterOdds = 1; $("#product-loop .product").each(function(index) { $(this).removeClass("first"); $(this).removeClass("last"); if (gsCounterOdds == 1) { $(this).addClass("first"); } if (gsCounterOdds == gsNumberOfColumns) { $(this).addClass("last"); } if (gsCounterOdds == gsNumberOfColumns) { gsCounterOdds = 0; } gsCounterOdds++; }); } if (specialTheme == 2 || specialTheme == 10) { $(".product_clear").remove(); var gsCounterOdds = 1; var gsCounterThree = 1; var gsNumberOfColumns = 3; var GSproductQuery = '#shopify-section-collection-template .products .one-third'; if ($(".collection-matrix .columns").length > 0) { GSproductQuery = '.collection-matrix .columns'; } if ($("#shopify-section-collection-template .products .eight").length > 0) { gsNumberOfColumns = 2; GSproductQuery = '#shopify-section-collection-template .products .eight'; } if ($("#shopify-section-collection-template .products .one-third").length > 0) { gsNumberOfColumns = 3; GSproductQuery = '#shopify-section-collection-template .products .one-third'; } if ($("#shopify-section-collection-template .products .four").length > 0) { gsNumberOfColumns = 4; GSproductQuery = '#shopify-section-collection-template .products .four'; } $(GSproductQuery).not(".modal_image").each(function(index) { $(this).removeClass("alpha"); $(this).removeClass("omega"); $(this).removeClass("even"); $(this).removeClass("odd"); if (gsCounterOdds == 1) { $(this).addClass("even"); } else { $(this).addClass("odd"); } if (gsCounterThree == 1) { $(this).addClass("alpha"); } if (gsCounterThree == gsNumberOfColumns) { $(this).addClass("omega"); $(this).after('
'); } if (gsCounterOdds == 2) { gsCounterOdds = 0; } if (gsCounterThree == gsNumberOfColumns) { gsCounterThree = 0; } gsCounterOdds++; gsCounterThree++; }); } $(".lazyloading").each(function() { $(this).removeClass("lazyloading"); $(this).addClass("lazyloaded"); }); try { collection.init(); } catch (err) {} } var GSLoader = function() { var url = window.location.href; // Consolidate return conditions if (url.indexOf("/products/") > 0 || url.indexOf("/blogs/") > 0 || (url.indexOf("/collections/") === -1 && url.indexOf("/search") === -1 && url.indexOf("/products/") === -1)) { if (url.indexOf("/products/") > 0) { try { sessionStorage.setItem('gsproductviewed', '1'); } catch (err) {} } return; } // Check for specific hash in URL if (window.location.hash === '#76dc') { return; } try { //if(sessionStorage.getItem('gscollectionurl') != window.location.href) { if ((sessionStorage.getItem('gscollectionurl') != window.location.href) || ($(".medium-up--one-half, .medium-up--one-third").length > 1 && ($('.card').length > 0))) { sessionStorage.setItem('gscollectionurl', window.location.href); sessionStorage.setItem('gscollectioncontent', ''); sessionStorage.setItem('gspaginatecontent', ''); sessionStorage.setItem('gscollectionpagenr', ''); } if (sessionStorage.getItem('gsproductviewed') == null || sessionStorage.getItem('gsproductviewed') == '0') { sessionStorage.setItem('gscollectionurl', window.location.href); sessionStorage.setItem('gscollectioncontent', ''); sessionStorage.setItem('gspaginatecontent', ''); sessionStorage.setItem('gscollectionpagenr', ''); } sessionStorage.setItem('gsproductviewed', '0'); } catch (err) {} paginateSelector = '.pagination'; collectionParent = '.products'; collectionParent = this.findCollectionParent(); if ($('.pagination').length == 0) { paginateSelector = ''; var paginationNodes = $(collectionParent).find('*[class*="agination"]'); if (paginationNodes.length > 0) { paginateSelector = '.' + $.trim(paginationNodes.first().attr("class")).replace(/\s\s+/g, ' ').replace(/ /gi, '.'); } else { if ($('#pagination').length > 0) { paginateSelector = '#pagination'; } else { paginationNodes = $('*[id*="agination"]'); if (paginationNodes.length > 0) { paginateSelector = '#' + paginationNodes.first().attr("id"); } else { paginationNodes = $('*[class*="aginate"]'); if (paginationNodes.length > 0) { paginateSelector = '.' + $.trim(paginationNodes.first().attr("class")).replace(/\s\s+/g, ' ').replace(/ /gi, '.'); } else { paginationNodes = $('*[id*="aginate"]'); if (paginationNodes.length > 0) { paginateSelector = '#' + paginationNodes.first().attr("id"); } } } } } if (paginateSelector == '') { var paginationNodes = $(collectionParent).parent().nextAll().find('*[class*="agination"]'); if (paginationNodes.length > 0) { paginateSelector = '.' + $.trim(paginationNodes.first().attr("class")).replace(/\s\s+/g, ' ').replace(/ /gi, '.'); } else { if ($('#pagination').length > 0) { paginateSelector = '#pagination'; } else { paginationNodes = $('*[id*="agination"]'); if (paginationNodes.length > 0) { paginateSelector = '#' + paginationNodes.first().attr("id"); } else { paginationNodes = $('*[class*="aginate"]'); if (paginationNodes.length > 0) { paginateSelector = '.' + $.trim(paginationNodes.first().attr("class")).replace(/\s\s+/g, ' ').replace(/ /gi, '.'); } else { paginationNodes = $('*[id*="aginate"]'); if (paginationNodes.length > 0) { paginateSelector = '#' + paginationNodes.first().attr("id"); } } } } } } if (paginateSelector == '#modal-pagination-wrapper') { paginateSelector = ''; } if (paginateSelector == '') { var paginationNodes = $('*[class*="agination"]'); if (paginationNodes.length > 0) { paginateSelector = '.' + $.trim(paginationNodes.first().attr("class")).replace(/\s\s+/g, ' ').replace(/ /gi, '.'); } else { if ($('#pagination').length > 0) { paginateSelector = '#pagination'; } else { paginationNodes = $('*[id*="agination"]'); if (paginationNodes.length > 0) { paginateSelector = '#' + paginationNodes.first().attr("id"); } else { paginationNodes = $('*[class*="aginate"]'); if (paginationNodes.length > 0) { paginateSelector = '.' + $.trim(paginationNodes.first().attr("class")).replace(/\s\s+/g, ' ').replace(/ /gi, '.'); } else { paginationNodes = $('*[id*="aginate"]'); if (paginationNodes.length > 0) { paginateSelector = '#' + paginationNodes.first().attr("id"); } } } } } } } if ($(".container-pushy-main").length > 0 && $("#category-sticky-parent").length > 0 && $(".pagination-buttons").length > 0) { paginateSelector = '.pagination-buttons'; } if (paginateSelector == '') { if ($('#paging').length > 0) { paginateSelector = '#paging'; } } if (($(".wide-container .jiggly-split").length > 0)) { paginateSelector = ".pager-button, .pagination"; } if (paginateSelector == '') { if ($('.page_c').length > 0) { paginateSelector = '.page_c'; collectionParent = collectionParent.replace('.animation-done', ''); $("body").append(""); } } if ($(".shopify-pagination").length > 0 && $(".pagination-gl_default").length > 0) { paginateSelector = '.shopify-pagination'; $("body").append(""); } if ($(".pull-right.pagination-btns").length > 0 && $(".product-listing").length > 0 && $(".filters-row__pagination").length > 0) { $('
').insertAfter(".product-listing"); $("#forcegscenter").append($($(".filters-row__pagination").get(0))); } if (specialTheme == 1) { $("body").append(""); } paginateSelector = paginateSelector.replace('..', '.').replace('..', '.').replace('..', '.').replace('..', '.').replace('..', '.'); if ($(paginateSelector).length > 0) { $("body").append(""); } if ($("#gscollectionbottom").length > 0) { $("#gscollectionbottom").remove(); } if ($("#bc-sf-filter-products").length == 0) { if (loaderMode == 1) { $($(paginateSelector).get(0)).after('
'); } else { $($(paginateSelector).get(0)).after('
'); } } else { if (loaderMode == 1) { $($("#bc-sf-filter-products").get(0)).after('
'); } else { $($(paginateSelector).get(0)).after('
'); } } $($(paginateSelector)).hide(); $("body").append(""); setInterval(function() { try { if ($(paginateSelector).css('float').length > 0) { $("#gscollectionbottom").css('float', $(paginateSelector).css('float')); } } catch (err) {} }, 500); $("*:contains('Page 1')").each(function() { if ($(this).children().length == 0) { $(this).hide(); } }); if ($(collectionParent).length > 1) { var tmpCnt = 1; $(collectionParent).each(function() { if (productsParentTmp.get(0).innerHTML.localeCompare($(this).get(0).innerHTML) == 0) { containerPos = tmpCnt; } tmpCnt++; }); } if ($(collectionParent).find(paginateSelector).length > 0) { $(collectionParent).after($("#gscollectionbottom")); } this.listenToScroll = this.listenToScroll.bind(this); this.analyseView = this.analyseView.bind(this); if (productsParentTmp === null) { $("#gscollectionbottom img").remove(); $("#gscollectionbottom button").remove(); return; } this.containerElement = productsParentTmp.get(0); if ($(".grid-link__container").length > 0) { this.containerElement = $(".grid-link__container").get(0); } if ($(".custom-category .toolbar-amount").length > 0 && $(".custom-products").length > 0) { this.containerElement = $(".custom-products .row").get(0); } if (!this.containerElement) { return; } this.paginateSection = document.querySelector(paginateSelector); paginateSel = this.paginateSection; if (sessionStorage.getItem('gscollectioncontent') != null && sessionStorage.getItem('gscollectioncontent') != "") { this.containerElement.insertAdjacentHTML('beforeend', sessionStorage.getItem('gscollectioncontent')); fixThemeSpecial(); this.paginateSection = document.querySelector(paginateSelector); this.paginateSection.innerHTML = sessionStorage.getItem('gspaginatecontent'); collectionPageNr = parseInt(sessionStorage.getItem('gscollectionpagenr')); setTimeout(function() { try { var resizeEvent = window.document.createEvent('UIEvents'); resizeEvent.initUIEvent('resize', true, false, window, 0); window.dispatchEvent(resizeEvent); $(window).trigger('forceproductblockheights'); } catch (err) {} //$(window).trigger('resize'); }, 1000); if ($(".medium-up--one-half, .medium-up--one-third").length > 0) { try { $(".card").css("opacity", '1'); } catch (err) {} } if (collectionPageNr == -1) { $("#gscollectionbottom button").remove(); $("#gscollectionbottom img").remove(); } } this.listenToScroll(); }; GSLoader.prototype.findCollectionParent = function() { var limititerations = 20; var colllectionParentTmp = $("a[href*='page=2']"); if ($("#bc-sf-filter-bottom-pagination").length > 0) { colllectionParentTmp = $("#bc-sf-filter-bottom-pagination"); } var collectionParentFound = false; while (limititerations > 0) { colllectionParentTmp = colllectionParentTmp.parent(); limititerations--; //console.debug($(colllectionParentTmp)); if ($(colllectionParentTmp).find('a[href*="/products/"]').length > 0) { collectionParentFound = true; limititerations = 0; } } if (!collectionParentFound) { return false; } var productInCollection = $(colllectionParentTmp).find('a[href*="/products/"]'); if (productInCollection.length < 2) { return false; } try { if ($('#collection-display #product-loop').length > 0) { productsParentTmp = $('#product-loop'); return '#product-loop'; } } catch (err) {} var productInCollectionFirst = productInCollection[0]; var productInCollectionLast = productInCollection[productInCollection.length - 1]; productsParentTmp = productInCollectionFirst; limititerations = 20; while (limititerations > 0) { productsParentTmp = $(productsParentTmp).parent(); if ($(".custom-category .toolbar-amount").length > 0 && $(".custom-products").length > 0) { $("body").append(""); productsParentTmp = $($('.custom-products').get(0)); return '.custom-products .row'; } limititerations--; //console.debug($(colllectionParentTmp)); if ($(productsParentTmp).find(productInCollectionLast).length > 0) { if (productsParentTmp.attr("id")) { var idName = '#' + productsParentTmp.attr("id"); return idName; } if (productsParentTmp.attr("class")) { //var className = '.' + productsParentTmp.attr("class").split(" ").join("."); //className = className.replace('..', '.').replace('..', '.').replace('..', '.').replace('..', '.').replace('..', '.'); var className = '.' + $.trim(productsParentTmp.attr("class")).replace(/\s\s+/g, ' ').replace(/ /gi, '.') return className; } limititerations = 0; } } return false; } GSLoader.prototype.listenToScroll = function() { if (this.paginateSection) { if (loaderMode == 1) { document.addEventListener('scroll', this.analyseView); window.addEventListener('resize', this.analyseView); window.addEventListener('orientationchange', this.analyseView); } else { $("#gsloadmore").click(this.clickMoreBtn); } } }; function postData(url, data) { url = url || ''; // Default value for url if not provided data = data || {}; // Default value for data if not provided return new Promise(function(resolve, reject) { fetch(url, { method: 'GET', // *GET, POST, PUT, DELETE, etc. mode: 'cors', // no-cors, *cors, same-origin cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached credentials: 'same-origin', // include, *same-origin, omit headers: { 'Content-Type': 'application/x-www-form-urlencoded' // 'Content-Type': 'application/x-www-form-urlencoded', }, redirect: 'follow', // manual, *follow, error referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url }).then(function(response) { return response.text(); // Process the response and get the text }).then(function(text) { resolve(text); // Resolve the Promise with the response text }).catch(function(error) { reject(error); // Reject the Promise if an error occurs }); }); } GSLoader.prototype.fetchNextPage = function() { httpRequest = new XMLHttpRequest(); try { httpRequest.responseType = 'document'; } catch (error) {} httpRequest.onreadystatechange = function loadingfinished() { try { if ($(".debugbygss").length == 0) { $("body").first().append('
'); } $(".gsdebuglisten10").remove(); $("#debugbygss").append("
Response status: " + httpRequest.status + " ready state: " + httpRequest.readyState + "
"); } catch (err) {} if (httpRequest.status == 200 && httpRequest.readyState == 4) { if (httpRequest.responseXML == null) { postData(this.nextStepLink, {}).then(data=>{ var data = $(data); var appendedSection = data.find(collectionParent).get(0); var appendaedPage = data.find(paginateSelector).get(0); var nextPageNr = collectionPageNr + 1; $("#gsloaderimg").hide(); $("#gsloadmore").show(); if (data.find("a[href*='page=" + nextPageNr + "']").length == 0) { $("#gscollectionbottom button").remove(); $("#gscollectionbottom img").remove(); } if ($(".medium-up--one-half").length > 1 && ($(data).find('.card').length > 0)) { var columnCnt = 0; $(data).find('.card').each(function() { $($($(".medium-up--one-half").get(columnCnt))).get(0).insertAdjacentHTML('beforeend', $($(this)).get(0).outerHTML); //$($(".medium-up--one-half").get(columnCnt)).html($(this).innerHTML); columnCnt++; if (columnCnt > ($(".medium-up--one-half").length - 1)) { columnCnt = 0; } }); // var appendedSection2 = httpRequest.responseXML.querySelectorAll('.medium-up--one-half')[0]; // $($(".medium-up--one-half").get(1)).insertAdjacentHTML('beforeend', appendedSection2.innerHTML); } else { $(data).find('img').each(function() { try { $(this).removeAttr("srcset"); } catch (err) {} }); $(".more-views-slider").each(function() { var images = $(this).find(".image-list"); $(images[0]).css('display', 'none'); $(images[0]).removeClass('lightSlider lsGrab lSSlide'); $(this).append(images[0]); $(this).find(".lSSlideOuter").each(function() { $(this).remove(); }); $(images[0]).css('display', 'block'); }); this.containerElement.insertAdjacentHTML('beforeend', appendedSection.innerHTML); //$("body").append($('script[src*="application.min"]').get(0).outerHTML); var thumbLoader = $(this.containerElement).find(".thumb-loader"); if (thumbLoader.length > 0) { $(thumbLoader).each(function() { $(this).css("opacity", '1'); }); } } var productImages = $(this.containerElement).find(".product-item .product-image img"); $(productImages).each(function() { if (!$(this).hasClass('loaded')) { $(this).addClass('loaded'); } }); if (collectionParent.indexOf("medium-up--one-half") > 0) { $(".card").css("opacity", '1'); } if ($(collectionParent).find(paginateSelector).length > 0) { $(this.containerElement).after($("#gscollectionbottom")); } this.paginateSection.innerHTML = appendaedPage.innerHTML; if ($(".cata-product .product-list-item").length > 0) { $(".cata-product .product-grid-item").each(function() { $(this).removeClass("product-grid-item"); $(this).addClass("product-list-item"); }); } if (loaderMode == 1) { this.listenToScroll(); } HsCartDrawer.quickBuyByttonByCollections(HsCartDrawer.json, HsCartDrawer.query); HsCartDrawer.addToCart(HsCartDrawer.json, HsCartDrawer.query); } ); return; } if (specialTheme == 17) { collectionParent = collectionParent.replace(".isotope-products.border-no.loaded", ".isotope-products"); } if (specialTheme == 21) { collectionParent = '.collection-products div'; } var appendedSection = httpRequest.responseXML.querySelectorAll(collectionParent)[0]; if (httpRequest.responseXML.querySelectorAll(collectionParent).length > 1) { appendedSection = httpRequest.responseXML.querySelectorAll(collectionParent)[containerPos - 1]; } try { $(appendedSection).find(".slide-up-animation").removeClass("slide-up-animation"); } catch (err) {} if (specialTheme == 12) { $(appendedSection).find(".box--add-hr").remove(); } // FIX FOR PARALAX THEME var paralaxImgs = $(appendedSection).find(".product_image .product_container img"); if (paralaxImgs.length > 0) { paralaxImgs.each(function() { $(this).css("opacity", "1"); }); } var appHeaderEls = $(appendedSection).find("header"); if (appHeaderEls.length > 0) { appHeaderEls.each(function() { $(this).hide(); }); } var containerForProducts = $(this.containerElement); $(appendedSection).find("script").each(function() { try { if (containerForProducts.attr("class") == $(this).parent().attr("class")) { $(this).remove(); } } catch (err) {} }); if ($(appendedSection).find("img:not(\"[src*='/products/']\")").length > 0 && $(appendedSection).find("img[src*='/products/']").length == 0) { $(appendedSection).find("img").not("img[src*='/products/']").not("img[src*='/files/']").each(function() { var imgReference = $(this).get(0); var suggestedImageUrl = ''; var productImgContHtml = $(this).parent().get(0).innerHTML; var splitImgUrls = productImgContHtml.split('cdn.shopify.com'); var splitCnt = 0; var stringToExaminForImageUrl = ''; $.each(splitImgUrls, function(index) { if (splitCnt > 0) { if (this.indexOf('/products/') > 0) { if (stringToExaminForImageUrl == '') { stringToExaminForImageUrl = this; } } } splitCnt++; }); if (splitImgUrls.length > 1) { var remainingpath = stringToExaminForImageUrl.replace("'", " ").replace('"', " ").replace(',', " ").replace(';', " "); splitImgUrls = remainingpath.split(" "); suggestedImageUrl = splitImgUrls[0]; suggestedImageUrl = '//cdn.shopify.com' + suggestedImageUrl; $(imgReference).attr('src', suggestedImageUrl); } }); } var appendaedPage = httpRequest.responseXML.querySelectorAll(paginateSelector)[0]; var nextPageNr = collectionPageNr + 1; //this.containerElement.insertAdjacentHTML('beforeend', sessionStorage.getItem('gscollectioncontent')); //sessionStorage.setItem('gscollectioncontent', sessionStorage.getItem('gscollectioncontent') + '' + appendedSection.innerHTML); $("#gsloaderimg").hide(); $("#gsloadmore").show(); window.gscollectionpagenr = collectionPageNr; if (!httpRequest.responseXML.querySelector("a[href*='page=" + nextPageNr + "']")) { try { //sessionStorage.setItem('gscollectionpagenr', -1); window.gscollectionpagenr = -1; } catch (err) {} $("#gscollectionbottom button").remove(); $("#gscollectionbottom img").remove(); } else { try { window.gscollectionpagenr = collectionPageNr; //sessionStorage.setItem('gscollectionpagenr', collectionPageNr); } catch (err) {} } if ($(".medium-up--one-half, .medium-up--one-third").length > 1 && ($(httpRequest.responseXML).find('.card').length > 0)) { var columnCnt = 0; $(httpRequest.responseXML).find('.card').each(function() { $($($(".medium-up--one-half, .medium-up--one-third").get(columnCnt))).get(0).insertAdjacentHTML('beforeend', $($(this)).get(0).outerHTML); //$($(".medium-up--one-half, .medium-up--one-third").get(columnCnt)).html($(this).innerHTML); columnCnt++; if (columnCnt > ($(".medium-up--one-half, .medium-up--one-third").length - 1)) { columnCnt = 0; } }); // var appendedSection2 = httpRequest.responseXML.querySelectorAll('.medium-up--one-half')[0]; // $($(".medium-up--one-half").get(1)).insertAdjacentHTML('beforeend', appendedSection2.innerHTML); } else { if ($(appendedSection).find(".hidden-handheld").length > 0) { $(appendedSection).find(".hidden-handheld").remove(); } $(appendedSection).find("img[src*='loader.gif']").each(function() { if ($(this).hasClass("product_image--current")) { $(this).attr("src", $(this).attr('data-src')); } }); $(httpRequest.responseXML).find('img').each(function() { try { $(this).removeAttr("srcset"); } catch (err) {} }); //console.debug(sessionStorage.getItem('gscollectioncontent')); if ($('.collection-grid-uninit .collection-header').length > 0) { if ($(appendedSection).find("header").length > 0) { $(appendedSection).find("header").remove(); } var containerForChildren = $("
"); $(appendedSection).find(".collection-grid-item").each(function() { containerForChildren.append($(this)); }); appendedSection = containerForChildren.get(0); } if (specialTheme == 33) { $(appendedSection).find("figure").each(function() { var backgroundFromTemplate = $(this).attr('data-rimg-template').replace("{size}", '544x800'); $(this).attr("style", 'background-image: url("' + backgroundFromTemplate + '");'); }); } if ($("#bc-sf-filter-products").length > 0) { $("#bc-sf-filter-products").append(appendedSection.innerHTML); } else { this.containerElement.insertAdjacentHTML('beforeend', appendedSection.innerHTML); try { $(this.containerElement).children("style").each(function() { $(this).hide(); }); } catch (error) {} try { theme.ProductBlockManager. loadImages ($("body")) ; } catch (err) {} try { var api = new Yotpo.API(yotpo); api.refreshWidgets(); } catch (err) {} try { DoublyGlobalCurrency.convertAll($('[name=doubly-currencies]').val()); setTimeout(function() { try { DoublyGlobalCurrency.convertAll($('[name=doubly-currencies]').val()); } catch (err) {} }, 1000); } catch (err) {} try { if ($(".fw-variants").length > 0) { $(".product_item").hover(function() { $(this).find(".fw-variant-list").stop().slideDown("slow"); }, function() { $(this).find(".fw-variant-list").stop().slideUp("slow"); }) } } catch (err) {} try { if ((typeof SCAShopify) !== 'undefined') { SCAShopify.jQuery(document).unbind('click.fb-start'); SCAShopify.loaded = false; SCAQVinit = undefined; $.getScript($('script[src*="sca-qv-"]').attr('src')); } } catch (err) {} try { if (typeof ReloadSmartWishlist !== "undefined" && $.isFunction(ReloadSmartWishlist)) ReloadSmartWishlist(); } catch (err) {} if (specialTheme == 15) { $("body").append($('script[src*="assets/theme.js"]').get(0).outerHTML); } if (specialTheme == 11) { $("body").append($('script[src*="assets/atlantic"]').get(0).outerHTML); } try { $("body").append($('script[src*="assets/empire.js"]').get(0).outerHTML); } catch (err) {} if (specialTheme == 17) { window.scrollBy(0, -2); } //this.containerElement.insertAdjacentHTML('beforeend', appendedSection.innerHTML); fixThemeSpecial(); } try { $(productsParentTmp.get(0)).find("script").hide(); } catch (err) {} $($(this.containerElement).find(".thumb-loader").length > 0) { $(this.containerElement).find(".thumb-loader").each(function() { $(this).css("opacity", '1'); }); } } if (collectionParent.indexOf("medium-up--one-half") > 0 || collectionParent.indexOf("medium-up--one-third") > 0) { $(".card").css("opacity", '1'); } if ($(collectionParent).find(paginateSelector).length > 0) { $(this.containerElement).after($("#gscollectionbottom")); } //this.paginateSection.innerHTML = appendaedPage.innerHTML; $(this.paginateSection).innerHTML = ''; //$(this.paginateSection).append($(appendaedPage.innerHTML)); $(this.paginateSection).append($(appendaedPage)); if ($(".custom-category .toolbar-amount").length > 0 && $(".custom-products").length > 0) { $('.modes').find(".active").trigger("click"); } if ($(".cata-product .product-list-item").length > 0) { $(".cata-product .product-grid-item").each(function() { $(this).removeClass("product-grid-item"); $(this).addClass("product-list-item"); }); } if (loaderMode == 1) { this.listenToScroll(); } setTimeout(function() { try { SPR.initRatingHandler(); SPR.initDomEls(); SPR.loadBadges(); } catch (error) {} }, 1000); setTimeout(function() { try { var resizeEvent = window.document.createEvent('UIEvents'); resizeEvent.initUIEvent('resize', true, false, window, 0); window.dispatchEvent(resizeEvent); $(window).trigger('forceproductblockheights'); } catch (err) {} //$(window).trigger('resize'); }, 1000); sessionStorage.setItem('gscollectionpagenr', window.gscollectionpagenr); try { if (sessionStorage.getItem('gscollectioncontent') != null && sessionStorage.getItem('gscollectioncontent') != "") { sessionStorage.setItem('gscollectioncontent', sessionStorage.getItem('gscollectioncontent') + '' + appendedSection.innerHTML); } else { sessionStorage.setItem('gscollectionurl', window.location.href); sessionStorage.setItem('gscollectioncontent', appendedSection.innerHTML); } } catch (err) { try { sessionStorage.setItem('gscollectioncontent', ''); } catch (err) {} } try { sessionStorage.setItem('gspaginatecontent', appendaedPage.innerHTML); } catch (err) {} } } .bind(this); try { httpRequest.gsOpen('GET', this.nextStepLink); httpRequest.responseType = 'document'; httpRequest.gsSend(); } catch (err) { httpRequest.open('GET', this.nextStepLink); httpRequest.responseType = 'document'; httpRequest.send(); } } ; GSLoader.prototype.analyseView = function() { if (document.getElementById("gscollectionbottom").getBoundingClientRect().top <= window.innerHeight && document.getElementById("gscollectionbottom").getBoundingClientRect().bottom >= 0) { window.collectionPageNr = collectionPageNr + 1; this.nextSetUrl = this.paginateSection.querySelector("a[href*='page=" + collectionPageNr + "']"); var pageUrl = window.location.href; if (pageUrl.indexOf('?')) { var exploded = pageUrl.split("?"); pageUrl = exploded[0]; } if (pageUrl.indexOf('#')) { var exploded = pageUrl.split("#"); pageUrl = exploded[0]; } document.removeEventListener('scroll', this.analyseView); window.removeEventListener('resize', this.analyseView); window.removeEventListener('orientationchange', this.analyseView); if (this.nextSetUrl || ($("#bc-sf-filter-products").length > 0)) { var paramGSStr = ''; if (getUrlParamsGS("sort_by") != null) { paramGSStr = paramGSStr + "&sort_by=" + getUrlParamsGS("sort_by"); } if (getUrlParamsGS("view") != null) { paramGSStr = paramGSStr + "&view=" + getUrlParamsGS("view"); } if (getUrlParamsGS("q") != null) { paramGSStr = paramGSStr + "&q=" + getUrlParamsGS("q"); } if (getUrlParamsGS("constraint") != null) { paramGSStr = paramGSStr + "&constraint=" + getUrlParamsGS("constraint"); } if (window.location.href.indexOf("?") != -1) { gsscroller.nextStepLink = window.location.href + '&page=' + collectionPageNr; } else { gsscroller.nextStepLink = pageUrl + '?page=' + collectionPageNr + paramGSStr; gsscroller.nextStepLink = window.location.href + '?page=' + collectionPageNr; } this.fetchNextPage(); } else { $("#gscollectionbottom img").remove(); } } } ; GSLoader.prototype.clickMoreBtn = function() { window.collectionPageNr = collectionPageNr + 1; gsscroller.nextSetUrl = paginateSel.querySelector("a[href*='page=" + collectionPageNr + "']"); var pageUrl = window.location.href; if (pageUrl.indexOf('?')) { var exploded = pageUrl.split("?"); pageUrl = exploded[0]; } if (pageUrl.indexOf('#')) { var exploded = pageUrl.split("#"); pageUrl = exploded[0]; } $("#gsloaderimg").show(); $("#gsloadmore").hide(); if (gsscroller.nextSetUrl) { var paramGSStr = ''; if (getUrlParamsGS("sort_by") != null) { paramGSStr = paramGSStr + "&sort_by=" + getUrlParamsGS("sort_by"); } if (getUrlParamsGS("view") != null) { paramGSStr = paramGSStr + "&view=" + getUrlParamsGS("view"); } if (getUrlParamsGS("q") != null) { paramGSStr = paramGSStr + "&q=" + getUrlParamsGS("q"); } if (getUrlParamsGS("constraint") != null) { paramGSStr = paramGSStr + "&constraint=" + getUrlParamsGS("constraint"); } if(window.location.href.indexOf("?") != -1) { gsscroller.nextStepLink = window.location.href + '&page=' + collectionPageNr; } else { gsscroller.nextStepLink = window.location.href + '?page=' + collectionPageNr; } gsscroller.fetchNextPage(); } else { $("#gscollectionbottom button").remove(); $("#gscollectionbottom img").remove(); } }; } })();