1 // ColorBox v1.3.20.1 - jQuery lightbox plugin
2 // (c) 2011 Jack Moore - jacklmoore.com
3 // License: http://www.opensource.org/licenses/mit-license.php
4 // + minWidth&minHeight support
5 // + colorbox_class support
6 (function ($, document
, window
) {
8 // Default settings object.
9 // See http://jacklmoore.com/colorbox for details.
11 transition
: "elastic",
36 current
: "image {current} of {total}",
40 xhrError
: "This content failed to load.",
41 imgError
: "This image failed to load.",
50 slideshowStart
: "start slideshow",
51 slideshowStop
: "stop slideshow",
68 // Abstracting the HTML and event identifiers for easy rebranding
69 colorbox
= 'colorbox',
70 colorbox_class
= 'box_mediabox box_modalbox',
72 boxElement
= prefix
+ 'Element',
75 event_open
= prefix
+ '_open',
76 event_load
= prefix
+ '_load',
77 event_complete
= prefix
+ '_complete',
78 event_cleanup
= prefix
+ '_cleanup',
79 event_closed
= prefix
+ '_closed',
80 event_purge
= prefix
+ '_purge',
82 // Special Handling for IE
83 isIE
= !$.support
.opacity
&& !$.support
.style
, // IE7 & IE8
84 isIE6
= isIE
&& !window
.XMLHttpRequest
, // IE6
85 event_ie6
= prefix
+ '_IE6',
87 // Cached jQuery Object Variables
109 // Variables for cached values or use across multiple functions
130 // Convience function for creating new jQuery objects
131 function $tag(tag
, id
, css
) {
132 var element
= document
.createElement(tag
);
135 element
.id
= prefix
+ id
;
139 element
.style
.cssText
= css
;
145 // Determine the next and previous members in a group.
146 function getIndex(increment
) {
148 max
= $related
.length
,
149 newIndex
= (index
+ increment
) % max
;
151 return (newIndex
< 0) ? max
+ newIndex
: newIndex
;
154 // Convert '%' and 'px' values to integers
155 function setSize(size
, dimension
) {
156 return Math
.round((/%/.test(size) ? ((dimension === 'x' ? winWidth() : winHeight()) / 100) : 1) * parseInt(size
, 10));
159 // Checks an href to see if it is a photo.
160 // There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
161 function isImage(url
) {
162 return settings
.photo
|| /\.(gif|png|jp(e|g|eg)|bmp|ico)((#|\?).*)?$/i.test(url
);
165 function winWidth() {
166 // $(window).width() is incorrect for some mobile browsers, but
167 // window.innerWidth is unsupported in IE8 and lower.
168 return window
.innerWidth
|| $window
.width();
171 function winHeight() {
172 return window
.innerHeight
|| $window
.height();
175 // Assigns function results to their respective properties
176 function makeSettings() {
178 data
= $.data(element
, colorbox
);
181 settings
= $.extend({}, defaults
);
182 if (console
&& console
.log
) {
183 console
.log('Error: cboxElement missing settings object');
186 settings
= $.extend({}, data
);
189 for (i
in settings
) {
190 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.
191 settings
[i
] = settings
[i
].call(element
);
195 settings
.rel
= settings
.rel
|| element
.rel
|| $(element
).data('rel') || 'nofollow';
196 settings
.href
= settings
.href
|| $(element
).attr('href');
197 settings
.title
= settings
.title
|| element
.title
;
199 if (typeof settings
.href
=== "string") {
200 settings
.href
= $.trim(settings
.href
);
204 function trigger(event
, callback
) {
205 $.event
.trigger(event
);
207 callback
.call(element
);
211 // Slideshow functionality
212 function slideshow() {
215 className
= prefix
+ "Slideshow_",
216 click
= "click." + prefix
,
221 if (settings
.slideshow
&& $related
[1]) {
222 start = function () {
224 .text(settings
.slideshowStop
)
226 .bind(event_complete
, function () {
227 if (settings
.loop
|| $related
[index
+ 1]) {
228 timeOut
= setTimeout(publicMethod
.next
, settings
.slideshowSpeed
);
231 .bind(event_load
, function () {
232 clearTimeout(timeOut
);
234 .one(click
+ ' ' + event_cleanup
, stop
);
235 $box
.removeClass(className
+ "off").addClass(className
+ "on");
236 timeOut
= setTimeout(publicMethod
.next
, settings
.slideshowSpeed
);
240 clearTimeout(timeOut
);
242 .text(settings
.slideshowStart
)
243 .unbind([event_complete
, event_load
, event_cleanup
, click
].join(' '))
244 .one(click
, function () {
248 $box
.removeClass(className
+ "on").addClass(className
+ "off");
251 if (settings
.slideshowAuto
) {
257 $box
.removeClass(className
+ "off " + className
+ "on");
261 var init_dimensions
= false;
262 function launch(target
) {
269 $related
= $(element
);
273 if (settings
.rel
!== 'nofollow') {
274 $related
= $('.' + boxElement
).filter(function () {
275 var data
= $.data(this, colorbox
),
279 relRelated
= $(this).data('rel') || data
.rel
|| this.rel
;
282 return (relRelated
=== settings
.rel
);
284 index
= $related
.index(element
);
286 // Check direct calls to ColorBox.
288 $related
= $related
.add(element
);
289 index
= $related
.length
- 1;
294 if (!init_dimensions
) {
295 init_dimensions
= true;
296 // Cache values needed for size calculations
297 interfaceHeight
= $topBorder
.height() + $bottomBorder
.height() + $content
.outerHeight(true) - $content
.height();//Subtraction needed for IE6
298 interfaceWidth
= $leftBorder
.width() + $rightBorder
.width() + $content
.outerWidth(true) - $content
.width();
299 loadedHeight
= $loaded
.outerHeight(true);
300 loadedWidth
= $loaded
.outerWidth(true);
302 // Setting padding to remove the need to do size conversions during the animation step.
303 $box
.css({"padding-bottom": interfaceHeight
, "padding-right": interfaceWidth
});
306 open
= active
= true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
310 if (settings
.returnFocus
) {
311 $(element
).blur().one(event_closed
, function () {
316 // +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
317 $overlay
.css({"opacity": +settings
.opacity
, "cursor": settings
.overlayClose
? "pointer" : "auto"}).show();
319 // Opens inital empty ColorBox prior to content being loaded.
320 settings
.w
= setSize(settings
.initialWidth
, 'x');
321 settings
.h
= setSize(settings
.initialHeight
, 'y');
322 publicMethod
.position();
325 $window
.bind('resize.' + event_ie6
+ ' scroll.' + event_ie6
, function () {
326 $overlay
.css({width
: winWidth(), height
: winHeight(), top
: $window
.scrollTop(), left
: $window
.scrollLeft()});
327 }).trigger('resize.' + event_ie6
);
330 trigger(event_open
, settings
.onOpen
);
332 $groupControls
.add($title
).hide();
334 $close
.html(settings
.close
).show();
337 publicMethod
.load(true);
341 // ColorBox's markup needs to be added to the DOM prior to being called
342 // so that the browser will go ahead and load the CSS background images.
343 function appendHTML() {
344 if (!$box
&& document
.body
) {
348 $box
= $tag(div
).attr({id
: colorbox
, 'class': (isIE
? prefix
+ (isIE6
? 'IE6' : 'IE') : '')+colorbox_class
}).hide();
349 $overlay
= $tag(div
, "Overlay", isIE6
? 'position:absolute' : '').hide();
350 $loadingOverlay
= $tag(div
, "LoadingOverlay").add($tag(div
, "LoadingGraphic"));
351 $wrap
= $tag(div
, "Wrapper");
352 $content
= $tag(div
, "Content").append(
353 $loaded
= $tag(div
, "LoadedContent", 'width:0; height:0; overflow:hidden'),
354 $title
= $tag(div
, "Title"),
355 $current
= $tag(div
, "Current"),
356 $next
= $tag(div
, "Next"),
357 $prev
= $tag(div
, "Previous"),
358 $slideshow
= $tag(div
, "Slideshow").bind(event_open
, slideshow
),
359 $close
= $tag(div
, "Close")
362 $wrap
.append( // The 3x3 Grid that makes up ColorBox
364 $tag(div
, "TopLeft"),
365 $topBorder
= $tag(div
, "TopCenter"),
366 $tag(div
, "TopRight")
368 $tag(div
, false, 'clear:left').append(
369 $leftBorder
= $tag(div
, "MiddleLeft"),
371 $rightBorder
= $tag(div
, "MiddleRight")
373 $tag(div
, false, 'clear:left').append(
374 $tag(div
, "BottomLeft"),
375 $bottomBorder
= $tag(div
, "BottomCenter"),
376 $tag(div
, "BottomRight")
378 ).find('div div').css({'float': 'left'});
380 $loadingBay
= $tag(div
, false, 'position:absolute; width:9999px; visibility:hidden; display:none');
382 $groupControls
= $next
.add($prev
).add($current
).add($slideshow
);
384 $(document
.body
).append($overlay
, $box
.append($wrap
, $loadingBay
));
388 // Add ColorBox's event bindings
389 function addBindings() {
394 // Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.
395 $next
.click(function () {
398 $prev
.click(function () {
401 $close
.click(function () {
402 publicMethod
.close();
404 $overlay
.click(function () {
405 if (settings
.overlayClose
) {
406 publicMethod
.close();
411 $(document
).bind('keydown.' + prefix
, function (e
) {
413 if (open
&& settings
.escKey
&& key
=== 27) {
415 publicMethod
.close();
417 if (open
&& settings
.arrowKey
&& $related
[1]) {
421 } else if (key
=== 39) {
428 $('.' + boxElement
, document
).live('click', function (e
) {
429 // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt.
430 // See: http://jacklmoore.com/notes/click-events/
431 if (!(e
.which
> 1 || e
.shiftKey
|| e
.altKey
|| e
.metaKey
)) {
442 // Don't do anything if ColorBox already exists.
447 // Append the HTML when the DOM loads
453 // Usage format: $.fn.colorbox.close();
454 // Usage from within an iframe: parent.$.fn.colorbox.close();
457 publicMethod
= $.fn
[colorbox
] = $[colorbox
] = function (options
, callback
) {
460 options
= options
|| {};
466 if ($this.selector
) { // if a selector was given and it didn't match any elements, go ahead and exit.
469 // if no selector was given (ie. $.colorbox()), create a temporary element to work with
471 options
.open
= true; // assume an immediate open
475 options
.onComplete
= callback
;
478 $this.each(function () {
479 $.data(this, colorbox
, $.extend({}, $.data(this, colorbox
) || defaults
, options
));
480 var eltclass
= $(this).attr('class');
482 if (eltclass
.indexOf("boxWidth-")!==-1) {
483 var w
= eltclass
.match(/boxWidth-([^\s'">]*)/);
484 w
= w
[1].replace(/pc/,'%'); // % not allowed in html attribute ; use 100pc instead of 100%
485 $.data(this, colorbox
, $.extend($.data(this, colorbox
),{width
:w
}));
487 if (eltclass
.indexOf("boxHeight-")!==-1) {
488 var h
= eltclass
.match(/boxHeight-([^\s'">]*)/);
489 h
= h
[1].replace(/pc/,'%'); // % not allowed in html attribute ; use 100pc instead of 100%
490 $.data(this, colorbox
, $.extend($.data(this, colorbox
),{height
:h
}));
492 if (eltclass
.indexOf("boxIframe")!==-1) {
493 $.data(this, colorbox
, $.extend($.data(this, colorbox
),{iframe
:true}));
495 if (eltclass
.indexOf("boxInline")!==-1) {
496 $.data(this, colorbox
, $.extend($.data(this, colorbox
),{inline
:true}));
498 if (eltclass
.indexOf("boxSlideshow_off")!==-1) {
499 $.data(this, colorbox
, $.extend($.data(this, colorbox
),{slideshow
:false}));
502 }).addClass(boxElement
);
504 if (($.isFunction(options
.open
) && options
.open
.call($this)) || options
.open
) {
512 publicMethod
.position = function (speed
, loadedCallback
) {
517 offset
= $box
.offset(),
521 $window
.unbind('resize.' + prefix
);
523 // remove the modal so that it doesn't influence the document width/height
524 $box
.css({top
: -9e4
, left
: -9e4
});
526 scrollTop
= $window
.scrollTop();
527 scrollLeft
= $window
.scrollLeft();
529 if (settings
.fixed
&& !isIE6
) {
530 offset
.top
-= scrollTop
;
531 offset
.left
-= scrollLeft
;
532 $box
.css({position
: 'fixed'});
536 $box
.css({position
: 'absolute'});
539 // keeps the top and left positions within the browser's viewport.
540 if (settings
.right
!== false) {
541 left
+= Math
.max(winWidth() - settings
.w
- loadedWidth
- interfaceWidth
- setSize(settings
.right
, 'x'), 0);
542 } else if (settings
.left
!== false) {
543 left
+= setSize(settings
.left
, 'x');
545 left
+= Math
.round(Math
.max(winWidth() - settings
.w
- loadedWidth
- interfaceWidth
, 0) / 2);
548 if (settings
.bottom
!== false) {
549 top
+= Math
.max(winHeight() - settings
.h
- loadedHeight
- interfaceHeight
- setSize(settings
.bottom
, 'y'), 0);
550 } else if (settings
.top
!== false) {
551 top
+= setSize(settings
.top
, 'y');
553 top
+= Math
.round(Math
.max(winHeight() - settings
.h
- loadedHeight
- interfaceHeight
, 0) / 2);
556 $box
.css({top
: offset
.top
, left
: offset
.left
});
558 // setting the speed to 0 to reduce the delay between same-sized content.
559 speed
= ($box
.width() === settings
.w
+ loadedWidth
&& $box
.height() === settings
.h
+ loadedHeight
) ? 0 : speed
|| 0;
561 // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
562 // but it has to be shrank down around the size of div#colorbox when it's done. If not,
563 // it can invoke an obscure IE bug when using iframes.
564 $wrap
[0].style
.width
= $wrap
[0].style
.height
= "9999px";
566 function modalDimensions(that
) {
567 $topBorder
[0].style
.width
= $bottomBorder
[0].style
.width
= $content
[0].style
.width
= that
.style
.width
;
568 $content
[0].style
.height
= $leftBorder
[0].style
.height
= $rightBorder
[0].style
.height
= that
.style
.height
;
571 css
= {width
: settings
.w
+ loadedWidth
, height
: settings
.h
+ loadedHeight
, top
: top
, left
: left
};
572 if(speed
===0){ // temporary workaround to side-step jQuery-UI 1.8 bug (http://bugs.jquery.com/ticket/12273)
575 $box
.dequeue().animate(css
, {
577 complete: function () {
578 modalDimensions(this);
582 // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
583 $wrap
[0].style
.width
= (settings
.w
+ loadedWidth
+ interfaceWidth
) + "px";
584 $wrap
[0].style
.height
= (settings
.h
+ loadedHeight
+ interfaceHeight
) + "px";
586 if (settings
.reposition
) {
587 setTimeout(function () { // small delay before binding onresize due to an IE8 bug.
588 $window
.bind('resize.' + prefix
, publicMethod
.position
);
592 if (loadedCallback
) {
597 modalDimensions(this);
602 publicMethod
.resize = function (options
) {
604 options
= options
|| {};
607 settings
.w
= setSize(options
.width
, 'x') - loadedWidth
- interfaceWidth
;
609 if (options
.innerWidth
) {
610 settings
.w
= setSize(options
.innerWidth
, 'x');
612 $loaded
.css({width
: settings
.w
});
614 if (options
.height
) {
615 settings
.h
= setSize(options
.height
, 'y') - loadedHeight
- interfaceHeight
;
617 if (options
.innerHeight
) {
618 settings
.h
= setSize(options
.innerHeight
, 'y');
620 if (!options
.innerHeight
&& !options
.height
) {
621 $loaded
.css({height
: "auto"});
622 settings
.h
= $loaded
.height();
624 $loaded
.css({height
: settings
.h
});
626 publicMethod
.position(settings
.transition
=== "none" ? 0 : settings
.speed
);
630 publicMethod
.prep = function (object
) {
635 var callback
, speed
= settings
.transition
=== "none" ? 0 : settings
.speed
;
638 $loaded
= $tag(div
, 'LoadedContent').append(object
);
640 function getWidth() {
641 settings
.w
= settings
.w
|| $loaded
.width();
642 settings
.w
= settings
.minw
&& settings
.minw
> settings
.w
? settings
.minw
: settings
.w
;
643 settings
.w
= settings
.mw
&& settings
.mw
< settings
.w
? settings
.mw
: settings
.w
;
646 function getHeight() {
647 settings
.h
= settings
.h
|| $loaded
.height();
648 settings
.h
= settings
.minh
&& settings
.minh
> settings
.h
? settings
.minh
: settings
.h
;
649 settings
.h
= settings
.mh
&& settings
.mh
< settings
.h
? settings
.mh
: settings
.h
;
654 .appendTo($loadingBay
.show())// content has to be appended to the DOM for accurate size calculations.
655 .css({width
: getWidth(), overflow
: settings
.scrolling
? 'auto' : 'hidden'})
656 .css({height
: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
657 .prependTo($content
);
661 // 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.
662 //$(photo).css({'float': 'none', marginLeft: 'auto', marginRight: 'auto'});
664 $(photo
).css({'float': 'none'});
666 // Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
668 $('select').not($box
.find('select')).filter(function () {
669 return this.style
.visibility
!== 'hidden';
670 }).css({'visibility': 'hidden'}).one(event_cleanup
, function () {
671 this.style
.visibility
= 'inherit';
675 callback = function () {
678 total
= $related
.length
,
680 frameBorder
= 'frameBorder',
681 allowTransparency
= 'allowTransparency',
691 function removeFilter() {
693 $box
[0].style
.removeAttribute('filter');
697 complete = function () {
698 clearTimeout(loadingTimer
);
699 // Detaching forces Andriod stock browser to redraw the area underneat the loading overlay. Hiding alone isn't enough.
700 $loadingOverlay
.detach().hide();
701 trigger(event_complete
, settings
.onComplete
);
705 //This fadeIn helps the bicubic resampling to kick-in.
711 $title
.html(settings
.title
).add($loaded
).show();
713 if (total
> 1) { // handle grouping
714 if (typeof settings
.current
=== "string") {
715 $current
.html(settings
.current
.replace('{current}', index
+ 1).replace('{total}', total
)).show();
718 $next
[(settings
.loop
|| index
< total
- 1) ? "show" : "hide"]().html(settings
.next
);
719 $prev
[(settings
.loop
|| index
) ? "show" : "hide"]().html(settings
.previous
);
721 if (settings
.slideshow
) {
725 // Preloads images within a rel group
726 if (settings
.preloading
) {
731 while (i
= $related
[preload
.pop()]) {
732 data
= $.data(i
, colorbox
);
734 if (data
&& data
.href
) {
736 if ($.isFunction(src
)) {
750 $groupControls
.hide();
753 if (settings
.iframe
) {
754 iframe
= $tag('iframe')[0];
756 if (frameBorder
in iframe
) {
757 iframe
[frameBorder
] = 0;
759 if (allowTransparency
in iframe
) {
760 iframe
[allowTransparency
] = "true";
762 // give the iframe a unique name to prevent caching
763 iframe
.name
= prefix
+ (+new Date());
764 if (settings
.fastIframe
) {
767 $(iframe
).one('load', complete
);
769 iframe
.src
= settings
.href
;
770 if (!settings
.scrolling
) {
771 iframe
.scrolling
= "no";
773 $(iframe
).addClass(prefix
+ 'Iframe').appendTo($loaded
).one(event_purge
, function () {
774 iframe
.src
= "//about:blank";
780 if (settings
.transition
=== 'fade') {
781 $box
.fadeTo(speed
, 1, removeFilter
);
787 if (settings
.transition
=== 'fade') {
788 $box
.fadeTo(speed
, 0, function () {
789 publicMethod
.position(0, callback
);
792 publicMethod
.position(speed
, callback
);
796 publicMethod
.load = function (launched
) {
797 var href
, setResize
, prep
= publicMethod
.prep
;
803 element
= $related
[index
];
809 trigger(event_purge
);
811 trigger(event_load
, settings
.onLoad
);
813 settings
.h
= settings
.height
?
814 setSize(settings
.height
, 'y') - loadedHeight
- interfaceHeight
:
815 settings
.innerHeight
&& setSize(settings
.innerHeight
, 'y');
817 settings
.w
= settings
.width
?
818 setSize(settings
.width
, 'x') - loadedWidth
- interfaceWidth
:
819 settings
.innerWidth
&& setSize(settings
.innerWidth
, 'x');
821 // Sets the minimum dimensions for use in image scaling
822 settings
.mw
= settings
.w
;
823 settings
.mh
= settings
.h
;
824 settings
.minw
= settings
.w
;
825 settings
.minh
= settings
.h
;
827 // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
828 // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
829 if (settings
.maxWidth
) {
830 settings
.mw
= setSize(settings
.maxWidth
, 'x') - loadedWidth
- interfaceWidth
;
831 settings
.mw
= settings
.w
&& settings
.w
< settings
.mw
? settings
.w
: settings
.mw
;
833 if(settings
.minWidth
){
834 settings
.minw
= setSize(settings
.minWidth
, 'x') - loadedWidth
- interfaceWidth
;
835 settings
.minw
= settings
.w
&& settings
.w
> settings
.minw
? settings
.w
: settings
.minw
;
837 if (settings
.maxHeight
) {
838 settings
.mh
= setSize(settings
.maxHeight
, 'y') - loadedHeight
- interfaceHeight
;
839 settings
.mh
= settings
.h
&& settings
.h
< settings
.mh
? settings
.h
: settings
.mh
;
841 if(settings
.minHeight
){
842 settings
.minh
= setSize(settings
.minHeight
, 'y') - loadedHeight
- interfaceHeight
;
843 settings
.minh
= settings
.h
&& settings
.h
> settings
.minh
? settings
.h
: settings
.minh
;
846 href
= settings
.href
;
848 loadingTimer
= setTimeout(function () {
849 $loadingOverlay
.show().appendTo($content
);
852 if (settings
.inline
) {
853 // Inserts an empty placeholder where inline content is being pulled from.
854 // An event is bound to put inline content back when ColorBox closes or loads new content.
855 $tag(div
).hide().insertBefore($(href
)[0]).one(event_purge
, function () {
856 $(this).replaceWith($loaded
.children());
859 } else if (settings
.iframe
) {
860 // IFrame element won't be added to the DOM until it is ready to be displayed,
861 // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
863 } else if (settings
.html
) {
865 } else if (isImage(href
)) {
866 $(photo
= new Image())
867 .addClass(prefix
+ 'Photo')
869 settings
.title
= false;
870 prep($tag(div
, 'Error').html(settings
.imgError
));
874 photo
.onload
= null; //stops animated gifs from firing the onload repeatedly.
876 if (settings
.scalePhotos
) {
877 setResize = function () {
878 photo
.height
-= photo
.height
* percent
;
879 photo
.width
-= photo
.width
* percent
;
881 if (settings
.mw
&& photo
.width
> settings
.mw
) {
882 percent
= (photo
.width
- settings
.mw
) / photo
.width
;
885 if (settings
.mh
&& photo
.height
> settings
.mh
) {
886 percent
= (photo
.height
- settings
.mh
) / photo
.height
;
892 photo
.style
.marginTop
= Math
.max(settings
.h
- photo
.height
, 0) / 2 + 'px';
895 if ($related
[1] && (settings
.loop
|| $related
[index
+ 1])) {
896 photo
.style
.cursor
= 'pointer';
897 photo
.onclick = function () {
903 photo
.style
.msInterpolationMode
= 'bicubic';
906 setTimeout(function () { // A pause because Chrome will sometimes report a 0 by 0 size otherwise.
911 setTimeout(function () { // A pause because Opera 10.6+ will sometimes not run the onload function otherwise.
915 $loadingBay
.load(href
, settings
.data
, function (data
, status
, xhr
) {
916 prep(status
=== 'error' ? $tag(div
, 'Error').html(settings
.xhrError
) : $(this).contents());
921 // Navigates to the next page/image in a set.
922 publicMethod
.next = function () {
923 if (!active
&& $related
[1] && (settings
.loop
|| $related
[index
+ 1])) {
929 publicMethod
.prev = function () {
930 if (!active
&& $related
[1] && (settings
.loop
|| index
)) {
931 index
= getIndex(-1);
936 // Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
937 publicMethod
.close = function () {
938 if (open
&& !closing
) {
944 trigger(event_cleanup
, settings
.onCleanup
);
946 $window
.unbind('.' + prefix
+ ' .' + event_ie6
);
948 $overlay
.fadeTo(200, 0);
950 $box
.stop().fadeTo(300, 0, function () {
952 $box
.add($overlay
).css({'opacity': 1, cursor
: 'auto'}).hide();
954 trigger(event_purge
);
958 setTimeout(function () {
960 trigger(event_closed
, settings
.onClosed
);
966 // Removes changes ColorBox made to the document, but does not remove the plugin
968 publicMethod
.remove = function () {
969 $([]).add($box
).add($overlay
).remove();
972 .removeData(colorbox
)
973 .removeClass(boxElement
)
977 // A method for fetching the current element ColorBox is referencing.
978 // returns a jQuery object.
979 publicMethod
.element = function () {
983 publicMethod
.settings
= defaults
;
985 }(jQuery
, document
, this));