PageSourceSearch

https://intigral.com/wp-content/themes/Intigral/js/intigral-responsive-rotator.js?ver=1.0

js intigral.com collected 2026-10-05 21:26:36 UTC 11,728 bytes, 456 lines download raw bytes

1// XML RESPONSIVE ROTATOR CUSTOM OPTIONS
2 
3var startSlide = 1; // Determines which slide the rotator starts on
4var randomSlide = false; // Set to 'true' to have the rotator start on a random slide
5var effectRotate = false; // Set to 'true' to have slides rotate, 'false' will default the transition to a fade
6var autoRotate = true; // Set to 'true' to have slides auto rotate
7var autoRotateSeconds = 8; // Determines how many seconds between auto rotations if autoRotate is set to 'true'
8var rotate;
9 
10// END CUSTOM OPTIONS
11 
12// BELOW IS THE SLIDER SCRIPT
13
14// SHARED GALLERY FEATURES 
15function gallerySetup() {
16 	var numSlides = $('.slide').length;
17 	
18 	if (randomSlide == true) {
19 		var randomMultiplier = Math.random();
20 		var randomNumber = Math.floor(randomMultiplier * numSlides) + 1;
21 		startSlide = randomNumber;
22 	}
23 	
24 	if (startSlide > numSlides) { 
25 		startSlide = 1;	
26 	}
27 	
28 	var navLinks;
29	if (navLinks == false) {
30 		$('.next').hide();
31 		$('.prev').hide();
32 	}
33
34	if (effectRotate) {
35		buildSlider(numSlides, startSlide);
36		$('.gallery').addClass('gallery-rotate');
37		$('.slide').show();
38	} else {
39		$('.gallery').addClass('gallery-fade');
40		buildFader(numSlides, startSlide);
41 	}
42
43	runRotateSlides();
44}
45// END SHARED GALLERY FEATURES
46
47
48// SLIDE EFFECT
49function buildSlider(numSlides, startSlide) {			
50	$('.gallery-inner').css('width', 100 * numSlides + '%');
51	$('.slide').css('width', 100 / numSlides + '%');
52	
53	var currentPos = $('.gallery-inner').position().left;
54	var newPos = currentPos - 100;
55	$('.gallery-inner').animate({
56		left: newPos + '%'
57	});
58 	
59 	$('.slide').each(function(e) {
60 		if (e == startSlide - 1) {
61 			$(this).addClass('active');
62 		}
63 		$(this).attr({
64 			id: 'slide' + e,
65 		});
66 	});
67 	
68 	if (startSlide == 1) {
69 		var lastItem = $('.slide').last();
70 		lastItem.remove();
71 		$('.gallery-inner').prepend(lastItem);
72 	} else if (startSlide > 2) {
73 		for (i = 1; i < startSlide - 1; i++) {
74 			var firstItem = $('.slide').first();
75 			firstItem.remove();
76 			$('.gallery-inner').append(firstItem);
77 		}
78 	}
79 	
80	$('.gallery-inner').css('left', 0);	
81 	
82	$('.gallery-nav .prev').after('<div class="slide-indicator"></div>');
83	for (i = 1; i <= numSlides; i++) {
84		$('.slide-indicator').append('<a class="indicator" id="indicate-' + i + '" href="#"></a>');
85	}
86	$('#indicate-' + startSlide).addClass('active');	
87 
88} 
89// END SLIDE EFFECT / BUILDSLIDER FUNCTION
90
91// FADE EFFECT
92function buildFader(numSlides, startSlide) {	
93	$('.slide').each(function(e) {
94		if (e == startSlide - 1) {
95			$(this).addClass('active');
96		}
97		$(this).attr({
98			id: 'slide' + e,
99		});
100	});
101	
102	$('.gallery-nav .prev').after('<div class="slide-indicator"></div>');
103	for (i = 1; i <= numSlides; i++) {
104		$('.slide-indicator').append('<a class="indicator" id="indicate-' + i + '" href="#"></a>');
105	}
106	$('#indicate-' + startSlide).addClass('active');	
107} 
108// END FADE EFFECT / BUILDFADER FUNCTION
109
110// AUTO RESIZE 
111$(window).load(function() {
112 	var activeHeight = $('.active').height();
113 	$('.gallery').animate({
114 		height: activeHeight
115 	});
116});
117 
118var rtime = new Date(1, 1, 2000, 12,00,00);
119var timeout = false;
120var delta = 200;
121$(window).resize(function() {
122	rtime = new Date();
123 	if (timeout === false) {
124 		timeout = true;
125 		setTimeout(resizeend, delta);
126 	}
127});
128 
129function resizeend() {
130	if (new Date() - rtime < delta) {
131 		setTimeout(resizeend, delta);
132 	} else {
133 		timeout = false;
134 		resizeGallery();
135 	}               
136}	
137// END AUTO RESIZE
138	
139// TOUCH EVENTS FOR SLIDING EFFECT
140if (effectRotate) {
141	var startX, curX, swipeDistance, origPos, currentPos, newPos, deviceWidth;
142	var startY, curY, yDistance, bodyPos, yScrolled, firstItems, lastItems, yDistAbs, swipeDistAbs, scrollPosOnTouch, scrollPosOnEnd;
143	var targetHref;
144	 
145	var swipeThreshold = 30;
146	var galleryInner = document.getElementById('gallery-inner');
147	var touchstart = function(event) {  
148		if (event.originalEvent.touches.length == 1) {
149				startX = event.originalEvent.touches[0].pageX;
150				startY = event.originalEvent.touches[0].pageY;
151				origPos = - 100; 
152		} else {
153			touchcancel(event);	
154		}
155		
156		deviceWidth = $(window).width();
157		if ($(event.target).parent().attr('href')) {
158			targetHref = $(event.target).parent().attr('href');
159		}
160		
161		scrollPosOnTouch = $(document).scrollTop();
162	};  
163	 
164	var touchmove = function(event) {  
165		curX = event.originalEvent.touches[0].pageX;
166		swipeDistance = curX - startX;
167		swipeDistAbs = Math.abs(swipeDistance);
168		curY = event.originalEvent.touches[0].pageY;
169		yDistance = curY - startY;
170		yDistAbs = Math.abs(yDistance);
171		
172		if(swipeDistAbs > yDistAbs) {
173			if (event.originalEvent.touches.length == 1) {
174				$('.active').removeClass('active');
175				newPos = parseInt(origPos) + ((swipeDistance/deviceWidth) * 100);
176				$('.gallery-inner').css('left', newPos + '%');
177			} else {
178				touchcancel(event);
179			}
180			return false;
181		} 
182	};  
183	
184	var touchend = function(event) {  
185		scrollPosOnEnd = $(document).scrollTop();
186		if (swipeDistAbs + 10 > yDistAbs && scrollPosOnTouch == scrollPosOnEnd) {
187			if (swipeDistance <= -swipeThreshold) {
188				goToNextSlide(origPos);
189			} else if (swipeDistance >= swipeThreshold) {
190				goToPrevSlide(origPos);
191			} else { 
192				returnToCurrentSlide(origPos);
193			}
194		} else {
195			if ($('.gallery-inner').position().left == origPos) {
196				// do nothing
197			} else {
198			returnToCurrentSlide(origPos);
199			}
200		}
201		touchcancel(event);
202	};  
203	 
204	var touchcancel = function(event) {  
205		swipeDistance = 0;
206		yDistance = 0;
207		swipeDistAbs = 0;
208		yDistAbs = 0;
209	};  
210	 
211	$('.gallery-inner')
212		.bind('touchstart', touchstart)
213		.bind('touchmove', touchmove)
214		.bind('touchend', touchend)
215		.bind('touchcancel', touchcancel);  	
216}
217// END TOUCH EVENTS 
218 
219// SLIDE EFFECT NAVIGATION
220$(document).on('click', '.gallery-rotate .indicator', function() {
221	var slideNumberClicked = $(this).attr('id');
222	slideNumberClicked = slideNumberClicked.split('indicate-');
223	slideNumberClicked = parseInt(slideNumberClicked[1]);
224	var activeSlide = $('.slide.active').attr('id');
225	if (activeSlide != undefined) {
226		var slideNum = activeSlide.split('slide');
227		slideNum = parseInt(slideNum[1]) + 1;
228		var difference = slideNumberClicked - slideNum;
229		if (difference != undefined && difference != 0) {
230			$('.active').removeClass('active');
231			jumpToSpecificSlide(difference);
232			clearTimeout(rotate);
233			runRotateSlides();
234		}
235	}
236	return false;
237});
238
239$(document).on('click', '.gallery-rotate .gallery-nav .next', function() {
240	$('.active').removeClass('active');
241	goToNextSlide();
242	clearTimeout(rotate);
243	runRotateSlides();
244	return false;
245});
246
247$(document).on('click', '.gallery-rotate .gallery-nav .prev', function() {
248	$('.active').removeClass('active');
249	goToPrevSlide();
250	clearTimeout(rotate);
251	runRotateSlides();
252	return false;
253});
254
255function goToPrevSlide() {
256	newPos = 0;	
257 	$('.gallery-inner').animate({
258 		left: newPos + '%'
259 	}, function() {
260		prevSlide();
261	});
262}
263
264function goToNextSlide() {
265	newPos = - 100 * 2;		
266 	$('.gallery-inner').animate({
267 		left: newPos + '%'
268 	}, function() {
269		nextSlide();
270 	});
271}
272 
273function nextSlide() {
274	newPos = -100;
275 	$('.gallery-inner').css('left', newPos + '%');
276 	
277 	var firstItem = $('.slide').first();
278 	firstItem.remove();
279 	$('.gallery-inner').append(firstItem);
280 	
281 	$('.slide').each(function(e) {
282 		if(e == 1) {
283 			$(this).addClass('active');
284 		}
285 	});
286 	updateIndicator();
287 	resizeGallery();
288}
289 
290function prevSlide() {
291 	newPos = -100; 
292 	$('.gallery-inner').css('left', newPos + '%');
293 	
294 	var lastItem = $('.slide').last();
295 	lastItem.remove();
296 	$('.gallery-inner').prepend(lastItem);
297 
298 	$('.slide').each(function(e) {
299 		if (e == 1) {
300 			$(this).addClass('active');				
301 		}
302 	});
303 	updateIndicator();
304 	resizeGallery();
305}
306 
307function jumpToSpecificSlide(slidesToMove) {
308 	if (slidesToMove != undefined && slidesToMove > 0) {
309 		if (slidesToMove > 1) { 
310 			for (i = 0; i < slidesToMove; i++) {
311 				var firstItem = $('.slide').first();
312 				firstItem.remove();
313 				$('.gallery-inner').append(firstItem);
314 			}
315 			newPos = - 100 * (slidesToMove + 1);
316 			$('.gallery-inner').animate({
317 				left: newPos + '%'
318 			}, 200, function() {
319 				newSlide(slidesToMove);
320 			});
321 		} else {
322 			goToNextSlide();
323 		}
324 	} else if (slidesToMove != undefined && slidesToMove < 0) {
325 		if (slidesToMove < -1) {
326 			for (i = 0; i > slidesToMove; i--) {
327 				var lastItem = $('.slide').last();
328 				lastItem.remove();
329 				$('.gallery-inner').prepend(lastItem);
330 			}
331 			newPos = 0;
332 			$('.gallery-inner').animate({
333 				left: newPos + '%'
334 			}, 200, function() {
335 				newSlide(slidesToMove);
336 			});
337 		} else {
338 			goToPrevSlide();
339 		}
340 	}
341}
342 			
343function newSlide(slidesToMove) {
344 	newPos = -100;
345 	$('.gallery-inner').css('left', newPos + '%');
346 
347 	$('.slide').each(function(e) {
348 		if(e == 1) {
349 			$(this).addClass('active');
350 		}
351 	});
352 	updateIndicator();
353 	resizeGallery();
354}
355 			
356function returnToCurrentSlide(position) {
357 	$('.gallery-inner').animate({
358 		left: position + '%'
359 	}, function() {
360 		$('.slide').each(function(e) {
361 			if(e == 1) {
362 				$(this).addClass('active');
363 			}
364 		});
365 		updateIndicator();
366 	});
367}
368// END SLIDE EFFECT NAVIGATION
369 
370// FADE EFFECT NAVIGATION
371$(document).on('click', '.gallery-fade .indicator', function() {
372	var slideNumberClicked = $(this).attr('id');
373	slideNumberClicked = slideNumberClicked.split('indicate-');
374	slideNumberClicked = parseInt(slideNumberClicked[1]);
375 	$('.active').removeClass('active');
376	$('.gallery .slide:nth-child(' + slideNumberClicked + ')').addClass('active');
377	updateIndicator();
378	clearTimeout(rotate);
379	runRotateSlides();
380	return false;
381});
382
383$(document).on('click', '.gallery-fade .gallery-nav .next', function() {
384	fadeNextSlide();
385	clearTimeout(rotate);
386	runRotateSlides();
387	return false;
388});
389
390$(document).on('click', '.gallery-fade .gallery-nav .prev', function() {
391	var active = $('.gallery .active');
392	if (active.is(':first-child')) {
393		$('.active').removeClass('active');
394		$('.gallery .slide:last-child').addClass('active');
395	} else {
396		$('.active').removeClass('active');
397		active.prev().addClass('active');
398	}
399	updateIndicator();
400	clearTimeout(rotate);
401	runRotateSlides();
402	return false;
403});
404
405function fadeNextSlide() {
406	var active = $('.gallery .active');
407	if (active.is(':last-child')) {
408		$('.active').removeClass('active');
409		$('.gallery .slide:first-child').addClass('active');
410	} else {
411		$('.active').removeClass('active');
412		active.next().addClass('active');
413	}
414	updateIndicator();
415}
416// END FADE EFFECT NAVIGATION
417
418
419// AUTO ROTATE
420function rotateSlides() {
421	if (effectRotate) {
422		$('.active').removeClass('active');
423		goToNextSlide();
424	} else {
425		fadeNextSlide();
426	}
427}
428 
429function runRotateSlides() {
430	if (autoRotate) {
431 		rotate = setInterval('rotateSlides()', autoRotateSeconds * 1000);
432 	} else {
433 		// Do nothing
434 	}
435}
436// END AUTO ROTATE
437
438 
439function updateIndicator() {
440 	var activeSlide = $('.slide.active').attr('id');
441 	var slideNum = activeSlide.split('slide');
442 	slideNum = parseInt(slideNum[1]) + 1;
443 	$('#indicate-' + slideNum).addClass('active');
444}
445 
446function resizeGallery() {
447 	var activeHeight = $('.active').height();
448 	$('.gallery').animate({
449 		height: activeHeight
450 	});
451}
452
453if ($('.gallery-inner').length > 0) {
454	gallerySetup();
455	$('#slide0 .gallery-header span').wrap('<h1></h1>');
456}

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.