PageSourceSearch

https://pioneer-online.ru/bitrix/templates/Pioneer_copy/js/skdslider.js

js pioneer-online.ru collected 2026-10-06 19:59:15 UTC 9,167 bytes, 291 lines download raw bytes

1/* =========================================================
2
3// SKD Slider
4// Update Date: 2013-12-24
5// Author: Samir Kumar Das
6// Mail: [email protected]
7// Web: http://dandywebsolution.com/skdslider
8// Version: 1.2
9 *  $('#demo').skdslider({'delay':5000, 'animationSpeed': 2000});
10 *
11
12// ========================================================= */
13(function($){
14    $.skdslider = function(container,options){
15        // settings
16        var config = {
17            'delay': 2000,
18            'animationSpeed': 500,
19			'showNav':true,
20			'autoSlide':true,
21			'showNextPrev':false,
22			'pauseOnHover':false,
23			'numericNav':false,
24			'showPlayButton':false,
25			'animationType':'fading', /* fading/sliding */
26        };
27		
28        if ( options ){$.extend(config, options);}
29        // variables
30		
31	    var touch = (( "ontouchstart" in window ) || window.DocumentTouch && document instanceof DocumentTouch);
32	  
33       
34	    $(container).wrap('<div class="skdslider"></div>');
35		var element=$(container).closest('div.skdslider');
36		element.find('ul').addClass('slides');
37        var slides = element.find('ul.slides li');
38		var targetSlide=0;
39		config.currentSlide=0;
40		config.currentState='pause';
41		config.running=false;
42		
43		var totalH = slides.eq(0).outerHeight();
44		element.height(totalH);
45		
46		if(config.animationType=='fading'){
47		   slides.each(function(){$(this).css({'position': 'absolute', 'left': '0','top': '0','bottom':'0','right':'0'});});
48		   slides.each(function(ind, obj){
49			   if(ind == 0) $(obj).addClass('active')
50				   else $(obj).hide();
51		   })
52		}
53		
54		if(config.animationType=='sliding'){
55		   slides.each(function(){$(this).css({'float': 'left', 'display': 'block','position': 'relative'});});
56		   
57		   var totalWidth=element.outerWidth()*slides.size();
58		   element.find('ul.slides').css({'position': 'absolute', 'left': '0','width':totalWidth});
59		   slides.css({'width':element.outerWidth(),'height':element.outerHeight()});
60		   
61		   $( window ).resize(function() {
62			  var totalWidth=element.outerWidth()*slides.size();
63		      element.find('ul.slides').css({'position': 'absolute', 'left': '0','width':totalWidth});
64		      slides.css({'width':element.outerWidth(),'height':element.outerHeight()});
65		   });
66		}
67		
68		//if (touch)
69		$.skdslider.enableTouch(element,slides, config);
70	   
71	    $.skdslider.createNav(element,slides, config);
72	    slides.eq(targetSlide).show();
73		if (config.autoSlide==true){
74		   config.currentState='play';	
75           config.interval=setTimeout(function() {
76                    $.skdslider.playSlide(element,slides, config);
77                }, config.delay); 
78		}
79		
80		if(config.pauseOnHover==true){
81		   slides.hover(function(){
82			  if (config.autoSlide==true){					 
83			    config.currentState='pause'; 
84			    clearTimeout(config.interval);
85			  }
86		   },function(){ 
87		     if (config.autoSlide==true){		
88		         config.currentState='play'; 
89			     if(config.autoSlide==true) $.skdslider.playSlide(element,slides, config);
90		       }
91			} );
92		}
93    };
94	
95
96  $.skdslider.createNav=function(element,slides,config){
97			
98			var slideSet ='<ul class="slide-navs">';
99			for(i=0;i<slides.length;i++){
100			  var slideContent='';
101			  if(config.numericNav==true) slideContent=(i+1);
102			  if(i==0)
103			  slideSet+='<li class="current-slide slide-nav-'+i+'"><a>'+slideContent+'</a></li>';
104			  else
105			  slideSet+='<li class="slide-nav-'+i+'"><a>'+slideContent+'</a></li>';
106			}
107			slideSet+='</ul>';
108			
109			
110			
111			if (config.showNav==true){
112					element.append(slideSet);
113					var nav_width=element.find('.slide-navs')[0].offsetWidth;
114					nav_width=parseInt((nav_width/2));
115					nav_width=(-1)*nav_width;
116					element.find('.slide-navs');
117					// Slide marker clicked
118					element.find('.slide-navs li').click(function(){
119						index = element.find('.slide-navs li').index(this);
120						targetSlide = index;
121						clearTimeout(config.interval);
122						config.currentState='play';
123						config.running=false;
124						$.skdslider.playSlide(element,slides, config,targetSlide);
125						return false;
126					});
127			}
128			
129	    if (config.showNextPrev==true){
130			 var nextPrevButton ='<a class="prev"><i class="fa fa-chevron-left"></i></a>'; 
131			     nextPrevButton +='<a class="next"><i class="fa fa-chevron-right"></i></a>'; 
132				 
133			 element.append(nextPrevButton);
134			 
135			 element.find('a.prev').click(function(){
136				 $.skdslider.prev(element,slides, config);									   
137			 });
138			
139			 element.find('a.next').click(function(){
140				  $.skdslider.next(element,slides, config);								   
141			 });
142		}
143		
144	  if (config.showPlayButton==true){
145		   
146			var playPause =(config.currentState=='play' || config.autoSlide==true)?'<a class="play-control pause"></a>':'<a class="play-control play"></a>';  
147			element.append(playPause);			
148			element.hover(function(){element.find('a.play-control').css('display','block');},function(){element.find('a.play-control').css('display','none');});
149		   
150		    element.find('a.play-control').click(function(){
151											   
152					if(config.autoSlide==true)
153					{
154					   clearTimeout(config.interval);
155					   config.autoSlide=false;
156					   config.currentState='pause';
157					   $(this).addClass('play');
158					   $(this).removeClass('pause');
159					}
160					else
161					{
162					   config.currentState='play';
163					   config.autoSlide=true;
164					   $(this).addClass('pause');
165					   $(this).removeClass('play');
166					   
167					   if((config.currentSlide+1)==slides.length)targetSlide = 0;
168					   else targetSlide = (config.currentSlide+1);
169					   
170					   clearTimeout(config.interval);
171					   $.skdslider.playSlide(element,slides, config,targetSlide);
172					}	
173				   return false;
174			 });
175	  }
176	  
177  };
178  
179 $.skdslider.next=function(element,slides,config){
180    if((config.currentSlide+1)==slides.length)targetSlide = 0;
181	else targetSlide = (config.currentSlide+1);
182	
183	clearTimeout(config.interval);
184	config.currentState='play';
185	$.skdslider.playSlide(element,slides, config,targetSlide);
186	return false;
187 }
188 
189 $.skdslider.prev=function(element,slides,config){
190    if(config.currentSlide==0)targetSlide = (slides.length-1);
191	else targetSlide = (config.currentSlide-1);
192
193	clearTimeout(config.interval);
194	config.currentState='play';
195	config.running=false;
196	$.skdslider.playSlide(element,slides, config,targetSlide);
197	return true;
198 }
199 
200 $.skdslider.prev=function(element,slides,config){
201    if(config.currentSlide==0)targetSlide = (slides.length-1);
202	else targetSlide = (config.currentSlide-1);
203
204	clearTimeout(config.interval);
205	config.currentState='play';
206	config.running=false;
207	$.skdslider.playSlide(element,slides, config,targetSlide);
208	return true;
209 }
210 
211 $.skdslider.playSlide=function(element,slides,config,targetSlide){
212	   
213	    if(config.currentState=='play' && config.running==false){
214			
215				element.find('.slide-navs li').removeClass('current-slide');
216				if(typeof (targetSlide)=='undefined'){
217					  targetSlide = ( config.currentSlide+1 == slides.length ) ? 0 : config.currentSlide+1;
218				}
219				if(config.animationType=='fading'){
220					config.running=true;
221					slides.eq(config.currentSlide).fadeOut(config.animationSpeed).removeClass('active');
222					slides.eq(targetSlide).fadeIn(config.animationSpeed, function() {		
223						$.skdslider.removeIEFilter($(this)[0]);
224						 config.running=false;		
225					}).addClass('active');
226				}
227				if(config.animationType=='sliding'){
228					var left=(targetSlide*element.outerWidth())*(-1);
229					config.running=true;
230					element.find('ul.slides').animate({left:left}, config.animationSpeed,function(){
231					  config.running=false;																		 
232					});
233				}
234				element.find('.slide-navs li').eq(targetSlide).addClass('current-slide');
235				config.currentSlide=targetSlide;
236		}
237		
238	  if (config.autoSlide==true && config.currentState=='play'){
239			config.interval=setTimeout((function() {
240				$.skdslider.playSlide(element,slides, config);
241			}), config.delay);
242	  }
243  };
244  
245  $.skdslider.enableTouch=function(element,slides,config){
246	  element[0].addEventListener('touchstart', onTouchStart, false);
247	   var startX;
248       var startY;
249	   var dx;
250	   var dy;
251	   
252	   function onTouchStart(e){
253		   startX = e.touches[0].pageX;
254    	   startY = e.touches[0].pageY; 
255		   element[0].addEventListener('touchmove', onTouchMove, false);
256           element[0].addEventListener('touchend', onTouchEnd, false);
257	   }
258	   
259	   function onTouchMove(e) {
260				 e.preventDefault();
261	    		 var x = e.touches[0].pageX;
262	    		 var y = e.touches[0].pageY;
263	    		 dx = startX - x;
264	    		 dy = startY - y;
265      }
266	  
267	 function onTouchEnd(e) {
268				 element[0].removeEventListener('touchmove', onTouchMove, false);
269				 if(dx>0){
270					  $.skdslider.next(element,slides, config);		 
271				 }else{
272				     $.skdslider.prev(element,slides, config);			 
273			     }
274	    		 element[0].removeEventListener('touchend', onTouchEnd, false);
275    	 }	
276  }
277   
278  
279  $.skdslider.removeIEFilter=function(elm){
280	  if(elm.style.removeAttribute){
281		elm.style.removeAttribute('filter');
282	   }  
283  }
284
285 $.fn.skdslider = function(options){
286        return this.each(function(){
287            (new $.skdslider(this,options));
288        });
289    };
290	
291})(jQuery);

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.