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.showWait(this.obCompare); 41 BX.ajax.post( 42 this.ajax.url, 43 this.ajax.reload, 44 BX.proxy(this.reloadResult, this) 45 ); 46}; 47 48window.JCCatalogCompareList.prototype.reloadResult = function(result) 49{ 50 var mode = 'none'; 51 BX.closeWait(); 52 this.obCompare.innerHTML = result; 53 // if (BX.type.isNotEmptyString(result)) 54 // { 55 // if (result.indexOf('<table') >= 0) 56 // mode = 'block'; 57 // } 58 // BX.style(this.obCompare, 'display', mode); 59}; 60 61window.JCCatalogCompareList.prototype.deleteCompare = function() 62{ 63 var target = BX.proxy_context, 64 itemID, 65 url; 66 67 if (!!target && target.hasAttribute('data-id')) 68 { 69 itemID = parseInt(target.getAttribute('data-id'), 10); 70 if (!isNaN(itemID)) 71 { 72 BX.showWait(this.obCompare); 73 url = this.ajax.url + this.ajax.templates.delete + itemID.toString(); 74 BX.ajax.loadJSON( 75 url, 76 this.ajax.params, 77 BX.proxy(this.deleteCompareResult, this) 78 ); 79 } 80 } 81}; 82 83window.JCCatalogCompareList.prototype.deleteCompareResult = function(result) 84{ 85 var tbl, 86 i, 87 cnt, 88 newCount; 89 90 BX.closeWait(); 91 if (BX.type.isPlainObject(result)) 92 { 93 if (BX.type.isNotEmptyString(result.STATUS) && result.STATUS === 'OK' && !!result.ID) 94 { 95 BX.onCustomEvent('onCatalogDeleteCompare', [result.ID]); 96 97 tbl = this.obCompare.querySelector('table[data-block="item-list"]'); 98 if (BX.type.isElementNode(tbl)) 99 { 100 if (tbl.rows.length > 1) 101 { 102 for (i = 0; i < tbl.rows.length; i++) 103 { 104 if ( 105 tbl.rows[i].hasAttribute('data-row-id') 106 && tbl.rows[i].getAttribute('data-row-id') === ('row' + result.ID) 107 ) 108 { 109 tbl.deleteRow(i); 110 } 111 } 112 if (BX.type.isNotEmptyString(result.COUNT) || BX.type.isNumber(result.COUNT)) 113 { 114 newCount = parseInt(result.COUNT, 10); 115 if (!isNaN(newCount)) 116 { 117 cnt = this.obCompare.querySelector('span[data-block="count"]'); 118 if (BX.type.isElementNode(cnt)) 119 { 120 cnt.innerHTML = newCount.toString(); 121 } 122 cnt = null; 123 BX.style(this.obCompare, 'display', (newCount > 0 ? 'block' : 'none')); 124 } 125 } 126 } 127 else 128 { 129 this.reload(); 130 } 131 } 132 tbl = null; 133 } 134 } 135}; 136 137window.JCCatalogCompareList.prototype.setVerticalAlign = function() 138{ 139 var topSize; 140 if (BX.type.isElementNode(this.obCompare) && BX.type.isElementNode(this.obAdminPanel)) 141 { 142 topSize = parseInt(this.obAdminPanel.offsetHeight, 10); 143 if (isNaN(topSize)) 144 { 145 topSize = 0; 146 } 147 topSize +=5; 148 BX.style(this.obCompare, 'top', topSize.toString()+'px'); 149 } 150}; 151 152})(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.