PageSourceSearch

https://sk-magic.ru/assets/templates/chu/js/powerSlide.js

js sk-magic.ru collected 2026-10-05 00:34:42 UTC 6,187 bytes, 205 lines download raw bytes

1(function($){
2
3	$.fn.powerSlide = function(options) {  
4
5		var opt = {
6			'width': 357, // Width and height of the images
7			'height': 475,
8			'position': 'bottom', // Position of the navigation
9			'bullets': false, // Show numbering navigation
10			'thumbs':  true, // Show thumbnail navigation
11			'row': 10, // Thumbnails per row
12			'auto': true, // Auto rotate
13			'autoSpeed': 6000, //ShowTime =)
14			'fadeSpeed': 3000
15		};
16
17		this.each(function() {        
18		
19			if (options) { 
20				$.extend(opt, options);
21			}
22
23			/* Container and wrapper
24			-----------------------------------------------*/
25			$(this).children().wrapAll('<div class="powerSlide" />');
26			var container = $(this).find('.powerSlide');
27			container.find('img').wrapAll('<div class="wrapper" />');
28			var wrapper = container.find('.wrapper');
29
30
31			/* Previous & next buttons
32			-----------------------------------------------*/
33			/*wrapper.append('<a href="#" class="prev">Prev</a><a href="#" class="next">Next</a>');*/
34
35
36			/* Navigation & captions
37			-----------------------------------------------*/
38			/*
39			switch (opt.position) { // Navigation position
40					case 'top': container.prepend('<div class="nav" />'); break;
41					case 'bottom': container.append('<div class="nav" />'); break;
42			}
43*/
44			var nav = container.find('.nav');
45
46			wrapper.find('img').each(function(i){
47
48				i += 1; // Start numbers at 1
49/**/
50				if (opt.bullets === true) { // Bullet navigation
51						nav.append('<a href="#">'+ i +'</a>'); 
52				}
53
54				if (opt.thumbs === true) { // Thumbnail navigation
55						nav.addClass('thumbs').append(
56							'<img class="thumb" src="'+
57							$(this).attr('src') +'" alt=""/>'); 
58				}
59
60				// Captions
61				
62				var title = $(this).attr('title');
63				$(this).wrapAll('<div class="image" />');
64				if (title !== undefined) {
65						$(this).attr('title', '');
66						$(this).after('<p></p>');/**/
67				}
68				
69			});			
70			
71			
72			/* Slider Object
73			-----------------------------------------------*/		
74			var Slider = function(){
75
76			this.imgs = wrapper.find('div.image');
77			this.imgCount = (this.imgs.length) - 1; // Match index
78			this.navPrev = wrapper.find('a.prev');
79			this.navNext = wrapper.find('a.next');
80			this.bullets = container.find('.nav a');
81			this.thumbs = container.find('.nav img.thumb');
82			this.captions = this.imgs.find('p');
83
84			this.getCurrentIndex = function(){ // Index
85					return this.imgs.filter('.current').index();
86			};
87
88			this.go = function(index){ // Rotate images
89					this.imgs
90						.removeClass('current')
91						.fadeOut(opt.fadeSpeed)
92						.eq(index)
93						.fadeIn(opt.fadeSpeed)
94						.addClass('current');
95					this.bullets
96						.removeClass('current')
97						.eq(index)
98						.addClass('current');
99					this.thumbs
100						.removeClass('current')
101						.eq(index)
102						.addClass('current');
103			};
104	
105			this.next = function(){
106					var index = this.getCurrentIndex();
107					if (index < this.imgCount) {
108						this.go(index + 1); // Go next
109					} else {
110						this.go(0); // If last go first
111					}
112			};
113	
114			this.prev = function(){
115					var index = this.getCurrentIndex();
116					if (index > 0) {
117						this.go(index - 1); // Go previous
118					} else {
119						this.go(this.imgCount); // If first go last
120					}
121			};	
122	
123			this.init = function(){ // Init
124				wrapper
125					.width(opt.width)
126					.height(opt.height); /* Set width and height */
127				
128				this.imgs.hide().first().addClass('current').show(); /* Set current image */
129				this.bullets.first().addClass('current');
130				this.thumbs.first().addClass('current');
131				
132				// Dimensions for thumbnails and captions
133				var padding = wrapper.css('padding-left').replace('px', '');
134				var captionsPadding = this.captions.css('padding-left').replace('px', '');
135				nav.width(opt.width);
136				if (opt.thumbs === true) { // thumbs
137					var thumbBorder = this.thumbs.css('border-left-width').replace('px', '');
138					var thumbMargin = this.thumbs.css('margin-right').replace('px', '');
139					var thumbMaxWidth = opt.width/opt.row;
140					this.thumbs.width( (thumbMaxWidth - (thumbMargin * 2)) - (thumbBorder * 2) );
141				}
142				this.captions // captions
143					.width(opt.width - (captionsPadding * 2) + 'px')
144					.css('margin-bottom', padding + 'px');
145				this.navNext.css('margin-right', padding + 'px');
146
147			};
148
149			};
150			
151			var slider = new Slider();
152			slider.init();		
153			
154			
155			/* Mouse Events
156			-----------------------------------------------*/
157			wrapper.hover(function(){ // Hover image wrapper
158				slider.captions.stop(true, true).fadeToggle();
159				slider.navNext.stop(true, true).fadeToggle();
160				slider.navPrev.stop(true, true).fadeToggle();
161			});
162			slider.navNext.click(function(e){ // Click next button
163				e.preventDefault();
164				slider.next(); 
165			});
166			slider.navPrev.click(function(e){ // Click previous button
167				e.preventDefault();
168				slider.prev();
169			});
170			slider.bullets.click(function(e){  // Click numbered bullet
171				e.preventDefault(); slider.captions.hide();
172				slider.go($(this).index());
173			});
174			slider.thumbs.click(function(){ // Click thumbnail
175				slider.captions.hide();
176				slider.go($(this).index());
177			});
178			
179			
180			
181			/* Auto Rotate	
182			-----------------------------------------------*/			
183			if (opt.auto === true) {
184
185				var timer = function(){
186						slider.next();
187						/*slider.captions.hide();*/
188				};
189				var interval = setInterval(timer, opt.autoSpeed);
190	
191				// Pause when hovering image
192				
193				/*wrapper.hover(function(){alert(opt.autoSpeed+"_"+interval+"_"+timer);}, function(){interval=setInterval(timer, opt.autoSpeed);});
194				wrapper.hover(function(){clearInterval(interval);}, function(){interval=setInterval(timer, opt.autoSpeed);});
195
196				// Reset timer when clicking thumbnail or bullet
197				slider.thumbs.click(function(){clearInterval(interval); interval=setInterval(timer, opt.autoSpeed);});
198				slider.bullets.click(function(){clearInterval(interval); interval=setInterval(timer, opt.autoSpeed);});
199				*/	
200		
201			}
202			
203		});
204	};
205})(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.