1 2; /* Start:"a:4:{s:4:"full";s:118:"/local/templates/main/components/bitrix/catalog/catalog_tools/bitrix/catalog.section/.default/script.js?16027624748297";s:6:"source";s:103:"/local/templates/main/components/bitrix/catalog/catalog_tools/bitrix/catalog.section/.default/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 17 if (params.navParams) 18 { 19 this.navParams = { 20 NavNum: params.navParams.NavNum || 1, 21 NavPageNomer: parseInt(params.navParams.NavPageNomer) || 1, 22 NavPageCount: parseInt(params.navParams.NavPageCount) || 1 23 }; 24 } 25 26 this.bigData = params.bigData || {enabled: false}; 27 this.container = document.querySelector('[data-entity="' + params.container + '"]'); 28 this.showMoreButton = null; 29 this.showMoreButtonMessage = null; 30 31 if (this.bigData.enabled && BX.util.object_keys(this.bigData.rows).length > 0) 32 { 33 BX.cookie_prefix = this.bigData.js.cookiePrefix || ''; 34 BX.cookie_domain = this.bigData.js.cookieDomain || ''; 35 BX.current_server_time = this.bigData.js.serverTime; 36 37 BX.ready(BX.delegate(this.bigDataLoad, this)); 38 } 39 40 if (params.initiallyShowHeader) 41 { 42 BX.ready(BX.delegate(this.showHeader, this)); 43 } 44 45 if (params.deferredLoad) 46 { 47 BX.ready(BX.delegate(this.deferredLoad, this)); 48 } 49 50 if (params.lazyLoad) 51 { 52 this.showMoreButton = document.querySelector('[data-use="show-more-' + this.navParams.NavNum + '"]'); 53 this.showMoreButtonMessage = this.showMoreButton.innerHTML; 54 BX.bind(this.showMoreButton, 'click', BX.proxy(this.showMore, this)); 55 } 56 57 if (params.loadOnScroll) 58 { 59 BX.bind(window, 'scroll', BX.proxy(this.loadOnScroll, this)); 60 } 61 }; 62 63 window.JCCatalogSectionComponent.prototype = 64 { 65 checkButton: function() 66 { 67 if (this.showMoreButton) 68 { 69 if (this.navParams.NavPageNomer == this.navParams.NavPageCount) 70 { 71 BX.remove(this.showMoreButton); 72 } 73 else 74 { 75 this.container.appendChild(this.showMoreButton); 76 } 77 } 78 }, 79 80 enableButton: function() 81 { 82 if (this.showMoreButton) 83 { 84 BX.removeClass(this.showMoreButton, 'disabled'); 85 this.showMoreButton.innerHTML = this.showMoreButtonMessage; 86 } 87 }, 88 89 disableButton: function() 90 { 91 if (this.showMoreButton) 92 { 93 BX.addClass(this.showMoreButton, 'disabled'); 94 this.showMoreButton.innerHTML = BX.message('BTN_MESSAGE_LAZY_LOAD_WAITER'); 95 } 96 }, 97 98 loadOnScroll: function() 99 { 100 var scrollTop = BX.GetWindowScrollPos().scrollTop, 101 containerBottom = BX.pos(this.container).bottom; 102 103 if (scrollTop + window.innerHeight > containerBottom) 104 { 105 this.showMore(); 106 } 107 }, 108 109 showMore: function() 110 { 111 if (this.navParams.NavPageNomer < this.navParams.NavPageCount) 112 { 113 var data = {}; 114 data['action'] = 'showMore'; 115 data['PAGEN_' + this.navParams.NavNum] = this.navParams.NavPageNomer + 1; 116 117 if (!this.formPosting) 118 { 119 this.formPosting = true; 120 this.disableButton(); 121 this.sendRequest(data); 122 } 123 } 124 }, 125 126 bigDataLoad: function() 127 { 128 var url = 'https://analytics.bitrix.info/crecoms/v1_0/recoms.php', 129 data = BX.ajax.prepareData(this.bigData.params); 130 131 if (data) 132 { 133 url += (url.indexOf('?') !== -1 ? '&' : '?') + data; 134 } 135 136 var onReady = BX.delegate(function(result){ 137 this.sendRequest({ 138 action: 'deferredLoad', 139 bigData: 'Y', 140 items: result && result.items || [], 141 rid: result && result.id, 142 count: this.bigData.count, 143 rowsRange: this.bigData.rowsRange, 144 shownIds: this.bigData.shownIds 145 }); 146 }, this); 147 148 BX.ajax({ 149 method: 'GET', 150 dataType: 'json', 151 url: url, 152 timeout: 3, 153 onsuccess: onReady, 154 onfailure: onReady 155 }); 156 }, 157 158 deferredLoad: function() 159 { 160 this.sendRequest({action: 'deferredLoad'}); 161 }, 162 163 sendRequest: function(data) 164 { 165 var defaultData = { 166 siteId: this.siteId, 167 template: this.template, 168 parameters: this.parameters 169 }; 170 171 if (this.ajaxId) 172 { 173 defaultData.AJAX_ID = this.ajaxId; 174 } 175 176 BX.ajax({ 177 url: this.componentPath + '/ajax.php' + (document.location.href.indexOf('clear_cache=Y') !== -1 ? '?clear_cache=Y' : ''), 178 method: 'POST', 179 dataType: 'json', 180 timeout: 60, 181 data: BX.merge(defaultData, data), 182 onsuccess: BX.delegate(function(result){ 183 if (!result || !result.JS) 184 return; 185 186 BX.ajax.processScripts( 187 BX.processHTML(result.JS).SCRIPT, 188 false, 189 BX.delegate(function(){this.showAction(result, data);}, this) 190 ); 191 }, this) 192 }); 193 }, 194 195 showAction: function(result, data) 196 { 197 if (!data) 198 return; 199 200 switch (data.action) 201 { 202 case 'showMore': 203 this.processShowMoreAction(result); 204 break; 205 case 'deferredLoad': 206 this.processDeferredLoadAction(result, data.bigData === 'Y'); 207 break; 208 } 209 }, 210 211 processShowMoreAction: function(result) 212 { 213 this.formPosting = false; 214 this.enableButton(); 215 216 if (result) 217 { 218 this.navParams.NavPageNomer++; 219 this.processItems(result.items); 220 this.processPagination(result.pagination); 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, origRows; 244 245 temporaryNode.innerHTML = processed.HTML; 246 items = temporaryNode.querySelectorAll('[data-entity="items-row"]'); 247 248 if (items.length) 249 { 250 this.showHeader(true); 251 252 for (k in items) 253 { 254 if (items.hasOwnProperty(k)) 255 { 256 origRows = position ? this.container.querySelectorAll('[data-entity="items-row"]') : false; 257 items[k].style.opacity = 0; 258 259 if (origRows && BX.type.isDomNode(origRows[position[k]])) 260 { 261 origRows[position[k]].parentNode.insertBefore(items[k], origRows[position[k]]); 262 } 263 else 264 { 265 this.container.appendChild(items[k]); 266 } 267 } 268 } 269 270 new BX.easing({ 271 duration: 2000, 272 start: {opacity: 0}, 273 finish: {opacity: 100}, 274 transition: BX.easing.makeEaseOut(BX.easing.transitions.quad), 275 step: function(state){ 276 for (var k in items) 277 { 278 if (items.hasOwnProperty(k)) 279 { 280 items[k].style.opacity = state.opacity / 100; 281 } 282 } 283 }, 284 complete: function(){ 285 for (var k in items) 286 { 287 if (items.hasOwnProperty(k)) 288 { 289 items[k].removeAttribute('style'); 290 } 291 } 292 } 293 }).animate(); 294 } 295 296 BX.ajax.processScripts(processed.SCRIPT); 297 }, 298 299 processPagination: function(paginationHtml) 300 { 301 if (!paginationHtml) 302 return; 303 304 var pagination = document.querySelectorAll('[data-pagination-num="' + this.navParams.NavNum + '"]'); 305 for (var k in pagination) 306 { 307 if (pagination.hasOwnProperty(k)) 308 { 309 pagination[k].innerHTML = paginationHtml; 310 } 311 } 312 }, 313 314 showHeader: function(animate) 315 { 316 var parentNode = BX.findParent(this.container, {attr: {'data-entity': 'parent-container'}}), 317 header; 318 319 if (parentNode && BX.type.isDomNode(parentNode)) 320 { 321 header = parentNode.querySelector('[data-entity="header"'); 322 323 if (header && header.getAttribute('data-showed') != 'true') 324 { 325 header.style.display = ''; 326 327 if (animate) 328 { 329 new BX.easing({ 330 duration: 2000, 331 start: {opacity: 0}, 332 finish: {opacity: 100}, 333 transition: BX.easing.makeEaseOut(BX.easing.transitions.quad), 334 step: function(state){ 335 header.style.opacity = state.opacity / 100; 336 }, 337 complete: function(){ 338 header.removeAttribute('style'); 339 header.setAttribute('data-showed', 'true'); 340 } 341 }).animate(); 342 } 343 else 344 { 345 header.style.opacity = 100; 346 } 347 } 348 } 349 } 350 }; 351})(); 352/* End */ 353;; /* /local/templates/main/components/bitrix/catalog/catalog_tools/bitrix/catalog.section/.default/script.js?16027624748297*/
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.