PageSourceSearch

https://jean-charles-hachet.com/plugins-dist/mediabox/javascript/jquery.colorbox.js?1618426021

js jean-charles-hachet.com collected 2026-10-03 01:01:16 UTC 30,992 bytes, 1,142 lines download raw bytes

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