PageSourceSearch

https://toolking.ru/bitrix/components/bitrix/catalog.compare.list/templates/.default/script.js?15594839773239

js toolking.ru collected 2026-10-04 05:04:30 UTC 3,239 bytes, 148 lines download raw bytes

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