1(function() { 2 'use strict'; 3 4 if (!!window.JCCatalogTopComponent) 5 return; 6 7 window.JCCatalogTopComponent = function(params) 8 { 9 this.formPosting = false; 10 this.siteId = params.siteId || ''; 11 this.ajaxId = params.ajaxId || ''; 12 this.template = params.template || ''; 13 this.componentPath = params.componentPath || ''; 14 this.parameters = params.parameters || ''; 15 16 this.bigData = params.bigData || {enabled: false}; 17 this.container = document.querySelector('[data-entity="' + params.container + '"]'); 18 19 if (this.bigData.enabled && BX.util.object_keys(this.bigData.rows).length > 0) 20 { 21 BX.cookie_prefix = this.bigData.js.cookiePrefix || ''; 22 BX.cookie_domain = this.bigData.js.cookieDomain || ''; 23 BX.current_server_time = this.bigData.js.serverTime; 24 25 BX.ready(BX.delegate(this.bigDataLoad, this)); 26 } 27 28 if (params.initiallyShowHeader) 29 { 30 BX.ready(BX.delegate(this.showHeader, this)); 31 } 32 33 if (params.deferredLoad) 34 { 35 BX.ready(BX.delegate(this.deferredLoad, this)); 36 } 37 }; 38 39 window.JCCatalogTopComponent.prototype = 40 { 41 bigDataLoad: function() 42 { 43 var url = 'https://analytics.bitrix.info/crecoms/v1_0/recoms.php', 44 data = BX.ajax.prepareData(this.bigData.params); 45 46 if (data) 47 { 48 url += (url.indexOf('?') !== -1 ? '&' : '?') + data; 49 } 50 51 var onReady = BX.delegate(function(result){ 52 this.sendRequest({ 53 action: 'deferredLoad', 54 bigData: 'Y', 55 items: result && result.items || [], 56 rid: result && result.id, 57 count: this.bigData.count, 58 rowsRange: this.bigData.rowsRange, 59 shownIds: this.bigData.shownIds 60 }); 61 }, this); 62 63 BX.ajax({ 64 method: 'GET', 65 dataType: 'json', 66 url: url, 67 timeout: 3, 68 onsuccess: onReady, 69 onfailure: onReady 70 }); 71 }, 72 73 deferredLoad: function() 74 { 75 this.sendRequest({action: 'deferredLoad'}); 76 }, 77 78 sendRequest: function(data) 79 { 80 var defaultData = { 81 siteId: this.siteId, 82 template: this.template, 83 parameters: this.parameters 84 }; 85 86 if (this.ajaxId) 87 { 88 defaultData.AJAX_ID = this.ajaxId; 89 } 90 91 BX.ajax({ 92 url: this.componentPath + '/ajax.php' + (document.location.href.indexOf('clear_cache=Y') !== -1 ? '?clear_cache=Y' : ''), 93 method: 'POST', 94 dataType: 'json', 95 timeout: 60, 96 data: BX.merge(defaultData, data), 97 onsuccess: BX.delegate(function(result){ 98 if (!result || !result.JS) 99 return; 100 101 BX.ajax.processScripts( 102 BX.processHTML(result.JS).SCRIPT, 103 false, 104 BX.delegate(function(){this.showAction(result, data);}, this) 105 ); 106 }, this) 107 }); 108 }, 109 110 showAction: function(result, data) 111 { 112 if (!data) 113 return; 114 115 switch (data.action) 116 { 117 case 'deferredLoad': 118 this.processDeferredLoadAction(result, data.bigData === 'Y'); 119 break; 120 } 121 }, 122 123 processDeferredLoadAction: function(result, bigData) 124 { 125 if (!result) 126 return; 127 128 var position = bigData ? this.bigData.rows : {}; 129 130 this.processItems(result.items, BX.util.array_keys(position)); 131 }, 132 133 processItems: function(itemsHtml, position) 134 { 135 if (!itemsHtml) 136 return; 137 138 var processed = BX.processHTML(itemsHtml, false), 139 temporaryNode = BX.create('DIV'); 140 141 var items, k, origRows; 142 143 temporaryNode.innerHTML = processed.HTML; 144 items = temporaryNode.querySelectorAll('[data-entity="items-row"]'); 145 146 if (items.length) 147 { 148 this.showHeader(true); 149 150 for (k in items) 151 { 152 if (items.hasOwnProperty(k)) 153 { 154 origRows = position ? this.container.querySelectorAll('[data-entity="items-row"]') : false; 155 items[k].style.opacity = 0; 156 157 if (origRows && BX.type.isDomNode(origRows[position[k]])) 158 { 159 origRows[position[k]].parentNode.insertBefore(items[k], origRows[position[k]]); 160 } 161 else 162 { 163 this.container.appendChild(items[k]); 164 } 165 } 166 } 167 168 new BX.easing({ 169 duration: 2000, 170 start: {opacity: 0}, 171 finish: {opacity: 100}, 172 transition: BX.easing.makeEaseOut(BX.easing.transitions.quad), 173 step: function(state){ 174 for (var k in items) 175 { 176 if (items.hasOwnProperty(k)) 177 { 178 items[k].style.opacity = state.opacity / 100; 179 } 180 } 181 }, 182 complete: function(){ 183 for (var k in items) 184 { 185 if (items.hasOwnProperty(k)) 186 { 187 items[k].removeAttribute('style'); 188 } 189 } 190 } 191 }).animate(); 192 } 193 194 BX.ajax.processScripts(processed.SCRIPT); 195 }, 196 197 showHeader: function(animate) 198 { 199 var parentNode = BX.findParent(this.container, {attr: {'data-entity': 'parent-container'}}), 200 header; 201 202 if (parentNode && BX.type.isDomNode(parentNode)) 203 { 204 header = parentNode.querySelector('[data-entity="header"]'); 205 206 if (header && header.getAttribute('data-showed') != 'true') 207 { 208 header.style.display = ''; 209 210 if (animate) 211 { 212 new BX.easing({ 213 duration: 2000,
214 start: {opacity: 0}, 215 finish: {opacity: 100}, 216 transition: BX.easing.makeEaseOut(BX.easing.transitions.quad), 217 step: function(state){ 218 header.style.opacity = state.opacity / 100; 219 }, 220 complete: function(){ 221 header.removeAttribute('style'); 222 header.setAttribute('data-showed', 'true'); 223 } 224 }).animate(); 225 } 226 else 227 { 228 header.style.opacity = 100; 229 } 230 } 231 } 232 } 233 }; 234})();
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.