PageSourceSearch

https://www.ibisbis.com.au/library/Default/js/vendor/jquery.colorbox.js

js ibisbis.com.au collected 2026-10-05 02:22:03 UTC 28,760 bytes, 1,024 lines download raw bytes

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