PageSourceSearch

https://www.goo-net.com/existing_https/common_v2/js/jquery.fancybox.js

js goo-net.com collected 2026-10-01 10:30:35 UTC 28,152 bytes, 1,155 lines download raw bytes

1/*
2 * FancyBox - jQuery Plugin
3 * Simple and fancy lightbox alternative
4 *
5 * Examples and documentation at: http://fancybox.net
6 *
7 * Copyright (c) 2008 - 2010 Janis Skarnelis
8 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
9 *
10 * Version: 1.3.4 (11/11/2010)
11 * Requires: jQuery v1.3+
12 *
13 * Dual licensed under the MIT and GPL licenses:
14 *   http://www.opensource.org/licenses/mit-license.php
15 *   http://www.gnu.org/licenses/gpl.html
16 */
17;(function($) {
18	var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,
19
20		selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],
21
22		ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,
23
24		loadingTimer, loadingFrame = 1,
25
26		titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),
27
28		isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,
29
30		/*
31		 * Private methods 
32		 */
33
34		_abort = function() {
35			loading.hide();
36
37			imgPreloader.onerror = imgPreloader.onload = null;
38
39			if (ajaxLoader) {
40				ajaxLoader.abort();
41			}
42
43			tmp.empty();
44		},
45
46		_error = function() {
47			if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
48				loading.hide();
49				busy = false;
50				return;
51			}
52
53			selectedOpts.titleShow = false;
54
55			selectedOpts.width = 'auto';
56			selectedOpts.height = 'auto';
57
58			tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' );
59
60			_process_inline();
61		},
62
63		_start = function() {
64			var obj = selectedArray[ selectedIndex ],
65				href, 
66				type, 
67				title,
68				str,
69				emb,
70				ret;
71
72			_abort();
73
74			selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
75
76			ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);
77
78			if (ret === false) {
79				busy = false;
80				return;
81			} else if (typeof ret == 'object') {
82				selectedOpts = $.extend(selectedOpts, ret);
83			}
84
85			title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';
86
87			if (obj.nodeName && !selectedOpts.orig) {
88				selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
89			}
90
91			if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
92				title = selectedOpts.orig.attr('alt');
93			}
94
95			href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;
96
97			if ((/^(?:javascript)/i).test(href) || href == '#') {
98				href = null;
99			}
100
101			if (selectedOpts.type) {
102				type = selectedOpts.type;
103
104				if (!href) {
105					href = selectedOpts.content;
106				}
107
108			} else if (selectedOpts.content) {
109				type = 'html';
110
111			} else if (href) {
112				if (href.match(imgRegExp)) {
113					type = 'image';
114
115				} else if (href.match(swfRegExp)) {
116					type = 'swf';
117
118				} else if ($(obj).hasClass("iframe")) {
119					type = 'iframe';
120
121				} else if (href.indexOf("#") === 0) {
122					type = 'inline';
123
124				} else {
125					type = 'ajax';
126				}
127			}
128
129			if (!type) {
130				_error();
131				return;
132			}
133
134			if (type == 'inline') {
135				obj	= href.substr(href.indexOf("#"));
136				type = $(obj).length > 0 ? 'inline' : 'ajax';
137			}
138
139			selectedOpts.type = type;
140			selectedOpts.href = href;
141			selectedOpts.title = title;
142
143			if (selectedOpts.autoDimensions) {
144				if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
145					selectedOpts.width = 'auto';
146					selectedOpts.height = 'auto';
147				} else {
148					selectedOpts.autoDimensions = false;	
149				}
150			}
151
152			if (selectedOpts.modal) {
153				selectedOpts.overlayShow = true;
154				selectedOpts.hideOnOverlayClick = false;
155				selectedOpts.hideOnContentClick = false;
156				selectedOpts.enableEscapeButton = false;
157				selectedOpts.showCloseButton = false;
158			}
159
160			selectedOpts.padding = parseInt(selectedOpts.padding, 10);
161			selectedOpts.margin = parseInt(selectedOpts.margin, 10);
162
163			tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));
164
165			$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
166				$(this).replaceWith(content.children());				
167			});
168
169			switch (type) {
170				case 'html' :
171					tmp.html( selectedOpts.content );
172					_process_inline();
173				break;
174
175				case 'inline' :
176					if ( $(obj).parent().is('#fancybox-content') === true) {
177						busy = false;
178						return;
179					}
180
181					$('<div class="fancybox-inline-tmp" />')
182						.hide()
183						.insertBefore( $(obj) )
184						.bind('fancybox-cleanup', function() {
185							$(this).replaceWith(content.children());
186						}).bind('fancybox-cancel', function() {
187							$(this).replaceWith(tmp.children());
188						});
189
190					$(obj).appendTo(tmp);
191
192					_process_inline();
193				break;
194
195				case 'image':
196					busy = false;
197
198					$.fancybox.showActivity();
199
200					imgPreloader = new Image();
201
202					imgPreloader.onerror = function() {
203						_error();
204					};
205
206					imgPreloader.onload = function() {
207						busy = true;
208
209						imgPreloader.onerror = imgPreloader.onload = null;
210
211						_process_image();
212					};
213
214					imgPreloader.src = href;
215				break;
216
217				case 'swf':
218					selectedOpts.scrolling = 'no';
219
220					str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
221					emb = '';
222
223					$.each(selectedOpts.swf, function(name, val) {
224						str += '<param name="' + name + '" value="' + val + '"></param>';
225						emb += ' ' + name + '="' + val + '"';
226					});
227
228					str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';
229
230					tmp.html(str);
231
232					_process_inline();
233				break;
234
235				case 'ajax':
236					busy = false;
237
238					$.fancybox.showActivity();
239
240					selectedOpts.ajax.win = selectedOpts.ajax.success;
241
242					ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
243						url	: href,
244						data : selectedOpts.ajax.data || {},
245						error : function(XMLHttpRequest, textStatus, errorThrown) {
246							if ( XMLHttpRequest.status > 0 ) {
247								_error();
248							}
249						},
250						success : function(data, textStatus, XMLHttpRequest) {
251							var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
252							if (o.status == 200) {
253								if ( typeof selectedOpts.ajax.win == 'function' ) {
254									ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);
255
256									if (ret === false) {
257										loading.hide();
258										return;
259									} else if (typeof ret == 'string' || typeof ret == 'object') {
260										data = ret;
261									}
262								}
263
264								tmp.html( data );
265								_process_inline();
266							}
267						}
268					}));
269
270				break;
271
272				case 'iframe':
273					_show();
274				break;
275			}
276		},
277
278		_process_inline = function() {
279			var
280				w = selectedOpts.width,
281				h = selectedOpts.height;
282
283			if (w.toString().indexOf('%') > -1) {
284				w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';
285
286			} else {
287				w = w == 'auto' ? 'auto' : w + 'px';	
288			}
289
290			if (h.toString().indexOf('%') > -1) {
291				h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';
292
293			} else {
294				h = h == 'auto' ? 'auto' : h + 'px';	
295			}
296
297			tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');
298
299			selectedOpts.width = tmp.width();
300			selectedOpts.height = tmp.height();
301
302			_show();
303		},
304
305		_process_image = function() {
306			selectedOpts.width = imgPreloader.width;
307			selectedOpts.height = imgPreloader.height;
308
309			$("<img />").attr({
310				'id' : 'fancybox-img',
311				'src' : imgPreloader.src,
312				'alt' : selectedOpts.title
313			}).appendTo( tmp );
314
315			_show();
316		},
317
318		_show = function() {
319			var pos, equal;
320
321			loading.hide();
322
323			if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
324				$.event.trigger('fancybox-cancel');
325
326				busy = false;
327				return;
328			}
329
330			busy = true;
331
332			$(content.add( overlay )).unbind();
333
334			$(window).unbind("resize.fb scroll.fb");
335			$(document).unbind('keydown.fb');
336
337			if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
338				wrap.css('height', wrap.height());
339			}
340
341			currentArray = selectedArray;
342			currentIndex = selectedIndex;
343			currentOpts = selectedOpts;
344
345			if (currentOpts.overlayShow) {
346				overlay.css({
347					'background-color' : currentOpts.overlayColor,
348					'opacity' : currentOpts.overlayOpacity,
349					'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
350					'height' : $(document).height()
351				});
352
353				if (!overlay.is(':visible')) {
354					if (isIE6) {
355						$('select:not(#fancybox-tmp select)').filter(function() {
356							return this.style.visibility !== 'hidden';
357						}).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() {
358							this.style.visibility = 'inherit';
359						});
360					}
361
362					overlay.show();
363				}
364			} else {
365				overlay.hide();
366			}
367
368			final_pos = _get_zoom_to();
369
370			_process_title();
371
372			if (wrap.is(":visible")) {
373				$( close.add( nav_left ).add( nav_right ) ).hide();
374
375				pos = wrap.position(),
376
377				start_pos = {
378					top	 : pos.top,
379					left : pos.left,
380					width : wrap.width(),
381					height : wrap.height()
382				};
383
384				equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);
385
386				content.fadeTo(currentOpts.changeFade, 0.3, function() {
387					var finish_resizing = function() {
388						content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
389					};
390
391					$.event.trigger('fancybox-change');
392
393					content
394						.empty()
395						.removeAttr('filter')
396						.css({
397							'border-width' : currentOpts.padding,
398							'width'	: final_pos.width - currentOpts.padding * 2,
399							'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
400						});
401
402					if (equal) {
403						finish_resizing();
404
405					} else {
406						fx.prop = 0;
407
408						$(fx).animate({prop: 1}, {
409							 duration : currentOpts.changeSpeed,
410							 easing : currentOpts.easingChange,
411							 step : _draw,
412							 complete : finish_resizing
413						});
414					}
415				});
416
417				return;
418			}
419
420			wrap.removeAttr("style");
421
422			content.css('border-width', currentOpts.padding);
423
424			if (currentOpts.transitionIn == 'elastic') {
425				start_pos = _get_zoom_from();
426
427				content.html( tmp.contents() );
428
429				wrap.show();
430
431				if (currentOpts.opacity) {
432					final_pos.opacity = 0;
433				}
434
435				fx.prop = 0;
436
437				$(fx).animate({prop: 1}, {
438					 duration : currentOpts.speedIn,
439					 easing : currentOpts.easingIn,
440					 step : _draw,
441					 complete : _finish
442				});
443
444				return;
445			}
446
447			if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {	
448				title.show();	
449			}
450
451			content
452				.css({
453					'width' : final_pos.width - currentOpts.padding * 2,
454					'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
455				})
456				.html( tmp.contents() );
457
458			wrap
459				.css(final_pos)
460				.fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
461		},
462
463		_format_title = function(title) {
464			if (title && title.length) {
465				if (currentOpts.titlePosition == 'float') {
466					return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>';
467				}
468
469				return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
470			}
471
472			return false;
473		},
474
475		_process_title = function() {
476			titleStr = currentOpts.title || '';
477			titleHeight = 0;
478
479			title
480				.empty()
481				.removeAttr('style')
482				.removeClass();
483
484			if (currentOpts.titleShow === false) {
485				title.hide();
486				return;
487			}
488
489			titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);
490
491			if (!titleStr || titleStr === '') {
492				title.hide();
493				return;
494			}
495
496			title
497				.addClass('fancybox-title-' + currentOpts.titlePosition)
498				.html( titleStr )
499				.appendTo( 'body' )
500				.show();
501
502			switch (currentOpts.titlePosition) {
503				case 'inside':
504					title
505						.css({
506							'width' : final_pos.width - (currentOpts.padding * 2),
507							'marginLeft' : currentOpts.padding,
508							'marginRight' : currentOpts.padding
509						});
510
511					titleHeight = title.outerHeight(true);
512
513					title.appendTo( outer );
514
515					final_pos.height += titleHeight;
516				break;
517
518				case 'over':
519					title
520						.css({
521							'marginLeft' : currentOpts.padding,
522							'width'	: final_pos.width - (currentOpts.padding * 2),
523							'bottom' : currentOpts.padding
524						})
525						.appendTo( outer );
526				break;
527
528				case 'float':
529					title
530						.css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1)
531						.appendTo( wrap );
532				break;
533
534				default:
535					title
536						.css({
537							'width' : final_pos.width - (currentOpts.padding * 2),
538							'paddingLeft' : currentOpts.padding,
539							'paddingRight' : currentOpts.padding
540						})
541						.appendTo( wrap );
542				break;
543			}
544
545			title.hide();
546		},
547
548		_set_navigation = function() {
549			if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
550				$(document).bind('keydown.fb', function(e) {
551					if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
552						e.preventDefault();
553						$.fancybox.close();
554
555					} else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
556						e.preventDefault();
557						$.fancybox[ e.keyCode == 37 ? 'prev' : 'next']();
558					}
559				});
560			}
561
562			if (!currentOpts.showNavArrows) { 
563				nav_left.hide();
564				nav_right.hide();
565				return;
566			}
567
568			if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
569				nav_left.show();
570			}
571
572			if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
573				nav_right.show();
574			}
575		},
576
577		_finish = function () {
578			if (!$.support.opacity) {
579				content.get(0).style.removeAttribute('filter');
580				wrap.get(0).style.removeAttribute('filter');
581			}
582
583			if (selectedOpts.autoDimensions) {
584				content.css('height', 'auto');
585			}
586
587			wrap.css('height', 'auto');
588
589			if (titleStr && titleStr.length) {
590				title.show();
591			}
592
593			if (currentOpts.showCloseButton) {
594				close.show();
595			}
596
597			_set_navigation();
598	
599			if (currentOpts.hideOnContentClick)	{
600				content.bind('click', $.fancybox.close);
601			}
602
603			if (currentOpts.hideOnOverlayClick)	{
604				overlay.bind('click', $.fancybox.close);
605			}
606
607			$(window).bind("resize.fb", $.fancybox.resize);
608
609			if (currentOpts.centerOnScroll) {
610				$(window).bind("scroll.fb", $.fancybox.center);
611			}
612
613			if (currentOpts.type == 'iframe') {
614				$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
615			}
616
617			wrap.show();
618
619			busy = false;
620
621			// $.fancybox.center();
622
623			currentOpts.onComplete(currentArray, currentIndex, currentOpts);
624
625			_preload_images();
626		},
627
628		_preload_images = function() {
629			var href, 
630				objNext;
631
632			if ((currentArray.length -1) > currentIndex) {
633				href = currentArray[ currentIndex + 1 ].href;
634
635				if (typeof href !== 'undefined' && href.match(imgRegExp)) {
636					objNext = new Image();
637					objNext.src = href;
638				}
639			}
640
641			if (currentIndex > 0) {
642				href = currentArray[ currentIndex - 1 ].href;
643
644				if (typeof href !== 'undefined' && href.match(imgRegExp)) {
645					objNext = new Image();
646					objNext.src = href;
647				}
648			}
649		},
650
651		_draw = function(pos) {
652			var dim = {
653				width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
654				height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),
655
656				top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
657				left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
658			};
659
660			if (typeof final_pos.opacity !== 'undefined') {
661				dim.opacity = pos < 0.5 ? 0.5 : pos;
662			}
663
664			wrap.css(dim);
665
666			content.css({
667				'width' : dim.width - currentOpts.padding * 2,
668				'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2
669			});
670		},
671
672		_get_viewport = function() {
673			return [
674				$(window).width() - (currentOpts.margin * 2),
675				$(window).height() - (currentOpts.margin * 2),
676				$(document).scrollLeft() + currentOpts.margin,
677				$(document).scrollTop() + currentOpts.margin
678			];
679		},
680
681		_get_zoom_to = function () {
682			var view = _get_viewport(),
683				to = {},
684				resize = currentOpts.autoScale,
685				double_padding = currentOpts.padding * 2,
686				ratio;
687
688			if (currentOpts.width.toString().indexOf('%') > -1) {
689				to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
690			} else {
691				to.width = currentOpts.width + double_padding;
692			}
693
694			if (currentOpts.height.toString().indexOf('%') > -1) {
695				to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
696			} else {
697				to.height = currentOpts.height + double_padding;
698			}
699
700			if (resize && (to.width > view[0] || to.height > view[1])) {
701				if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
702					ratio = (currentOpts.width ) / (currentOpts.height );
703
704					if ((to.width ) > view[0]) {
705						to.width = view[0];
706						to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
707					}
708
709					if ((to.height) > view[1]) {
710						to.height = view[1];
711						to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
712					}
713
714				} else {
715					to.width = Math.min(to.width, view[0]);
716					to.height = Math.min(to.height, view[1]);
717				}
718			}
719
720			to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
721			to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);
722
723			return to;
724		},
725
726		_get_obj_pos = function(obj) {
727			var pos = obj.offset();
728
729			pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0;
730			pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0;
731
732			pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0;
733			pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0;
734
735			pos.width = obj.width();
736			pos.height = obj.height();
737
738			return pos;
739		},
740
741		_get_zoom_from = function() {
742			var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
743				from = {},
744				pos,
745				view;
746
747			if (orig && orig.length) {
748				pos = _get_obj_pos(orig);
749
750				from = {
751					width : pos.width + (currentOpts.padding * 2),
752					height : pos.height + (currentOpts.padding * 2),
753					top	: pos.top - currentOpts.padding - 20,
754					left : pos.left - currentOpts.padding - 20
755				};
756
757			} else {
758				view = _get_viewport();
759
760				from = {
761					width : currentOpts.padding * 2,
762					height : currentOpts.padding * 2,
763					top	: parseInt(view[3] + view[1] * 0.5, 10),
764					left : parseInt(view[2] + view[0] * 0.5, 10)
765				};
766			}
767
768			return from;
769		},
770
771		_animate_loading = function() {
772			if (!loading.is(':visible')){
773				clearInterval(loadingTimer);
774				return;
775			}
776
777			$('div', loading).css('top', (loadingFrame * -40) + 'px');
778
779			loadingFrame = (loadingFrame + 1) % 12;
780		};
781
782	/*
783	 * Public methods 
784	 */
785
786	$.fn.fancybox = function(options) {
787		if (!$(this).length) {
788			return this;
789		}
790
791		$(this)
792			.data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
793			.unbind('click.fb')
794			.bind('click.fb', function(e) {
795				e.preventDefault();
796
797				if (busy) {
798					return;
799				}
800
801				busy = true;
802
803				$(this).blur();
804
805				selectedArray = [];
806				selectedIndex = 0;
807
808				var rel = $(this).attr('rel') || '';
809
810				if (!rel || rel == '' || rel === 'nofollow') {
811					selectedArray.push(this);
812
813				} else {
814					selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
815					selectedIndex = selectedArray.index( this );
816				}
817
818				_start();
819
820				return;
821			});
822
823		return this;
824	};
825
826	$.fancybox = function(obj) {
827		var opts;
828
829		if (busy) {
830			return;
831		}
832
833		busy = true;
834		opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
835
836		selectedArray = [];
837		selectedIndex = parseInt(opts.index, 10) || 0;
838
839		if ($.isArray(obj)) {
840			for (var i = 0, j = obj.length; i < j; i++) {
841				if (typeof obj[i] == 'object') {
842					$(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
843				} else {
844					obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
845				}
846			}
847
848			selectedArray = jQuery.merge(selectedArray, obj);
849
850		} else {
851			if (typeof obj == 'object') {
852				$(obj).data('fancybox', $.extend({}, opts, obj));
853			} else {
854				obj = $({}).data('fancybox', $.extend({content : obj}, opts));
855			}
856
857			selectedArray.push(obj);
858		}
859
860		if (selectedIndex > selectedArray.length || selectedIndex < 0) {
861			selectedIndex = 0;
862		}
863
864		_start();
865	};
866
867	$.fancybox.showActivity = function() {
868		clearInterval(loadingTimer);
869
870		loading.show();
871		loadingTimer = setInterval(_animate_loading, 66);
872	};
873
874	$.fancybox.hideActivity = function() {
875		loading.hide();
876	};
877
878	$.fancybox.next = function() {
879		return $.fancybox.pos( currentIndex + 1);
880	};
881
882	$.fancybox.prev = function() {
883		return $.fancybox.pos( currentIndex - 1);
884	};
885
886	$.fancybox.pos = function(pos) {
887		if (busy) {
888			return;
889		}
890
891		pos = parseInt(pos);
892
893		selectedArray = currentArray;
894
895		if (pos > -1 && pos < currentArray.length) {
896			selectedIndex = pos;
897			_start();
898
899		} else if (currentOpts.cyclic && currentArray.length > 1) {
900			selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
901			_start();
902		}
903
904		return;
905	};
906
907	$.fancybox.cancel = function() {
908		if (busy) {
909			return;
910		}
911
912		busy = true;
913
914		$.event.trigger('fancybox-cancel');
915
916		_abort();
917
918		selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
919
920		busy = false;
921	};
922
923	// Note: within an iframe use - parent.$.fancybox.close();
924	$.fancybox.close = function() {
925		if (busy || wrap.is(':hidden')) {
926			return;
927		}
928
929		busy = true;
930
931		if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
932			busy = false;
933			return;
934		}
935
936		_abort();
937
938		$(close.add( nav_left ).add( nav_right )).hide();
939
940		$(content.add( overlay )).unbind();
941
942		$(window).unbind("resize.fb scroll.fb");
943		$(document).unbind('keydown.fb');
944
945		content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'about:blank' : 'about:blank');
946
947		if (currentOpts.titlePosition !== 'inside') {
948			title.empty();
949		}
950
951		wrap.stop();
952
953		function _cleanup() {
954			overlay.fadeOut('fast');
955
956			title.empty().hide();
957			wrap.hide();
958
959			$.event.trigger('fancybox-cleanup');
960
961			content.empty();
962
963			currentOpts.onClosed(currentArray, currentIndex, currentOpts);
964
965			currentArray = selectedOpts	= [];
966			currentIndex = selectedIndex = 0;
967			currentOpts = selectedOpts	= {};
968
969			busy = false;
970		}
971
972		if (currentOpts.transitionOut == 'elastic') {
973			start_pos = _get_zoom_from();
974
975			var pos = wrap.position();
976
977			final_pos = {
978				top	 : pos.top ,
979				left : pos.left,
980				width :	wrap.width(),
981				height : wrap.height()
982			};
983
984			if (currentOpts.opacity) {
985				final_pos.opacity = 1;
986			}
987
988			title.empty().hide();
989
990			fx.prop = 1;
991
992			$(fx).animate({ prop: 0 }, {
993				 duration : currentOpts.speedOut,
994				 easing : currentOpts.easingOut,
995				 step : _draw,
996				 complete : _cleanup
997			});
998
999		} else {
1000			wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
1001		}
1002	};
1003
1004	$.fancybox.resize = function() {
1005		if (overlay.is(':visible')) {
1006			overlay.css('height', $(document).height());
1007		}
1008
1009		$.fancybox.center(true);
1010	};
1011
1012	$.fancybox.center = function() {
1013		var view, align;
1014
1015		if (busy) {
1016			return;	
1017		}
1018
1019		align = arguments[0] === true ? 1 : 0;
1020		view = _get_viewport();
1021
1022		if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
1023			return;	
1024		}
1025
1026		wrap
1027			.stop()
1028			.animate({
1029				'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
1030				'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
1031			}, typeof arguments[0] == 'number' ? arguments[0] : 200);
1032	};
1033
1034	$.fancybox.init = function() {
1035		if ($("#fancybox-wrap").length) {
1036			return;
1037		}
1038
1039		$('body').append(
1040			tmp	= $('<div id="fancybox-tmp"></div>'),
1041			loading	= $('<div id="fancybox-loading"><div></div></div>'),
1042			overlay	= $('<div id="fancybox-overlay"></div>'),
1043			wrap = $('<div id="fancybox-wrap"></div>')
1044		);
1045
1046		 outer = $('<div id="fancybox-outer"></div>')
1047			//.append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>')
1048			.appendTo( wrap );
1049
1050		outer.append(
1051			content = $('<div id="fancybox-content"></div>'),
1052			close = $('<a id="fancybox-close"></a>'),
1053			title = $('<div id="fancybox-title"></div>'),
1054
1055			nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
1056			nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
1057		);
1058
1059		close.click($.fancybox.close);
1060		loading.click($.fancybox.cancel);
1061
1062		nav_left.click(function(e) {
1063			e.preventDefault();
1064			$.fancybox.prev();
1065		});
1066
1067		nav_right.click(function(e) {
1068			e.preventDefault();
1069			$.fancybox.next();
1070		});
1071
1072		if ($.fn.mousewheel) {
1073			wrap.bind('mousewheel.fb', function(e, delta) {
1074				if (busy) {
1075					e.preventDefault();
1076
1077				} else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
1078					e.preventDefault();
1079					$.fancybox[ delta > 0 ? 'prev' : 'next']();
1080				}
1081			});
1082		}
1083
1084		if (!$.support.opacity) {
1085			wrap.addClass('fancybox-ie');
1086		}
1087
1088		if (isIE6) {
1089			loading.addClass('fancybox-ie6');
1090			wrap.addClass('fancybox-ie6');
1091
1092			$('<iframe id="fancybox-hide-sel-frame" src="about:blank" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);
1093		}
1094	};
1095
1096	$.fn.fancybox.defaults = {
1097		padding : 10,
1098		margin : 40,
1099		opacity : false,
1100		modal : false,
1101		cyclic : false,
1102		scrolling : 'auto',	// 'auto', 'yes' or 'no'
1103
1104		width : 560,
1105		height : 340,
1106
1107		autoScale : true,
1108		autoDimensions : true,
1109		centerOnScroll : true,
1110
1111		ajax : {},
1112		swf : { wmode: 'transparent' },
1113
1114		hideOnOverlayClick : true,
1115		hideOnContentClick : false,
1116
1117		overlayShow : true,
1118		overlayOpacity : 0.8,
1119		overlayColor : '#333',
1120
1121		titleShow : true,
1122		titlePosition : 'float', // 'float', 'outside', 'inside' or 'over'
1123		titleFormat : null,
1124		titleFromAlt : false,
1125
1126		transitionIn : 'fade', // 'elastic', 'fade' or 'none'
1127		transitionOut : 'fade', // 'elastic', 'fade' or 'none'
1128
1129		speedIn : 300,
1130		speedOut : 300,
1131
1132		changeSpeed : 300,
1133		changeFade : 'fast',
1134
1135		easingIn : 'swing',
1136		easingOut : 'swing',
1137
1138		showCloseButton	 : true,
1139		showNavArrows : true,
1140		enableEscapeButton : true,
1141		enableKeyboardNav : true,
1142
1143		onStart : function(){},
1144		onCancel : function(){},
1145		onComplete : function(){},
1146		onCleanup : function(){},
1147		onClosed : function(){},
1148		onError : function(){}
1149	};
1150
1151	$(document).ready(function() {
1152		$.fancybox.init();
1153	});
1154
1155})(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.