PageSourceSearch

https://www.yadashi.com/x_js/x_slides.js

js yadashi.com collected 2026-10-08 20:48:09 UTC 10,113 bytes, 370 lines download raw bytes

1$(function() {
2	$.fn.slides = function(option) {
3		option = $.extend({},
4		$.fn.slides.option, option);
5		return this.each(function() {
6			$('.' + option.container, $(this)).children().wrapAll('<div class="slides_control"/>');
7			var elem = $(this),
8			control = $('.slides_control', elem),
9			total = control.children().size(),
10			width = control.children().outerWidth(),
11			height = control.children().outerHeight(),
12			start = option.start - 1,
13			effect = option.effect.indexOf(',') < 0 ? option.effect: option.effect.replace(' ', '').split(',')[0],
14			paginationEffect = option.effect.indexOf(',') < 0 ? effect: option.effect.replace(' ', '').split(',')[1],
15			next = 0,
16			prev = 0,
17			number = 0,
18			current = 0,
19			loaded,
20			active,
21			clicked,
22			position,
23			direction;
24			if (total < 2) {
25				return;
26			}
27			if (start < 0) {
28				start = 0;
29			};
30			if (start > total) {
31				start = total - 1;
32			};
33			if (option.start) {
34				current = start;
35			};
36			if (option.randomize) {
37				control.randomize();
38			}
39			$('.' + option.container, elem).css({
40				overflow: 'hidden',
41				position: 'relative'
42			});
43			control.css({
44				position: 'relative',
45				width: (width * 3),
46				height: height,
47				left: -width
48			});
49			control.children().css({
50				position: 'absolute',
51				top: 0,
52				left: width,
53				zIndex: 0,
54				display: 'none'
55			});
56			if (option.autoHeight) {
57				control.animate({
58					height: control.children(':eq(' + start + ')').outerHeight()
59				},
60				option.autoHeightSpeed);
61			}
62			if (option.preload && control.children()[0].tagName == 'IMG') {
63				elem.css({
64					background: 'url(' + option.preloadImage + ') no-repeat 50% 50%'
65				});
66				var img = $('img:eq(' + start + ')', elem).attr('src') + '?' + (new Date()).getTime();
67				$('img:eq(' + start + ')', elem).attr('src', img).load(function() {
68					$(this).fadeIn(option.fadeSpeed,
69					function() {
70						$(this).css({
71							zIndex: 5
72						});
73						elem.css({
74							background: ''
75						});
76						loaded = true;
77					});
78				});
79			} else {
80				control.children(':eq(' + start + ')').fadeIn(option.fadeSpeed,
81				function() {
82					loaded = true;
83				});
84			}
85			if (option.bigTarget) {
86				control.children().css({
87					cursor: 'pointer'
88				});
89				control.children().click(function() {
90					animate('next', effect);
91					return false;
92				});
93			}
94			if (option.hoverPause && option.play) {
95				control.children().bind('mouseover',
96				function() {
97					stop();
98				});
99				control.children().bind('mouseleave',
100				function() {
101					pause();
102				});
103			}
104			if (option.generateNextPrev) {
105				$('.' + option.container, elem).after('<a href="#" class="' + option.prev + '">Prev</a>');
106				$('.' + option.prev, elem).after('<a href="#" class="' + option.next + '">Next</a>');
107			}
108			$('.' + option.next, elem).click(function(e) {
109				e.preventDefault();
110				if (option.play) {
111					pause();
112				};
113				animate('next', effect);
114			});
115			$('.' + option.prev, elem).click(function(e) {
116				e.preventDefault();
117				if (option.play) {
118					pause();
119				};
120				animate('prev', effect);
121			});
122			if (option.generatePagination) {
123				elem.append('<ul class=' + option.paginationClass + '></ul>');
124				control.children().each(function() {
125					$('.' + option.paginationClass, elem).append('<li><a href="#' + number + '">' + (number + 1) + '</a></li>');
126					number++;
127				});
128			} else {
129				$('.' + option.paginationClass + ' li a', elem).each(function() {
130					$(this).attr('href', '#' + number);
131					number++;
132				});
133			}
134			$('.' + option.paginationClass + ' li a[href=#' + start + ']', elem).parent().addClass('current');
135			$('.' + option.paginationClass + ' li a', elem).click(function() {
136				if (option.play) {
137					pause();
138				};
139				clicked = $(this).attr('href').replace('#', '');
140				if (current != clicked) {
141					animate('pagination', paginationEffect, clicked);
142				}
143				return false;
144			});
145			$('a.link', elem).click(function() {
146				if (option.play) {
147					pause();
148				};
149				clicked = $(this).attr('href').replace('#', '') - 1;
150				if (current != clicked) {
151					animate('pagination', paginationEffect, clicked);
152				}
153				return false;
154			});
155			if (option.play) {
156				playInterval = setInterval(function() {
157					animate('next', effect);
158				},
159				option.play);
160				elem.data('interval', playInterval);
161			};
162			function stop() {
163				clearInterval(elem.data('interval'));
164			};
165			function pause() {
166				if (option.pause) {
167					clearTimeout(elem.data('pause'));
168					clearInterval(elem.data('interval'));
169					pauseTimeout = setTimeout(function() {
170						clearTimeout(elem.data('pause'));
171						playInterval = setInterval(function() {
172							animate("next", effect);
173						},
174						option.play);
175						elem.data('interval', playInterval);
176					},
177					option.pause);
178					elem.data('pause', pauseTimeout);
179				} else {
180					stop();
181				}
182			};
183			function animate(direction, effect, clicked) {
184				if (!active && loaded) {
185					active = true;
186					switch (direction) {
187					case 'next':
188						prev = current;
189						next = current + 1;
190						next = total === next ? 0 : next;
191						position = width * 2;
192						direction = -width * 2;
193						current = next;
194						break;
195					case 'prev':
196						prev = current;
197						next = current - 1;
198						next = next === -1 ? total - 1 : next;
199						position = 0;
200						direction = 0;
201						current = next;
202						break;
203					case 'pagination':
204						next = parseInt(clicked, 10);
205						prev = $('.' + option.paginationClass + ' li.current a', elem).attr('href').replace('#', '');
206						if (next > prev) {
207							position = width * 2;
208							direction = -width * 2;
209						} else {
210							position = 0;
211							direction = 0;
212						}
213						current = next;
214						break;
215					}
216					if (effect === 'fade') {
217						option.animationStart();
218						if (option.crossfade) {
219							control.children(':eq(' + next + ')', elem).css({
220								zIndex: 10
221							}).fadeIn(option.fadeSpeed,
222							function() {
223								control.children(':eq(' + prev + ')', elem).css({
224									display: 'none',
225									zIndex: 0
226								});
227								$(this).css({
228									zIndex: 0
229								});
230								option.animationComplete(next + 1);
231								active = false;
232							});
233						} else {
234							option.animationStart();
235							control.children(':eq(' + prev + ')', elem).fadeOut(option.fadeSpeed,
236							function() {
237								if (option.autoHeight) {
238									control.animate({
239										height: control.children(':eq(' + next + ')', elem).outerHeight()
240									},
241									option.autoHeightSpeed,
242									function() {
243										control.children(':eq(' + next + ')', elem).fadeIn(option.fadeSpeed);
244									});
245								} else {
246									control.children(':eq(' + next + ')', elem).fadeIn(option.fadeSpeed,
247									function() {
248										if ($.browser.msie) {
249											$(this).get(0).style.removeAttribute('filter');
250										}
251									});
252								}
253								option.animationComplete(next + 1);
254								active = false;
255							});
256						}
257					} else {
258						control.children(':eq(' + next + ')').css({
259							left: position,
260							display: 'block'
261						});
262						if (option.autoHeight) {
263							option.animationStart();
264							control.animate({
265								left: direction,
266								height: control.children(':eq(' + next + ')').outerHeight()
267							},
268							option.slideSpeed,
269							function() {
270								control.css({
271									left: -width
272								});
273								control.children(':eq(' + next + ')').css({
274									left: width,
275									zIndex: 5
276								});
277								control.children(':eq(' + prev + ')').css({
278									left: width,
279									display: 'none',
280									zIndex: 0
281								});
282								option.animationComplete(next + 1);
283								active = false;
284							});
285						} else {
286							option.animationStart();
287							control.animate({
288								left: direction
289							},
290							option.slideSpeed,
291							function() {
292								control.css({
293									left: -width
294								});
295								control.children(':eq(' + next + ')').css({
296									left: width,
297									zIndex: 5
298								});
299								control.children(':eq(' + prev + ')').css({
300									left: width,
301									display: 'none',
302									zIndex: 0
303								});
304								option.animationComplete(next + 1);
305								active = false;
306							});
307						}
308					}
309					if (option.pagination) {
310						$('.' + option.paginationClass + ' li.current', elem).removeClass('current');
311						$('.' + option.paginationClass + ' li a[href=#' + next + ']', elem).parent().addClass('current');
312					}
313				}
314			};
315		});
316	};
317	$.fn.slides.option = {
318		preload: false,
319		preloadImage: '/x_images/loading.gif',
320		container: 'slides_container',
321		generateNextPrev: false,
322		next: 'next',
323		prev: 'prev',
324		pagination: true,
325		generatePagination: true,
326		paginationClass: 'pagination',
327		fadeSpeed: 350,
328		slideSpeed: 350,
329		start: 1,
330		effect: 'slide',
331		crossfade: false,
332		randomize: false,
333		play: 0,
334		pause: 0,
335		hoverPause: false,
336		autoHeight: false,
337		autoHeightSpeed: 350,
338		bigTarget: false,
339		animationStart: function() {},
340		animationComplete: function() {}
341	};
342	$.fn.randomize = function(callback) {
343		function randomizeOrder() {
344			return (Math.round(Math.random()) - 0.5);
345		}
346		return ($(this).each(function() {
347			var $this = $(this);
348			var $children = $this.children();
349			var childCount = $children.length;
350			if (childCount > 1) {
351				$children.hide();
352				var indices = [];
353				for (i = 0; i < childCount; i++) {
354					indices[indices.length] = i;
355				}
356				indices = indices.sort(randomizeOrder);
357				$.each(indices,
358				function(j, k) {
359					var $child = $children.eq(k);
360					var $clone = $child.clone(true);
361					$clone.show().appendTo($this);
362					if (callback !== undefined) {
363						callback($child, $clone);
364					}
365					$child.remove();
366				});
367			}
368		}));
369	};
370});

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.