1(function (window) { 2 3if (!!window.JCCatalogCompareList) 4{ 5 return; 6} 7 8window.JCCatalogCompareList = function (params) 9{ 10 this.obCompare = null; 11 this.obAdminPanel = null; 12 this.visual = params.VISUAL; 13 this.ajax = params.AJAX; 14 this.position = params.POSITION; 15 16 BX.ready(BX.proxy(this.init, this)); 17}; 18 19window.JCCatalogCompareList.prototype.init = function() 20{ 21 this.obCompare = BX(this.visual.ID); 22 if (BX.type.isElementNode(this.obCompare)) 23 { 24 BX.addCustomEvent(window, "OnCompareChange", BX.proxy(this.reload, this)); 25 BX.bindDelegate(this.obCompare, 'click', {tagName : 'a'}, BX.proxy(this.deleteCompare, this)); 26 if (this.position.fixed && this.position.align.vertical === 'top') 27 { 28 this.obAdminPanel = BX('bx-panel'); 29 if (BX.type.isElementNode(this.obAdminPanel)) 30 { 31 this.setVerticalAlign(); 32 BX.addCustomEvent(window, 'onTopPanelCollapse', BX.proxy(this.setVerticalAlign, this)); 33 } 34 } 35 } 36}; 37 38window.JCCatalogCompareList.prototype.reload = function() 39{ 40 BX.ajax.post( 41 this.ajax.url, 42 this.ajax.reload, 43 BX.proxy(this.reloadResult, this) 44 ); 45}; 46 47window.JCCatalogCompareList.prototype.reloadResult = function(result) 48{ 49 this.obCompare.innerHTML = result; 50 if(this.obCompare.innerText > 0){ 51 this.obCompare.style.display = 'flex'; 52 }else{ 53 this.obCompare.style.display = 'none'; 54 } 55}; 56 57window.JCCatalogCompareList.prototype.deleteCompare = function() 58{ 59 var target = BX.proxy_context, 60 itemID, 61 url; 62 63 if (!!target && target.hasAttribute('data-id')) 64 { 65 itemID = parseInt(target.getAttribute('data-id'), 10); 66 if (!isNaN(itemID)) 67 { 68 BX.showWait(this.obCompare); 69 url = this.ajax.url + this.ajax.templates.delete + itemID.toString(); 70 BX.ajax.loadJSON( 71 url, 72 this.ajax.params, 73 BX.proxy(this.deleteCompareResult, this) 74 ); 75 } 76 } 77}; 78 79window.JCCatalogCompareList.prototype.deleteCompareResult = function(result) 80{ 81 var tbl, 82 i, 83 cnt, 84 newCount; 85 86 BX.closeWait(); 87 if (BX.type.isPlainObject(result)) 88 { 89 if (BX.type.isNotEmptyString(result.STATUS) && result.STATUS === 'OK' && !!result.ID) 90 { 91 BX.onCustomEvent('onCatalogDeleteCompare', [result.ID]); 92 93 tbl = this.obCompare.querySelector('table[data-block="item-list"]'); 94 if (BX.type.isElementNode(tbl)) 95 { 96 if (tbl.rows.length > 1) 97 { 98 for (i = 0; i < tbl.rows.length; i++) 99 { 100 if ( 101 tbl.rows[i].hasAttribute('data-row-id') 102 && tbl.rows[i].getAttribute('data-row-id') === ('row' + result.ID) 103 ) 104 { 105 tbl.deleteRow(i); 106 } 107 } 108 if (BX.type.isNotEmptyString(result.COUNT) || BX.type.isNumber(result.COUNT)) 109 { 110 newCount = parseInt(result.COUNT, 10); 111 if (!isNaN(newCount)) 112 { 113 cnt = this.obCompare.querySelector('span[data-block="count"]'); 114 if (BX.type.isElementNode(cnt)) 115 { 116 cnt.innerHTML = newCount.toString(); 117 } 118 cnt = null; 119 BX.style(this.obCompare, 'display', (newCount > 0 ? 'block' : 'none')); 120 } 121 } 122 } 123 else 124 { 125 this.reload(); 126 } 127 } 128 tbl = null; 129 } 130 } 131}; 132 133window.JCCatalogCompareList.prototype.setVerticalAlign = function() 134{ 135 var topSize; 136 if (BX.type.isElementNode(this.obCompare) && BX.type.isElementNode(this.obAdminPanel)) 137 { 138 topSize = parseInt(this.obAdminPanel.offsetHeight, 10); 139 if (isNaN(topSize)) 140 { 141 topSize = 0; 142 } 143 topSize +=5; 144 //BX.style(this.obCompare, 'top', topSize.toString()+'px'); 145 } 146}; 147 148})(window);
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.