PageSourceSearch

https://estatut.ru/js/jquery.fancybox.js

js estatut.ru collected 2026-10-02 07:16:23 UTC 48,720 bytes, 2,019 lines download raw bytes

vendor: 5,753 bytes, lines 1-213
1/*!
2 * fancyBox - jQuery Plugin
3 * version: 2.1.5 (Fri, 14 Jun 2013)
4 * @requires jQuery v1.6 or later
5 *
6 * Examples at http://fancyapps.com/fancybox/
7 * License: www.fancyapps.com/fancybox/#license
8 *
9 * Copyright 2012 Janis Skarnelis - [email protected]
10 *
11 */
12
13(function (window, document, $, undefined) {
14	"use strict";
15
16	var H = $("html"),
17		W = $(window),
18		D = $(document),
19		F = $.fancybox = function () {
20			F.open.apply( this, arguments );
21		},
22		IE =  navigator.userAgent.match(/msie/i),
23		didUpdate	= null,
24		isTouch		= document.createTouch !== undefined,
25
26		isQuery	= function(obj) {
27			return obj && obj.hasOwnProperty && obj instanceof $;
28		},
29		isString = function(str) {
30			return str && $.type(str) === "string";
31		},
32		isPercentage = function(str) {
33			return isString(str) && str.indexOf('%') > 0;
34		},
35		isScrollable = function(el) {
36			return (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight)));
37		},
38		getScalar = function(orig, dim) {
39			var value = parseInt(orig, 10) || 0;
40
41			if (dim && isPercentage(orig)) {
42				value = F.getViewport()[ dim ] / 100 * value;
43			}
44
45			return Math.ceil(value);
46		},
47		getValue = function(value, dim) {
48			return getScalar(value, dim) + 'px';
49		};
50
51	$.extend(F, {
52		// The current version of fancyBox
53		version: '2.1.5',
54
55		defaults: {
56			padding : 15,
57			margin  : 20,
58
59			width     : 800,
60			height    : 600,
61			minWidth  : 100,
62			minHeight : 100,
63			maxWidth  : 9999,
64			maxHeight : 9999,
65			pixelRatio: 1, // Set to 2 for retina display support
66
67			autoSize   : true,
68			autoHeight : false,
69			autoWidth  : false,
70
71			autoResize  : true,
72			autoCenter  : !isTouch,
73			fitToView   : true,
74			aspectRatio : false,
75			topRatio    : 0.5,
76			leftRatio   : 0.5,
77
78			scrolling : 'auto', // 'auto', 'yes' or 'no'
79			wrapCSS   : '',
80
81			arrows     : true,
82			closeBtn   : true,
83			closeClick : false,
84			nextClick  : false,
85			mouseWheel : true,
86			autoPlay   : false,
87			playSpeed  : 3000,
88			preload    : 3,
89			modal      : false,
90			loop       : true,
91
92			ajax  : {
93				dataType : 'html',
94				headers  : { 'X-fancyBox': true }
95			},
96			iframe : {
97				scrolling : 'auto',
98				preload   : true
99			},
100			swf : {
101				wmode: 'transparent',
102				allowfullscreen   : 'true',
103				allowscriptaccess : 'always'
104			},
105
106			keys  : {
107				next : {
108					13 : 'left', // enter
109					34 : 'up',   // page down
110					39 : 'left', // right arrow
111					40 : 'up'    // down arrow
112				},
113				prev : {
114					8  : 'right',  // backspace
115					33 : 'down',   // page up
116					37 : 'right',  // left arrow
117					38 : 'down'    // up arrow
118				},
119				close  : [27], // escape key
120				play   : [32], // space - start/stop slideshow
121				toggle : [70]  // letter "f" - toggle fullscreen
122			},
123
124			direction : {
125				next : 'left',
126				prev : 'right'
127			},
128
129			scrollOutside  : true,
130
131			// Override some properties
132			index   : 0,
133			type    : null,
134			href    : null,
135			content : null,
136			title   : null,
137
138			// HTML templates
139			tpl: {
140				wrap     : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
141				image    : '<img class="fancybox-image" src="{href}" alt="" />',
142				iframe   : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' + (IE ? ' allowtransparency="true"' : '') + '></iframe>',
143				error    : '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
144				closeBtn : '<a title="Закрыть" class="fancybox-item fancybox-close" href="javascript:;"></a>',
145				next     : '<a title="След." class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
146				prev     : '<a title="Пред." class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
147			},
148
149			// Properties for each animation type
150			// Opening fancyBox
151			openEffect  : 'fade', // 'elastic', 'fade' or 'none'
152			openSpeed   : 250,
153			openEasing  : 'swing',
154			openOpacity : true,
155			openMethod  : 'zoomIn',
156
157			// Closing fancyBox
158			closeEffect  : 'fade', // 'elastic', 'fade' or 'none'
159			closeSpeed   : 250,
160			closeEasing  : 'swing',
161			closeOpacity : true,
162			closeMethod  : 'zoomOut',
163
164			// Changing next gallery item
165			nextEffect : 'elastic', // 'elastic', 'fade' or 'none'
166			nextSpeed  : 250,
167			nextEasing : 'swing',
168			nextMethod : 'changeIn',
169
170			// Changing previous gallery item
171			prevEffect : 'elastic', // 'elastic', 'fade' or 'none'
172			prevSpeed  : 250,
173			prevEasing : 'swing',
174			prevMethod : 'changeOut',
175
176			// Enable default helpers
177			helpers : {
178				overlay : true,
179				title   : true
180			},
181
182			// Callbacks
183			onCancel     : $.noop, // If canceling
184			beforeLoad   : $.noop, // Before loading
185			afterLoad    : $.noop, // After loading
186			beforeShow   : $.noop, // Before changing in current item
187			afterShow    : $.noop, // After opening
188			beforeChange : $.noop, // Before changing gallery item
189			beforeClose  : $.noop, // Before closing
190			afterClose   : $.noop  // After closing
191		},
192
193		//Current state
194		group    : {}, // Selected group
195		opts     : {}, // Group options
196		previous : null,  // Previous element
197		coming   : null,  // Element being loaded
198		current  : null,  // Currently loaded element
199		isActive : false, // Is activated
200		isOpen   : false, // Is currently open
201		isOpened : false, // Have been fully opened at least once
202
203		wrap  : null,
204		skin  : null,
205		outer : null,
206		inner : null,
207
208		player : {
209			timer    : null,
210			isActive : false
211		},
212
213		// Loaders
vendor: 12,015 bytes, lines 214-760
214		ajaxLoad   : null,
215		imgPreload : null,
216
217		// Some collections
218		transitions : {},
219		helpers     : {},
220
221		/*
222		 *	Static methods
223		 */
224
225		open: function (group, opts) {
226			if (!group) {
227				return;
228			}
229
230			if (!$.isPlainObject(opts)) {
231				opts = {};
232			}
233
234			// Close if already active
235			if (false === F.close(true)) {
236				return;
237			}
238
239			// Normalize group
240			if (!$.isArray(group)) {
241				group = isQuery(group) ? $(group).get() : [group];
242			}
243
244			// Recheck if the type of each element is `object` and set content type (image, ajax, etc)
245			$.each(group, function(i, element) {
246				var obj = {},
247					href,
248					title,
249					content,
250					type,
251					rez,
252					hrefParts,
253					selector;
254
255				if ($.type(element) === "object") {
256					// Check if is DOM element
257					if (element.nodeType) {
258						element = $(element);
259					}
260
261					if (isQuery(element)) {
262						obj = {
263							href    : element.data('fancybox-href') || element.attr('href'),
264							title   : element.data('fancybox-title') || element.attr('title'),
265							isDom   : true,
266							element : element
267						};
268
269						if ($.metadata) {
270							$.extend(true, obj, element.metadata());
271						}
272
273					} else {
274						obj = element;
275					}
276				}
277
278				href  = opts.href  || obj.href || (isString(element) ? element : null);
279				title = opts.title !== undefined ? opts.title : obj.title || '';
280
281				content = opts.content || obj.content;
282				type    = content ? 'html' : (opts.type  || obj.type);
283
284				if (!type && obj.isDom) {
285					type = element.data('fancybox-type');
286
287					if (!type) {
288						rez  = element.prop('class').match(/fancybox\.(\w+)/);
289						type = rez ? rez[1] : null;
290					}
291				}
292
293				if (isString(href)) {
294					// Try to guess the content type
295					if (!type) {
296						if (F.isImage(href)) {
297							type = 'image';
298
299						} else if (F.isSWF(href)) {
300							type = 'swf';
301
302						} else if (href.charAt(0) === '#') {
303							type = 'inline';
304
305						} else if (isString(element)) {
306							type    = 'html';
307							content = element;
308						}
309					}
310
311					// Split url into two pieces with source url and content selector, e.g,
312					// "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id"
313					if (type === 'ajax') {
314						hrefParts = href.split(/\s+/, 2);
315						href      = hrefParts.shift();
316						selector  = hrefParts.shift();
317					}
318				}
319
320				if (!content) {
321					if (type === 'inline') {
322						if (href) {
323							content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
324
325						} else if (obj.isDom) {
326							content = element;
327						}
328
329					} else if (type === 'html') {
330						content = href;
331
332					} else if (!type && !href && obj.isDom) {
333						type    = 'inline';
334						content = element;
335					}
336				}
337
338				$.extend(obj, {
339					href     : href,
340					type     : type,
341					content  : content,
342					title    : title,
343					selector : selector
344				});
345
346				group[ i ] = obj;
347			});
348
349			// Extend the defaults
350			F.opts = $.extend(true, {}, F.defaults, opts);
351
352			// All options are merged recursive except keys
353			if (opts.keys !== undefined) {
354				F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
355			}
356
357			F.group = group;
358
359			return F._start(F.opts.index);
360		},
361
362		// Cancel image loading or abort ajax request
363		cancel: function () {
364			var coming = F.coming;
365
366			if (!coming || false === F.trigger('onCancel')) {
367				return;
368			}
369
370			F.hideLoading();
371
372			if (F.ajaxLoad) {
373				F.ajaxLoad.abort();
374			}
375
376			F.ajaxLoad = null;
377
378			if (F.imgPreload) {
379				F.imgPreload.onload = F.imgPreload.onerror = null;
380			}
381
382			if (coming.wrap) {
383				coming.wrap.stop(true, true).trigger('onReset').remove();
384			}
385
386			F.coming = null;
387
388			// If the first item has been canceled, then clear everything
389			if (!F.current) {
390				F._afterZoomOut( coming );
391			}
392		},
393
394		// Start closing animation if is open; remove immediately if opening/closing
395		close: function (event) {
396			F.cancel();
397
398			if (false === F.trigger('beforeClose')) {
399				return;
400			}
401
402			F.unbindEvents();
403
404			if (!F.isActive) {
405				return;
406			}
407
408			if (!F.isOpen || event === true) {
409				$('.fancybox-wrap').stop(true).trigger('onReset').remove();
410
411				F._afterZoomOut();
412
413			} else {
414				F.isOpen = F.isOpened = false;
415				F.isClosing = true;
416
417				$('.fancybox-item, .fancybox-nav').remove();
418
419				F.wrap.stop(true, true).removeClass('fancybox-opened');
420
421				F.transitions[ F.current.closeMethod ]();
422			}
423		},
424
425		// Manage slideshow:
426		//   $.fancybox.play(); - toggle slideshow
427		//   $.fancybox.play( true ); - start
428		//   $.fancybox.play( false ); - stop
429		play: function ( action ) {
430			var clear = function () {
431					clearTimeout(F.player.timer);
432				},
433				set = function () {
434					clear();
435
436					if (F.current && F.player.isActive) {
437						F.player.timer = setTimeout(F.next, F.current.playSpeed);
438					}
439				},
440				stop = function () {
441					clear();
442
443					D.unbind('.player');
444
445					F.player.isActive = false;
446
447					F.trigger('onPlayEnd');
448				},
449				start = function () {
450					if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
451						F.player.isActive = true;
452
453						D.bind({
454							'onCancel.player beforeClose.player' : stop,
455							'onUpdate.player'   : set,
456							'beforeLoad.player' : clear
457						});
458
459						set();
460
461						F.trigger('onPlayStart');
462					}
463				};
464
465			if (action === true || (!F.player.isActive && action !== false)) {
466				start();
467			} else {
468				stop();
469			}
470		},
471
472		// Navigate to next gallery item
473		next: function ( direction ) {
474			var current = F.current;
475
476			if (current) {
477				if (!isString(direction)) {
478					direction = current.direction.next;
479				}
480
481				F.jumpto(current.index + 1, direction, 'next');
482			}
483		},
484
485		// Navigate to previous gallery item
486		prev: function ( direction ) {
487			var current = F.current;
488
489			if (current) {
490				if (!isString(direction)) {
491					direction = current.direction.prev;
492				}
493
494				F.jumpto(current.index - 1, direction, 'prev');
495			}
496		},
497
498		// Navigate to gallery item by index
499		jumpto: function ( index, direction, router ) {
500			var current = F.current;
501
502			if (!current) {
503				return;
504			}
505
506			index = getScalar(index);
507
508			F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];
509			F.router    = router || 'jumpto';
510
511			if (current.loop) {
512				if (index < 0) {
513					index = current.group.length + (index % current.group.length);
514				}
515
516				index = index % current.group.length;
517			}
518
519			if (current.group[ index ] !== undefined) {
520				F.cancel();
521
522				F._start(index);
523			}
524		},
525
526		// Center inside viewport and toggle position type to fixed or absolute if needed
527		reposition: function (e, onlyAbsolute) {
528			var current = F.current,
529				wrap    = current ? current.wrap : null,
530				pos;
531
532			if (wrap) {
533				pos = F._getPosition(onlyAbsolute);
534
535				if (e && e.type === 'scroll') {
536					delete pos.position;
537
538					wrap.stop(true, true).animate(pos, 200);
539
540				} else {
541					wrap.css(pos);
542
543					current.pos = $.extend({}, current.dim, pos);
544				}
545			}
546		},
547
548		update: function (e) {
549			var type = (e && e.type),
550				anyway = !type || type === 'orientationchange';
551
552			if (anyway) {
553				clearTimeout(didUpdate);
554
555				didUpdate = null;
556			}
557
558			if (!F.isOpen || didUpdate) {
559				return;
560			}
561
562			didUpdate = setTimeout(function() {
563				var current = F.current;
564
565				if (!current || F.isClosing) {
566					return;
567				}
568
569				F.wrap.removeClass('fancybox-tmp');
570
571				if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) {
572					F._setDimension();
573				}
574
575				if (!(type === 'scroll' && current.canShrink)) {
576					F.reposition(e);
577				}
578
579				F.trigger('onUpdate');
580
581				didUpdate = null;
582
583			}, (anyway && !isTouch ? 0 : 300));
584		},
585
586		// Shrink content to fit inside viewport or restore if resized
587		toggle: function ( action ) {
588			if (F.isOpen) {
589				F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView;
590
591				// Help browser to restore document dimensions
592				if (isTouch) {
593					F.wrap.removeAttr('style').addClass('fancybox-tmp');
594
595					F.trigger('onUpdate');
596				}
597
598				F.update();
599			}
600		},
601
602		hideLoading: function () {
603			D.unbind('.loading');
604
605			$('#fancybox-loading').remove();
606		},
607
608		showLoading: function () {
609			var el, viewport;
610
611			F.hideLoading();
612
613			el = $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
614
615			// If user will press the escape-button, the request will be canceled
616			D.bind('keydown.loading', function(e) {
617				if ((e.which || e.keyCode) === 27) {
618					e.preventDefault();
619
620					F.cancel();
621				}
622			});
623
624			if (!F.defaults.fixed) {
625				viewport = F.getViewport();
626
627				el.css({
628					position : 'absolute',
629					top  : (viewport.h * 0.5) + viewport.y,
630					left : (viewport.w * 0.5) + viewport.x
631				});
632			}
633		},
634
635		getViewport: function () {
636			var locked = (F.current && F.current.locked) || false,
637				rez    = {
638					x: W.scrollLeft(),
639					y: W.scrollTop()
640				};
641
642			if (locked) {
643				rez.w = locked[0].clientWidth;
644				rez.h = locked[0].clientHeight;
645
646			} else {
647				// See http://bugs.jquery.com/ticket/6724
648				rez.w = isTouch && window.innerWidth  ? window.innerWidth  : W.width();
649				rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height();
650			}
651
652			return rez;
653		},
654
655		// Unbind the keyboard / clicking actions
656		unbindEvents: function () {
657			if (F.wrap && isQuery(F.wrap)) {
658				F.wrap.unbind('.fb');
659			}
660
661			D.unbind('.fb');
662			W.unbind('.fb');
663		},
664
665		bindEvents: function () {
666			var current = F.current,
667				keys;
668
669			if (!current) {
670				return;
671			}
672
673			// Changing document height on iOS devices triggers a 'resize' event,
674			// that can change document height... repeating infinitely
675			W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);
676
677			keys = current.keys;
678
679			if (keys) {
680				D.bind('keydown.fb', function (e) {
681					var code   = e.which || e.keyCode,
682						target = e.target || e.srcElement;
683
684					// Skip esc key if loading, because showLoading will cancel preloading
685					if (code === 27 && F.coming) {
686						return false;
687					}
688
689					// Ignore key combinations and key events within form elements
690					if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {
691						$.each(keys, function(i, val) {
692							if (current.group.length > 1 && val[ code ] !== undefined) {
693								F[ i ]( val[ code ] );
694
695								e.preventDefault();
696								return false;
697							}
698
699							if ($.inArray(code, val) > -1) {
700								F[ i ] ();
701
702								e.preventDefault();
703								return false;
704							}
705						});
706					}
707				});
708			}
709
710			if ($.fn.mousewheel && current.mouseWheel) {
711				F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) {
712					var target = e.target || null,
713						parent = $(target),
714						canScroll = false;
715
716					while (parent.length) {
717						if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) {
718							break;
719						}
720						canScroll = isScrollable( parent[0] );
721						parent    = $(parent).parent();
722					}
723
724					if (delta !== 0 && !canScroll) {
725						if (F.group.length > 1 && !current.canShrink) {
726							if (deltaY > 0 || deltaX > 0) {
727								F.prev( deltaY > 0 ? 'down' : 'left' );
728
729							} else if (deltaY < 0 || deltaX < 0) {
730								F.next( deltaY < 0 ? 'up' : 'right' );
731							}
732
733							e.preventDefault();
734						}
735					}
736				});
737			}
738		},
739
740		trigger: function (event, o) {
741			var ret, obj = o || F.coming || F.current;
742
743			if (!obj) {
744				return;
745			}
746
747			if ($.isFunction( obj[event] )) {
748				ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
749			}
750
751			if (ret === false) {
752				return false;
753			}
754
755			if (obj.helpers) {
756				$.each(obj.helpers, function (helper, opts) {
757					if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) {
758						F.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj);
759					}
760				});
vendor: 8,050 bytes, lines 760-1119
760
761			}
762
763			D.trigger(event);
764		},
765
766		isImage: function (str) {
767			return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
768		},
769
770		isSWF: function (str) {
771			return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i);
772		},
773
774		_start: function (index) {
775			var coming = {},
776				obj,
777				href,
778				type,
779				margin,
780				padding;
781
782			index = getScalar( index );
783			obj   = F.group[ index ] || null;
784
785			if (!obj) {
786				return false;
787			}
788
789			coming = $.extend(true, {}, F.opts, obj);
790
791			// Convert margin and padding properties to array - top, right, bottom, left
792			margin  = coming.margin;
793			padding = coming.padding;
794
795			if ($.type(margin) === 'number') {
796				coming.margin = [margin, margin, margin, margin];
797			}
798
799			if ($.type(padding) === 'number') {
800				coming.padding = [padding, padding, padding, padding];
801			}
802
803			// 'modal' propery is just a shortcut
804			if (coming.modal) {
805				$.extend(true, coming, {
806					closeBtn   : false,
807					closeClick : false,
808					nextClick  : false,
809					arrows     : false,
810					mouseWheel : false,
811					keys       : null,
812					helpers: {
813						overlay : {
814							closeClick : false
815						}
816					}
817				});
818			}
819
820			// 'autoSize' property is a shortcut, too
821			if (coming.autoSize) {
822				coming.autoWidth = coming.autoHeight = true;
823			}
824
825			if (coming.width === 'auto') {
826				coming.autoWidth = true;
827			}
828
829			if (coming.height === 'auto') {
830				coming.autoHeight = true;
831			}
832
833			/*
834			 * Add reference to the group, so it`s possible to access from callbacks, example:
835			 * afterLoad : function() {
836			 *     this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
837			 * }
838			 */
839
840			coming.group  = F.group;
841			coming.index  = index;
842
843			// Give a chance for callback or helpers to update coming item (type, title, etc)
844			F.coming = coming;
845
846			if (false === F.trigger('beforeLoad')) {
847				F.coming = null;
848
849				return;
850			}
851
852			type = coming.type;
853			href = coming.href;
854
855			if (!type) {
856				F.coming = null;
857
858				//If we can not determine content type then drop silently or display next/prev item if looping through gallery
859				if (F.current && F.router && F.router !== 'jumpto') {
860					F.current.index = index;
861
862					return F[ F.router ]( F.direction );
863				}
864
865				return false;
866			}
867
868			F.isActive = true;
869
870			if (type === 'image' || type === 'swf') {
871				coming.autoHeight = coming.autoWidth = false;
872				coming.scrolling  = 'visible';
873			}
874
875			if (type === 'image') {
876				coming.aspectRatio = true;
877			}
878
879			if (type === 'iframe' && isTouch) {
880				coming.scrolling = 'scroll';
881			}
882
883			// Build the neccessary markup
884			coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' );
885
886			$.extend(coming, {
887				skin  : $('.fancybox-skin',  coming.wrap),
888				outer : $('.fancybox-outer', coming.wrap),
889				inner : $('.fancybox-inner', coming.wrap)
890			});
891
892			$.each(["Top", "Right", "Bottom", "Left"], function(i, v) {
893				coming.skin.css('padding' + v, getValue(coming.padding[ i ]));
894			});
895
896			F.trigger('onReady');
897
898			// Check before try to load; 'inline' and 'html' types need content, others - href
899			if (type === 'inline' || type === 'html') {
900				if (!coming.content || !coming.content.length) {
901					return F._error( 'content' );
902				}
903
904			} else if (!href) {
905				return F._error( 'href' );
906			}
907
908			if (type === 'image') {
909				F._loadImage();
910
911			} else if (type === 'ajax') {
912				F._loadAjax();
913
914			} else if (type === 'iframe') {
915				F._loadIframe();
916
917			} else {
918				F._afterLoad();
919			}
920		},
921
922		_error: function ( type ) {
923			$.extend(F.coming, {
924				type       : 'html',
925				autoWidth  : true,
926				autoHeight : true,
927				minWidth   : 0,
928				minHeight  : 0,
929				scrolling  : 'no',
930				hasError   : type,
931				content    : F.coming.tpl.error
932			});
933
934			F._afterLoad();
935		},
936
937		_loadImage: function () {
938			// Reset preload image so it is later possible to check "complete" property
939			var img = F.imgPreload = new Image();
940
941			img.onload = function () {
942				this.onload = this.onerror = null;
943
944				F.coming.width  = this.width / F.opts.pixelRatio;
945				F.coming.height = this.height / F.opts.pixelRatio;
946
947				F._afterLoad();
948			};
949
950			img.onerror = function () {
951				this.onload = this.onerror = null;
952
953				F._error( 'image' );
954			};
955
956			img.src = F.coming.href;
957
958			if (img.complete !== true) {
959				F.showLoading();
960			}
961		},
962
963		_loadAjax: function () {
964			var coming = F.coming;
965
966			F.showLoading();
967
968			F.ajaxLoad = $.ajax($.extend({}, coming.ajax, {
969				url: coming.href,
970				error: function (jqXHR, textStatus) {
971					if (F.coming && textStatus !== 'abort') {
972						F._error( 'ajax', jqXHR );
973
974					} else {
975						F.hideLoading();
976					}
977				},
978				success: function (data, textStatus) {
979					if (textStatus === 'success') {
980						coming.content = data;
981
982						F._afterLoad();
983					}
984				}
985			}));
986		},
987
988		_loadIframe: function() {
989			var coming = F.coming,
990				iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime()))
991					.attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling)
992					.attr('src', coming.href);
993
994			// This helps IE
995			$(coming.wrap).bind('onReset', function () {
996				try {
997					$(this).find('iframe').hide().attr('src', '//about:blank').end().empty();
998				} catch (e) {}
999			});
1000
1001			if (coming.iframe.preload) {
1002				F.showLoading();
1003
1004				iframe.one('load', function() {
1005					$(this).data('ready', 1);
1006
1007					// iOS will lose scrolling if we resize
1008					if (!isTouch) {
1009						$(this).bind('load.fb', F.update);
1010					}
1011
1012					// Without this trick:
1013					//   - iframe won't scroll on iOS devices
1014					//   - IE7 sometimes displays empty iframe
1015					$(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show();
1016
1017					F._afterLoad();
1018				});
1019			}
1020
1021			coming.content = iframe.appendTo( coming.inner );
1022
1023			if (!coming.iframe.preload) {
1024				F._afterLoad();
1025			}
1026		},
1027
1028		_preloadImages: function() {
1029			var group   = F.group,
1030				current = F.current,
1031				len     = group.length,
1032				cnt     = current.preload ? Math.min(current.preload, len - 1) : 0,
1033				item,
1034				i;
1035
1036			for (i = 1; i <= cnt; i += 1) {
1037				item = group[ (current.index + i ) % len ];
1038
1039				if (item.type === 'image' && item.href) {
1040					new Image().src = item.href;
1041				}
1042			}
1043		},
1044
1045		_afterLoad: function () {
1046			var coming   = F.coming,
1047				previous = F.current,
1048				placeholder = 'fancybox-placeholder',
1049				current,
1050				content,
1051				type,
1052				scrolling,
1053				href,
1054				embed;
1055
1056			F.hideLoading();
1057
1058			if (!coming || F.isActive === false) {
1059				return;
1060			}
1061
1062			if (false === F.trigger('afterLoad', coming, previous)) {
1063				coming.wrap.stop(true).trigger('onReset').remove();
1064
1065				F.coming = null;
1066
1067				return;
1068			}
1069
1070			if (previous) {
1071				F.trigger('beforeChange', previous);
1072
1073				previous.wrap.stop(true).removeClass('fancybox-opened')
1074					.find('.fancybox-item, .fancybox-nav')
1075					.remove();
1076			}
1077
1078			F.unbindEvents();
1079
1080			current   = coming;
1081			content   = coming.content;
1082			type      = coming.type;
1083			scrolling = coming.scrolling;
1084
1085			$.extend(F, {
1086				wrap  : current.wrap,
1087				skin  : current.skin,
1088				outer : current.outer,
1089				inner : current.inner,
1090				current  : current,
1091				previous : previous
1092			});
1093
1094			href = current.href;
1095
1096			switch (type) {
1097				case 'inline':
1098				case 'ajax':
1099				case 'html':
1100					if (current.selector) {
1101						content = $('<div>').html(content).find(current.selector);
1102
1103					} else if (isQuery(content)) {
1104						if (!content.data(placeholder)) {
1105							content.data(placeholder, $('<div class="' + placeholder + '"></div>').insertAfter( content ).hide() );
1106						}
1107
1108						content = content.show().detach();
1109
1110						current.wrap.bind('onReset', function () {
1111							if ($(this).find(content).length) {
1112								content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);
1113							}
1114						});
1115					}
1116				break;
1117
1118				case 'image':
1119					content = current.tpl.image.replace(
vendor: 19,741 bytes, lines 1119-1891
1119'{href}', href);
1120				break;
1121
1122				case 'swf':
1123					content = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + href + '"></param>';
1124					embed   = '';
1125
1126					$.each(current.swf, function(name, val) {
1127						content += '<param name="' + name + '" value="' + val + '"></param>';
1128						embed   += ' ' + name + '="' + val + '"';
1129					});
1130
1131					content += '<embed src="' + href + '" type="application/x-shockwave-flash" width="100%" height="100%"' + embed + '></embed></object>';
1132				break;
1133			}
1134
1135			if (!(isQuery(content) && content.parent().is(current.inner))) {
1136				current.inner.append( content );
1137			}
1138
1139			// Give a chance for helpers or callbacks to update elements
1140			F.trigger('beforeShow');
1141
1142			// Set scrolling before calculating dimensions
1143			current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
1144
1145			// Set initial dimensions and start position
1146			F._setDimension();
1147
1148			F.reposition();
1149
1150			F.isOpen = false;
1151			F.coming = null;
1152
1153			F.bindEvents();
1154
1155			if (!F.isOpened) {
1156				$('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();
1157
1158			} else if (previous.prevMethod) {
1159				F.transitions[ previous.prevMethod ]();
1160			}
1161
1162			F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();
1163
1164			F._preloadImages();
1165		},
1166
1167		_setDimension: function () {
1168			var viewport   = F.getViewport(),
1169				steps      = 0,
1170				canShrink  = false,
1171				canExpand  = false,
1172				wrap       = F.wrap,
1173				skin       = F.skin,
1174				inner      = F.inner,
1175				current    = F.current,
1176				width      = current.width,
1177				height     = current.height,
1178				minWidth   = current.minWidth,
1179				minHeight  = current.minHeight,
1180				maxWidth   = current.maxWidth,
1181				maxHeight  = current.maxHeight,
1182				scrolling  = current.scrolling,
1183				scrollOut  = current.scrollOutside ? current.scrollbarWidth : 0,
1184				margin     = current.margin,
1185				wMargin    = getScalar(margin[1] + margin[3]),
1186				hMargin    = getScalar(margin[0] + margin[2]),
1187				wPadding,
1188				hPadding,
1189				wSpace,
1190				hSpace,
1191				origWidth,
1192				origHeight,
1193				origMaxWidth,
1194				origMaxHeight,
1195				ratio,
1196				width_,
1197				height_,
1198				maxWidth_,
1199				maxHeight_,
1200				iframe,
1201				body;
1202
1203			// Reset dimensions so we could re-check actual size
1204			wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');
1205
1206			wPadding = getScalar(skin.outerWidth(true)  - skin.width());
1207			hPadding = getScalar(skin.outerHeight(true) - skin.height());
1208
1209			// Any space between content and viewport (margin, padding, border, title)
1210			wSpace = wMargin + wPadding;
1211			hSpace = hMargin + hPadding;
1212
1213			origWidth  = isPercentage(width)  ? (viewport.w - wSpace) * getScalar(width)  / 100 : width;
1214			origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;
1215
1216			if (current.type === 'iframe') {
1217				iframe = current.content;
1218
1219				if (current.autoHeight && iframe.data('ready') === 1) {
1220					try {
1221						if (iframe[0].contentWindow.document.location) {
1222							inner.width( origWidth ).height(9999);
1223
1224							body = iframe.contents().find('body');
1225
1226							if (scrollOut) {
1227								body.css('overflow-x', 'hidden');
1228							}
1229
1230							origHeight = body.outerHeight(true);
1231						}
1232
1233					} catch (e) {}
1234				}
1235
1236			} else if (current.autoWidth || current.autoHeight) {
1237				inner.addClass( 'fancybox-tmp' );
1238
1239				// Set width or height in case we need to calculate only one dimension
1240				if (!current.autoWidth) {
1241					inner.width( origWidth );
1242				}
1243
1244				if (!current.autoHeight) {
1245					inner.height( origHeight );
1246				}
1247
1248				if (current.autoWidth) {
1249					origWidth = inner.width();
1250				}
1251
1252				if (current.autoHeight) {
1253					origHeight = inner.height();
1254				}
1255
1256				inner.removeClass( 'fancybox-tmp' );
1257			}
1258
1259			width  = getScalar( origWidth );
1260			height = getScalar( origHeight );
1261
1262			ratio  = origWidth / origHeight;
1263
1264			// Calculations for the content
1265			minWidth  = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);
1266			maxWidth  = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);
1267
1268			minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);
1269			maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);
1270
1271			// These will be used to determine if wrap can fit in the viewport
1272			origMaxWidth  = maxWidth;
1273			origMaxHeight = maxHeight;
1274
1275			if (current.fitToView) {
1276				maxWidth  = Math.min(viewport.w - wSpace, maxWidth);
1277				maxHeight = Math.min(viewport.h - hSpace, maxHeight);
1278			}
1279
1280			maxWidth_  = viewport.w - wMargin;
1281			maxHeight_ = viewport.h - hMargin;
1282
1283			if (current.aspectRatio) {
1284				if (width > maxWidth) {
1285					width  = maxWidth;
1286					height = getScalar(width / ratio);
1287				}
1288
1289				if (height > maxHeight) {
1290					height = maxHeight;
1291					width  = getScalar(height * ratio);
1292				}
1293
1294				if (width < minWidth) {
1295					width  = minWidth;
1296					height = getScalar(width / ratio);
1297				}
1298
1299				if (height < minHeight) {
1300					height = minHeight;
1301					width  = getScalar(height * ratio);
1302				}
1303
1304			} else {
1305				width = Math.max(minWidth, Math.min(width, maxWidth));
1306
1307				if (current.autoHeight && current.type !== 'iframe') {
1308					inner.width( width );
1309
1310					height = inner.height();
1311				}
1312
1313				height = Math.max(minHeight, Math.min(height, maxHeight));
1314			}
1315
1316			// Try to fit inside viewport (including the title)
1317			if (current.fitToView) {
1318				inner.width( width ).height( height );
1319
1320				wrap.width( width + wPadding );
1321
1322				// Real wrap dimensions
1323				width_  = wrap.width();
1324				height_ = wrap.height();
1325
1326				if (current.aspectRatio) {
1327					while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {
1328						if (steps++ > 19) {
1329							break;
1330						}
1331
1332						height = Math.max(minHeight, Math.min(maxHeight, height - 10));
1333						width  = getScalar(height * ratio);
1334
1335						if (width < minWidth) {
1336							width  = minWidth;
1337							height = getScalar(width / ratio);
1338						}
1339
1340						if (width > maxWidth) {
1341							width  = maxWidth;
1342							height = getScalar(width / ratio);
1343						}
1344
1345						inner.width( width ).height( height );
1346
1347						wrap.width( width + wPadding );
1348
1349						width_  = wrap.width();
1350						height_ = wrap.height();
1351					}
1352
1353				} else {
1354					width  = Math.max(minWidth,  Math.min(width,  width  - (width_  - maxWidth_)));
1355					height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));
1356				}
1357			}
1358
1359			if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {
1360				width += scrollOut;
1361			}
1362
1363			inner.width( width ).height( height );
1364
1365			wrap.width( width + wPadding );
1366
1367			width_  = wrap.width();
1368			height_ = wrap.height();
1369
1370			canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;
1371			canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));
1372
1373			$.extend(current, {
1374				dim : {
1375					width	: getValue( width_ ),
1376					height	: getValue( height_ )
1377				},
1378				origWidth  : origWidth,
1379				origHeight : origHeight,
1380				canShrink  : canShrink,
1381				canExpand  : canExpand,
1382				wPadding   : wPadding,
1383				hPadding   : hPadding,
1384				wrapSpace  : height_ - skin.outerHeight(true),
1385				skinSpace  : skin.height() - height
1386			});
1387
1388			if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {
1389				inner.height('auto');
1390			}
1391		},
1392
1393		_getPosition: function (onlyAbsolute) {
1394			var current  = F.current,
1395				viewport = F.getViewport(),
1396				margin   = current.margin,
1397				width    = F.wrap.width()  + margin[1] + margin[3],
1398				height   = F.wrap.height() + margin[0] + margin[2],
1399				rez      = {
1400					position: 'absolute',
1401					top  : margin[0],
1402					left : margin[3]
1403				};
1404
1405			if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
1406				rez.position = 'fixed';
1407
1408			} else if (!current.locked) {
1409				rez.top  += viewport.y;
1410				rez.left += viewport.x;
1411			}
1412
1413			rez.top  = getValue(Math.max(rez.top,  rez.top  + ((viewport.h - height) * current.topRatio)));
1414			rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width)  * current.leftRatio)));
1415
1416			return rez;
1417		},
1418
1419		_afterZoomIn: function () {
1420			var current = F.current;
1421
1422			if (!current) {
1423				return;
1424			}
1425
1426			F.isOpen = F.isOpened = true;
1427
1428			F.wrap.css('overflow', 'visible').addClass('fancybox-opened');
1429
1430			F.update();
1431
1432			// Assign a click event
1433			if ( current.closeClick || (current.nextClick && F.group.length > 1) ) {
1434				F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
1435					if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
1436						e.preventDefault();
1437
1438						F[ current.closeClick ? 'close' : 'next' ]();
1439					}
1440				});
1441			}
1442
1443			// Create a close button
1444			if (current.closeBtn) {
1445				$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
1446					e.preventDefault();
1447
1448					F.close();
1449				});
1450			}
1451
1452			// Create navigation arrows
1453			if (current.arrows && F.group.length > 1) {
1454				if (current.loop || current.index > 0) {
1455					$(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
1456				}
1457
1458				if (current.loop || current.index < F.group.length - 1) {
1459					$(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);
1460				}
1461			}
1462
1463			F.trigger('afterShow');
1464
1465			// Stop the slideshow if this is the last item
1466			if (!current.loop && current.index === current.group.length - 1) {
1467				F.play( false );
1468
1469			} else if (F.opts.autoPlay && !F.player.isActive) {
1470				F.opts.autoPlay = false;
1471
1472				F.play();
1473			}
1474		},
1475
1476		_afterZoomOut: function ( obj ) {
1477			obj = obj || F.current;
1478
1479			$('.fancybox-wrap').trigger('onReset').remove();
1480
1481			$.extend(F, {
1482				group  : {},
1483				opts   : {},
1484				router : false,
1485				current   : null,
1486				isActive  : false,
1487				isOpened  : false,
1488				isOpen    : false,
1489				isClosing : false,
1490				wrap   : null,
1491				skin   : null,
1492				outer  : null,
1493				inner  : null
1494			});
1495
1496			F.trigger('afterClose', obj);
1497		}
1498	});
1499
1500	/*
1501	 *	Default transitions
1502	 */
1503
1504	F.transitions = {
1505		getOrigPosition: function () {
1506			var current  = F.current,
1507				element  = current.element,
1508				orig     = current.orig,
1509				pos      = {},
1510				width    = 50,
1511				height   = 50,
1512				hPadding = current.hPadding,
1513				wPadding = current.wPadding,
1514				viewport = F.getViewport();
1515
1516			if (!orig && current.isDom && element.is(':visible')) {
1517				orig = element.find('img:first');
1518
1519				if (!orig.length) {
1520					orig = element;
1521				}
1522			}
1523
1524			if (isQuery(orig)) {
1525				pos = orig.offset();
1526
1527				if (orig.is('img')) {
1528					width  = orig.outerWidth();
1529					height = orig.outerHeight();
1530				}
1531
1532			} else {
1533				pos.top  = viewport.y + (viewport.h - height) * current.topRatio;
1534				pos.left = viewport.x + (viewport.w - width)  * current.leftRatio;
1535			}
1536
1537			if (F.wrap.css('position') === 'fixed' || current.locked) {
1538				pos.top  -= viewport.y;
1539				pos.left -= viewport.x;
1540			}
1541
1542			pos = {
1543				top     : getValue(pos.top  - hPadding * current.topRatio),
1544				left    : getValue(pos.left - wPadding * current.leftRatio),
1545				width   : getValue(width  + wPadding),
1546				height  : getValue(height + hPadding)
1547			};
1548
1549			return pos;
1550		},
1551
1552		step: function (now, fx) {
1553			var ratio,
1554				padding,
1555				value,
1556				prop       = fx.prop,
1557				current    = F.current,
1558				wrapSpace  = current.wrapSpace,
1559				skinSpace  = current.skinSpace;
1560
1561			if (prop === 'width' || prop === 'height') {
1562				ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);
1563
1564				if (F.isClosing) {
1565					ratio = 1 - ratio;
1566				}
1567
1568				padding = prop === 'width' ? current.wPadding : current.hPadding;
1569				value   = now - padding;
1570
1571				F.skin[ prop ](  getScalar( prop === 'width' ?  value : value - (wrapSpace * ratio) ) );
1572				F.inner[ prop ]( getScalar( prop === 'width' ?  value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );
1573			}
1574		},
1575
1576		zoomIn: function () {
1577			var current  = F.current,
1578				startPos = current.pos,
1579				effect   = current.openEffect,
1580				elastic  = effect === 'elastic',
1581				endPos   = $.extend({opacity : 1}, startPos);
1582
1583			// Remove "position" property that breaks older IE
1584			delete endPos.position;
1585
1586			if (elastic) {
1587				startPos = this.getOrigPosition();
1588
1589				if (current.openOpacity) {
1590					startPos.opacity = 0.1;
1591				}
1592
1593			} else if (effect === 'fade') {
1594				startPos.opacity = 0.1;
1595			}
1596
1597			F.wrap.css(startPos).animate(endPos, {
1598				duration : effect === 'none' ? 0 : current.openSpeed,
1599				easing   : current.openEasing,
1600				step     : elastic ? this.step : null,
1601				complete : F._afterZoomIn
1602			});
1603		},
1604
1605		zoomOut: function () {
1606			var current  = F.current,
1607				effect   = current.closeEffect,
1608				elastic  = effect === 'elastic',
1609				endPos   = {opacity : 0.1};
1610
1611			if (elastic) {
1612				endPos = this.getOrigPosition();
1613
1614				if (current.closeOpacity) {
1615					endPos.opacity = 0.1;
1616				}
1617			}
1618
1619			F.wrap.animate(endPos, {
1620				duration : effect === 'none' ? 0 : current.closeSpeed,
1621				easing   : current.closeEasing,
1622				step     : elastic ? this.step : null,
1623				complete : F._afterZoomOut
1624			});
1625		},
1626
1627		changeIn: function () {
1628			var current   = F.current,
1629				effect    = current.nextEffect,
1630				startPos  = current.pos,
1631				endPos    = { opacity : 1 },
1632				direction = F.direction,
1633				distance  = 200,
1634				field;
1635
1636			startPos.opacity = 0.1;
1637
1638			if (effect === 'elastic') {
1639				field = direction === 'down' || direction === 'up' ? 'top' : 'left';
1640
1641				if (direction === 'down' || direction === 'right') {
1642					startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance);
1643					endPos[ field ]   = '+=' + distance + 'px';
1644
1645				} else {
1646					startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance);
1647					endPos[ field ]   = '-=' + distance + 'px';
1648				}
1649			}
1650
1651			// Workaround for http://bugs.jquery.com/ticket/12273
1652			if (effect === 'none') {
1653				F._afterZoomIn();
1654
1655			} else {
1656				F.wrap.css(startPos).animate(endPos, {
1657					duration : current.nextSpeed,
1658					easing   : current.nextEasing,
1659					complete : F._afterZoomIn
1660				});
1661			}
1662		},
1663
1664		changeOut: function () {
1665			var previous  = F.previous,
1666				effect    = previous.prevEffect,
1667				endPos    = { opacity : 0.1 },
1668				direction = F.direction,
1669				distance  = 200;
1670
1671			if (effect === 'elastic') {
1672				endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px';
1673			}
1674
1675			previous.wrap.animate(endPos, {
1676				duration : effect === 'none' ? 0 : previous.prevSpeed,
1677				easing   : previous.prevEasing,
1678				complete : function () {
1679					$(this).trigger('onReset').remove();
1680				}
1681			});
1682		}
1683	};
1684
1685	/*
1686	 *	Overlay helper
1687	 */
1688
1689	F.helpers.overlay = {
1690		defaults : {
1691			closeClick : true,      // if true, fancyBox will be closed when user clicks on the overlay
1692			speedOut   : 200,       // duration of fadeOut animation
1693			showEarly  : true,      // indicates if should be opened immediately or wait until the content is ready
1694			css        : {},        // custom CSS properties
1695			locked     : !isTouch,  // if true, the content will be locked into overlay
1696			fixed      : true       // if false, the overlay CSS position property will not be set to "fixed"
1697		},
1698
1699		overlay : null,      // current handle
1700		fixed   : false,     // indicates if the overlay has position "fixed"
1701		el      : $('html'), // element that contains "the lock"
1702
1703		// Public methods
1704		create : function(opts) {
1705			opts = $.extend({}, this.defaults, opts);
1706
1707			if (this.overlay) {
1708				this.close();
1709			}
1710
1711			this.overlay = $('<div class="fancybox-overlay"></div>').appendTo( F.coming ? F.coming.parent : opts.parent );
1712			this.fixed   = false;
1713
1714			if (opts.fixed && F.defaults.fixed) {
1715				this.overlay.addClass('fancybox-overlay-fixed');
1716
1717				this.fixed = true;
1718			}
1719		},
1720
1721		open : function(opts) {
1722			var that = this;
1723
1724			opts = $.extend({}, this.defaults, opts);
1725
1726			if (this.overlay) {
1727				this.overlay.unbind('.overlay').width('auto').height('auto');
1728
1729			} else {
1730				this.create(opts);
1731			}
1732
1733			if (!this.fixed) {
1734				W.bind('resize.overlay', $.proxy( this.update, this) );
1735
1736				this.update();
1737			}
1738
1739			if (opts.closeClick) {
1740				this.overlay.bind('click.overlay', function(e) {
1741					if ($(e.target).hasClass('fancybox-overlay')) {
1742						if (F.isActive) {
1743							F.close();
1744						} else {
1745							that.close();
1746						}
1747
1748						return false;
1749					}
1750				});
1751			}
1752
1753			this.overlay.css( opts.css ).show();
1754		},
1755
1756		close : function() {
1757			var scrollV, scrollH;
1758
1759			W.unbind('resize.overlay');
1760
1761			if (this.el.hasClass('fancybox-lock')) {
1762				$('.fancybox-margin').removeClass('fancybox-margin');
1763
1764				scrollV = W.scrollTop();
1765				scrollH = W.scrollLeft();
1766
1767				this.el.removeClass('fancybox-lock');
1768
1769				W.scrollTop( scrollV ).scrollLeft( scrollH );
1770			}
1771
1772			$('.fancybox-overlay').remove().hide();
1773
1774			$.extend(this, {
1775				overlay : null,
1776				fixed   : false
1777			});
1778		},
1779
1780		// Private, callbacks
1781
1782		update : function () {
1783			var width = '100%', offsetWidth;
1784
1785			// Reset width/height so it will not mess
1786			this.overlay.width(width).height('100%');
1787
1788			// jQuery does not return reliable result for IE
1789			if (IE) {
1790				offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
1791
1792				if (D.width() > offsetWidth) {
1793					width = D.width();
1794				}
1795
1796			} else if (D.width() > W.width()) {
1797				width = D.width();
1798			}
1799
1800			this.overlay.width(width).height(D.height());
1801		},
1802
1803		// This is where we can manipulate DOM, because later it would cause iframes to reload
1804		onReady : function (opts, obj) {
1805			var overlay = this.overlay;
1806
1807			$('.fancybox-overlay').stop(true, true);
1808
1809			if (!overlay) {
1810				this.create(opts);
1811			}
1812
1813			if (opts.locked && this.fixed && obj.fixed) {
1814				if (!overlay) {
1815					this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false;
1816				}
1817
1818				obj.locked = this.overlay.append( obj.wrap );
1819				obj.fixed  = false;
1820			}
1821
1822			if (opts.showEarly === true) {
1823				this.beforeShow.apply(this, arguments);
1824			}
1825		},
1826
1827		beforeShow : function(opts, obj) {
1828			var scrollV, scrollH;
1829
1830			if (obj.locked) {
1831				if (this.margin !== false) {
1832					$('*').filter(function(){
1833						return ($(this).css('position') === 'fixed' && !$(this).hasClass("fancybox-overlay") && !$(this).hasClass("fancybox-wrap") );
1834					}).addClass('fancybox-margin');
1835
1836					this.el.addClass('fancybox-margin');
1837				}
1838
1839				scrollV = W.scrollTop();
1840				scrollH = W.scrollLeft();
1841
1842				this.el.addClass('fancybox-lock');
1843
1844				W.scrollTop( scrollV ).scrollLeft( scrollH );
1845			}
1846
1847			this.open(opts);
1848		},
1849
1850		onUpdate : function() {
1851			if (!this.fixed) {
1852				this.update();
1853			}
1854		},
1855
1856		afterClose: function (opts) {
1857			// Remove overlay if exists and fancyBox is not opening
1858			// (e.g., it is not being open using afterClose callback)
1859			//if (this.overlay && !F.isActive) {
1860			if (this.overlay && !F.coming) {
1861				this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this ));
1862			}
1863		}
1864	};
1865
1866	/*
1867	 *	Title helper
1868	 */
1869
1870	F.helpers.title = {
1871		defaults : {
1872			type     : 'float', // 'float', 'inside', 'outside' or 'over',
1873			position : 'bottom' // 'top' or 'bottom'
1874		},
1875
1876		beforeShow: function (opts) {
1877			var current = F.current,
1878				text    = current.title,
1879				type    = opts.type,
1880				title,
1881				target;
1882
1883			if ($.isFunction(text)) {
1884				text = text.call(current.element, current);
1885			}
1886
1887			if (!isString(text) || $.trim(text) === '') {
1888				return;
1889			}
1890
1891			title = $('<div class="fancybox-title fancybox-title-' + type + '-wrap">
vendor: 3,161 bytes, lines 1891-2019
1891' + text + '</div>');
1892
1893			switch (type) {
1894				case 'inside':
1895					target = F.skin;
1896				break;
1897
1898				case 'outside':
1899					target = F.wrap;
1900				break;
1901
1902				case 'over':
1903					target = F.inner;
1904				break;
1905
1906				default: // 'float'
1907					target = F.skin;
1908
1909					title.appendTo('body');
1910
1911					if (IE) {
1912						title.width( title.width() );
1913					}
1914
1915					title.wrapInner('<span class="child"></span>');
1916
1917					//Increase bottom margin so this title will also fit into viewport
1918					F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
1919				break;
1920			}
1921
1922			title[ (opts.position === 'top' ? 'prependTo'  : 'appendTo') ](target);
1923		}
1924	};
1925
1926	// jQuery plugin initialization
1927	$.fn.fancybox = function (options) {
1928		var index,
1929			that     = $(this),
1930			selector = this.selector || '',
1931			run      = function(e) {
1932				var what = $(this).blur(), idx = index, relType, relVal;
1933
1934				if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {
1935					relType = options.groupAttr || 'data-fancybox-group';
1936					relVal  = what.attr(relType);
1937
1938					if (!relVal) {
1939						relType = 'rel';
1940						relVal  = what.get(0)[ relType ];
1941					}
1942
1943					if (relVal && relVal !== '' && relVal !== 'nofollow') {
1944						what = selector.length ? $(selector) : that;
1945						what = what.filter('[' + relType + '="' + relVal + '"]');
1946						idx  = what.index(this);
1947					}
1948
1949					options.index = idx;
1950
1951					// Stop an event from bubbling if everything is fine
1952					if (F.open(what, options) !== false) {
1953						e.preventDefault();
1954					}
1955				}
1956			};
1957
1958		options = options || {};
1959		index   = options.index || 0;
1960
1961		if (!selector || options.live === false) {
1962			that.unbind('click.fb-start').bind('click.fb-start', run);
1963
1964		} else {
1965			D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
1966		}
1967
1968		this.filter('[data-fancybox-start=1]').trigger('click');
1969
1970		return this;
1971	};
1972
1973	// Tests that need a body at doc ready
1974	D.ready(function() {
1975		var w1, w2;
1976
1977		if ( $.scrollbarWidth === undefined ) {
1978			// http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth
1979			$.scrollbarWidth = function() {
1980				var parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body'),
1981					child  = parent.children(),
1982					width  = child.innerWidth() - child.height( 99 ).innerWidth();
1983
1984				parent.remove();
1985
1986				return width;
1987			};
1988		}
1989
1990		if ( $.support.fixedPosition === undefined ) {
1991			$.support.fixedPosition = (function() {
1992				var elem  = $('<div style="position:fixed;top:20px;"></div>').appendTo('body'),
1993					fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 );
1994
1995				elem.remove();
1996
1997				return fixed;
1998			}());
1999		}
2000
2001		$.extend(F.defaults, {
2002			scrollbarWidth : $.scrollbarWidth(),
2003			fixed  : $.support.fixedPosition,
2004			parent : $('body')
2005		});
2006
2007		//Get real width of page scroll-bar
2008		w1 = $(window).width();
2009
2010		H.addClass('fancybox-lock-test');
2011
2012		w2 = $(window).width();
2013
2014		H.removeClass('fancybox-lock-test');
2015
2016		$("<style type='text/css'>.fancybox-margin{margin-right:" + (w2 - w1) + "px;}</style>").appendTo("head");
2017	});
2018
2019}(window, document, 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.