PageSourceSearch

https://cabanasraras.org/js/jquery.colorbox.js

js cabanasraras.org collected 2026-10-03 00:51:30 UTC 28,086 bytes, 1,038 lines download raw bytes

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