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