1 2; /* Start:"a:4:{s:4:"full";s:89:"/local/templates/alpha_s1/components/bitrix/catalog.section/main/script.js?17826845887498";s:6:"source";s:74:"/local/templates/alpha_s1/components/bitrix/catalog.section/main/script.js";s:3:"min";s:0:"";s:3:"map";s:0:"";}"*/ 3(function() { 4 'use strict'; 5 6 if (!!window.JCCatalogSectionComponent) 7 return; 8 9 window.JCCatalogSectionComponent = function(params) { 10 this.formPosting = false; 11 this.siteId = params.siteId || ''; 12 this.ajaxId = params.ajaxId || ''; 13 this.template = params.template || ''; 14 this.componentPath = params.componentPath || ''; 15 this.parameters = params.parameters || ''; 16 this.slider = null; 17 18 if (params.navParams) 19 { 20 this.navParams = { 21 NavNum: params.navParams.NavNum || 1, 22 NavPageNomer: parseInt(params.navParams.NavPageNomer) || 1, 23 NavPageCount: parseInt(params.navParams.NavPageCount) || 1 24 }; 25 } 26 27 this.bigData = params.bigData || {enabled: false}; 28 this.container = document.querySelector('[data-entity="' + params.container + '"]'); 29 this.lazyLoadContainer = document.querySelector('[data-entity="lazy-' + params.container + '"]'); 30 this.showMoreButton = null; 31 this.showMoreButtonMessage = null; 32 33 34 if (this.bigData.enabled && BX.util.object_keys(this.bigData.rows).length > 0) 35 { 36 BX.cookie_prefix = this.bigData.js.cookiePrefix || ''; 37 BX.cookie_domain = this.bigData.js.cookieDomain || ''; 38 BX.current_server_time = this.bigData.js.serverTime; 39 40 BX.ready(BX.delegate(this.bigDataLoad, this)); 41 } 42 43 44 if (params.deferredLoad) 45 { 46 BX.ready(BX.delegate(this.deferredLoad, this)); 47 } 48 49 if (params.lazyLoad) 50 { 51 this.showMoreButton = document.querySelector('[data-use="show-more-' + this.navParams.NavNum + '"]'); 52 this.showMoreButtonMessage = this.showMoreButton.innerHTML; 53 BX.bind(this.showMoreButton, 'click', BX.proxy(this.showMore, this)); 54 } 55 56 if (params.loadOnScroll) 57 { 58 BX.bind(window, 'scroll', BX.proxy(this.loadOnScroll, this)); 59 } 60 }; 61 62 window.JCCatalogSectionComponent.prototype = 63 { 64 checkButton: function() 65 { 66 if (this.showMoreButton) 67 { 68 if (this.navParams.NavPageNomer == this.navParams.NavPageCount) 69 { 70 BX.remove(this.showMoreButton); 71 } 72 else 73 { 74 this.lazyLoadContainer.appendChild(this.showMoreButton); 75 } 76 } 77 }, 78 79 enableButton: function() 80 { 81 if (this.showMoreButton) 82 { 83 BX.removeClass(this.showMoreButton, 'disabled'); 84 this.showMoreButton.innerHTML = this.showMoreButtonMessage; 85 } 86 }, 87 88 disableButton: function() 89 { 90 if (this.showMoreButton) 91 { 92 BX.addClass(this.showMoreButton, 'disabled'); 93 this.showMoreButton.innerHTML = BX.message('BTN_MESSAGE_LAZY_LOAD_WAITER'); 94 } 95 }, 96 97 loadOnScroll: function() 98 { 99 var scrollTop = BX.GetWindowScrollPos().scrollTop, 100 containerBottom = BX.pos(this.container).bottom; 101 102 if (scrollTop + window.innerHeight > containerBottom) 103 { 104 this.showMore(); 105 } 106 }, 107 108 showMore: function() 109 { 110 if (this.navParams.NavPageNomer < this.navParams.NavPageCount) 111 { 112 var data = {}; 113 data['action'] = 'showMore'; 114 data['PAGEN_' + this.navParams.NavNum] = this.navParams.NavPageNomer + 1; 115 116 if (!this.formPosting) 117 { 118 this.formPosting = true; 119 this.disableButton(); 120 this.sendRequest(data); 121 } 122 } 123 }, 124 125 bigDataLoad: function() 126 { 127 var url = 'https://analytics.bitrix.info/crecoms/v1_0/recoms.php', 128 data = BX.ajax.prepareData(this.bigData.params); 129 130 if (data) 131 { 132 url += (url.indexOf('?') !== -1 ? '&' : '?') + data; 133 } 134 135 var onReady = BX.delegate(function(result){ 136 this.sendRequest({ 137 action: 'deferredLoad', 138 bigData: 'Y', 139 items: result && result.items || [], 140 rid: result && result.id, 141 count: this.bigData.count, 142 rowsRange: this.bigData.rowsRange, 143 shownIds: this.bigData.shownIds 144 }); 145 }, this); 146 147 BX.ajax({ 148 method: 'GET', 149 dataType: 'json', 150 url: url, 151 timeout: 3, 152 onsuccess: onReady, 153 onfailure: onReady 154 }); 155 }, 156 157 deferredLoad: function() 158 { 159 this.sendRequest({action: 'deferredLoad'}); 160 }, 161 162 sendRequest: function(data) 163 { 164 var defaultData = { 165 siteId: this.siteId, 166 template: this.template, 167 parameters: this.parameters 168 }; 169 170 if (this.ajaxId) 171 { 172 defaultData.AJAX_ID = this.ajaxId; 173 } 174 175 BX.ajax({ 176 url: this.componentPath + '/ajax.php' + (document.location.href.indexOf('clear_cache=Y') !== -1 ? '?clear_cache=Y' : ''), 177 method: 'POST', 178 dataType: 'json', 179 timeout: 60, 180 data: BX.merge(defaultData, data), 181 onsuccess: BX.delegate(function(result){ 182 if (!result || !result.JS) 183 return; 184 185 BX.ajax.processScripts( 186 BX.processHTML(result.JS).SCRIPT, 187 false, 188 BX.delegate(function(){this.showAction(result, data);}, this) 189 ); 190 }, this) 191 }); 192 }, 193 194 showAction: function(result, data) 195 { 196 if (!data) 197 return; 198 199 switch (data.action) 200 { 201 case 'showMore': 202 this.processShowMoreAction(result); 203 break; 204 case 'deferredLoad': 205 this.processDeferredLoadAction(result, data.bigData === 'Y'); 206 break; 207 } 208 }, 209 210 processShowMoreAction: function(result) 211 { 212 this.formPosting = false;
213 this.enableButton(); 214 215 if (result) 216 { 217 this.navParams.NavPageNomer++; 218 this.processItems(result.items); 219 this.processPagination(result.pagination); 220 this.processEpilogue(result.epilogue); 221 this.checkButton(); 222 } 223 }, 224 225 processDeferredLoadAction: function(result, bigData) 226 { 227 if (!result) 228 return; 229 230 var position = bigData ? this.bigData.rows : {}; 231 232 this.processItems(result.items, BX.util.array_keys(position)); 233 }, 234 235 processItems: function(itemsHtml, position) 236 { 237 if (!itemsHtml) 238 return; 239 240 var processed = BX.processHTML(itemsHtml, false), 241 temporaryNode = BX.create('DIV'); 242 243 var items, k; 244 245 temporaryNode.innerHTML = processed.HTML; 246 items = temporaryNode.querySelectorAll('[data-entity="item"]'); 247 248 if (items.length) 249 { 250 var lastItem = this.container.querySelector('[data-entity="item"]:not(.fullwidth):last-child'); 251 252 for (k in items) 253 { 254 if (items.hasOwnProperty(k)) 255 { 256 this.container.appendChild(items[k]); 257 } 258 } 259 260 if (!!lastItem) 261 { 262 var scrollTop = BX.GetWindowScrollPos().scrollTop, 263 lastItemTop = BX.pos(lastItem).top - 75; 264 265 new BX.easing({ 266 duration: 1000, 267 start: {scroll: scrollTop}, 268 finish: {scroll: lastItemTop}, 269 transition: BX.easing.makeEaseOut(BX.easing.transitions.quint), 270 step: BX.delegate(function(state){ 271 window.scrollTo(0, state.scroll); 272 }, this) 273 }).animate(); 274 } 275 276 } 277 278 BX.ajax.processScripts(processed.SCRIPT); 279 BX.onCustomEvent('onAjaxSuccess'); 280 281 }, 282 283 processPagination: function(paginationHtml) 284 { 285 if (!paginationHtml) 286 return; 287 288 var pagination = document.querySelectorAll('[data-pagination-num="' + this.navParams.NavNum + '"]'); 289 for (var k in pagination) 290 { 291 if (pagination.hasOwnProperty(k)) 292 { 293 pagination[k].innerHTML = paginationHtml; 294 } 295 } 296 }, 297 298 processEpilogue: function(epilogueHtml) 299 { 300 if (!epilogueHtml) 301 return; 302 303 var processed = BX.processHTML(epilogueHtml, false); 304 BX.ajax.processScripts(processed.SCRIPT); 305 }, 306 307 308 }; 309})(); 310/* End */ 311;; /* /local/templates/alpha_s1/components/bitrix/catalog.section/main/script.
311js?17826845887498*/
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.