1function initInfiniteScroll(newurl = false, reset_pagination = false, page_type = 'products') { 2 3 var InfiniteScrollSetings = []; 4 var pathBlock = ''; 5 var items = ''; 6 switch(page_type) { 7 case 'products': 8 pathBlock = $('ul.pagination li:last a'); 9 InfiniteScrollSetings['list'] = '#product_list'; 10 InfiniteScrollSetings['navSelector'] = '#pagination'; 11 InfiniteScrollSetings['nextSelector'] = 'ul.pagination li:last a'; 12 InfiniteScrollSetings['itemSelector'] = '.product_list .ajax_block_product'; 13 InfiniteScrollSetings['append'] = '#product_list .ajax_block_product'; 14 InfiniteScrollSetings['loadOnScroll'] = false; 15 InfiniteScrollSetings['orderBy'] = ''; 16 InfiniteScrollSetings['ordreWay'] = ''; 17 items = 'div.ajax_block_product'; 18 break; 19 case 'recipes': 20 pathBlock = $('.view-next-button'); 21 InfiniteScrollSetings['list'] = '#recipes-list'; 22 InfiniteScrollSetings['navSelector'] = ''; 23 InfiniteScrollSetings['nextSelector'] = ''; 24 InfiniteScrollSetings['itemSelector'] = '#recipes-list .recipe-item'; 25 InfiniteScrollSetings['append'] = '#recipes-list .recipe-item'; 26 InfiniteScrollSetings['loadOnScroll'] = false; 27 InfiniteScrollSetings['orderBy'] = ''; 28 InfiniteScrollSetings['ordreWay'] = ''; 29 items = '.recipe-item'; 30 break; 31 default: 32 return; 33 } 34 35 $('.view-more-button-container').show(); 36 37 var t1 = $('#pagination_next').length; 38 var t2 = $('#pagination_next').hasClass('disabled'); 39 var t3 = "undefined" == typeof (InfiniteScroll); 40 41 if (page_type == 'products') { 42 if (!($('#pagination_next').length) || $('#pagination_next').hasClass('disabled') || "undefined" == typeof (InfiniteScroll)) { 43 if ($('.view-next-button').length) { 44 viewMoreDetached = $('.view-next-button').hide(); 45 } 46 if ($('.view-all-button').length) { 47 viewAllDetached = $('.view-all-button').hide(); 48 } 49 return; 50 } 51 } else if (page_type == 'recipes'){ 52 var viewMoreDetached = null; 53 var viewAllDetached = null; 54 } 55 productListContainer = new InfiniteScroll(InfiniteScrollSetings['list'], { 56 navSelector: InfiniteScrollSetings['navSelector'], 57 nextSelector: InfiniteScrollSetings['nextSelector'], 58 itemSelector: InfiniteScrollSetings['itemSelector'], 59 append: InfiniteScrollSetings['append'], 60 loadOnScroll: InfiniteScrollSetings['loadOnScroll'], 61 orderBy: InfiniteScrollSetings['orderBy'], 62 ordreWay: InfiniteScrollSetings['ordreWay'], 63 path: function () { 64 65 this.reset_pagination = reset_pagination; 66 var path = ''; 67 this.multiplier = 4; 68 69 if (this.load_fast && this.appended) { 70 this.pageIndex += this.multiplier; 71 } 72 if (this.appended) { 73 this.appended = false; 74 } 75 76 if (this.reset_pagination) { 77 page_number = 1; 78 } 79 80 var new_page = page_number + this.pageIndex; 81 82 if ($(items).length < nb_products) { 83 var pag = "p=" + new_page; 84 85 if (newurl) { 86 let urlObj = new URL(newurl); 87 let paramsDivider = Array.from(urlObj.searchParams).length > 0 ? '&' : '?'; 88 89 pathBlock.attr('href', newurl + paramsDivider + pag); 90 } 91 var hrefAttr = pathBlock.attr('data-href') || pathBlock.attr('href'); 92 path = hrefAttr.replace(/p=\d*/, pag); 93 94 var fastScrollNext = parseInt(new_page)+this.multiplier; 95 if (fastScrollNext > Math.ceil(nb_products/products_on_page)) { 96 fastScrollNext = Math.ceil(nb_products/products_on_page); 97 } 98 $('.view-next-button').each(function () { 99 var attrName = ($(this).attr('data-href') !== undefined) ? 'data-href' : 'href'; 100 $(this).attr(attrName, $(this).attr(attrName).replace(/p=\d*/, 'p=' + new_page)); 101 }); 102 103 $('.view-all-button').each(function () { 104 var attrName = ($(this).attr('data-href') !== undefined) ? 'data-href' : 'href'; 105 $(this).attr(attrName, $(this).attr(attrName).replace(/p=\d*/, 'p=' + fastScrollNext)); 106 }); 107 108 if (!this.load_fast) { 109 path += '&infScroll=1'; 110 } 111 if (this.load_fast) { 112 path += '&infScrollFast=1'; 113 } 114 let $selectedLi = $('.selectPrductSort #jsDropdownList li.selected'); 115 if ($selectedLi.length) { 116 let value = $selectedLi.data('value'); 117 if (value) { 118 let parts = value.split(':'); 119 path += '&orderby=' + parts[0] + '&orderway=' + parts[1]; 120 } 121 } 122 if (this.orderBy && this.orderWay) { 123 if (!path.indexOf("orderby=")) { 124 path += '&orderby=' + this.orderBy; 125 } 126 if (!path.indexOf("orderway=")) { 127 path += '&orderway=' + this.orderWay; 128 } 129 } 130 } 131 132 $('.gsrDisplayRating').each(function () { 133 var params = { 134 readOnly: true, 135 ratingField: "iRating", 136 starGif: "/modules/gsnippetsreviews/img/hook/star.gif", 137 starWidth: $(this).data('star-width') 138 }; 139 if ('undefined' != typeof ($(this).data('half')) && 1 == $(this).data('half')) { 140 params['half'] = true; 141 params['split'] = 2; 142 } 143 144 $(this).find('.star:visible').rating(params); 145 }); 146 147 initNiceCombinationsSelect(); 148 equalHeightsProductCardBottom(); 149 150 var viewed = Math.min((new_page - 1) * products_on_page, nb_products); 151 $('.page-progress .load').text(viewed); 152 $('.page-progress .bar .done').width(Math.ceil(viewed * 100 / nb_products) + '%'); 153 154 if (!reset_pagination) { 155 if (viewed == nb_products && $('.view-next-button').length) { 156 viewMoreDetached = $('.view-next-button').hide(); 157 } 158 if (viewed + products_on_page >= nb_products && $('.view-all-button').length) { 159 viewAllDetached = $('.view-all-button').hide(); 160 } 161 } 162 163 $('.view-all-button').text($('.view-all-button').text().replace(/\d+/g, Math.min(nb_products - viewed, products_on_page*5))); 164 165 if (reset_pagination) { 166 reset_pagination = false;
167 } 168 169 return path; 170 } 171 }); 172 173 $('.view-more-button').add(viewMoreDetached).add(viewAllDetached).on('click', function (e) { 174 e.preventDefault(); 175 if ($('#jsDropdownList li[class=selected]').data('value')) { 176 let sortType = $('#jsDropdownList li[class=selected]').data('value').split(':'); 177 productListContainer.orderBy = sortType[0]; 178 productListContainer.orderWay = sortType[1]; 179 } 180 productListContainer.load_fast = (typeof $(this).data('load_fast') !== 'undefined'); 181 productListContainer.loadNextPage(); 182 $(this).addClass('loading'); 183 }); 184 productListContainer.on('append', function () { 185 $('.lazy').Lazy({ 186 chainable: false, 187 afterLoad : function (e) { 188 e.prev('.product-overlay').show(); 189 $(e).removeClass('lazy-loading'); 190 $(e).addClass('lazy-loaded'); 191 let productCardWrap = $('.productCardWrap'); 192 if (productCardWrap) { 193 productCardWrap.equalHeights(); 194 } 195 } 196 }); 197 $('.view-more-button').removeClass('loading'); 198 ajaxCart.overrideButtonsInThePage(); 199 200 this.reset_pagination = false; 201 this.appended = true; 202 }); 203 productListContainer.on('history', function (title, path) { 204 if (this.load_fast) { 205 if (this.pageIndex > Math.ceil(nb_products/products_on_page)) { 206 var fastScrollCurrent = Math.ceil(nb_products/products_on_page); 207 } else { 208 fastScrollCurrent = this.pageIndex; 209 } 210 path = path.replace(/p=\d*/, "p="+fastScrollCurrent); 211 } 212 history.pushState({}, null, path.replace(/&infScroll=\d*/, "").replace(/&infScrollFast=\d*/, "")); 213 }); 214}
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.