PageSourceSearch

https://woodlin.ru/bitrix/templates/woodlin/components/bitrix/catalog.comments/.default/script.js

js woodlin.ru collected 2026-09-26 05:45:56 UTC 5,427 bytes, 249 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	if ('object' === typeof arParams)
50	{
51		this.params = arParams;
52		if (!!this.params.serviceList && typeof(this.params.serviceList) === 'object')
53		{
54			for (i in this.serviceList)
55			{
56				if (this.serviceList.hasOwnProperty(i) && !!this.params.serviceList[i])
57				{
58					this.serviceList[i] = true;
59				}
60			}
61		}
62		if (this.serviceList.blog)
63		{
64			this.initParams('blog');
65		}
66		if (this.serviceList.facebook)
67		{
68			this.initParams('facebook');
69		}
70	}
71	else
72	{
73		this.errorCode = -1;
74	}
75
76	if (this.errorCode === 0)
77	{
78		BX.ready(BX.delegate(this.Init, this));
79	}
80};
81
82window.JCCatalogSocnetsComments.prototype.initParams = function(id)
83{
84	var i;
85
86	if (!!this.params.settings && typeof(this.params.settings) === 'object' && typeof(this.params.settings[id]) === 'object')
87	{
88		for (i in this.settings[id])
89		{
90			if (this.settings[id].hasOwnProperty(i) && !!this.params.settings[id][i])
91			{
92				this.settings[id][i] = this.params.settings[id][i];
93			}
94		}
95	}
96};
97
98window.JCCatalogSocnetsComments.prototype.Init = function()
99{
100	if (this.serviceList.blog)
101	{
102		this.services.blog.obBlogCont = BX(this.settings.blog.contID);
103		if (!this.services.blog.obBlogCont)
104		{
105			this.serviceList.blog = false;
106			this.errorCode = -16;
107		}
108	}
109	if (this.serviceList.facebook)
110	{
111		this.services.facebook.obFBCont = BX(this.settings.facebook.contID);
112		if (!this.services.facebook.obFBCont)
113		{
114			this.serviceList.facebook = false;
115			this.errorCode = -32;
116		}
117		else
118		{
119			this.services.facebook.obFBContWidth = this.services.facebook.obFBCont.firstChild;
120		}
121		this.services.facebook.obFBParentCont = BX(this.settings.facebook.parentContID);
122	}
123
124	if (this.errorCode === 0)
125	{
126		if (this.serviceList.blog)
127		{
128			this.loadBlog();
129		}
130		if (this.serviceList.facebook)
131		{
132			this.loadFB();
133		}
134	}
135
136	this.params = {};
137};
138
139window.JCCatalogSocnetsComments.prototype.loadBlog = function()
140{
141	var postData;
142
143	if (this.errorCode !== 0 || !this.serviceList.blog || this.settings.blog.ajaxUrl.length === 0)
144	{
145		return;
146	}
147
148	postData = this.settings.blog.ajaxParams;
149	postData.sessid = BX.bitrix_sessid();
150	BX.ajax({
151		timeout:   30,
152		method:   'POST',
153		dataType: 'html',
154		url:       this.settings.blog.ajaxUrl,
155		data:      postData,
156		onsuccess: BX.proxy(this.loadBlogResult, this)
157	});
158};
159
160window.JCCatalogSocnetsComments.prototype.loadBlogResult = function(result)
161{
162	if (BX.type.isNotEmptyString(result))
163	{
164		BX.adjust(this.services.blog.obBlogCont, { html: result });
165		popUpComment();
166	}
167};
168
169window.JCCatalogSocnetsComments.prototype.loadFB = function()
170{
171	var width;
172
173	if (this.services.facebook.obFBParentCont && this.services.facebook.obFBContWidth)
174	{
175		width = parseInt(this.services.facebook.obFBParentCont.offsetWidth, 10);
176		if (!isNaN(width))
177		{
178			BX.adjust(this.services.facebook.obFBContWidth, { attrs: { 'data-width': (width-30) } });
179			this.services.facebook.currentWidth = width;
180		}
181
182		if (!this.services.facebook.obFBjSDK)
183		{
184			this.services.facebook.obFBjSDK = true;
185			BX.defer(BX.proxy((function(d, s, id, fbpath) {
186				var js, fjs = d.getElementsByTagName(s)[0];
187				if (d.getElementById(id))
188				{
189					return;
190				}
191				js = d.createElement(s); js.id = id;
192				js.src = fbpath;
193				fjs.parentNode.insertBefore(js, fjs);
194			}(document, "script", this.settings.facebook.facebookJSDK, this.settings.facebook.facebookPath)), this));
195		}
196	}
197};
198
199window.JCCatalogSocnetsComments.prototype.getFBParentWidth = function()
200{
201	var width = 0;
202	if (!!this.services.facebook.obFBParentCont)
203	{
204		width = parseInt(this.services.facebook.obFBParentCont.offsetWidth, 10);
205		if (isNaN(width))
206		{
207			width = 0;
208		}
209	}
210	return width;
211};
212
213window.JCCatalogSocnetsComments.prototype.setFBWidth = function(width)
214{
215	var obFrame = null,
216		src,
217		newSrc;
218
219	if (
220		this.serviceList.facebook &&
221		this.services.facebook.currentWidth !== width &&
222		width > 20 &&
223		!!this.services.facebook.obFBContWidth
224	)
225	{
226		if (!!this.services.facebook.obFBContWidth.firstChild && !!this.services.facebook.obFBContWidth.firstChild.fitrstChild)
227		{
228			obFrame = this.services.facebook.obFBContWidth.firstChild.fitrstChild;
229			if (!!obFrame)
230			{
231				src = obFrame.getAttribute("src");
232				newSrc = src.replace(/width=(\d+)/ig, "width="+width);
233				BX.adjust(this.services.facebook.obFBContWidth, { attrs: { 'data-width': (width-30) } });
234				this.services.facebook.currentWidth = width;
235				BX.style(this.services.facebook.obFBContWidth.firstChild, 'width', width+'px');
236				BX.adjust(obFrame, { attrs : { src: newSrc }, style: { width: width+'px' } });
237			}
238		}
239	}
240};
241
242window.JCCatalogSocnetsComments.prototype.onResize = function()
243{
244	if (this.serviceList.facebook)
245	{
246		this.setFBWidth(this.getFBParentWidth());
247	}
248};
249})(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.