PageSourceSearch

https://book24.ua/bitrix/templates/aspro_max/components/bitrix/catalog.comments/catalog/script.js

js book24.ua collected 2026-09-24 21:09:00 UTC 7,341 bytes, 310 lines download raw bytes

1;(function(window) {
2if (!!window.JCCatalogSocnetsComments)
3{
4	return;
5}
6
7window.JCCatalogSocnetsComments = function(arParams)
8{
9	var i;
10
11	this.errorCode = 0;
12
13	this.params = {};
14
15	this.serviceList = {
16		blog: false,
17		facebook: false,
18		vk: false
19	};
20	this.settings = {
21		blog: {
22			ajaxUrl: '',
23			ajaxParams: {},
24			contID: 'bx-cat-soc-comments-blg'
25		},
26		facebook: {
27			contID: 'bx-cat-soc-comments-fb',
28			contWidthID: '',
29			parentContID: 'soc_comments',
30			facebookJSDK: 'facebook-jssdk',
31			facebookPath: ''
32		},
33		vk: {}
34	};
35
36	this.services = {
37		blog: {
38			obBlogCont: null
39		},
40		facebook: {
41			obFBCont: null,
42			obFBContWidth: null,
43			obFBParentCont: null,
44			obFBjSDK: null,
45			currentWidth: 0
46		}
47	};
48
49	this.activeTabId = '';
50	this.currentTab = -1;
51	this.tabsContId = '';
52	this.tabList = [];
53	this.obTabList = [];
54
55	if (typeof arParams === 'object')
56	{
57		this.params = arParams;
58		if (!!this.params.serviceList && typeof(this.params.serviceList) === 'object')
59		{
60			for (i in this.serviceList)
61			{
62				if (this.serviceList.hasOwnProperty(i) && !!this.params.serviceList[i])
63					this.serviceList[i] = true;
64			}
65		}
66		if (this.serviceList.blog)
67			this.initParams('blog');
68		if (this.serviceList.facebook)
69			this.initParams('facebook');
70
71		if (typeof(this.params.tabs) === 'object')
72		{
73			this.activeTabId = this.params.tabs.activeTabId;
74			this.tabsContId = this.params.tabs.tabsContId;
75			this.tabList = this.params.tabs.tabList;
76		}
77	}
78	else
79	{
80		this.errorCode = -1;
81	}
82
83	if (this.errorCode === 0)
84		BX.ready(BX.proxy(this.Init, this));
85};
86
87window.JCCatalogSocnetsComments.prototype.initParams = function(id)
88{
89	var i;
90
91	if (!!this.params.settings && typeof(this.params.settings) === 'object' && typeof(this.params.settings[id]) === 'object')
92	{
93		for (i in this.settings[id])
94		{
95			if (this.settings[id].hasOwnProperty(i) && !!this.params.settings[id][i])
96				this.settings[id][i] = this.params.settings[id][i];
97		}
98	}
99};
100
101window.JCCatalogSocnetsComments.prototype.Init = function()
102{
103	if (!this.tabList || !BX.type.isArray(this.tabList) || this.tabList.length === 0)
104	{
105		this.errorCode = -1;
106		return;
107	}
108	var i,
109		strFullId;
110
111	for (i = 0; i < this.tabList.length; i++)
112	{
113		strFullId = this.tabsContId + this.tabList[i];
114		this.obTabList[i] = {
115			id: this.tabList[i],
116			tabId: strFullId,
117			contId: strFullId+'_cont',
118			tab: BX(strFullId),
119			cont: BX(strFullId+'_cont')
120		};
121		if (!this.obTabList[i].tab || !this.obTabList[i].cont)
122		{
123			this.errorCode = -2;
124			break;
125		}
126		if (this.activeTabId === this.tabList[i])
127			this.currentTab = i;
128		BX.bind(this.obTabList[i].tab, 'click', BX.proxy(this.onClick, this));
129	}
130
131	if (this.serviceList.blog)
132	{
133		this.services.blog.obBlogCont = BX(this.settings.blog.contID);
134		if (!this.services.blog.obBlogCont)
135		{
136			this.serviceList.blog = false;
137			this.errorCode = -16;
138		}
139	}
140	if (this.serviceList.facebook)
141	{
142		this.services.facebook.obFBCont = BX(this.settings.facebook.contID);
143		if (!this.services.facebook.obFBCont)
144		{
145			this.serviceList.facebook = false;
146			this.errorCode = -32;
147		}
148		else
149		{
150			this.services.facebook.obFBContWidth = this.services.facebook.obFBCont.firstChild;
151		}
152		this.services.facebook.obFBParentCont = BX(this.settings.facebook.parentContID);
153	}
154
155	if (this.errorCode === 0)
156	{
157		this.showActiveTab();
158		if (this.serviceList.blog)
159			this.loadBlog();
160		if (this.serviceList.facebook)
161			this.loadFB();
162	}
163
164	this.params = {};
165};
166
167window.JCCatalogSocnetsComments.prototype.loadBlog = function()
168{
169	var postData;
170
171	if (this.errorCode !== 0 || !this.serviceList.blog || this.settings.blog.ajaxUrl.length === 0)
172	{
173		return;
174	}
175
176	postData = this.settings.blog.ajaxParams;
177	postData.sessid = BX.bitrix_sessid();
178	BX.ajax({
179		timeout:   30,
180		method:   'POST',
181		dataType: 'html',
182		url:       this.settings.blog.ajaxUrl,
183		data:      postData,
184		onsuccess: BX.proxy(this.loadBlogResult, this)
185	});
186};
187
188window.JCCatalogSocnetsComments.prototype.loadBlogResult = function(result)
189{
190	if (BX.type.isNotEmptyString(result))
191		BX.adjust(this.services.blog.obBlogCont, { html: result });
192};
193
194window.JCCatalogSocnetsComments.prototype.loadFB = function()
195{
196	var width;
197
198	if (this.services.facebook.obFBParentCont && this.services.facebook.obFBContWidth)
199	{
200		width = parseInt(this.services.facebook.obFBParentCont.offsetWidth, 10);
201		if (!isNaN(width))
202		{
203			BX.adjust(this.services.facebook.obFBContWidth, { attrs: { 'data-width': (width-20) } });
204			this.services.facebook.currentWidth = width;
205		}
206
207		if (!this.services.facebook.obFBjSDK)
208		{
209			this.services.facebook.obFBjSDK = true;
210			BX.defer(BX.proxy((function(d, s, id, fbpath) {
211				var js, fjs = d.getElementsByTagName(s)[0];
212				if (d.getElementById(id))
213				{
214					return;
215				}
216				js = d.createElement(s); js.id = id;
217				js.src = fbpath;
218				fjs.parentNode.insertBefore(js, fjs);
219			}(document, "script", this.settings.facebook.facebookJSDK, this.settings.facebook.facebookPath)), this));
220		}
221	}
222};
223
224window.JCCatalogSocnetsComments.prototype.getFBParentWidth = function()
225{
226	var width = 0;
227	if (!!this.services.facebook.obFBParentCont)
228	{
229		width = parseInt(this.services.facebook.obFBParentCont.offsetWidth, 10);
230		if (isNaN(width))
231			width = 0;
232	}
233	return width;
234};
235
236window.JCCatalogSocnetsComments.prototype.setFBWidth = function(width)
237{
238	var obFrame = null,
239		src,
240		newSrc;
241
242	if (
243		this.serviceList.facebook &&
244		this.services.facebook.currentWidth !== width &&
245		width > 20 &&
246		!!this.services.facebook.obFBContWidth
247	)
248	{
249		if (!!this.services.facebook.obFBContWidth.firstChild && !!this.services.facebook.obFBContWidth.firstChild.fitrstChild)
250		{
251			obFrame = this.services.facebook.obFBContWidth.firstChild.fitrstChild;
252			if (!!obFrame)
253			{
254				src = obFrame.getAttribute("src");
255				newSrc = src.replace(/width=(\d+)/ig, "width="+width);
256				BX.adjust(this.services.facebook.obFBContWidth, { attrs: { 'data-width': (width-20) } });
257				this.services.facebook.currentWidth = width;
258				BX.style(this.services.facebook.obFBContWidth.firstChild, 'width', width+'px');
259				BX.adjust(obFrame, { attrs : { src: newSrc }, style: { width: width+'px' } });
260			}
261		}
262	}
263};
264
265window.JCCatalogSocnetsComments.prototype.onResize = function()
266{
267	if (this.serviceList.facebook)
268		this.setFBWidth(this.getFBParentWidth());
269};
270
271window.JCCatalogSocnetsComments.prototype.onClick = function()
272{
273	var target = BX.proxy_context,
274		index = -1,
275		i;
276
277	for (i = 0; i < this.obTabList.length; i++)
278	{
279		if (target.id === this.obTabList[i].tabId)
280		{
281			index = i;
282			break;
283		}
284	}
285	if (index > -1)
286	{
287		if (index !== this.currentTab)
288		{
289			this.hideActiveTab();
290			this.currentTab = index;
291			this.showActiveTab();
292		}
293	}
294};
295
296window.JCCatalogSocnetsComments.prototype.hideActiveTab = function()
297{
298	BX.removeClass(this.obTabList[this.currentTab].tab, 'active');
299	BX.addClass(this.obTabList[this.currentTab].cont, 'tab-off');
300	BX.addClass(this.obTabList[this.currentTab].cont, 'hidden');
301};
302
303window.JCCatalogSocnetsComments.prototype.showActiveTab = function()
304{
305	BX.onCustomEvent('onAfterBXCatTabsSetActive_'+this.tabsContId,[{activeTab: this.obTabList[this.currentTab].id}]);
306	BX.addClass(this.obTabList[this.currentTab].tab, 'active');
307	BX.removeClass(this.obTabList[this.currentTab].cont, 'tab-off');
308	BX.removeClass(this.obTabList[this.currentTab].cont, 'hidden');
309};
310})(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.