PageSourceSearch

https://ijcmas.com/colorbox/jquery.colorbox.js

js ijcmas.com collected 2026-10-02 05:08:02 UTC 26,018 bytes, 942 lines download raw bytes

1// ColorBox v1.3.20.2 - jQuery lightbox plugin
2// (c) 2012 Jack Moore - jacklmoore.com
3// License: http://www.opensource.org/licenses/mit-license.php
4(function ($, document, window) {
5	var
6	// Default settings object.
7	// See http://jacklmoore.com/colorbox for details.
8	defaults = {
9		transition: "elastic",
10		speed: 300,
11		width: false,
12		initialWidth: "600",
13		innerWidth: false,
14		maxWidth: false,
15		height: false,
16		initialHeight: "450",
17		innerHeight: false,
18		maxHeight: false,
19		scalePhotos: true,
20		scrolling: true,
21		inline: false,
22		html: false,
23		iframe: false,
24		fastIframe: true,
25		photo: false,
26		href: false,
27		title: false,
28		rel: false,
29		opacity: 0.9,
30		preloading: true,
31
32		current: "image {current} of {total}",
33		previous: "previous",
34		next: "next",
35		close: "close",
36		xhrError: "This content failed to load.",
37		imgError: "This image failed to load.",
38
39		open: false,
40		returnFocus: true,
41		reposition: true,
42		loop: true,
43		slideshow: false,
44		slideshowAuto: true,
45		slideshowSpeed: 2500,
46		slideshowStart: "start slideshow",
47		slideshowStop: "stop slideshow",
48		onOpen: false,
49		onLoad: false,
50		onComplete: false,
51		onCleanup: false,
52		onClosed: false,
53		overlayClose: true,
54		escKey: true,
55		arrowKey: true,
56		top: false,
57		bottom: false,
58		left: false,
59		right: false,
60		fixed: false,
61		data: undefined
62	},
63	
64	// Abstracting the HTML and event identifiers for easy rebranding
65	colorbox = 'colorbox',
66	prefix = 'cbox',
67	boxElement = prefix + 'Element',
68	
69	// Events
70	event_open = prefix + '_open',
71	event_load = prefix + '_load',
72	event_complete = prefix + '_complete',
73	event_cleanup = prefix + '_cleanup',
74	event_closed = prefix + '_closed',
75	event_purge = prefix + '_purge',
76	
77	// Special Handling for IE
78	isIE = !$.support.opacity && !$.support.style, // IE7 & IE8
79	isIE6 = isIE && !window.XMLHttpRequest, // IE6
80	event_ie6 = prefix + '_IE6',
81
82	// Cached jQuery Object Variables
83	$overlay,
84	$box,
85	$wrap,
86	$content,
87	$topBorder,
88	$leftBorder,
89	$rightBorder,
90	$bottomBorder,
91	$related,
92	$window,
93	$loaded,
94	$loadingBay,
95	$loadingOverlay,
96	$title,
97	$current,
98	$slideshow,
99	$next,
100	$prev,
101	$close,
102	$groupControls,
103	
104	// Variables for cached values or use across multiple functions
105	settings,
106	interfaceHeight,
107	interfaceWidth,
108	loadedHeight,
109	loadedWidth,
110	element,
111	index,
112	photo,
113	open,
114	active,
115	closing,
116	loadingTimer,
117	publicMethod,
118	div = "div",
119	init;
120
121	// ****************
122	// HELPER FUNCTIONS
123	// ****************
124	
125	// Convience function for creating new jQuery objects
126	function $tag(tag, id, css) {
127		var element = document.createElement(tag);
128
129		if (id) {
130			element.id = prefix + id;
131		}
132
133		if (css) {
134			element.style.cssText = css;
135		}
136
137		return $(element);
138	}
139
140	// Determine the next and previous members in a group.
141	function getIndex(increment) {
142		var
143		max = $related.length,
144		newIndex = (index + increment) % max;
145		
146		return (newIndex < 0) ? max + newIndex : newIndex;
147	}
148
149	// Convert '%' and 'px' values to integers
150	function setSize(size, dimension) {
151		return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : $window.height()) / 100) : 1) * parseInt(size, 10));
152	}
153	
154	// Checks an href to see if it is a photo.
155	// There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
156	function isImage(url) {
157		return settings.photo || /\.(gif|png|jp(e|g|eg)|bmp|ico)((#|\?).*)?$/i.test(url);
158	}
159
160	// Assigns function results to their respective properties
161	function makeSettings() {
162		var i,
163			data = $.data(element, colorbox);
164		
165		if (data == null) {
166			settings = $.extend({}, defaults);
167			if (console && console.log) {
168				console.log('Error: cboxElement missing settings object');
169			}
170		} else {
171			settings = $.extend({}, data);
172		}
173		
174		for (i in settings) {
175			if ($.isFunction(settings[i]) && i.slice(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
176				settings[i] = settings[i].call(element);
177			}
178		}
179		
180		settings.rel = settings.rel || element.rel || $(element).data('rel') || 'nofollow';
181		settings.href = settings.href || $(element).attr('href');
182		settings.title = settings.title || element.title;
183		
184		if (typeof settings.href === "string") {
185			settings.href = $.trim(settings.href);
186		}
187	}
188
189	function trigger(event, callback) {
190		$.event.trigger(event);
191		if (callback) {
192			callback.call(element);
193		}
194	}
195
196	// Slideshow functionality
197	function slideshow() {
198		var
199		timeOut,
200		className = prefix + "Slideshow_",
201		click = "click." + prefix,
202		start,
203		stop;
204		
205		if (settings.slideshow && $related[1]) {
206			start = function () {
207				$slideshow
208					.html(settings.slideshowStop)
209					.unbind(click)
210					.bind(event_complete, function () {
211						if (settings.loop || $related[index + 1]) {
212							timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
213						}
214					})
215					.bind(event_load, function () {
216						clearTimeout(timeOut);
217					})
218					.one(click + ' ' + event_cleanup, stop);
219				$box.removeClass(className + "off").addClass(className + "on");
220				timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
221			};
222			
223			stop = function () {
224				clearTimeout(timeOut);
225				$slideshow
226					.html(settings.slideshowStart)
227					.unbind([event_complete, event_load, event_cleanup, click].join(' '))
228					.one(click, function () {
229						publicMethod.next();
230						start();
231					});
232				$box.removeClass(className + "on").addClass(className + "off");
233			};
234			
235			if (settings.slideshowAuto) {
236				start();
237			} else {
238				stop();
239			}
240		} else {
241			$box.removeClass(className + "off " + className + "on");
242		}
243	}
244
245	function launch(target) {
246		if (!closing) {
247			
248			element = target;
249			
250			makeSettings();
251			
252			$related = $(element);
253			
254			index = 0;
255			
256			if (settings.rel !== 'nofollow') {
257				$related = $('.' + boxElement).filter(function () {
258					var data = $.data(this, colorbox),
259						relRelated;
260
261					if (data) {
262						relRelated =  $(this).data('rel') || data.rel || this.rel;
263					}
264					
265					return (relRelated === settings.rel);
266				});
267				index = $related.index(element);
268				
269				// Check direct calls to ColorBox.
270				if (index === -1) {
271					$related = $related.add(element);
272					index = $related.length - 1;
273				}
274			}
275			
276			if (!open) {
277				open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
278				
279				$box.show();
280				
281				if (settings.returnFocus) {
282					$(element).blur().one(event_closed, function () {
283						$(this).focus();
284					});
285				}
286				
287				// +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
288				$overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show();
289				
290				// Opens inital empty ColorBox prior to content being loaded.
291				settings.w = setSize(settings.initialWidth, 'x');
292				settings.h = setSize(settings.initialHeight, 'y');
293				publicMethod.position();
294				
295				if (isIE6) {
296					$window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () {
297						$overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
298					}).trigger('resize.' + event_ie6);
299				}
300				
301				trigger(event_open, settings.onOpen);
302				
303				$groupControls.add($title).hide();
304				
305				$close.html(settings.close).show();
306			}
307			
308			publicMethod.load(true);
309		}
310	}
311
312	// ColorBox's markup needs to be added to the DOM prior to being called
313	// so that the browser will go ahead and load the CSS background images.
314	function appendHTML() {
315		if (!$box && document.body) {
316			init = false;
317
318			$window = $(window);
319			$box = $tag(div).attr({id: colorbox, 'class': isIE ? prefix + (isIE6 ? 'IE6' : 'IE') : ''}).hide();
320			$overlay = $tag(div, "Overlay", isIE6 ? 'position:absolute' : '').hide();
321			$loadingOverlay = $tag(div, "LoadingOverlay").add($tag(div, "LoadingGraphic"));
322			$wrap = $tag(div, "Wrapper");
323			$content = $tag(div, "Content").append(
324				$loaded = $tag(div, "LoadedContent", 'width:0; height:0; overflow:hidden'),
325				$title = $tag(div, "Title"),
326				$current = $tag(div, "Current"),
327				$next = $tag(div, "Next"),
328				$prev = $tag(div, "Previous"),
329				$slideshow = $tag(div, "Slideshow").bind(event_open, slideshow),
330				$close = $tag(div, "Close")
331			);
332			
333			$wrap.append( // The 3x3 Grid that makes up ColorBox
334				$tag(div).append(
335					$tag(div, "TopLeft"),
336					$topBorder = $tag(div, "TopCenter"),
337					$tag(div, "TopRight")
338				),
339				$tag(div, false, 'clear:left').append(
340					$leftBorder = $tag(div, "MiddleLeft"),
341					$content,
342					$rightBorder = $tag(div, "MiddleRight")
343				),
344				$tag(div, false, 'clear:left').append(
345					$tag(div, "BottomLeft"),
346					$bottomBorder = $tag(div, "BottomCenter"),
347					$tag(div, "BottomRight")
348				)
349			).find('div div').css({'float': 'left'});
350			
351			$loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none');
352			
353			$groupControls = $next.add($prev).add($current).add($slideshow);
354
355			$(document.body).append($overlay, $box.append($wrap, $loadingBay));
356		}
357	}
358
359	// Add ColorBox's event bindings
360	function addBindings() {
361		if ($box) {
362			if (!init) {
363				init = true;
364
365				// Cache values needed for size calculations
366				interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
367				interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
368				loadedHeight = $loaded.outerHeight(true);
369				loadedWidth = $loaded.outerWidth(true);
370				
371				// Setting padding to remove the need to do size conversions during the animation step.
372				$box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth});
373
374				// Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.
375				$next.click(function () {
376					publicMethod.next();
377				});
378				$prev.click(function () {
379					publicMethod.prev();
380				});
381				$close.click(function () {
382					publicMethod.close();
383				});
384				$overlay.click(function () {
385					if (settings.overlayClose) {
386						publicMethod.close();
387					}
388				});
389				
390				// Key Bindings
391				$(document).bind('keydown.' + prefix, function (e) {
392					var key = e.keyCode;
393					if (open && settings.escKey && key === 27) {
394						e.preventDefault();
395						publicMethod.close();
396					}
397					if (open && settings.arrowKey && $related[1]) {
398						if (key === 37) {
399							e.preventDefault();
400							$prev.click();
401						} else if (key === 39) {
402							e.preventDefault();
403							$next.click();
404						}
405					}
406				});
407
408				$(document).delegate('.'+boxElement, 'click', function(e) {
409					// ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt.
410					// See: http://jacklmoore.com/notes/click-events/
411					if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey)) {
412						e.preventDefault();
413						launch(this);
414					}
415				});
416			}
417			return true;
418		}
419		return false;
420	}
421
422	// Don't do anything if ColorBox already exists.
423	if ($.colorbox) {
424		return;
425	}
426
427	// Append the HTML when the DOM loads
428	$(appendHTML);
429
430
431	// ****************
432	// PUBLIC FUNCTIONS
433	// Usage format: $.fn.colorbox.close();
434	// Usage from within an iframe: parent.$.fn.colorbox.close();
435	// ****************
436	
437	publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
438		var $this = this;
439		
440		options = options || {};
441		
442		appendHTML();
443
444		if (addBindings()) {
445			if (!$this[0]) {
446				if ($this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit.
447					return $this;
448				}
449				// if no selector was given (ie. $.colorbox()), create a temporary element to work with
450				$this = $('<a/>');
451				options.open = true; // assume an immediate open
452			}
453			
454			if (callback) {
455				options.onComplete = callback;
456			}
457			
458			$this.each(function () {
459				$.data(this, colorbox, $.extend({}, $.data(this, colorbox) || defaults, options));
460			}).addClass(boxElement);
461			
462			if (($.isFunction(options.open) && options.open.call($this)) || options.open) {
463				launch($this[0]);
464			}
465		}
466		
467		return $this;
468	};
469
470	publicMethod.position = function (speed, loadedCallback) {
471		var
472		css,
473		top = 0,
474		left = 0,
475		offset = $box.offset(),
476		scrollTop,
477		scrollLeft;
478		
479		$window.unbind('resize.' + prefix);
480
481		// remove the modal so that it doesn't influence the document width/height
482		$box.css({top: -9e4, left: -9e4});
483
484		scrollTop = $window.scrollTop();
485		scrollLeft = $window.scrollLeft();
486
487		if (settings.fixed && !isIE6) {
488			offset.top -= scrollTop;
489			offset.left -= scrollLeft;
490			$box.css({position: 'fixed'});
491		} else {
492			top = scrollTop;
493			left = scrollLeft;
494			$box.css({position: 'absolute'});
495		}
496
497		// keeps the top and left positions within the browser's viewport.
498		if (settings.right !== false) {
499			left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(sett
499ings.right, 'x'), 0);
500		} else if (settings.left !== false) {
501			left += setSize(settings.left, 'x');
502		} else {
503			left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
504		}
505		
506		if (settings.bottom !== false) {
507			top += Math.max($window.height() - settings.h - loadedHeight - interfaceHeight - setSize(settings.bottom, 'y'), 0);
508		} else if (settings.top !== false) {
509			top += setSize(settings.top, 'y');
510		} else {
511			top += Math.round(Math.max($window.height() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
512		}
513
514		$box.css({top: offset.top, left: offset.left});
515
516		// setting the speed to 0 to reduce the delay between same-sized content.
517		speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed || 0;
518		
519		// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
520		// but it has to be shrank down around the size of div#colorbox when it's done.  If not,
521		// it can invoke an obscure IE bug when using iframes.
522		$wrap[0].style.width = $wrap[0].style.height = "9999px";
523		
524		function modalDimensions(that) {
525			$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
526			$content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
527		}
528
529		css = {width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: top, left: left};
530		if(speed===0){ // temporary workaround to side-step jQuery-UI 1.8 bug (http://bugs.jquery.com/ticket/12273)
531			$box.css(css);
532		}
533		$box.dequeue().animate(css, {
534			duration: speed,
535			complete: function () {
536				modalDimensions(this);
537				
538				active = false;
539				
540				// shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
541				$wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
542				$wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
543				
544				if (settings.reposition) {
545					setTimeout(function () {  // small delay before binding onresize due to an IE8 bug.
546						$window.bind('resize.' + prefix, publicMethod.position);
547					}, 1);
548				}
549
550				if (loadedCallback) {
551					loadedCallback();
552				}
553			},
554			step: function () {
555				modalDimensions(this);
556			}
557		});
558	};
559
560	publicMethod.resize = function (options) {
561		if (open) {
562			options = options || {};
563			
564			if (options.width) {
565				settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
566			}
567			if (options.innerWidth) {
568				settings.w = setSize(options.innerWidth, 'x');
569			}
570			$loaded.css({width: settings.w});
571			
572			if (options.height) {
573				settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
574			}
575			if (options.innerHeight) {
576				settings.h = setSize(options.innerHeight, 'y');
577			}
578			if (!options.innerHeight && !options.height) {
579				$loaded.css({height: "auto"});
580				settings.h = $loaded.height();
581			}
582			$loaded.css({height: settings.h});
583			
584			publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
585		}
586	};
587
588	publicMethod.prep = function (object) {
589		if (!open) {
590			return;
591		}
592		
593		var callback, speed = settings.transition === "none" ? 0 : settings.speed;
594		
595		$loaded.remove();
596		$loaded = $tag(div, 'LoadedContent').append(object);
597		
598		function getWidth() {
599			settings.w = settings.w || $loaded.width();
600			settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
601			return settings.w;
602		}
603		function getHeight() {
604			settings.h = settings.h || $loaded.height();
605			settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
606			return settings.h;
607		}
608		
609		$loaded.hide()
610		.appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
611		.css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
612		.css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
613		.prependTo($content);
614		
615		$loadingBay.hide();
616		
617		// floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
618		//$(photo).css({'float': 'none', marginLeft: 'auto', marginRight: 'auto'});
619		
620		$(photo).css({'float': 'none'});
621		
622		// Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
623		if (isIE6) {
624			$('select').not($box.find('select')).filter(function () {
625				return this.style.visibility !== 'hidden';
626			}).css({'visibility': 'hidden'}).one(event_cleanup, function () {
627				this.style.visibility = 'inherit';
628			});
629		}
630		
631		callback = function () {
632			var preload,
633				i,
634				total = $related.length,
635				iframe,
636				frameBorder = 'frameBorder',
637				allowTransparency = 'allowTransparency',
638				complete,
639				src,
640				img,
641				data;
642			
643			if (!open) {
644				return;
645			}
646			
647			function removeFilter() {
648				if (isIE) {
649					$box[0].style.removeAttribute('filter');
650				}
651			}
652			
653			complete = function () {
654				clearTimeout(loadingTimer);
655				// Detaching forces Andriod stock browser to redraw the area underneat the loading overlay.  Hiding alone isn't enough.
656				$loadingOverlay.detach().hide();
657				trigger(event_complete, settings.onComplete);
658			};
659			
660			if (isIE) {
661				//This fadeIn helps the bicubic resampling to kick-in.
662				if (photo) {
663					$loaded.fadeIn(100);
664				}
665			}
666			
667			$title.html(settings.title).add($loaded).show();
668			
669			if (total > 1) { // handle grouping
670				if (typeof settings.current === "string") {
671					$current.html(settings.current.replace('{current}', index + 1).replace('{total}', total)).show();
672				}
673				
674				$next[(settings.loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
675				$prev[(settings.loop || index) ? "show" : "hide"]().html(settings.previous);
676				
677				if (settings.slideshow) {
678					$slideshow.show();
679				}
680				
681				// Preloads images within a rel group
682				if (settings.preloading) {
683					preload = [
684						getIndex(-1),
685						getIndex(1)
686					];
687					while (i = $related[preload.pop()]) {
688						data = $.data(i, colorbox);
689						
690						if (data && data.href) {
691							src = data.href;
692							if ($.isFunction(src)) {
693								src = src.call(i);
694							}
695						} else {
696							src = i.href;
697						}
698
699						if (isImage(src)) {
700							img = new Image();
701							img.src = src;
702						}
703					}
704				}
705			} else {
706				$groupControls.hide();
707			}
708			
709			if (settings.iframe) {
710				iframe = $tag('iframe')[0];
711				
712				if (frameBorder in iframe) {
713					iframe[frameBorder] = 0;
714				}
715				
716				if (allowTransparency in iframe) {
717					iframe[allowTransparency] = "true";
718				}
719
720				if (!settings.scrolling) {
721					iframe.scrolling = "no";
722				}
723				
724				$(iframe)
725					.attr({
726						src: settings.href,
727						name: (new Date()).getTime(), // give the iframe a unique name to prevent caching
728						'class': prefix + 'Iframe',
729						allowFullScreen : true, // allow HTML5 video to go fullscreen
730						webkitAllowFullScreen : true,
731						mozallowfullscreen : true
732					})
733					.one('load', complete)
734					.one(event_purge, function () {
735						iframe.src = "//about:blank";
736					})
737					.appendTo($loaded);
738				
739				if (settings.fastIframe) {
740					$(iframe).trigger('load');
741				}
742			} else {
743				complete();
744			}
745			
746			if (settings.transition === 'fade') {
747				$box.fadeTo(speed, 1, removeFilter);
748			} else {
749				removeFilter();
750			}
751		};
752		
753		if (settings.transition === 'fade') {
754			$box.fadeTo(speed, 0, function () {
755				publicMethod.position(0, callback);
756			});
757		} else {
758			publicMethod.position(speed, callback);
759		}
760	};
761
762	publicMethod.load = function (launched) {
763		var href, setResize, prep = publicMethod.prep;
764		
765		active = true;
766		
767		photo = false;
768		
769		element = $related[index];
770		
771		if (!launched) {
772			makeSettings();
773		}
774		
775		trigger(event_purge);
776		
777		trigger(event_load, settings.onLoad);
778		
779		settings.h = settings.height ?
780				setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
781				settings.innerHeight && setSize(settings.innerHeight, 'y');
782		
783		settings.w = settings.width ?
784				setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
785				settings.innerWidth && setSize(settings.innerWidth, 'x');
786		
787		// Sets the minimum dimensions for use in image scaling
788		settings.mw = settings.w;
789		settings.mh = settings.h;
790		
791		// Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
792		// If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
793		if (settings.maxWidth) {
794			settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
795			settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
796		}
797		if (settings.maxHeight) {
798			settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
799			settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
800		}
801		
802		href = settings.href;
803		
804		loadingTimer = setTimeout(function () {
805			$loadingOverlay.show().appendTo($content);
806		}, 100);
807		
808		if (settings.inline) {
809			// Inserts an empty placeholder where inline content is being pulled from.
810			// An event is bound to put inline content back when ColorBox closes or loads new content.
811			$tag(div).hide().insertBefore($(href)[0]).one(event_purge, function () {
812				$(this).replaceWith($loaded.children());
813			});
814			prep($(href));
815		} else if (settings.iframe) {
816			// IFrame element won't be added to the DOM until it is ready to be displayed,
817			// to avoid problems with DOM-ready JS that might be trying to run in that iframe.
818			prep(" ");
819		} else if (settings.html) {
820			prep(settings.html);
821		} else if (isImage(href)) {
822			$(photo = new Image())
823			.addClass(prefix + 'Photo')
824			.error(function () {
825				settings.title = false;
826				prep($tag(div, 'Error').html(settings.imgError));
827			})
828			.load(function () {
829				var percent;
830				photo.onload = null; //stops animated gifs from firing the onload repeatedly.
831				
832				if (settings.scalePhotos) {
833					setResize = function () {
834						photo.height -= photo.height * percent;
835						photo.width -= photo.width * percent;
836					};
837					if (settings.mw && photo.width > settings.mw) {
838						percent = (photo.width - settings.mw) / photo.width;
839						setResize();
840					}
841					if (settings.mh && photo.height > settings.mh) {
842						percent = (photo.height - settings.mh) / photo.height;
843						setResize();
844					}
845				}
846				
847				if (settings.h) {
848					photo.style.marginTop = Math.max(settings.h - photo.height, 0) / 2 + 'px';
849				}
850				
851				if ($related[1] && (settings.loop || $related[index + 1])) {
852					photo.style.cursor = 'pointer';
853					photo.onclick = function () {
854						publicMethod.next();
855					};
856				}
857				
858				if (isIE) {
859					photo.style.msInterpolationMode = 'bicubic';
860				}
861				
862				setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
863					prep(photo);
864				}, 1);
865			});
866			
867			setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
868				photo.src = href;
869			}, 1);
870		} else if (href) {
871			$loadingBay.load(href, settings.data, function (data, status) {
872				prep(status === 'error' ? $tag(div, 'Error').html(settings.xhrError) : $(this).contents());
873			});
874		}
875	};
876		
877	// Navigates to the next page/image in a set.
878	publicMethod.next = function () {
879		if (!active && $related[1] && (settings.loop || $related[index + 1])) {
880			index = getIndex(1);
881			publicMethod.load();
882		}
883	};
884	
885	publicMethod.prev = function () {
886		if (!active && $related[1] && (settings.loop || index)) {
887			index = getIndex(-1);
888			publicMethod.load();
889		}
890	};
891
892	// Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
893	publicMethod.close = function () {
894		if (open && !closing) {
895			
896			closing = true;
897			
898			open = false;
899			
900			trigger(event_cleanup, settings.onCleanup);
901			
902			$window.unbind('.' + prefix + ' .' + event_ie6);
903			
904			$overlay.fadeTo(200, 0);
905			
906			$box.stop().fadeTo(300, 0, function () {
907			
908				$box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
909				
910				trigger(event_purge);
911				
912				$loaded.remove();
913				
914				setTimeout(function () {
915					closing = false;
916					trigger(event_closed, settings.onClosed);
917				}, 1);
918			});
919		}
920	};
921
922	// Removes changes ColorBox made to the document, but does not remove the plugin
923	// from jQuery.
924	publicMethod.remove = function () {
925		$([]).add($box).add($overlay).remove();
926		$box = null;
927		$('.' + boxElement)
928			.removeData(colorbox)
929			.removeClass(boxElement);
930
931		$(document).undelegate('.'+boxElement);
932	};
933
934	// A method for fetching the current element ColorBox is referencing.
935	// returns a jQuery object.
936	publicMethod.element = function () {
937		return $(element);
938	};
939
940	publicMethod.settings = defaults;
941
942}(jQuery, document, window));

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.