PageSourceSearch

https://www.bsmpg.com/Portals/52884/js/jquery.cycle.js

js bsmpg.com collected 2026-09-24 10:03:23 UTC 29,980 bytes, 846 lines download raw bytes

1/*!
2 * jQuery Cycle Plugin (with Transition Definitions)
3 * Examples and documentation at: http://jquery.malsup.com/cycle/
4 * Copyright (c) 2007-2009 M. Alsup
5 * Version: 2.73 (04-NOV-2009)
6 * Dual licensed under the MIT and GPL licenses:
7 * http://www.opensource.org/licenses/mit-license.php
8 * http://www.gnu.org/licenses/gpl.html
9 * Requires: jQuery v1.2.6 or later
10 *
11 * Originally based on the work of:
12 *	1) Matt Oakes
13 *	2) Torsten Baldes (http://medienfreunde.com/lab/innerfade/)
14 *	3) Benjamin Sterling (http://www.benjaminsterling.com/experiments/jqShuffle/)
15 */
16;(function($) {
17
18var ver = '2.73';
19
20// if $.support is not defined (pre jQuery 1.3) add what I need
21if ($.support == undefined) {
22	$.support = {
23		opacity: !($.browser.msie)
24	};
25}
26
27function debug(s) {
28	if ($.fn.cycle.debug)
29		log(s);
30}		
31function log() {
32	if (window.console && window.console.log)
33		window.console.log('[cycle] ' + Array.prototype.join.call(arguments,' '));
34	//$('body').append('<div>'+Array.prototype.join.call(arguments,' ')+'</div>');
35};
36
37// the options arg can be...
38//   a number  - indicates an immediate transition should occur to the given slide index
39//   a string  - 'stop', 'pause', 'resume', or the name of a transition effect (ie, 'fade', 'zoom', etc)
40//   an object - properties to control the slideshow
41//
42// the arg2 arg can be...
43//   the name of an fx (only used in conjunction with a numeric value for 'options')
44//   the value true (only used in conjunction with a options == 'resume') and indicates
45//	 that the resume should occur immediately (not wait for next timeout)
46
47$.fn.cycle = function(options, arg2) {
48	var o = { s: this.selector, c: this.context };
49
50	// in 1.3+ we can fix mistakes with the ready state
51	if (this.length === 0 && options != 'stop') {
52		if (!$.isReady && o.s) {
53			log('DOM not ready, queuing slideshow');
54			$(function() {
55				$(o.s,o.c).cycle(options,arg2);
56			});
57			return this;
58		}
59		// is your DOM ready?  http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
60		log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
61		return this;
62	}
63
64	// iterate the matched nodeset
65	return this.each(function() {
66		var opts = handleArguments(this, options, arg2);
67		if (opts === false)
68			return;
69
70		// stop existing slideshow for this container (if there is one)
71		if (this.cycleTimeout)
72			clearTimeout(this.cycleTimeout);
73		this.cycleTimeout = this.cyclePause = 0;
74
75		var $cont = $(this);
76		var $slides = opts.slideExpr ? $(opts.slideExpr, this) : $cont.children();
77		var els = $slides.get();
78		if (els.length < 2) {
79			log('terminating; too few slides: ' + els.length);
80			return;
81		}
82
83		var opts2 = buildOptions($cont, $slides, els, opts, o);
84		if (opts2 === false)
85			return;
86
87		var startTime = opts2.continuous ? 10 : getTimeout(opts2.currSlide, opts2.nextSlide, opts2, !opts2.rev);
88
89		// if it's an auto slideshow, kick it off
90		if (startTime) {
91			startTime += (opts2.delay || 0);
92			if (startTime < 10)
93				startTime = 10;
94			debug('first timeout: ' + startTime);
95			this.cycleTimeout = setTimeout(function(){go(els,opts2,0,!opts2.rev)}, startTime);
96		}
97	});
98};
99
100// process the args that were passed to the plugin fn
101function handleArguments(cont, options, arg2) {
102	if (cont.cycleStop == undefined)
103		cont.cycleStop = 0;
104	if (options === undefined || options === null)
105		options = {};
106	if (options.constructor == String) {
107		switch(options) {
108		case 'stop':
109			cont.cycleStop++; // callbacks look for change
110			if (cont.cycleTimeout)
111				clearTimeout(cont.cycleTimeout);
112			cont.cycleTimeout = 0;
113			$(cont).removeData('cycle.opts');
114			return false;
115		case 'pause':
116			cont.cyclePause = 1;
117			return false;
118		case 'resume':
119			cont.cyclePause = 0;
120			if (arg2 === true) { // resume now!
121				options = $(cont).data('cycle.opts');
122				if (!options) {
123					log('options not found, can not resume');
124					return false;
125				}
126				if (cont.cycleTimeout) {
127					clearTimeout(cont.cycleTimeout);
128					cont.cycleTimeout = 0;
129				}
130				go(options.elements, options, 1, 1);
131			}
132			return false;
133		case 'prev':
134		case 'next':
135			var opts = $(cont).data('cycle.opts');
136			if (!opts) {
137				log('options not found, "prev/next" ignored');
138				return false;
139			}
140			$.fn.cycle[options](opts);
141			return false;
142		default:
143			options = { fx: options };
144		};
145		return options;
146	}
147	else if (options.constructor == Number) {
148		// go to the requested slide
149		var num = options;
150		options = $(cont).data('cycle.opts');
151		if (!options) {
152			log('options not found, can not advance slide');
153			return false;
154		}
155		if (num < 0 || num >= options.elements.length) {
156			log('invalid slide index: ' + num);
157			return false;
158		}
159		options.nextSlide = num;
160		if (cont.cycleTimeout) {
161			clearTimeout(cont.cycleTimeout);
162			cont.cycleTimeout = 0;
163		}
164		if (typeof arg2 == 'string')
165			options.oneTimeFx = arg2;
166		go(options.elements, options, 1, num >= options.currSlide);
167		return false;
168	}
169	return options;
170};
171
172function removeFilter(el, opts) {
173	if (!$.support.opacity && opts.cleartype && el.style.filter) {
174		try { el.style.removeAttribute('filter'); }
175		catch(smother) {} // handle old opera versions
176	}
177};
178
179// one-time initialization
180function buildOptions($cont, $slides, els, options, o) {
181	// support metadata plugin (v1.0 and v2.0)
182	var opts = $.extend({}, $.fn.cycle.defaults, options || {}, $.metadata ? $cont.metadata() : $.meta ? $cont.data() : {});
183	if (opts.autostop)
184		opts.countdown = opts.autostopCount || els.length;
185
186	var cont = $cont[0];
187	$cont.data('cycle.opts', opts);
188	opts.$cont = $cont;
189	opts.stopCount = cont.cycleStop;
190	opts.elements = els;
191	opts.before = opts.before ? [opts.before] : [];
192	opts.after = opts.after ? [opts.after] : [];
193	opts.after.unshift(function(){ opts.busy=0; });
194
195	// push some after callbacks
196	if (!$.support.opacity && opts.cleartype)
197		opts.after.push(function() { removeFilter(this, opts); });
198	if (opts.continuous)
199		opts.after.push(function() { go(els,opts,0,!opts.rev); });
200
201	saveOriginalOpts(opts);
202
203	// clearType corrections
204	if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
205		clearTypeFix($slides);
206
207	// container requires non-static position so that slides can be position within
208	if ($cont.css('position') == 'static')
209		$cont.css('position', 'relative');
210	if (opts.width)
211		$cont.width(opts.width);
212	if (opts.height && opts.height != 'auto')
213		$cont.height(opts.height);
214
215	if (opts.startingSlide)
216		opts.startingSlide = parseInt(opts.startingSlide);
217
218	// if random, mix up the slide array
219	if (opts.random) {
220		opts.randomMap = [];
221		for (var i = 0; i < els.length; i++)
222			opts.randomMap.push(i);
223		opts.randomMap.sort(function(a,b) {return Math.random() - 0.5;});
224		opts.randomIndex = 0;
225		opts.startingSlide = opts.randomMap[0];
226	}
227	else if (opts.startingSlide >= els.length)
228		opts.startingSlide = 0; // catch bogus input
229	opts.currSlide = opts.startingSlide = opts.startingSlide || 0;
230	var first = opts.startingSlide;
231
232	// set position and zIndex on all the slides
233	$slides.css({position: 'absolute', top:0, left:0}).hide().each(function(i) {
234		var z = first ? i >= first ? els.length - (i-first) : first-i : els.length-i;
235		$(this).css('z-index', z)
236	});
237
238	// make sure first slide is visible
239	$(els[first]).css('opacity',1).show(); // opacity bit needed to handle restart use case
240	removeFilter(els[first], opts);
241
242	// stretch slides
243	if (opts.fit && opts.width)
244		$slides.width(opts.width);
245	if (opts.fit && opts.height && opts.height != 'auto')
246		$slides.height(opts.height);
247
248	// stretch container
249	var reshape = opts.containerResize && !$cont.innerHeight();
250	if (reshape) { // do this only if container has no size http://tinyurl.com/da2oa9
251		var maxw = 0, maxh = 0;
252		for(var j=0; j < els.length; j++) {
253			var $e = $(els[j]), e = $e[0], w = $e.outerWidth(), h = $e.outerHeight();
254			if (!w) w = e.offsetWidth;
255			if (!h) h = e.offsetHeight;
256			maxw = w > maxw ? w : maxw;
257			maxh = h > maxh ? h : maxh;
258		}
259		if (maxw > 0 && maxh > 0)
260			$cont.css({width:maxw+'px',height:maxh+'px'});
261	}
262
263	if (opts.pause)
264		$cont.hover(function(){this.cyclePause++;},function(){this.cyclePause--;});
265
266	if (supportMultiTransitions(opts) === false)
267		return false;
268
269	// apparently a lot of people use image slideshows without height/width attributes on the images.
270	// Cycle 2.50+ requires the sizing info for every slide; this block tries to deal with that.
271	var requeue = false;
272	options.requeueAttempts = options.requeueAttempts || 0;
273	$slides.each(function() {
274		// try to get height/width of each slide
275		var $el = $(this);
276		this.cycleH = (opts.fit && opts.height) ? opts.height : $el.height();
277		this.cycleW = (opts.fit && opts.width) ? opts.width : $el.width();
278
279		if ( $el.is('img') ) {
280			// sigh..  sniffing, hacking, shrugging...  this crappy hack tries to account for what browsers do when
281			// an image is being downloaded and the markup did not include sizing info (height/width attributes);
282			// there seems to be some "default" sizes used in this situation
283			var loadingIE	= ($.browser.msie  && this.cycleW == 28 && this.cycleH == 30 && !this.complete);
284			var loadingFF	= ($.browser.mozilla && this.cycleW == 34 && this.cycleH == 19 && !this.complete);
285			var loadingOp	= ($.browser.opera && ((this.cycleW == 42 && this.cycleH == 19) || (this.cycleW == 37 && this.cycleH == 17)) && !this.complete);
286			var loadingOther = (this.cycleH == 0 && this.cycleW == 0 && !this.complete);
287			// don't requeue for images that are still loading but have a valid size
288			if (loadingIE || loadingFF || loadingOp || loadingOther) {
289				if (o.s && opts.requeueOnImageNotLoaded && ++options.requeueAttempts < 100) { // track retry count so we don't loop forever
290					log(options.requeueAttempts,' - img slide not loaded, requeuing slideshow: ', this.src, this.cycleW, this.cycleH);
291					setTimeout(function() {$(o.s,o.c).cycle(options)}, opts.requeueTimeout);
292					requeue = true;
293					return false; // break each loop
294				}
295				else {
296					log('could not determine size of image: '+this.src, this.cycleW, this.cycleH);
297				}
298			}
299		}
300		return true;
301	});
302
303	if (requeue)
304		return false;
305
306	opts.cssBefore = opts.cssBefore || {};
307	opts.animIn = opts.animIn || {};
308	opts.animOut = opts.animOut || {};
309
310	$slides.not(':eq('+first+')').css(opts.cssBefore);
311	if (opts.cssFirst)
312		$($slides[first]).css(opts.cssFirst);
313
314	if (opts.timeout) {
315		opts.timeout = parseInt(opts.timeout);
316		// ensure that timeout and speed settings are sane
317		if (opts.speed.constructor == String)
318			opts.speed = $.fx.speeds[opts.speed] || parseInt(opts.speed);
319		if (!opts.sync)
320			opts.speed = opts.speed / 2;
321		while((opts.timeout - opts.speed) < 250) // sanitize timeout
322			opts.timeout += opts.speed;
323	}
324	if (opts.easing)
325		opts.easeIn = opts.easeOut = opts.easing;
326	if (!opts.speedIn)
327		opts.speedIn = opts.speed;
328	if (!opts.speedOut)
329		opts.speedOut = opts.speed;
330
331	opts.slideCount = els.length;
332	opts.currSlide = opts.lastSlide = first;
333	if (opts.random) {
334		opts.nextSlide = opts.currSlide;
335		if (++opts.randomIndex == els.length)
336			opts.randomIndex = 0;
337		opts.nextSlide = opts.randomMap[opts.randomIndex];
338	}
339	else
340		opts.nextSlide = opts.startingSlide >= (els.length-1) ? 0 : opts.startingSlide+1;
341
342	// run transition init fn
343	if (!opts.multiFx) {
344		var init = $.fn.cycle.transitions[opts.fx];
345		if ($.isFunction(init))
346			init($cont, $slides, opts);
347		else if (opts.fx != 'custom' && !opts.multiFx) {
348			log('unknown transition: ' + opts.fx,'; slideshow terminating');
349			return false;
350		}
351	}
352
353	// fire artificial events
354	var e0 = $slides[first];
355	if (opts.before.length)
356		opts.before[0].apply(e0, [e0, e0, opts, true]);
357	if (opts.after.length > 1)
358		opts.after[1].apply(e0, [e0, e0, opts, true]);
359
360	if (opts.next)
361		$(opts.next).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?-1:1)});
362	if (opts.prev)
363		$(opts.prev).bind(opts.prevNextEvent,function(){return advance(opts,opts.rev?1:-1)});
364	if (opts.pager)
365		buildPager(els,opts);
366
367	exposeAddSlide(opts, els);
368
369	return opts;
370};
371
372// save off original opts so we can restore after clearing state
373function saveOriginalOpts(opts) {
374	opts.original = { before: [], after: [] };
375	opts.original.cssBefore = $.extend({}, opts.cssBefore);
376	opts.original.cssAfter  = $.extend({}, opts.cssAfter);
377	opts.original.animIn	= $.extend({}, opts.animIn);
378	opts.original.animOut   = $.extend({}, opts.animOut);
379	$.each(opts.before, function() { opts.original.before.push(this); });
380	$.each(opts.after,  function() { opts.original.after.push(this); });
381};
382
383function supportMultiTransitions(opts) {
384	var i, tx, txs = $.fn.cycle.transitions;
385	// look for multiple effects
386	if (opts.fx.indexOf(',') > 0) {
387		opts.multiFx = true;
388		opts.fxs = opts.fx.replace(/\s*/g,'').split(',');
389		// discard any bogus effect names
390		for (i=0; i < opts.fxs.length; i++) {
391			var fx = opts.fxs[i];
392			tx = txs[fx];
393			if (!tx || !txs.hasOwnProperty(fx) || !$.isFunction(tx)) {
394				log('discarding unknown transition: ',fx);
395				opts.fxs.splice(i,1);
396				i--;
397			}
398		}
399		// if we have an empty list then we threw everything away!
400		if (!opts.fxs.length) {
401			log('No valid transitions named; slideshow terminating.');
402			return false;
403		}
404	}
405	else if (opts.fx == 'all') {  // auto-gen the list of transitions
406		opts.multiFx = true;
407		opts.fxs = [];
408		for (p in txs) {
409			tx = txs[p];
410			if (txs.hasOwnProperty(p) && $.isFunction(tx))
411				opts.fxs.push(p);
412		}
413	}
414	if (opts.multiFx && opts.randomizeEffects) {
415		// munge the fxs array to make effect selection random
416		var r1 = Math.floor(Math.random() * 20) + 30;
417		for (i = 0; i < r1; i++) {
418			var r2 = Math.floor(Math.random() * opts.fxs.length);
419			opts.fxs.push(opts.fxs.splice(r2,1)[0]);
420		}
421		debug('randomized fx sequence: ',opts.fxs);
422	}
423	return true;
424};
425
426// provide a mechanism for adding slides after the slideshow has started
427function exposeAddSlide(opts, els) {
428	opts.addSlide = function(newSlide, prepend) {
429		var $s = $(newSlide), s = $s[0];
430		if (!opts.autostopCount)
431			opts.countdown++;
432		els[prepend?'unshift':'push'](s);
433		if (opts.els)
434			opts.els[prepend?'unshift':'push'](s); // shuffle needs this
435		opts.slideCount = els.length;
436
437		$s.css('position','absolute');
438		$s[prepend?'prependTo':'appendTo'](opts.$cont);
439
440		if (prepend) {
441			opts.currSlide++;
442			opts.nextSlide++;
443		}
444
445		if (!$.support.opacity && opts.cleartype && !opts.cleartypeNoBg)
446			clearTypeFix($s);
447
448		if (opts.fit && opts.width)
449			$s.width(opts.width);
450		if (opts.fit && opts.height && opts.height != 'auto')
451			$slides.height(opts.height);
452		s.cycleH = (opts.fit && opts.height) ? opts.height : $s.height();
453		s.cycleW = (opts.fit && opts.width) ? opts.width : $s.width();
454
455		$s.css(opts.cssBefore);
456
457		if (opts.pager)
458			$.fn.cycle.createPagerAnchor(els.length-1, s, $(opts.pager), els, opts);
459
460		if ($.isFunction(opts.onAddSlide))
461			opts.onAddSlide($s);
462		else
463			$s.hide(); // default behavior
464	};
465}
466
467// reset internal state; we do this on every pass in order to support multiple effects
468$.fn.cycle.resetState = function(opts, fx) {
469	fx = fx || opts.fx;
470	opts.before = []; opts.after = [];
471	opts.cssBefore = $.extend({}, opts.original.cssBefore);
472	opts.cssAfter  = $.extend({}, opts.original.cssAfter);
473	opts.animIn	= $.extend({}, opts.original.animIn);
474	opts.animOut   = $.extend({}, opts.original.animOut);
475	opts.fxFn = null;
476	$.each(opts.original.before, function() { opts.before.push(this); });
477	$.each(opts.original.after,  function() { opts.after.push(this); });
478
479	// re-init
480	var init = $.fn.cycle.transitions[fx];
481	if ($.isFunction(init))
482		init(opts.$cont, $(opts.elements), opts);
483};
484
485// this is the main engine fn, it handles the timeouts, callbacks and slide index mgmt
486function go(els, opts, manual, fwd) {
487	// opts.busy is true if we're in the middle of an animation
488	if (manual && opts.busy && opts.manualTrump) {
489		// let manual transitions requests trump active ones
490		$(els).stop(true,true);
491		opts.busy = false;
492	}
493	// don't begin another timeout-based transition if there is one active
494	if (opts.busy)
495		return;
496
497	var p = opts.$cont[0], curr = els[opts.currSlide], next = els[opts.nextSlide];
498
499	// stop cycling if we have an outstanding stop request
500	if (p.cycleStop != opts.stopCount || p.cycleTimeout === 0 && !manual)
501		return;
502
503	// check to see if we should stop cycling based on autostop options
504	if (!manual && !p.cyclePause &&
505		((opts.autostop && (--opts.countdown <= 0)) ||
506		(opts.nowrap && !opts.random && opts.nextSlide < opts.currSlide))) {
507		if (opts.end)
508			opts.end(opts);
509		return;
510	}
511
512	// if slideshow is paused, only transition on a manual trigger
513	if (manual || !p.cyclePause) {
514		var fx = opts.fx;
515		// keep trying to get the slide size if we don't have it yet
516		curr.cycleH = curr.cycleH || $(curr).height();
517		curr.cycleW = curr.cycleW || $(curr).width();
518		next.cycleH = next.cycleH || $(next).height();
519		next.cycleW = next.cycleW || $(next).width();
520
521		// support multiple transition types
522		if (opts.multiFx) {
523			if (opts.lastFx == undefined || ++opts.lastFx >= opts.fxs.length)
524				opts.lastFx = 0;
525			fx = opts.fxs[opts.lastFx];
526			opts.currFx = fx;
527		}
528
529		// one-time fx overrides apply to:  $('div').cycle(3,'zoom');
530		if (opts.oneTimeFx) {
531			fx = opts.oneTimeFx;
532			opts.oneTimeFx = null;
533		}
534
535		$.fn.cycle.resetState(opts, fx);
536
537		// run the before callbacks
538		if (opts.before.length)
539			$.each(opts.before, function(i,o) {
540				if (p.cycleStop != opts.stopCount) return;
541				o.apply(next, [curr, next, opts, fwd]);
542			});
543
544		// stage the after callacks
545		var after = function() {
546			$.each(opts.after, function(i,o) {
547				if (p.cycleStop != opts.stopCount) return;
548				o.apply(next, [curr, next, opts, fwd]);
549			});
550		};
551
552		if (opts.nextSlide != opts.currSlide) {
553			// get ready to perform the transition
554			opts.busy = 1;
555			if (opts.fxFn) // fx function provided?
556				opts.fxFn(curr, next, opts, after, fwd);
557			else if ($.isFunction($.fn.cycle[opts.fx])) // fx plugin ?
558				$.fn.cycle[opts.fx](curr, next, opts, after);
559			else
560				$.fn.cycle.custom(curr, next, opts, after, manual && opts.fastOnEvent);
561		}
562
563		// calculate the next slide
564		opts.lastSlide = opts.currSlide;
565		if (opts.random) {
566			opts.currSlide = opts.nextSlide;
567			if (++opts.randomIndex == els.length)
568				opts.randomIndex = 0;
569			opts.nextSlide = opts.randomMap[opts.randomIndex];
570		}
571		else { // sequence
572			var roll = (opts.nextSlide + 1) == els.length;
573			opts.nextSlide = roll ? 0 : opts.nextSlide+1;
574			opts.currSlide = roll ? els.length-1 : opts.nextSlide-1;
575		}
576
577		if (opts.pager)
578			$.fn.cycle.updateActivePagerLink(opts.pager, opts.currSlide);
579	}
580
581	// stage the next transtion
582	var ms = 0;
583	if (opts.timeout && !opts.continuous)
584		ms = getTimeout(curr, next, opts, fwd);
585	else if (opts.continuous && p.cyclePause) // continuous shows work off an after callback, not this timer logic
586		ms = 10;
587	if (ms > 0)
588		p.cycleTimeout = setTimeout(function(){ go(els, opts, 0, !opts.rev) }, ms);
589};
590
591// invoked after transition
592$.fn.cycle.updateActivePagerLink = function(pager, currSlide) {
593	$(pager).each(function() {
594		$(this).find('a').removeClass('activeSlide').filter('a:eq('+currSlide+')').addClass('activeSlide');
595	});
596};
597
598// calculate timeout value for current transition
599function getTimeout(curr, next, opts, fwd) {
600	if (opts.timeoutFn) {
601		// call user provided calc fn
602		var t = opts.timeoutFn(curr,next,opts,fwd);
603		while ((t - opts.speed) < 250) // sanitize timeout
604			t += opts.speed;
605		debug('calculated timeout: ' + t + '; speed: ' + opts.speed);
606		if (t !== false)
607			return t;
608	}
609	return opts.timeout;
610};
611
612// expose next/prev function, caller must pass in state
613$.fn.cycle.next = function(opts) { advance(opts, opts.rev?-1:1); };
614$.fn.cycle.prev = function(opts) { advance(opts, opts.rev?1:-1);};
615
616// advance slide forward or back
617function advance(opts, val) {
618	var els = opts.elements;
619	var p = opts.$cont[0], timeout = p.cycleTimeout;
620	if (timeout) {
621		clearTimeout(timeout);
622		p.cycleTimeout = 0;
623	}
624	if (opts.random && val < 0) {
625		// move back to the previously display slide
626		opts.randomIndex--;
627		if (--opts.randomIndex == -2)
628			opts.randomIndex = els.length-2;
629		else if (opts.randomIndex == -1)
630			opts.randomIndex = els.length-1;
631		opts.nextSlide = opts.randomMap[opts.randomIndex];
632	}
633	else if (opts.random) {
634		if (++opts.randomIndex == els.length)
635			opts.randomIndex = 0;
636		opts.nextSlide = opts.randomMap[opts.randomIndex];
637	}
638	else {
639		opts.nextSlide = opts.currSlide + val;
640		if (opts.nextSlide < 0) {
641			if (opts.nowrap) return false;
642			opts.nextSlide = els.length - 1;
643		}
644		else if (opts.nextSlide >= els.length) {
645			if (opts.nowrap) return false;
646			opts.nextSlide = 0;
647		}
648	}
649
650	if ($.isFunction(opts.prevNextClick))
651		opts.prevNextClick(val > 0, opts.nextSlide, els[opts.nextSlide]);
652	go(els, opts, 1, val>=0);
653	return false;
654};
655
656function buildPager(els, opts) {
657	var $p = $(opts.pager);
658	$.each(els, function(i,o) {
659		$.fn.cycle.createPagerAnchor(i,o,$p,els,opts);
660	});
661   $.fn.cycle.updateActivePagerLink(opts.pager, opts.startingSlide);
662};
663
664$.fn.cycle.createPagerAnchor = function(i, el, $p, els, opts) {
665	var a;
666	if ($.isFunction(opts.pagerAnchorBuilder))
667		a = opts.pagerAnchorBuilder(i,el);
668	else
669		a = '<a href="#">'+(i+1)+'</a>';
670		
671	if (!a)
672		return;
673	var $a = $(a);
674	// don't reparent if anchor is in the dom
675	if ($a.parents('body').length === 0) {
676		var arr = [];
677		if ($p.length > 1) {
678			$p.each(function() {
679				var $clone = $a.clone(true);
680				$(this).append($clone);
681				arr.push($clone[0]);
682			});
683			$a = $(arr);
684		}
685		else {
686			$a.appendTo($p);
687		}
688	}
689
690	$a.bind(opts.pagerEvent, function(e) {
691		e.preventDefault();
692		opts.nextSlide = i;
693		var p = opts.$cont[0], timeout = p.cycleTimeout;
694		if (timeout) {
695			clearTimeout(timeout);
696			p.cycleTimeout = 0;
697		}
698		if ($.isFunction(opts.pagerClick))
699			opts.pagerClick(opts.nextSlide, els[opts.nextSlide]);
700		go(els,opts,1,opts.currSlide < i); // trigger the trans
701		return false;
702	});
703	
704	if (opts.pagerEvent != 'click')
705		$a.click(function(){return false;}); // supress click
706	
707	if (opts.pauseOnPagerHover)
708		$a.hover(function() { opts.$cont[0].cyclePause++; }, function() { opts.$cont[0].cyclePause--; } );
709};
710
711// helper fn to calculate the number of slides between the current and the next
712$.fn.cycle.hopsFromLast = function(opts, fwd) {
713	var hops, l = opts.lastSlide, c = opts.currSlide;
714	if (fwd)
715		hops = c > l ? c - l : opts.slideCount - l;
716	else
717		hops = c < l ? l - c : l + opts.slideCount - c;
718	return hops;
719};
720
721// fix clearType problems in ie6 by setting an explicit bg color
722// (otherwise text slides look horrible during a fade transition)
723function clearTypeFix($slides) {
724	function hex(s) {
725		s = parseInt(s).toString(16);
726		return s.length < 2 ? '0'+s : s;
727	};
728	function getBg(e) {
729		for ( ; e && e.nodeName.toLowerCase() != 'html'; e = e.parentNode) {
730			var v = $.css(e,'background-color');
731			if (v.indexOf('rgb') >= 0 ) {
732				var rgb = v.match(/\d+/g);
733				return '#'+ hex(rgb[0]) + hex(rgb[1]) + hex(rgb[2]);
734			}
735			if (v && v != 'transparent')
736				return v;
737		}
738		return '#ffffff';
739	};
740//	$slides.each(function() { $(this).css('background-color', getBg(this)); });
741};
742
743// reset common props before the next transition
744$.fn.cycle.commonReset = function(curr,next,opts,w,h,rev) {
745	$(opts.elements).not(curr).hide();
746	opts.cssBefore.opacity = 1;
747	opts.cssBefore.display = 'block';
748	if (w !== false && next.cycleW > 0)
749		opts.cssBefore.width = next.cycleW;
750	if (h !== false && next.cycleH > 0)
751		opts.cssBefore.height = next.cycleH;
752	opts.cssAfter = opts.cssAfter || {};
753	opts.cssAfter.display = 'none';
754	$(curr).css('zIndex',opts.slideCount + (rev === true ? 1 : 0));
755	$(next).css('zIndex',opts.slideCount + (rev === true ? 0 : 1));
756};
757
758// the actual fn for effecting a transition
759$.fn.cycle.custom = function(curr, next, opts, cb, speedOverride) {
760	var $l = $(curr), $n = $(next);
761	var speedIn = opts.speedIn, speedOut = opts.speedOut, easeIn = opts.easeIn, easeOut = opts.easeOut;
762	$n.css(opts.cssBefore);
763	if (speedOverride) {
764		if (typeof speedOverride == 'number')
765			speedIn = speedOut = speedOverride;
766		else
767			speedIn = speedOut = 1;
768		easeIn = easeOut = null;
769	}
770	var fn = function() {$n.animate(opts.animIn, speedIn, easeIn, cb)};
771	$l.animate(opts.animOut, speedOut, easeOut, function() {
772		if (opts.cssAfter) $l.css(opts.cssAfter);
773		if (!opts.sync) fn();
774	});
775	if (opts.sync) fn();
776};
777
778// transition definitions - only fade is defined here, transition pack defines the rest
779$.fn.cycle.transitions = {
780	fade: function($cont, $slides, opts) {
781		$slides.not(':eq('+opts.currSlide+')').css('opacity',0);
782		opts.before.push(function(curr,next,opts) {
783			$.fn.cycle.commonReset(curr,next,opts);
784			opts.cssBefore.opacity = 0;
785		});
786		opts.animIn	   = { opacity: 1 };
787		opts.animOut   = { opacity: 0 };
788		opts.cssBefore = { top: 0, left: 0 };
789	}
790};
791
792$.fn.cycle.ver = function() { return ver; };
793
794// override these globally if you like (they are all optional)
795$.fn.cycle.defaults = {
796	fx:			  'fade', // name of transition effect (or comma separated names, ex: fade,scrollUp,shuffle)
797	timeout:	   4000,  // milliseconds between slide transitions (0 to disable auto advance)
798	timeoutFn:	 null,  // callback for determining per-slide timeout value:  function(currSlideElement, nextSlideElement, options, forwardFlag)
799	continuous:	   0,	  // true to start next transition immediately after current one completes
800	speed:		   1000,  // speed of the transition (any valid fx speed value)
801	speedIn:	   null,  // speed of the 'in' transition
802	speedOut:	   null,  // speed of the 'out' transition
803	next:		   null,  // selector for element to use as click trigger for next slide
804	prev:		   null,  // selector for element to use as click trigger for previous slide
805	prevNextClick: null,  // callback fn for prev/next clicks:	function(isNext, zeroBasedSlideIndex, slideElement)
806	prevNextEvent:'click',// event which drives the manual transition to the previous or next slide
807	pager:		   null,  // selector for element to use as pager container
808	pagerClick:	   null,  // callback fn for pager clicks:	function(zeroBasedSlideIndex, slideElement)
809	pagerEvent:	  'click', // name of event which drives the pager navigation
810	pagerAnchorBuilder: null, // callback fn for building anchor links:  function(index, DOMelement)
811	before:		   null,  // transition callback (scope set to element to be shown):	 function(currSlideElement, nextSlideElement, options, forwardFlag)
812	after:		   null,  // transition callback (scope set to element that was shown):  function(currSlideElement, nextSlideElement, options, forwardFlag)
813	end:		   null,  // callback invoked when the slideshow terminates (use with autostop or nowrap options): function(options)
814	easing:		   null,  // easing method for both in and out transitions
815	easeIn:		   null,  // easing for "in" transition
816	easeOut:	   null,  // easing for "out" transition
817	shuffle:	   null,  // coords for shuffle animation, ex: { top:15, left: 200 }
818	animIn:		   null,  // properties that define how the slide animates in
819	animOut:	   null,  // properties that define how the slide animates out
820	cssBefore:	   null,  // properties that define the initial state of the slide before transitioning in
821	cssAfter:	   null,  // properties that defined the state of the slide after transitioning out
822	fxFn:		   null,  // function used to control the transition: function(currSlideElement, nextSlideElement, options, afterCalback, forwardFlag)
823	height:		  'auto', // container height
824	startingSlide: 0,	  // zero-based index of the first slide to be displayed
825	sync:		   1,	  // true if in/out transitions should occur simultaneously
826	random:		   0,	  // true for random, false for sequence (not applicable to shuffle fx)
827	fit:		   0,	  // force slides to fit container
828	containerResize: 1,	  // resize container to fit largest slide
829	pause:		   0,	  // true to enable "pause on hover"
830	pauseOnPagerHover: 0, // true to pause when hovering over pager link
831	autostop:	   0,	  // true to end slideshow after X transitions (where X == slide count)
832	autostopCount: 0,	  // number of transitions (optionally used with autostop to define X)
833	delay:		   0,	  // additional delay (in ms) for first transition (hint: can be negative)
834	slideExpr:	   null,  // expression for selecting slides (if something other than all children is required)
835	cleartype:	   !$.support.opacity,  // true if clearType corrections should be applied (for IE)
836	cleartypeNoBg: false, // set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
837	nowrap:		   0,	  // true to prevent slideshow from wrapping
838	fastOnEvent:   0,	  // force fast transitions when triggered manually (via pager or prev/next); value == time in ms
839	randomizeEffects: 1,  // valid when multiple effects are used; true to make the effect sequence random
840	rev:		   0,	 // causes animations to transition in reverse
841	manualTrump:   true,  // causes manual transition to stop an active transition instead of being ignored
842	requeueOnImageNotLoaded: true, // requeue the slideshow if any image slides are not yet loaded
843	requeueTimeout: 250   // ms delay for requeue
844};
845
846})(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.