PageSourceSearch

https://sleeps.ru/local/templates/custom/components/bitrix/news.list/reviews_slider/script.js?17332560294815

js sleeps.ru collected 2026-09-26 05:06:18 UTC 4,815 bytes, 198 lines download raw bytes

1(function (window)
2{
3	if (!!window.JCNewsSlider)
4	{
5		return;
6	}
7
8	window.JCNewsSlider = function (containerId, options)
9	{
10		if (containerId && options)
11		{
12			var container = BX(containerId);
13			if (container)
14			{
15				var sliderImages = BX.findChildByClassName(container, options.imagesContainerClassName, true);
16				var sliderLeft = BX.findChildByClassName(container, options.leftArrowClassName, true);
17				var sliderRight = BX.findChildByClassName(container, options.rightArrowClassName, true);
18				var sliderControl = BX.findChildByClassName(container, options.controlContainerClassName, true);
19				if (sliderImages && sliderLeft && sliderRight && sliderControl)
20				{
21					var slider = new JCNewsSlider;
22					slider.Init(sliderImages, sliderControl, sliderLeft, sliderRight);
23				}
24			}
25		}
26	};
27
28	window.JCNewsSlider.prototype.Init = function(sliderImages, sliderControl, sliderLeft, sliderRight)
29	{
30		this.time = 0.5;
31		this.type = 'accelerated';
32		//swipe
33		this.threshold = 50;
34		this.allowedTime = 500;
35		this.startX = 0;
36		this.startY = 0;
37		this.startTime = 0;
38
39		this.sliderImages = sliderImages;
40		BX.bind(sliderImages, 'touchstart', BX.delegate(this.touchStart, this));
41		BX.bind(sliderImages, 'touchend', BX.delegate(this.touchEnd, this));
42
43		this.sliderControls = BX.findChildren(sliderControl, {tagName: 'LI'}, true);
44		var proxy = function(j, func)
45		{
46			return function()
47			{
48				return func(j);
49			}
50		}
51		for (var j = 0; j < this.sliderControls.length; j++)
52		{
53			BX.bind(this.sliderControls[j], 'click', proxy(j, BX.delegate(this.slideTo, this)));
54		}
55
56		this.sliderLeft = sliderLeft;
57		BX.bind(sliderLeft, 'click', BX.delegate(this.slideLeft, this));
58
59		this.sliderRight = sliderRight;
60		BX.bind(sliderRight, 'click', BX.delegate(this.slideRight, this));
61	};
62
63	window.JCNewsSlider.prototype.slideRight = function()
64	{
65		if (this.animation)
66			return;
67		this.animation = true;
68
69		var p = parseInt(this.sliderImages.style.left, 10);
70		if (p <= -100 * (this.sliderControls.length-1))
71		{
72			this.animation = false;
73			return;
74		}
75
76		var _this = this;
77		(new BX.fx({
78			start: p,
79			finish: p - 100,
80			time: this.time,
81			type: this.type,
82			callback: function(res){
83				_this.sliderImages.style.left = res + '%';
84			},
85			callback_start: function(){
86				_this.sliderImages.style.left = p + '%';
87			},
88			callback_complete: function(){
89				_this.sliderImages.style.left = (p - 100) + '%';
90				_this.adjustSliderControls(-(p - 100) / 100);
91				_this.animation = false;
92			}
93		})).start();
94	};
95
96	window.JCNewsSlider.prototype.slideLeft = function()
97	{
98		if (this.animation)
99			return;
100		this.animation = true;
101
102		var p = parseInt(this.sliderImages.style.left, 10);
103		if (p >= 0)
104		{
105			this.animation = false;
106			return;
107		}
108
109		var _this = this;
110		(new BX.fx({
111			start: p,
112			finish: p + 100,
113			time: this.time,
114			type: this.type,
115			callback: function(res){
116				_this.sliderImages.style.left = res + '%';
117			},
118			callback_start: function(){
119				_this.sliderImages.style.left = p + '%';
120			},
121			callback_complete: function(){
122				_this.sliderImages.style.left = (p + 100) + '%';
123				_this.adjustSliderControls(-(p + 100) / 100);
124				_this.animation = false;
125			}
126		})).start();
127	};
128
129	window.JCNewsSlider.prototype.slideTo = function(j)
130	{
131		if (this.animation)
132			return;
133		this.animation = true;
134
135		var p = parseInt(this.sliderImages.style.left, 10);
136		if (p == (-j * 100))
137		{
138			this.animation = false;
139			return;
140		}
141
142		var _this = this;
143		(new BX.fx({
144			start: p,
145			finish: -j * 100,
146			time: this.time,
147			type: this.type,
148			callback: function(res){
149				_this.sliderImages.style.left = res + '%';
150			},
151			callback_start: function(){
152				_this.sliderImages.style.left = p + '%';
153				_this.adjustSliderControls(j);
154			},
155			callback_complete: function(){
156				_this.sliderImages.style.left = (-j * 100) + '%';
157				_this.animation = false;
158			}
159		})).start();
160	};
161
162	window.JCNewsSlider.prototype.adjustSliderControls = function(i)
163	{
164		for (var j = 0; j < this.sliderControls.length; j++)
165		{
166			if (i == j)
167				BX.addClass(this.sliderControls[j], 'current');
168			else
169				BX.removeClass(this.sliderControls[j], 'current');
170		}
171	};
172
173	window.JCNewsSlider.prototype.touchStart = function(e)
174	{
175		var touchObject = e.changedTouches[0];
176		this.startX = touchObject.pageX;
177		this.startY = touchObject.pageY;
178		this.startTime = new Date().getTime();
179		e.preventDefault();
180	};
181
182	window.JCNewsSlider.prototype.touchEnd = function(e)
183	{
184		var touchObject = e.changedTouches[0];
185		var distance = touchObject.pageX - this.startX;
186		var elapsedTime = new Date().getTime() - this.startTime;
187
188		if (elapsedTime <= this.allowedTime)
189		{
190			if (distance > this.threshold)
191				this.slideLeft();
192			else if (distance < -this.threshold)
193				this.slideRight();
194		}
195		e.preventDefault()
196	};
197}
198)(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.