PageSourceSearch

https://actionnetwork.org/includes/js/fancybox/jquery.fancybox-1.3.4.fix.js?v=1

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