PageSourceSearch

https://www.dema-france.com/global/scripts/colorbox/jquery.colorbox.js

js dema-france.com collected 2026-10-04 03:34:26 UTC 26,733 bytes, 997 lines download raw bytes

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