Version Description
(2010-09-12) = * CHANGE: Update of Colorbox library to version 1.3.9 which fixes lots of bugs. Most notably the "0 by 0" bug in Chrome.
Download this release
Release Info
| Developer | techotronic |
| Plugin | |
| Version | 3.6 |
| Comparing to | |
| See all releases | |
Code changes from version 3.5 to 3.6
- jquery-colorbox.php +4 -3
- js/jquery.colorbox-min.js +4 -2
- js/jquery.colorbox.js +392 -380
- readme.txt +5 -2
jquery-colorbox.php
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
* Plugin Name: jQuery Colorbox
|
| 7 |
* Plugin URI: http://www.techotronic.de/plugins/jquery-colorbox/
|
| 8 |
* Description: Used to overlay images on the current page. Images in one post are grouped automatically.
|
| 9 |
-
* Version: 3.
|
| 10 |
* Author: Arne Franken
|
| 11 |
* Author URI: http://www.techotronic.de/
|
| 12 |
* License: GPL
|
|
@@ -19,7 +19,8 @@
|
|
| 19 |
?>
|
| 20 |
<?php
|
| 21 |
//define constants
|
| 22 |
-
define('JQUERYCOLORBOX_VERSION', '3.
|
|
|
|
| 23 |
|
| 24 |
if (!defined('JQUERYCOLORBOX_PLUGIN_BASENAME')) {
|
| 25 |
define('JQUERYCOLORBOX_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
|
@@ -145,7 +146,7 @@ class jQueryColorbox {
|
|
| 145 |
// enqueue javascripts in wordpress
|
| 146 |
wp_register_style('colorbox-' . $this->colorboxSettings['colorboxTheme'], plugins_url('themes/' . $this->colorboxSettings['colorboxTheme'] . '/colorbox.css', __FILE__), array(), JQUERYCOLORBOX_VERSION, 'screen');
|
| 147 |
wp_enqueue_style('colorbox-' . $this->colorboxSettings['colorboxTheme']);
|
| 148 |
-
wp_enqueue_script('colorbox', plugins_url('js/jquery.colorbox-min.js', __FILE__), array('jquery'),
|
| 149 |
// if($this->colorboxSettings['draggable']) {
|
| 150 |
// ?!?wp_enqueue_script('jquery-ui-draggable');
|
| 151 |
// wp_enqueue_script('colorbox-draggable', plugins_url('js/jquery-colorbox-draggable.js', __FILE__), array('jquery-ui-draggable'), JQUERYCOLORBOX_VERSION);
|
| 6 |
* Plugin Name: jQuery Colorbox
|
| 7 |
* Plugin URI: http://www.techotronic.de/plugins/jquery-colorbox/
|
| 8 |
* Description: Used to overlay images on the current page. Images in one post are grouped automatically.
|
| 9 |
+
* Version: 3.6
|
| 10 |
* Author: Arne Franken
|
| 11 |
* Author URI: http://www.techotronic.de/
|
| 12 |
* License: GPL
|
| 19 |
?>
|
| 20 |
<?php
|
| 21 |
//define constants
|
| 22 |
+
define('JQUERYCOLORBOX_VERSION', '3.6');
|
| 23 |
+
define('COLORBOXLIBRARY_VERSION', '1.3.9');
|
| 24 |
|
| 25 |
if (!defined('JQUERYCOLORBOX_PLUGIN_BASENAME')) {
|
| 26 |
define('JQUERYCOLORBOX_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
| 146 |
// enqueue javascripts in wordpress
|
| 147 |
wp_register_style('colorbox-' . $this->colorboxSettings['colorboxTheme'], plugins_url('themes/' . $this->colorboxSettings['colorboxTheme'] . '/colorbox.css', __FILE__), array(), JQUERYCOLORBOX_VERSION, 'screen');
|
| 148 |
wp_enqueue_style('colorbox-' . $this->colorboxSettings['colorboxTheme']);
|
| 149 |
+
wp_enqueue_script('colorbox', plugins_url('js/jquery.colorbox-min.js', __FILE__), array('jquery'), COLORBOXLIBRARY_VERSION);
|
| 150 |
// if($this->colorboxSettings['draggable']) {
|
| 151 |
// ?!?wp_enqueue_script('jquery-ui-draggable');
|
| 152 |
// wp_enqueue_script('colorbox-draggable', plugins_url('js/jquery-colorbox-draggable.js', __FILE__), array('jquery-ui-draggable'), JQUERYCOLORBOX_VERSION);
|
js/jquery.colorbox-min.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
|
|
| 1 |
+
// ColorBox v1.3.9 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
|
| 2 |
+
// c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
|
| 3 |
+
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
| 4 |
+
(function(b,gb){var v="none",t="click",N="LoadedContent",d=false,x="resize.",o="y",u="auto",f=true,M="nofollow",q="on",n="x";function e(a,c){a=a?' id="'+k+a+'"':"";c=c?' style="'+c+'"':"";return b("<div"+a+c+"/>")}function p(a,b){b=b===n?m.width():m.height();return typeof a==="string"?Math.round(a.match(/%/)?b/100*parseInt(a,10):parseInt(a,10)):a}function Q(c){c=b.isFunction(c)?c.call(h):c;return a.photo||c.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)}function cb(){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!==q)a[c]=a[c].call(h);a.rel=a.rel||h.rel||M;a.href=a.href||b(h).attr("href");a.title=a.title||h.title}function db(d){h=d;a=b.extend({},b(h).data(r));cb();if(a.rel!==M){i=b("."+H).filter(function(){return (b(this).data(r).rel||this.rel)===a.rel});g=i.index(h);if(g===-1){i=i.add(h);g=i.length-1}}else{i=b(h);g=0}if(!w){w=F=f;R=h;try{R.blur()}catch(e){}b.event.trigger(hb);a.onOpen&&a.onOpen.call(h);y.css({opacity:+a.opacity,cursor:a.overlayClose?"pointer":u}).show();a.w=p(a.initialWidth,n);a.h=p(a.initialHeight,o);c.position(0);S&&m.bind(x+O+" scroll."+O,function(){y.css({width:m.width(),height:m.height(),top:m.scrollTop(),left:m.scrollLeft()})}).trigger("scroll."+O)}T.add(I).add(J).add(z).add(U).hide();V.html(a.close).show();c.slideshow();c.load()}var eb={transition:"elastic",speed:300,width:d,initialWidth:"600",innerWidth:d,maxWidth:d,height:d,initialHeight:"450",innerHeight:d,maxHeight:d,scalePhotos:f,scrolling:f,inline:d,html:d,iframe:d,photo:d,href:d,title:d,rel:d,opacity:.9,preloading:f,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:d,loop:f,slideshow:d,slideshowAuto:f,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:d,onLoad:d,onComplete:d,onCleanup:d,onClosed:d,overlayClose:f,escKey:f,arrowKey:f},r="colorbox",k="cbox",hb=k+"_open",P=k+"_load",W=k+"_complete",X=k+"_cleanup",fb=k+"_closed",G=b.browser.msie&&!b.support.opacity,S=G&&b.browser.version<7,O=k+"_IE6",y,j,E,s,Y,Z,ab,bb,i,m,l,K,L,U,T,z,J,I,V,C,D,A,B,h,R,g,a,w,F,c,H=k+"Element";c=b.fn[r]=b[r]=function(c,d){var a=this;if(!a[0]&&a.selector)return a;c=c||{};if(d)c.onComplete=d;if(!a[0]||a.selector===undefined){a=b("<a/>");c.open=f}a.each(function(){b(this).data(r,b.extend({},b(this).data(r)||eb,c)).addClass(H)});c.open&&db(a[0]);return a};c.init=function(){var h="hover";m=b(gb);j=e().attr({id:r,"class":G?k+"IE":""});y=e("Overlay",S?"position:absolute":"").hide();E=e("Wrapper");s=e("Content").append(l=e(N,"width:0; height:0"),L=e("LoadingOverlay").add(e("LoadingGraphic")),U=e("Title"),T=e("Current"),J=e("Next"),I=e("Previous"),z=e("Slideshow"),V=e("Close"));E.append(e().append(e("TopLeft"),Y=e("TopCenter"),e("TopRight")),e().append(Z=e("MiddleLeft"),s,ab=e("MiddleRight")),e().append(e("BottomLeft"),bb=e("BottomCenter"),e("BottomRight"))).children().children().css({"float":"left"});K=e(d,"position:absolute; width:9999px; visibility:hidden; display:none");b("body").prepend(y,j.append(E,K));s.children().hover(function(){b(this).addClass(h)},function(){b(this).removeClass(h)}).addClass(h);C=Y.height()+bb.height()+s.outerHeight(f)-s.height();D=Z.width()+ab.width()+s.outerWidth(f)-s.width();A=l.outerHeight(f);B=l.outerWidth(f);j.css({"padding-bottom":C,"padding-right":D}).hide();J.click(c.next);I.click(c.prev);V.click(c.close);s.children().removeClass(h);b("."+H).live(t,function(a){if(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)return f;else{db(this);return d}});y.click(function(){a.overlayClose&&c.close()});b(document).bind("keydown",function(b){if(w&&a.escKey&&b.keyCode===27){b.preventDefault();c.close()}if(w&&a.arrowKey&&!F&&i[1])if(b.keyCode===37&&(g||a.loop)){b.preventDefault();I.click()}else if(b.keyCode===39&&(g<i.length-1||a.loop)){b.preventDefault();J.click()}})};c.remove=function(){j.add(y).remove();b("."+H).die(t).removeData(r).removeClass(H)};c.position=function(f,b){function c(a){Y[0].style.width=bb[0].style.width=s[0].style.width=a.style.width;L[0].style.height=L[1].style.height=s[0].style.height=Z[0].style.height=ab[0].style.height=a.style.height}var e,h=Math.max(m.height()-a.h-A-C,0)/2+m.scrollTop(),g=Math.max(m.width()-a.w-B-D,0)/2+m.scrollLeft();e=j.width()===a.w+B&&j.height()===a.h+A?0:f;E[0].style.width=E[0].style.height="9999px";j.dequeue().animate({width:a.w+B,height:a.h+A,top:h,left:g},{duration:e,complete:function(){c(this);F=d;E[0].style.width=a.w+B+D+"px";E[0].style.height=a.h+A+C+"px";b&&b()},step:function(){c(this)}})};c.resize=function(b){if(w){b=b||{};if(b.width)a.w=p(b.width,n)-B-D;if(b.innerWidth)a.w=p(b.innerWidth,n);l.css({width:a.w});if(b.height)a.h=p(b.height,o)-A-C;if(b.innerHeight)a.h=p(b.innerHeight,o);if(!b.innerHeight&&!b.height){b=l.wrapInner("<div style='overflow:auto'></div>").children();a.h=b.height();b.replaceWith(b.children())}l.css({height:a.h});c.position(a.transition===v?0:a.speed)}};c.prep=function(o){var d="hidden";function n(t){var o,q,s,n,d=i.length,e=a.loop;c.position(t,function(){function t(){G&&j[0].style.removeAttribute("filter")}if(w){G&&p&&l.fadeIn(100);a.iframe&&b("<iframe frameborder=0"+(a.scrolling?"":" scrolling='no'")+(G?" allowtransparency='true'":"")+"/>").attr({src:a.href,name:(new Date).getTime()}).appendTo(l);l.show();U.show().html(a.title);if(d>1){T.html(a.current.replace(/\{current\}/,g+1).replace(/\{total\}/,d)).show();J[e||g<d-1?"show":"hide"]().html(a.next);I[e||g?"show":"hide"]().html(a.previous);o=g?i[g-1]:i[d-1];s=g<d-1?i[g+1]:i[0];if(a.slideshow){z.show();g===d-1&&!e&&j.is("."+k+"Slideshow_on")&&z.click()}if(a.preloading){n=b(s).data(r).href||s.href;q=b(o).data(r).href||o.href;if(Q(n))b("<img/>")[0].src=n;if(Q(q))b("<img/>")[0].src=q}}L.hide();a.transition==="fade"?j.fadeTo(f,1,function(){t()}):t();m.bind(x+k,function(){c.position(0)});b.event.trigger(W);a.onComplete&&a.onComplete.call(h)}})}if(w){var p,f=a.transition===v?0:a.speed;m.unbind(x+k);l.remove();l=e(N).html(o);l.hide().appendTo(K.show()).css({width:function(){a.w=a.w||l.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}(),overflow:a.scrolling?u:d}).css({height:function(){a.h=a.h||l.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}()}).prependTo(s);K.hide();b("#"+k+"Photo").css({cssFloat:v});S&&b("select").not(j.find("select")).filter(function(){return this.style.visibility!==d}).css({visibility:d}).one(X,function(){this.style.visibility="inherit"});a.transition==="fade"?j.fadeTo(f,0,function(){n(0)}):n(f)}};c.load=function(){var j,d,q,m=c.prep;F=f;h=i[g];a=b.extend({},b(h).data(r));cb();b.event.trigger(P);a.onLoad&&a.onLoad.call(h);a.h=a.height?p(a.height,o)-A-C:a.innerHeight&&p(a.innerHeight,o);a.w=a.width?p(a.width,n)-B-D:a.innerWidth&&p(a.innerWidth,n);a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=p(a.maxWidth,n)-B-D;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=p(a.maxHeight,o)-A-C;a.mh=a.h&&a.h<a.mh?a.h:a.mh}j=a.href;L.show();if(a.inline){e("InlineTemp").hide().insertBefore(b(j)[0]).bind(P+" "+X,function(){b(this).replaceWith(l.children())});m(b(j))}else if(a.iframe)m(" ");else if(a.html)m(a.html);else if(Q(j)){d=new Image;d.onload=function(){var e;d.onload=null;d.id=k+"Photo";b(d).css({margin:u,border:v,display:"block",cssFloat:"left"});if(a.scalePhotos){q=function(){d.height-=d.height*e;d.width-=d.width*e};if(a.mw&&d.width>a.mw){e=(d.width-a.mw)/d.width;q()}if(a.mh&&d.height>a.mh){e=(d.height-a.mh)/d.height;q()}}if(a.h)d.style.marginTop=Math.max(a.h-d.height,0)/2+"px";setTimeout(function(){m(d)},1);i[1]&&(g<i.length-1||a.loop)&&b(d).css({cursor:"pointer"}).click(c.next);if(G)d.style.msInterpolationMode="bicubic"};d.src=j}else e().appendTo(K).load(j,function(c,a,b){m(a==="error"?"Request unsuccessful: "+b.statusText:this)})};c.next=function(){if(!F){g=g<i.length-1?g+1:0;c.load()}};c.prev=function(){if(!F){g=g?g-1:i.length-1;c.load()}};c.slideshow=function(){function f(){z.text(a.slideshowStop).bind(W,function(){d=setTimeout(c.next,a.slideshowSpeed)}).bind(P,function(){clearTimeout(d)}).one(t,function(){e()});j.removeClass(b+"off").addClass(b+q)}var e,d,b=k+"Slideshow_";z.bind(fb,function(){z.unbind();clearTimeout(d);j.removeClass(b+"off "+b+q)});e=function(){clearTimeout(d);z.text(a.slideshowStart).unbind(W+" "+P).one(t,function(){f();d=setTimeout(c.next,a.slideshowSpeed)});j.removeClass(b+q).addClass(b+"off")};if(a.slideshow&&i[1])a.slideshowAuto?f():e()};c.close=function(){if(w){w=d;b.event.trigger(X);a.onCleanup&&a.onCleanup.call(h);m.unbind("."+k+" ."+O);y.fadeTo("fast",0);j.stop().fadeTo("fast",0,function(){j.find("iframe").attr("src","about:blank");l.remove();j.add(y).css({opacity:1,cursor:u}).hide();try{R.focus()}catch(c){}setTimeout(function(){b.event.trigger(fb);a.onClosed&&a.onClosed.call(h)},1)})}};c.element=function(){return b(h)};c.settings=eb;b(c.init)})(jQuery,this)
|
js/jquery.colorbox.js
CHANGED
|
@@ -1,28 +1,73 @@
|
|
| 1 |
-
// ColorBox v1.3.
|
| 2 |
// c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
|
| 3 |
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
// Cached jQuery Object Variables
|
| 24 |
$overlay,
|
| 25 |
-
$
|
| 26 |
$wrap,
|
| 27 |
$content,
|
| 28 |
$topBorder,
|
|
@@ -34,7 +79,6 @@
|
|
| 34 |
$loaded,
|
| 35 |
$loadingBay,
|
| 36 |
$loadingOverlay,
|
| 37 |
-
$loadingGraphic,
|
| 38 |
$title,
|
| 39 |
$current,
|
| 40 |
$slideshow,
|
|
@@ -54,57 +98,23 @@
|
|
| 54 |
open,
|
| 55 |
active,
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
defaults = {
|
| 60 |
-
transition: "elastic",
|
| 61 |
-
speed: 350,
|
| 62 |
-
width: FALSE,
|
| 63 |
-
height: FALSE,
|
| 64 |
-
innerWidth: FALSE,
|
| 65 |
-
innerHeight: FALSE,
|
| 66 |
-
initialWidth: "400",
|
| 67 |
-
initialHeight: "400",
|
| 68 |
-
maxWidth: FALSE,
|
| 69 |
-
maxHeight: FALSE,
|
| 70 |
-
scalePhotos: TRUE,
|
| 71 |
-
scrolling: TRUE,
|
| 72 |
-
inline: FALSE,
|
| 73 |
-
html: FALSE,
|
| 74 |
-
iframe: FALSE,
|
| 75 |
-
photo: FALSE,
|
| 76 |
-
href: FALSE,
|
| 77 |
-
title: FALSE,
|
| 78 |
-
rel: FALSE,
|
| 79 |
-
opacity: 0.9,
|
| 80 |
-
preloading: TRUE,
|
| 81 |
-
current: "image {current} of {total}",
|
| 82 |
-
previous: "previous",
|
| 83 |
-
next: "next",
|
| 84 |
-
close: "close",
|
| 85 |
-
open: FALSE,
|
| 86 |
-
overlayClose: TRUE,
|
| 87 |
-
|
| 88 |
-
slideshow: FALSE,
|
| 89 |
-
slideshowAuto: TRUE,
|
| 90 |
-
slideshowSpeed: 2500,
|
| 91 |
-
slideshowStart: "start slideshow",
|
| 92 |
-
slideshowStop: "stop slideshow",
|
| 93 |
-
|
| 94 |
-
onOpen: FALSE,
|
| 95 |
-
onLoad: FALSE,
|
| 96 |
-
onComplete: FALSE,
|
| 97 |
-
onCleanup: FALSE,
|
| 98 |
-
onClosed: FALSE
|
| 99 |
-
};
|
| 100 |
|
| 101 |
// ****************
|
| 102 |
// HELPER FUNCTIONS
|
| 103 |
// ****************
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
// Convert % values to pixels
|
| 106 |
function setSize(size, dimension) {
|
| 107 |
-
dimension = dimension === 'x' ? $window.width() : $window.height()
|
| 108 |
return (typeof size === 'string') ? Math.round((size.match(/%/) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size;
|
| 109 |
}
|
| 110 |
|
|
@@ -122,8 +132,8 @@
|
|
| 122 |
settings[i] = settings[i].call(element);
|
| 123 |
}
|
| 124 |
}
|
| 125 |
-
settings.rel = settings.rel || element.rel;
|
| 126 |
-
settings.href = settings.href || element.href;
|
| 127 |
settings.title = settings.title || element.title;
|
| 128 |
}
|
| 129 |
|
|
@@ -131,19 +141,19 @@
|
|
| 131 |
|
| 132 |
element = elem;
|
| 133 |
|
| 134 |
-
settings = $(element).data(colorbox);
|
| 135 |
|
| 136 |
process(); // Convert functions to their returned values.
|
| 137 |
|
| 138 |
-
if (settings.rel
|
| 139 |
-
$related = $('.
|
| 140 |
var relRelated = $(this).data(colorbox).rel || this.rel;
|
| 141 |
return (relRelated === settings.rel);
|
| 142 |
});
|
| 143 |
index = $related.index(element);
|
| 144 |
|
| 145 |
// Check direct calls to ColorBox.
|
| 146 |
-
if (index
|
| 147 |
$related = $related.add(element);
|
| 148 |
index = $related.length - 1;
|
| 149 |
}
|
|
@@ -153,52 +163,31 @@
|
|
| 153 |
}
|
| 154 |
|
| 155 |
if (!open) {
|
| 156 |
-
open =
|
| 157 |
-
|
| 158 |
-
active = TRUE; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
|
| 159 |
|
| 160 |
bookmark = element;
|
| 161 |
|
| 162 |
-
|
|
|
|
|
|
|
| 163 |
|
| 164 |
-
|
| 165 |
-
$(document).bind("keydown.cbox_close", function (e) {
|
| 166 |
-
if (e.keyCode === 27) {
|
| 167 |
-
e.preventDefault();
|
| 168 |
-
cboxPublic.close();
|
| 169 |
-
}
|
| 170 |
-
}).bind("keydown.cbox_arrows", function (e) {
|
| 171 |
-
if ($related.length > 1) {
|
| 172 |
-
if (e.keyCode === 37) {
|
| 173 |
-
e.preventDefault();
|
| 174 |
-
$prev.click();
|
| 175 |
-
} else if (e.keyCode === 39) {
|
| 176 |
-
e.preventDefault();
|
| 177 |
-
$next.click();
|
| 178 |
-
}
|
| 179 |
-
}
|
| 180 |
-
});
|
| 181 |
-
|
| 182 |
-
if (settings.overlayClose) {
|
| 183 |
-
$overlay.css({"cursor": "pointer"}).one('click', cboxPublic.close);
|
| 184 |
-
}
|
| 185 |
-
|
| 186 |
-
$.event.trigger(cbox_open);
|
| 187 |
if (settings.onOpen) {
|
| 188 |
settings.onOpen.call(element);
|
| 189 |
}
|
| 190 |
|
| 191 |
-
|
|
|
|
| 192 |
|
| 193 |
// Opens inital empty ColorBox prior to content being loaded.
|
| 194 |
settings.w = setSize(settings.initialWidth, 'x');
|
| 195 |
settings.h = setSize(settings.initialHeight, 'y');
|
| 196 |
-
|
| 197 |
|
| 198 |
if (isIE6) {
|
| 199 |
-
$window.bind('resize.
|
| 200 |
$overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
|
| 201 |
-
}).trigger(
|
| 202 |
}
|
| 203 |
}
|
| 204 |
|
|
@@ -206,9 +195,9 @@
|
|
| 206 |
|
| 207 |
$close.html(settings.close).show();
|
| 208 |
|
| 209 |
-
|
| 210 |
|
| 211 |
-
|
| 212 |
}
|
| 213 |
|
| 214 |
// ****************
|
|
@@ -217,349 +206,372 @@
|
|
| 217 |
// Usage from within an iframe: parent.$.fn.colorbox.close();
|
| 218 |
// ****************
|
| 219 |
|
| 220 |
-
|
| 221 |
var $this = this;
|
| 222 |
|
| 223 |
-
if (!$this.
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
}
|
| 231 |
|
| 232 |
$this.each(function () {
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
$(this).data(colorbox, data).addClass("cboxElement");
|
| 236 |
-
|
| 237 |
-
if (callback) {
|
| 238 |
-
$(this).data(colorbox).onComplete = callback;
|
| 239 |
-
}
|
| 240 |
});
|
| 241 |
|
| 242 |
-
if (options
|
| 243 |
-
launch($this);
|
| 244 |
}
|
| 245 |
|
| 246 |
-
return this;
|
| 247 |
};
|
| 248 |
|
| 249 |
// Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
|
| 250 |
// This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only
|
| 251 |
// having to run once, instead of each time colorbox is opened.
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
// jQuery object generator to save a bit of space
|
| 255 |
-
function $div(id) {
|
| 256 |
-
return $('<div id="cbox' + id + '"/>');
|
| 257 |
-
}
|
| 258 |
-
|
| 259 |
// Create & Append jQuery Objects
|
| 260 |
$window = $(window);
|
| 261 |
-
$
|
| 262 |
-
$overlay = $div("Overlay").hide();
|
|
|
|
| 263 |
$wrap = $div("Wrapper");
|
| 264 |
$content = $div("Content").append(
|
| 265 |
-
$loaded = $div("LoadedContent"
|
| 266 |
-
$loadingOverlay = $div("LoadingOverlay"),
|
| 267 |
-
$loadingGraphic = $div("LoadingGraphic"),
|
| 268 |
$title = $div("Title"),
|
| 269 |
$current = $div("Current"),
|
| 270 |
-
$slideshow = $div("Slideshow"),
|
| 271 |
$next = $div("Next"),
|
| 272 |
$prev = $div("Previous"),
|
|
|
|
| 273 |
$close = $div("Close")
|
| 274 |
);
|
| 275 |
$wrap.append( // The 3x3 Grid that makes up ColorBox
|
| 276 |
-
$(
|
| 277 |
$div("TopLeft"),
|
| 278 |
$topBorder = $div("TopCenter"),
|
| 279 |
$div("TopRight")
|
| 280 |
),
|
| 281 |
-
$(
|
| 282 |
$leftBorder = $div("MiddleLeft"),
|
| 283 |
$content,
|
| 284 |
$rightBorder = $div("MiddleRight")
|
| 285 |
),
|
| 286 |
-
$(
|
| 287 |
$div("BottomLeft"),
|
| 288 |
$bottomBorder = $div("BottomCenter"),
|
| 289 |
$div("BottomRight")
|
| 290 |
)
|
| 291 |
).children().children().css({'float': 'left'});
|
| 292 |
|
| 293 |
-
$loadingBay = $(
|
| 294 |
|
| 295 |
-
$('body').prepend($overlay, $
|
| 296 |
-
|
| 297 |
-
if (isIE) {
|
| 298 |
-
$cbox.addClass('cboxIE');
|
| 299 |
-
if (isIE6) {
|
| 300 |
-
$overlay.css('position', 'absolute');
|
| 301 |
-
}
|
| 302 |
-
}
|
| 303 |
|
| 304 |
-
// Add rollover event to navigation elements
|
| 305 |
$content.children()
|
| 306 |
-
.
|
| 307 |
-
$(this).
|
| 308 |
-
}
|
|
|
|
|
|
|
| 309 |
|
| 310 |
// Cache values needed for size calculations
|
| 311 |
-
interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(
|
| 312 |
-
interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(
|
| 313 |
-
loadedHeight = $loaded.outerHeight(
|
| 314 |
-
loadedWidth = $loaded.outerWidth(
|
| 315 |
|
| 316 |
// Setting padding to remove the need to do size conversions during the animation step.
|
| 317 |
-
$
|
| 318 |
|
| 319 |
-
// Setup button
|
| 320 |
-
$next.click(
|
| 321 |
-
$prev.click(
|
| 322 |
-
$close.click(
|
| 323 |
|
| 324 |
// Adding the 'hover' class allowed the browser to load the hover-state
|
| 325 |
// background graphics. The class can now can be removed.
|
| 326 |
-
$content.children().removeClass(hover);
|
| 327 |
|
| 328 |
-
$('.
|
| 329 |
-
|
| 330 |
-
|
|
|
|
| 331 |
} else {
|
| 332 |
launch(this);
|
| 333 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
}
|
| 335 |
});
|
| 336 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
|
| 338 |
-
|
| 339 |
var
|
| 340 |
animate_speed,
|
| 341 |
-
winHeight = $window.height(),
|
| 342 |
// keeps the top and left positions within the browser's viewport.
|
| 343 |
-
posTop = Math.max(
|
| 344 |
-
posLeft = Math.max(
|
| 345 |
|
| 346 |
// setting the speed to 0 to reduce the delay between same-sized content.
|
| 347 |
-
animate_speed = ($
|
| 348 |
|
| 349 |
// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
|
| 350 |
// but it has to be shrank down around the size of div#colorbox when it's done. If not,
|
| 351 |
// it can invoke an obscure IE bug when using iframes.
|
| 352 |
$wrap[0].style.width = $wrap[0].style.height = "9999px";
|
| 353 |
|
| 354 |
-
function modalDimensions
|
| 355 |
-
// loading overlay
|
| 356 |
$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
|
| 357 |
-
$
|
| 358 |
}
|
| 359 |
|
| 360 |
-
$
|
| 361 |
-
|
|
|
|
| 362 |
modalDimensions(this);
|
| 363 |
|
| 364 |
-
active =
|
| 365 |
|
| 366 |
// shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
|
| 367 |
-
$wrap[0].style.width = (settings.w+loadedWidth+interfaceWidth) + "px";
|
| 368 |
-
$wrap[0].style.height = (settings.h+loadedHeight+interfaceHeight) + "px";
|
| 369 |
|
| 370 |
-
if (loadedCallback) {
|
|
|
|
|
|
|
| 371 |
},
|
| 372 |
-
step: function(){
|
| 373 |
modalDimensions(this);
|
| 374 |
}
|
| 375 |
});
|
| 376 |
};
|
| 377 |
|
| 378 |
-
|
| 379 |
-
if(
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
-
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
|
|
|
|
|
|
|
|
|
| 394 |
var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be.
|
| 395 |
settings.h = $child.height();
|
| 396 |
-
$loaded.css({height:settings.h});
|
| 397 |
$child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
|
| 398 |
-
|
| 399 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
return;
|
| 401 |
}
|
| 402 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
$loaded.remove();
|
| 404 |
-
$loaded = $('
|
| 405 |
|
| 406 |
-
function getWidth(){
|
| 407 |
settings.w = settings.w || $loaded.width();
|
| 408 |
settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
|
| 409 |
return settings.w;
|
| 410 |
}
|
| 411 |
-
function getHeight(){
|
| 412 |
settings.h = settings.h || $loaded.height();
|
| 413 |
settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
|
| 414 |
return settings.h;
|
| 415 |
}
|
| 416 |
|
| 417 |
$loaded.hide()
|
| 418 |
-
.appendTo($loadingBay)// content has to be appended to the DOM for accurate size calculations.
|
| 419 |
-
.css({width:getWidth(), overflow:settings.scrolling ? 'auto' : 'hidden'})
|
| 420 |
-
.css({height:getHeight()})// sets the height independently from the width in case the new width influences the value of height.
|
| 421 |
.prependTo($content);
|
| 422 |
|
| 423 |
-
$
|
|
|
|
|
|
|
| 424 |
|
| 425 |
// Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
|
| 426 |
if (isIE6) {
|
| 427 |
-
$('select
|
| 428 |
return this.style.visibility !== 'hidden';
|
| 429 |
-
}).css({'visibility':'hidden'}).one(
|
| 430 |
this.style.visibility = 'inherit';
|
| 431 |
});
|
| 432 |
}
|
| 433 |
|
| 434 |
-
function setPosition
|
| 435 |
-
|
| 436 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 437 |
|
| 438 |
if (isIE) {
|
| 439 |
//This fadeIn helps the bicubic resampling to kick-in.
|
| 440 |
-
if(
|
| 441 |
-
|
| 442 |
-
|
| 443 |
}
|
| 444 |
|
| 445 |
//Waited until the iframe is added to the DOM & it is visible before setting the src.
|
| 446 |
//This increases compatability with pages using DOM dependent JavaScript.
|
| 447 |
-
if(settings.iframe){
|
| 448 |
-
$
|
|
|
|
|
|
|
| 449 |
}
|
| 450 |
|
| 451 |
$loaded.show();
|
| 452 |
|
| 453 |
$title.show().html(settings.title);
|
| 454 |
|
| 455 |
-
if (
|
| 456 |
-
$current.html(settings.current.replace(/\{current\}/, index+1).replace(/\{total\}/,
|
| 457 |
-
$next.html(settings.next).show();
|
| 458 |
-
$prev.html(settings.previous).show();
|
| 459 |
|
| 460 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 461 |
$slideshow.show();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 462 |
}
|
| 463 |
}
|
| 464 |
|
| 465 |
$loadingOverlay.hide();
|
| 466 |
-
$loadingGraphic.hide();
|
| 467 |
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
}
|
| 472 |
-
|
| 473 |
-
if (settings.transition === 'fade'){
|
| 474 |
-
$cbox.fadeTo(speed, 1, function(){
|
| 475 |
-
if(isIE){$cbox[0].style.removeAttribute("filter");}
|
| 476 |
});
|
|
|
|
|
|
|
| 477 |
}
|
| 478 |
|
| 479 |
-
$window.bind(
|
| 480 |
-
|
| 481 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 482 |
});
|
| 483 |
}
|
| 484 |
|
| 485 |
-
if(
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
nextSrc = $(next).data(colorbox).href || next.href;
|
| 492 |
-
prevSrc = $(prev).data(colorbox).href || prev.href;
|
| 493 |
-
|
| 494 |
-
if(isImage(nextSrc)){
|
| 495 |
-
$('<img />').attr('src', nextSrc);
|
| 496 |
-
}
|
| 497 |
-
|
| 498 |
-
if(isImage(prevSrc)){
|
| 499 |
-
$('<img />').attr('src', prevSrc);
|
| 500 |
-
}
|
| 501 |
}
|
| 502 |
};
|
| 503 |
|
| 504 |
-
|
| 505 |
-
var href, img, setResize,
|
| 506 |
-
|
| 507 |
-
active =
|
| 508 |
-
|
| 509 |
-
/*
|
| 510 |
-
|
| 511 |
-
// I decided to comment this out because I can see it causing problems as users
|
| 512 |
-
// really should just set the dimensions on their IMG elements instead,
|
| 513 |
-
// but I'm leaving the code in as it may be useful to someone.
|
| 514 |
-
// To use, uncomment the function and change 'if(textStatus === "success"){ resize(this); }'
|
| 515 |
-
// to 'if(textStatus === "success"){ preload(this); }'
|
| 516 |
-
|
| 517 |
-
// Preload loops through the HTML to find IMG elements and loads their sources.
|
| 518 |
-
// This allows the resize method to accurately estimate the dimensions of the new content.
|
| 519 |
-
function preload(html){
|
| 520 |
-
var
|
| 521 |
-
$ajax = $(html),
|
| 522 |
-
$imgs = $ajax.find('img'),
|
| 523 |
-
x = $imgs.length;
|
| 524 |
-
|
| 525 |
-
function loadloop(){
|
| 526 |
-
var img = new Image();
|
| 527 |
-
x = x-1;
|
| 528 |
-
if(x >= 0){
|
| 529 |
-
img.onload = loadloop;
|
| 530 |
-
img.src = $imgs[x].src;
|
| 531 |
-
} else {
|
| 532 |
-
resize($ajax);
|
| 533 |
-
}
|
| 534 |
-
}
|
| 535 |
-
|
| 536 |
-
loadloop();
|
| 537 |
-
}
|
| 538 |
-
*/
|
| 539 |
|
| 540 |
element = $related[index];
|
| 541 |
|
| 542 |
-
settings = $(element).data(colorbox);
|
| 543 |
|
| 544 |
//convert functions to static values
|
| 545 |
process();
|
| 546 |
|
| 547 |
-
$.event.trigger(
|
| 548 |
if (settings.onLoad) {
|
| 549 |
settings.onLoad.call(element);
|
| 550 |
}
|
| 551 |
|
| 552 |
-
// Evaluate the height based on the optional height and width settings.
|
| 553 |
settings.h = settings.height ?
|
| 554 |
setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
|
| 555 |
-
settings.innerHeight
|
| 556 |
-
|
| 557 |
-
FALSE;
|
| 558 |
settings.w = settings.width ?
|
| 559 |
setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
|
| 560 |
-
settings.innerWidth
|
| 561 |
-
setSize(settings.innerWidth, 'x') :
|
| 562 |
-
FALSE;
|
| 563 |
|
| 564 |
// Sets the minimum dimensions for use in image scaling
|
| 565 |
settings.mw = settings.w;
|
|
@@ -567,11 +579,11 @@
|
|
| 567 |
|
| 568 |
// Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
|
| 569 |
// If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
|
| 570 |
-
if(settings.maxWidth){
|
| 571 |
settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
|
| 572 |
settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
|
| 573 |
}
|
| 574 |
-
if(settings.maxHeight){
|
| 575 |
settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
|
| 576 |
settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
|
| 577 |
}
|
|
@@ -579,127 +591,120 @@
|
|
| 579 |
href = settings.href;
|
| 580 |
|
| 581 |
$loadingOverlay.show();
|
| 582 |
-
$loadingGraphic.show();
|
| 583 |
|
| 584 |
if (settings.inline) {
|
| 585 |
// Inserts an empty placeholder where inline content is being pulled from.
|
| 586 |
// An event is bound to put inline content back when ColorBox closes or loads new content.
|
| 587 |
-
$('
|
| 588 |
$(this).replaceWith($loaded.children());
|
| 589 |
});
|
| 590 |
-
|
| 591 |
} else if (settings.iframe) {
|
| 592 |
// IFrame element won't be added to the DOM until it is ready to be displayed,
|
| 593 |
// to avoid problems with DOM-ready JS that might be trying to run in that iframe.
|
| 594 |
-
|
| 595 |
} else if (settings.html) {
|
| 596 |
-
|
| 597 |
-
} else if (isImage(href)){
|
| 598 |
img = new Image();
|
| 599 |
-
img.onload = function(){
|
| 600 |
var percent;
|
| 601 |
|
| 602 |
img.onload = null;
|
|
|
|
|
|
|
| 603 |
|
| 604 |
-
|
| 605 |
-
|
| 606 |
-
$(img).css({margin:'auto', border:'none', display:'block', cssFloat:'left'});
|
| 607 |
-
|
| 608 |
-
if(settings.scalePhotos){
|
| 609 |
-
setResize = function(){
|
| 610 |
img.height -= img.height * percent;
|
| 611 |
img.width -= img.width * percent;
|
| 612 |
};
|
| 613 |
-
if(settings.mw && img.width > settings.mw){
|
| 614 |
percent = (img.width - settings.mw) / img.width;
|
| 615 |
setResize();
|
| 616 |
}
|
| 617 |
-
if(settings.mh && img.height > settings.mh){
|
| 618 |
percent = (img.height - settings.mh) / img.height;
|
| 619 |
setResize();
|
| 620 |
}
|
| 621 |
}
|
| 622 |
|
| 623 |
if (settings.h) {
|
| 624 |
-
img.style.marginTop = Math.max(settings.h - img.height,0)/2 + 'px';
|
| 625 |
}
|
| 626 |
|
| 627 |
-
|
|
|
|
|
|
|
| 628 |
|
| 629 |
-
if($related.length
|
| 630 |
-
$(img).css({cursor:'pointer'}).click(
|
| 631 |
}
|
| 632 |
|
| 633 |
-
if(isIE){
|
| 634 |
-
img.style.msInterpolationMode='bicubic';
|
| 635 |
}
|
| 636 |
};
|
| 637 |
img.src = href;
|
| 638 |
} else {
|
| 639 |
-
$(
|
| 640 |
-
|
| 641 |
-
resize(this);
|
| 642 |
-
} else {
|
| 643 |
-
resize($("<p>Request unsuccessful.</p>"));
|
| 644 |
-
}
|
| 645 |
});
|
| 646 |
}
|
| 647 |
};
|
| 648 |
|
| 649 |
// Navigates to the next page/image in a set.
|
| 650 |
-
|
| 651 |
-
if(!active){
|
| 652 |
-
index = index < $related.length-1 ? index+1 : 0;
|
| 653 |
-
|
| 654 |
}
|
| 655 |
};
|
| 656 |
|
| 657 |
-
|
| 658 |
-
if(!active){
|
| 659 |
-
index = index
|
| 660 |
-
|
| 661 |
}
|
| 662 |
};
|
| 663 |
|
| 664 |
-
|
| 665 |
-
var stop, timeOut, className = '
|
| 666 |
|
| 667 |
-
$slideshow.bind(
|
| 668 |
$slideshow.unbind();
|
| 669 |
clearTimeout(timeOut);
|
| 670 |
-
$
|
| 671 |
});
|
| 672 |
|
| 673 |
-
function start(){
|
| 674 |
$slideshow
|
| 675 |
.text(settings.slideshowStop)
|
| 676 |
-
.bind(
|
| 677 |
-
timeOut = setTimeout(
|
| 678 |
})
|
| 679 |
-
.bind(
|
| 680 |
clearTimeout(timeOut);
|
| 681 |
-
}).one("click", function(){
|
| 682 |
stop();
|
| 683 |
-
$(this).removeClass(hover);
|
| 684 |
});
|
| 685 |
-
$
|
| 686 |
}
|
| 687 |
|
| 688 |
-
stop = function(){
|
| 689 |
clearTimeout(timeOut);
|
| 690 |
$slideshow
|
| 691 |
.text(settings.slideshowStart)
|
| 692 |
-
.unbind(
|
| 693 |
-
.one("click", function(){
|
| 694 |
start();
|
| 695 |
-
timeOut = setTimeout(
|
| 696 |
-
$(this).removeClass(hover);
|
| 697 |
});
|
| 698 |
-
$
|
| 699 |
};
|
| 700 |
|
| 701 |
-
if(settings.slideshow && $related
|
| 702 |
-
if(settings.slideshowAuto){
|
| 703 |
start();
|
| 704 |
} else {
|
| 705 |
stop();
|
|
@@ -708,45 +713,52 @@
|
|
| 708 |
};
|
| 709 |
|
| 710 |
// Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
|
| 711 |
-
|
| 712 |
-
|
| 713 |
-
|
| 714 |
-
if (settings.onCleanup) {
|
| 715 |
-
settings.onCleanup.call(element);
|
| 716 |
-
}
|
| 717 |
-
|
| 718 |
-
open = FALSE;
|
| 719 |
-
$(document).unbind("keydown.cbox_close keydown.cbox_arrows");
|
| 720 |
-
$window.unbind(cbox_resize+' resize.cboxie6 scroll.cboxie6');
|
| 721 |
-
$overlay.css({cursor: 'auto'}).fadeOut('fast');
|
| 722 |
-
|
| 723 |
-
$cbox
|
| 724 |
-
.stop(TRUE, FALSE)
|
| 725 |
-
.fadeOut('fast', function () {
|
| 726 |
-
$('#colorbox iframe').attr('src', 'about:blank');
|
| 727 |
-
$loaded.remove();
|
| 728 |
-
$cbox.css({'opacity': 1});
|
| 729 |
|
| 730 |
-
|
| 731 |
-
bookmark.focus();
|
| 732 |
-
} catch (er){
|
| 733 |
-
// do nothing
|
| 734 |
-
}
|
| 735 |
|
| 736 |
-
|
| 737 |
-
|
| 738 |
-
settings.onClosed.call(element);
|
| 739 |
}
|
| 740 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 741 |
};
|
| 742 |
|
| 743 |
// A method for fetching the current element ColorBox is referencing.
|
| 744 |
// returns a jQuery object.
|
| 745 |
-
|
|
|
|
|
|
|
| 746 |
|
| 747 |
-
|
| 748 |
|
| 749 |
// Initializes ColorBox when the DOM has loaded
|
| 750 |
-
$(
|
| 751 |
|
| 752 |
-
}(jQuery));
|
| 1 |
+
// ColorBox v1.3.9 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
|
| 2 |
// c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
|
| 3 |
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
| 4 |
+
(function ($, window) {
|
| 5 |
+
|
| 6 |
+
var
|
| 7 |
+
// ColorBox Default Settings.
|
| 8 |
+
// See http://colorpowered.com/colorbox for details.
|
| 9 |
+
defaults = {
|
| 10 |
+
transition: "elastic",
|
| 11 |
+
speed: 300,
|
| 12 |
+
width: false,
|
| 13 |
+
initialWidth: "600",
|
| 14 |
+
innerWidth: false,
|
| 15 |
+
maxWidth: false,
|
| 16 |
+
height: false,
|
| 17 |
+
initialHeight: "450",
|
| 18 |
+
innerHeight: false,
|
| 19 |
+
maxHeight: false,
|
| 20 |
+
scalePhotos: true,
|
| 21 |
+
scrolling: true,
|
| 22 |
+
inline: false,
|
| 23 |
+
html: false,
|
| 24 |
+
iframe: false,
|
| 25 |
+
photo: false,
|
| 26 |
+
href: false,
|
| 27 |
+
title: false,
|
| 28 |
+
rel: false,
|
| 29 |
+
opacity: 0.9,
|
| 30 |
+
preloading: true,
|
| 31 |
+
current: "image {current} of {total}",
|
| 32 |
+
previous: "previous",
|
| 33 |
+
next: "next",
|
| 34 |
+
close: "close",
|
| 35 |
+
open: false,
|
| 36 |
+
loop: true,
|
| 37 |
+
slideshow: false,
|
| 38 |
+
slideshowAuto: true,
|
| 39 |
+
slideshowSpeed: 2500,
|
| 40 |
+
slideshowStart: "start slideshow",
|
| 41 |
+
slideshowStop: "stop slideshow",
|
| 42 |
+
onOpen: false,
|
| 43 |
+
onLoad: false,
|
| 44 |
+
onComplete: false,
|
| 45 |
+
onCleanup: false,
|
| 46 |
+
onClosed: false,
|
| 47 |
+
overlayClose: true,
|
| 48 |
+
escKey: true,
|
| 49 |
+
arrowKey: true
|
| 50 |
+
},
|
| 51 |
+
|
| 52 |
+
// Abstracting the HTML and event identifiers for easy rebranding
|
| 53 |
+
colorbox = 'colorbox',
|
| 54 |
+
prefix = 'cbox',
|
| 55 |
+
|
| 56 |
+
// Events
|
| 57 |
+
event_open = prefix + '_open',
|
| 58 |
+
event_load = prefix + '_load',
|
| 59 |
+
event_complete = prefix + '_complete',
|
| 60 |
+
event_cleanup = prefix + '_cleanup',
|
| 61 |
+
event_closed = prefix + '_closed',
|
| 62 |
+
|
| 63 |
+
// Special Handling for IE
|
| 64 |
+
isIE = $.browser.msie && !$.support.opacity, // feature detection alone gave a false positive on at least one phone browser and on some development versions of Chrome.
|
| 65 |
+
isIE6 = isIE && $.browser.version < 7,
|
| 66 |
+
event_ie6 = prefix + '_IE6',
|
| 67 |
|
| 68 |
// Cached jQuery Object Variables
|
| 69 |
$overlay,
|
| 70 |
+
$box,
|
| 71 |
$wrap,
|
| 72 |
$content,
|
| 73 |
$topBorder,
|
| 79 |
$loaded,
|
| 80 |
$loadingBay,
|
| 81 |
$loadingOverlay,
|
|
|
|
| 82 |
$title,
|
| 83 |
$current,
|
| 84 |
$slideshow,
|
| 98 |
open,
|
| 99 |
active,
|
| 100 |
|
| 101 |
+
publicMethod,
|
| 102 |
+
boxElement = prefix + 'Element';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
// ****************
|
| 105 |
// HELPER FUNCTIONS
|
| 106 |
// ****************
|
| 107 |
+
|
| 108 |
+
// jQuery object generator to reduce code size
|
| 109 |
+
function $div(id, css) {
|
| 110 |
+
id = id ? ' id="' + prefix + id + '"' : '';
|
| 111 |
+
css = css ? ' style="' + css + '"' : '';
|
| 112 |
+
return $('<div' + id + css + '/>');
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
// Convert % values to pixels
|
| 116 |
function setSize(size, dimension) {
|
| 117 |
+
dimension = dimension === 'x' ? $window.width() : $window.height();
|
| 118 |
return (typeof size === 'string') ? Math.round((size.match(/%/) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size;
|
| 119 |
}
|
| 120 |
|
| 132 |
settings[i] = settings[i].call(element);
|
| 133 |
}
|
| 134 |
}
|
| 135 |
+
settings.rel = settings.rel || element.rel || 'nofollow';
|
| 136 |
+
settings.href = settings.href || $(element).attr('href');
|
| 137 |
settings.title = settings.title || element.title;
|
| 138 |
}
|
| 139 |
|
| 141 |
|
| 142 |
element = elem;
|
| 143 |
|
| 144 |
+
settings = $.extend({}, $(element).data(colorbox));
|
| 145 |
|
| 146 |
process(); // Convert functions to their returned values.
|
| 147 |
|
| 148 |
+
if (settings.rel !== 'nofollow') {
|
| 149 |
+
$related = $('.' + boxElement).filter(function () {
|
| 150 |
var relRelated = $(this).data(colorbox).rel || this.rel;
|
| 151 |
return (relRelated === settings.rel);
|
| 152 |
});
|
| 153 |
index = $related.index(element);
|
| 154 |
|
| 155 |
// Check direct calls to ColorBox.
|
| 156 |
+
if (index === -1) {
|
| 157 |
$related = $related.add(element);
|
| 158 |
index = $related.length - 1;
|
| 159 |
}
|
| 163 |
}
|
| 164 |
|
| 165 |
if (!open) {
|
| 166 |
+
open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
|
|
|
|
|
|
|
| 167 |
|
| 168 |
bookmark = element;
|
| 169 |
|
| 170 |
+
try {
|
| 171 |
+
bookmark.blur(); // Remove the focus from the calling element.
|
| 172 |
+
}catch (e) {}
|
| 173 |
|
| 174 |
+
$.event.trigger(event_open);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
if (settings.onOpen) {
|
| 176 |
settings.onOpen.call(element);
|
| 177 |
}
|
| 178 |
|
| 179 |
+
// +settings.opacity avoids a problem in IE when using non-zero-prefixed-string-values, like '.5'
|
| 180 |
+
$overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer" : "auto"}).show();
|
| 181 |
|
| 182 |
// Opens inital empty ColorBox prior to content being loaded.
|
| 183 |
settings.w = setSize(settings.initialWidth, 'x');
|
| 184 |
settings.h = setSize(settings.initialHeight, 'y');
|
| 185 |
+
publicMethod.position(0);
|
| 186 |
|
| 187 |
if (isIE6) {
|
| 188 |
+
$window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function () {
|
| 189 |
$overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
|
| 190 |
+
}).trigger('scroll.' + event_ie6);
|
| 191 |
}
|
| 192 |
}
|
| 193 |
|
| 195 |
|
| 196 |
$close.html(settings.close).show();
|
| 197 |
|
| 198 |
+
publicMethod.slideshow();
|
| 199 |
|
| 200 |
+
publicMethod.load();
|
| 201 |
}
|
| 202 |
|
| 203 |
// ****************
|
| 206 |
// Usage from within an iframe: parent.$.fn.colorbox.close();
|
| 207 |
// ****************
|
| 208 |
|
| 209 |
+
publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
|
| 210 |
var $this = this;
|
| 211 |
|
| 212 |
+
if (!$this[0] && $this.selector) { // if a selector was given and it didn't match any elements, go ahead and exit.
|
| 213 |
+
return $this;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
options = options || {};
|
| 217 |
+
|
| 218 |
+
if (callback) {
|
| 219 |
+
options.onComplete = callback;
|
| 220 |
+
}
|
| 221 |
+
|
| 222 |
+
if (!$this[0] || $this.selector === undefined) { // detects $.colorbox() and $.fn.colorbox()
|
| 223 |
+
$this = $('<a/>');
|
| 224 |
+
options.open = true; // assume an immediate open
|
| 225 |
}
|
| 226 |
|
| 227 |
$this.each(function () {
|
| 228 |
+
$(this).data(colorbox, $.extend({}, $(this).data(colorbox) || defaults, options)).addClass(boxElement);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
});
|
| 230 |
|
| 231 |
+
if (options.open) {
|
| 232 |
+
launch($this[0]);
|
| 233 |
}
|
| 234 |
|
| 235 |
+
return $this;
|
| 236 |
};
|
| 237 |
|
| 238 |
// Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
|
| 239 |
// This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only
|
| 240 |
// having to run once, instead of each time colorbox is opened.
|
| 241 |
+
publicMethod.init = function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 242 |
// Create & Append jQuery Objects
|
| 243 |
$window = $(window);
|
| 244 |
+
$box = $div().attr({id: colorbox, 'class': isIE ? prefix + 'IE' : ''});
|
| 245 |
+
$overlay = $div("Overlay", isIE6 ? 'position:absolute' : '').hide();
|
| 246 |
+
|
| 247 |
$wrap = $div("Wrapper");
|
| 248 |
$content = $div("Content").append(
|
| 249 |
+
$loaded = $div("LoadedContent", 'width:0; height:0'),
|
| 250 |
+
$loadingOverlay = $div("LoadingOverlay").add($div("LoadingGraphic")),
|
|
|
|
| 251 |
$title = $div("Title"),
|
| 252 |
$current = $div("Current"),
|
|
|
|
| 253 |
$next = $div("Next"),
|
| 254 |
$prev = $div("Previous"),
|
| 255 |
+
$slideshow = $div("Slideshow"),
|
| 256 |
$close = $div("Close")
|
| 257 |
);
|
| 258 |
$wrap.append( // The 3x3 Grid that makes up ColorBox
|
| 259 |
+
$div().append(
|
| 260 |
$div("TopLeft"),
|
| 261 |
$topBorder = $div("TopCenter"),
|
| 262 |
$div("TopRight")
|
| 263 |
),
|
| 264 |
+
$div().append(
|
| 265 |
$leftBorder = $div("MiddleLeft"),
|
| 266 |
$content,
|
| 267 |
$rightBorder = $div("MiddleRight")
|
| 268 |
),
|
| 269 |
+
$div().append(
|
| 270 |
$div("BottomLeft"),
|
| 271 |
$bottomBorder = $div("BottomCenter"),
|
| 272 |
$div("BottomRight")
|
| 273 |
)
|
| 274 |
).children().children().css({'float': 'left'});
|
| 275 |
|
| 276 |
+
$loadingBay = $div(false, 'position:absolute; width:9999px; visibility:hidden; display:none');
|
| 277 |
|
| 278 |
+
$('body').prepend($overlay, $box.append($wrap, $loadingBay));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
|
|
|
|
| 280 |
$content.children()
|
| 281 |
+
.hover(function () {
|
| 282 |
+
$(this).addClass('hover');
|
| 283 |
+
}, function () {
|
| 284 |
+
$(this).removeClass('hover');
|
| 285 |
+
}).addClass('hover');
|
| 286 |
|
| 287 |
// Cache values needed for size calculations
|
| 288 |
+
interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();//Subtraction needed for IE6
|
| 289 |
+
interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
|
| 290 |
+
loadedHeight = $loaded.outerHeight(true);
|
| 291 |
+
loadedWidth = $loaded.outerWidth(true);
|
| 292 |
|
| 293 |
// Setting padding to remove the need to do size conversions during the animation step.
|
| 294 |
+
$box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
|
| 295 |
|
| 296 |
+
// Setup button events.
|
| 297 |
+
$next.click(publicMethod.next);
|
| 298 |
+
$prev.click(publicMethod.prev);
|
| 299 |
+
$close.click(publicMethod.close);
|
| 300 |
|
| 301 |
// Adding the 'hover' class allowed the browser to load the hover-state
|
| 302 |
// background graphics. The class can now can be removed.
|
| 303 |
+
$content.children().removeClass('hover');
|
| 304 |
|
| 305 |
+
$('.' + boxElement).live('click', function (e) {
|
| 306 |
+
// checks to see if it was a non-left mouse-click and for clicks modified with ctrl, shift, or alt.
|
| 307 |
+
if ((e.button !== 0 && typeof e.button !== 'undefined') || e.ctrlKey || e.shiftKey || e.altKey) {
|
| 308 |
+
return true;
|
| 309 |
} else {
|
| 310 |
launch(this);
|
| 311 |
+
return false;
|
| 312 |
+
}
|
| 313 |
+
});
|
| 314 |
+
|
| 315 |
+
$overlay.click(function () {
|
| 316 |
+
if (settings.overlayClose) {
|
| 317 |
+
publicMethod.close();
|
| 318 |
+
}
|
| 319 |
+
});
|
| 320 |
+
|
| 321 |
+
// Set Navigation Key Bindings
|
| 322 |
+
$(document).bind("keydown", function (e) {
|
| 323 |
+
if (open && settings.escKey && e.keyCode === 27) {
|
| 324 |
+
e.preventDefault();
|
| 325 |
+
publicMethod.close();
|
| 326 |
+
}
|
| 327 |
+
if (open && settings.arrowKey && !active && $related[1]) {
|
| 328 |
+
if (e.keyCode === 37 && (index || settings.loop)) {
|
| 329 |
+
e.preventDefault();
|
| 330 |
+
$prev.click();
|
| 331 |
+
} else if (e.keyCode === 39 && (index < $related.length - 1 || settings.loop)) {
|
| 332 |
+
e.preventDefault();
|
| 333 |
+
$next.click();
|
| 334 |
+
}
|
| 335 |
}
|
| 336 |
});
|
| 337 |
};
|
| 338 |
+
|
| 339 |
+
publicMethod.remove = function () {
|
| 340 |
+
$box.add($overlay).remove();
|
| 341 |
+
$('.' + boxElement).die('click').removeData(colorbox).removeClass(boxElement);
|
| 342 |
+
};
|
| 343 |
|
| 344 |
+
publicMethod.position = function (speed, loadedCallback) {
|
| 345 |
var
|
| 346 |
animate_speed,
|
|
|
|
| 347 |
// keeps the top and left positions within the browser's viewport.
|
| 348 |
+
posTop = Math.max($window.height() - settings.h - loadedHeight - interfaceHeight, 0) / 2 + $window.scrollTop(),
|
| 349 |
+
posLeft = Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2 + $window.scrollLeft();
|
| 350 |
|
| 351 |
// setting the speed to 0 to reduce the delay between same-sized content.
|
| 352 |
+
animate_speed = ($box.width() === settings.w + loadedWidth && $box.height() === settings.h + loadedHeight) ? 0 : speed;
|
| 353 |
|
| 354 |
// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
|
| 355 |
// but it has to be shrank down around the size of div#colorbox when it's done. If not,
|
| 356 |
// it can invoke an obscure IE bug when using iframes.
|
| 357 |
$wrap[0].style.width = $wrap[0].style.height = "9999px";
|
| 358 |
|
| 359 |
+
function modalDimensions(that) {
|
| 360 |
+
// loading overlay height has to be explicitly set for IE6.
|
| 361 |
$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
|
| 362 |
+
$loadingOverlay[0].style.height = $loadingOverlay[1].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
|
| 363 |
}
|
| 364 |
|
| 365 |
+
$box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: posTop, left: posLeft}, {
|
| 366 |
+
duration: animate_speed,
|
| 367 |
+
complete: function () {
|
| 368 |
modalDimensions(this);
|
| 369 |
|
| 370 |
+
active = false;
|
| 371 |
|
| 372 |
// shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
|
| 373 |
+
$wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
|
| 374 |
+
$wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
|
| 375 |
|
| 376 |
+
if (loadedCallback) {
|
| 377 |
+
loadedCallback();
|
| 378 |
+
}
|
| 379 |
},
|
| 380 |
+
step: function () {
|
| 381 |
modalDimensions(this);
|
| 382 |
}
|
| 383 |
});
|
| 384 |
};
|
| 385 |
|
| 386 |
+
publicMethod.resize = function (options) {
|
| 387 |
+
if (open) {
|
| 388 |
+
options = options || {};
|
| 389 |
+
|
| 390 |
+
if (options.width) {
|
| 391 |
+
settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
|
| 392 |
+
}
|
| 393 |
+
if (options.innerWidth) {
|
| 394 |
+
settings.w = setSize(options.innerWidth, 'x');
|
| 395 |
+
}
|
| 396 |
+
$loaded.css({width: settings.w});
|
| 397 |
+
|
| 398 |
+
if (options.height) {
|
| 399 |
+
settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
|
| 400 |
+
}
|
| 401 |
+
if (options.innerHeight) {
|
| 402 |
+
settings.h = setSize(options.innerHeight, 'y');
|
| 403 |
+
}
|
| 404 |
+
if (!options.innerHeight && !options.height) {
|
| 405 |
var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be.
|
| 406 |
settings.h = $child.height();
|
|
|
|
| 407 |
$child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
|
| 408 |
+
}
|
| 409 |
+
$loaded.css({height: settings.h});
|
| 410 |
+
|
| 411 |
+
publicMethod.position(settings.transition === "none" ? 0 : settings.speed);
|
| 412 |
+
}
|
| 413 |
+
};
|
| 414 |
+
|
| 415 |
+
publicMethod.prep = function (object) {
|
| 416 |
+
if (!open) {
|
| 417 |
return;
|
| 418 |
}
|
| 419 |
|
| 420 |
+
var photo,
|
| 421 |
+
speed = settings.transition === "none" ? 0 : settings.speed;
|
| 422 |
+
|
| 423 |
+
$window.unbind('resize.' + prefix);
|
| 424 |
$loaded.remove();
|
| 425 |
+
$loaded = $div('LoadedContent').html(object);
|
| 426 |
|
| 427 |
+
function getWidth() {
|
| 428 |
settings.w = settings.w || $loaded.width();
|
| 429 |
settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
|
| 430 |
return settings.w;
|
| 431 |
}
|
| 432 |
+
function getHeight() {
|
| 433 |
settings.h = settings.h || $loaded.height();
|
| 434 |
settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
|
| 435 |
return settings.h;
|
| 436 |
}
|
| 437 |
|
| 438 |
$loaded.hide()
|
| 439 |
+
.appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
|
| 440 |
+
.css({width: getWidth(), overflow: settings.scrolling ? 'auto' : 'hidden'})
|
| 441 |
+
.css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
|
| 442 |
.prependTo($content);
|
| 443 |
|
| 444 |
+
$loadingBay.hide();
|
| 445 |
+
|
| 446 |
+
$('#' + prefix + 'Photo').css({cssFloat: 'none'});// 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.
|
| 447 |
|
| 448 |
// Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
|
| 449 |
if (isIE6) {
|
| 450 |
+
$('select').not($box.find('select')).filter(function () {
|
| 451 |
return this.style.visibility !== 'hidden';
|
| 452 |
+
}).css({'visibility': 'hidden'}).one(event_cleanup, function () {
|
| 453 |
this.style.visibility = 'inherit';
|
| 454 |
});
|
| 455 |
}
|
| 456 |
|
| 457 |
+
function setPosition(s) {
|
| 458 |
+
var prev, prevSrc, next, nextSrc, total = $related.length, loop = settings.loop;
|
| 459 |
+
publicMethod.position(s, function () {
|
| 460 |
+
function defilter() {
|
| 461 |
+
if (isIE) {
|
| 462 |
+
//IE adds a filter when ColorBox fades in and out that can cause problems if the loaded content contains transparent pngs.
|
| 463 |
+
$box[0].style.removeAttribute("filter");
|
| 464 |
+
}
|
| 465 |
+
}
|
| 466 |
+
|
| 467 |
+
if (!open) {
|
| 468 |
+
return;
|
| 469 |
+
}
|
| 470 |
|
| 471 |
if (isIE) {
|
| 472 |
//This fadeIn helps the bicubic resampling to kick-in.
|
| 473 |
+
if (photo) {
|
| 474 |
+
$loaded.fadeIn(100);
|
| 475 |
+
}
|
| 476 |
}
|
| 477 |
|
| 478 |
//Waited until the iframe is added to the DOM & it is visible before setting the src.
|
| 479 |
//This increases compatability with pages using DOM dependent JavaScript.
|
| 480 |
+
if (settings.iframe) {
|
| 481 |
+
$("<iframe frameborder=0" + (settings.scrolling ? "" : " scrolling='no'") + (isIE ? " allowtransparency='true'" : '') + "/>")
|
| 482 |
+
.attr({src: settings.href, name: new Date().getTime()})
|
| 483 |
+
.appendTo($loaded);
|
| 484 |
}
|
| 485 |
|
| 486 |
$loaded.show();
|
| 487 |
|
| 488 |
$title.show().html(settings.title);
|
| 489 |
|
| 490 |
+
if (total > 1) { // handle grouping
|
| 491 |
+
$current.html(settings.current.replace(/\{current\}/, index + 1).replace(/\{total\}/, total)).show();
|
|
|
|
|
|
|
| 492 |
|
| 493 |
+
$next[(loop || index < total - 1) ? "show" : "hide"]().html(settings.next);
|
| 494 |
+
$prev[(loop || index) ? "show" : "hide"]().html(settings.previous);
|
| 495 |
+
|
| 496 |
+
prev = index ? $related[index - 1] : $related[total - 1];
|
| 497 |
+
next = index < total - 1 ? $related[index + 1] : $related[0];
|
| 498 |
+
|
| 499 |
+
if (settings.slideshow) {
|
| 500 |
$slideshow.show();
|
| 501 |
+
if (index === total - 1 && !loop && $box.is('.' + prefix + 'Slideshow_on')) {
|
| 502 |
+
$slideshow.click();
|
| 503 |
+
}
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
// Preloads images within a rel group
|
| 507 |
+
if (settings.preloading) {
|
| 508 |
+
nextSrc = $(next).data(colorbox).href || next.href;
|
| 509 |
+
prevSrc = $(prev).data(colorbox).href || prev.href;
|
| 510 |
+
|
| 511 |
+
if (isImage(nextSrc)) {
|
| 512 |
+
$('<img/>')[0].src = nextSrc;
|
| 513 |
+
}
|
| 514 |
+
|
| 515 |
+
if (isImage(prevSrc)) {
|
| 516 |
+
$('<img/>')[0].src = prevSrc;
|
| 517 |
+
}
|
| 518 |
}
|
| 519 |
}
|
| 520 |
|
| 521 |
$loadingOverlay.hide();
|
|
|
|
| 522 |
|
| 523 |
+
if (settings.transition === 'fade') {
|
| 524 |
+
$box.fadeTo(speed, 1, function () {
|
| 525 |
+
defilter();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 526 |
});
|
| 527 |
+
} else {
|
| 528 |
+
defilter();
|
| 529 |
}
|
| 530 |
|
| 531 |
+
$window.bind('resize.' + prefix, function () {
|
| 532 |
+
publicMethod.position(0);
|
| 533 |
});
|
| 534 |
+
|
| 535 |
+
$.event.trigger(event_complete);
|
| 536 |
+
if (settings.onComplete) {
|
| 537 |
+
settings.onComplete.call(element);
|
| 538 |
+
}
|
| 539 |
});
|
| 540 |
}
|
| 541 |
|
| 542 |
+
if (settings.transition === 'fade') {
|
| 543 |
+
$box.fadeTo(speed, 0, function () {
|
| 544 |
+
setPosition(0);
|
| 545 |
+
});
|
| 546 |
+
} else {
|
| 547 |
+
setPosition(speed);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
}
|
| 549 |
};
|
| 550 |
|
| 551 |
+
publicMethod.load = function () {
|
| 552 |
+
var href, img, setResize, prep = publicMethod.prep;
|
| 553 |
+
|
| 554 |
+
active = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 555 |
|
| 556 |
element = $related[index];
|
| 557 |
|
| 558 |
+
settings = $.extend({}, $(element).data(colorbox));
|
| 559 |
|
| 560 |
//convert functions to static values
|
| 561 |
process();
|
| 562 |
|
| 563 |
+
$.event.trigger(event_load);
|
| 564 |
if (settings.onLoad) {
|
| 565 |
settings.onLoad.call(element);
|
| 566 |
}
|
| 567 |
|
|
|
|
| 568 |
settings.h = settings.height ?
|
| 569 |
setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
|
| 570 |
+
settings.innerHeight && setSize(settings.innerHeight, 'y');
|
| 571 |
+
|
|
|
|
| 572 |
settings.w = settings.width ?
|
| 573 |
setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
|
| 574 |
+
settings.innerWidth && setSize(settings.innerWidth, 'x');
|
|
|
|
|
|
|
| 575 |
|
| 576 |
// Sets the minimum dimensions for use in image scaling
|
| 577 |
settings.mw = settings.w;
|
| 579 |
|
| 580 |
// Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
|
| 581 |
// If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
|
| 582 |
+
if (settings.maxWidth) {
|
| 583 |
settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
|
| 584 |
settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
|
| 585 |
}
|
| 586 |
+
if (settings.maxHeight) {
|
| 587 |
settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
|
| 588 |
settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
|
| 589 |
}
|
| 591 |
href = settings.href;
|
| 592 |
|
| 593 |
$loadingOverlay.show();
|
|
|
|
| 594 |
|
| 595 |
if (settings.inline) {
|
| 596 |
// Inserts an empty placeholder where inline content is being pulled from.
|
| 597 |
// An event is bound to put inline content back when ColorBox closes or loads new content.
|
| 598 |
+
$div('InlineTemp').hide().insertBefore($(href)[0]).bind(event_load + ' ' + event_cleanup, function () {
|
| 599 |
$(this).replaceWith($loaded.children());
|
| 600 |
});
|
| 601 |
+
prep($(href));
|
| 602 |
} else if (settings.iframe) {
|
| 603 |
// IFrame element won't be added to the DOM until it is ready to be displayed,
|
| 604 |
// to avoid problems with DOM-ready JS that might be trying to run in that iframe.
|
| 605 |
+
prep(" ");
|
| 606 |
} else if (settings.html) {
|
| 607 |
+
prep(settings.html);
|
| 608 |
+
} else if (isImage(href)) {
|
| 609 |
img = new Image();
|
| 610 |
+
img.onload = function () {
|
| 611 |
var percent;
|
| 612 |
|
| 613 |
img.onload = null;
|
| 614 |
+
img.id = prefix + 'Photo';
|
| 615 |
+
$(img).css({margin: 'auto', border: 'none', display: 'block', cssFloat: 'left'});
|
| 616 |
|
| 617 |
+
if (settings.scalePhotos) {
|
| 618 |
+
setResize = function () {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 619 |
img.height -= img.height * percent;
|
| 620 |
img.width -= img.width * percent;
|
| 621 |
};
|
| 622 |
+
if (settings.mw && img.width > settings.mw) {
|
| 623 |
percent = (img.width - settings.mw) / img.width;
|
| 624 |
setResize();
|
| 625 |
}
|
| 626 |
+
if (settings.mh && img.height > settings.mh) {
|
| 627 |
percent = (img.height - settings.mh) / img.height;
|
| 628 |
setResize();
|
| 629 |
}
|
| 630 |
}
|
| 631 |
|
| 632 |
if (settings.h) {
|
| 633 |
+
img.style.marginTop = Math.max(settings.h - img.height, 0) / 2 + 'px';
|
| 634 |
}
|
| 635 |
|
| 636 |
+
setTimeout(function () { // Chrome will sometimes report a 0 by 0 size if there isn't pause in execution
|
| 637 |
+
prep(img);
|
| 638 |
+
}, 1);
|
| 639 |
|
| 640 |
+
if ($related[1] && (index < $related.length - 1 || settings.loop)) {
|
| 641 |
+
$(img).css({cursor: 'pointer'}).click(publicMethod.next);
|
| 642 |
}
|
| 643 |
|
| 644 |
+
if (isIE) {
|
| 645 |
+
img.style.msInterpolationMode = 'bicubic';
|
| 646 |
}
|
| 647 |
};
|
| 648 |
img.src = href;
|
| 649 |
} else {
|
| 650 |
+
$div().appendTo($loadingBay).load(href, function (data, status, xhr) {
|
| 651 |
+
prep(status === 'error' ? 'Request unsuccessful: ' + xhr.statusText : this);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 652 |
});
|
| 653 |
}
|
| 654 |
};
|
| 655 |
|
| 656 |
// Navigates to the next page/image in a set.
|
| 657 |
+
publicMethod.next = function () {
|
| 658 |
+
if (!active) {
|
| 659 |
+
index = index < $related.length - 1 ? index + 1 : 0;
|
| 660 |
+
publicMethod.load();
|
| 661 |
}
|
| 662 |
};
|
| 663 |
|
| 664 |
+
publicMethod.prev = function () {
|
| 665 |
+
if (!active) {
|
| 666 |
+
index = index ? index - 1 : $related.length - 1;
|
| 667 |
+
publicMethod.load();
|
| 668 |
}
|
| 669 |
};
|
| 670 |
|
| 671 |
+
publicMethod.slideshow = function () {
|
| 672 |
+
var stop, timeOut, className = prefix + 'Slideshow_';
|
| 673 |
|
| 674 |
+
$slideshow.bind(event_closed, function () {
|
| 675 |
$slideshow.unbind();
|
| 676 |
clearTimeout(timeOut);
|
| 677 |
+
$box.removeClass(className + "off " + className + "on");
|
| 678 |
});
|
| 679 |
|
| 680 |
+
function start() {
|
| 681 |
$slideshow
|
| 682 |
.text(settings.slideshowStop)
|
| 683 |
+
.bind(event_complete, function () {
|
| 684 |
+
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
|
| 685 |
})
|
| 686 |
+
.bind(event_load, function () {
|
| 687 |
clearTimeout(timeOut);
|
| 688 |
+
}).one("click", function () {
|
| 689 |
stop();
|
|
|
|
| 690 |
});
|
| 691 |
+
$box.removeClass(className + "off").addClass(className + "on");
|
| 692 |
}
|
| 693 |
|
| 694 |
+
stop = function () {
|
| 695 |
clearTimeout(timeOut);
|
| 696 |
$slideshow
|
| 697 |
.text(settings.slideshowStart)
|
| 698 |
+
.unbind(event_complete + ' ' + event_load)
|
| 699 |
+
.one("click", function () {
|
| 700 |
start();
|
| 701 |
+
timeOut = setTimeout(publicMethod.next, settings.slideshowSpeed);
|
|
|
|
| 702 |
});
|
| 703 |
+
$box.removeClass(className + "on").addClass(className + "off");
|
| 704 |
};
|
| 705 |
|
| 706 |
+
if (settings.slideshow && $related[1]) {
|
| 707 |
+
if (settings.slideshowAuto) {
|
| 708 |
start();
|
| 709 |
} else {
|
| 710 |
stop();
|
| 713 |
};
|
| 714 |
|
| 715 |
// Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
|
| 716 |
+
publicMethod.close = function () {
|
| 717 |
+
if (open) {
|
| 718 |
+
open = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 719 |
|
| 720 |
+
$.event.trigger(event_cleanup);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 721 |
|
| 722 |
+
if (settings.onCleanup) {
|
| 723 |
+
settings.onCleanup.call(element);
|
|
|
|
| 724 |
}
|
| 725 |
+
|
| 726 |
+
$window.unbind('.' + prefix + ' .' + event_ie6);
|
| 727 |
+
|
| 728 |
+
$overlay.fadeTo('fast', 0);
|
| 729 |
+
|
| 730 |
+
$box.stop().fadeTo('fast', 0, function () {
|
| 731 |
+
$box.find('iframe').attr('src', 'about:blank'); // change the location of the iframe to avoid a problem in IE with flash objects not clearing.
|
| 732 |
+
|
| 733 |
+
$loaded.remove();
|
| 734 |
+
|
| 735 |
+
$box.add($overlay).css({'opacity': 1, cursor: 'auto'}).hide();
|
| 736 |
+
|
| 737 |
+
try {
|
| 738 |
+
bookmark.focus();
|
| 739 |
+
} catch (e) {
|
| 740 |
+
// do nothing
|
| 741 |
+
}
|
| 742 |
+
|
| 743 |
+
setTimeout(function () {
|
| 744 |
+
$.event.trigger(event_closed);
|
| 745 |
+
if (settings.onClosed) {
|
| 746 |
+
settings.onClosed.call(element);
|
| 747 |
+
}
|
| 748 |
+
}, 1);
|
| 749 |
+
});
|
| 750 |
+
}
|
| 751 |
};
|
| 752 |
|
| 753 |
// A method for fetching the current element ColorBox is referencing.
|
| 754 |
// returns a jQuery object.
|
| 755 |
+
publicMethod.element = function () {
|
| 756 |
+
return $(element);
|
| 757 |
+
};
|
| 758 |
|
| 759 |
+
publicMethod.settings = defaults;
|
| 760 |
|
| 761 |
// Initializes ColorBox when the DOM has loaded
|
| 762 |
+
$(publicMethod.init);
|
| 763 |
|
| 764 |
+
}(jQuery, this));
|
readme.txt
CHANGED
|
@@ -4,7 +4,7 @@ Donate link: http://www.techotronic.de/donate/
|
|
| 4 |
Tags: jquery, colorbox, lightbox, images, pictures, photos, gallery, javascript, overlay, nextgen gallery, nextgen-gallery, image, picture, photo, media, slideshow, ngg, mu
|
| 5 |
Requires at least: 2.8
|
| 6 |
Tested up to: 3.0
|
| 7 |
-
Stable tag: 3.
|
| 8 |
|
| 9 |
Adds Colorbox/Lightbox functionality to images, grouped by post or page. Works for WordPress and NextGEN galleries. Comes with different themes.
|
| 10 |
|
|
@@ -44,7 +44,7 @@ Localization
|
|
| 44 |
|
| 45 |
Is your native language missing? Translating the plugin is easy if you understand english and are fluent in another language. Just send me an email.
|
| 46 |
|
| 47 |
-
Includes <a href="http://colorpowered.com/colorbox/">ColorBox</a> 1.3.
|
| 48 |
Colorbox is licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>.
|
| 49 |
jQuery Colorbox uses the jQuery library version 1.3.2 bundled with Wordpress. Works with jQuery 1.4.2 too.
|
| 50 |
The picture I used for the screenshots was designed by <a href="http://wallpapers.vintage.it/">Davide Vicariotto</a>
|
|
@@ -164,6 +164,9 @@ Feel free to write an email to blog [at] techotronic.de or open a thread at <a h
|
|
| 164 |
I'll include new FAQs in every new version. Promise.
|
| 165 |
|
| 166 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
| 167 |
= 3.5 (2010-06-16) =
|
| 168 |
* NEW: Ukrainian translation by <a href="http://www.politcult.com/">Yuri Kryzhanivskyi</a>
|
| 169 |
* NEW: Italian translation by <a href="http://erkinson.altervista.org/">Erkinson</a>
|
| 4 |
Tags: jquery, colorbox, lightbox, images, pictures, photos, gallery, javascript, overlay, nextgen gallery, nextgen-gallery, image, picture, photo, media, slideshow, ngg, mu
|
| 5 |
Requires at least: 2.8
|
| 6 |
Tested up to: 3.0
|
| 7 |
+
Stable tag: 3.6
|
| 8 |
|
| 9 |
Adds Colorbox/Lightbox functionality to images, grouped by post or page. Works for WordPress and NextGEN galleries. Comes with different themes.
|
| 10 |
|
| 44 |
|
| 45 |
Is your native language missing? Translating the plugin is easy if you understand english and are fluent in another language. Just send me an email.
|
| 46 |
|
| 47 |
+
Includes <a href="http://colorpowered.com/colorbox/">ColorBox</a> 1.3.9 jQuery plugin from Jack Moore.
|
| 48 |
Colorbox is licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>.
|
| 49 |
jQuery Colorbox uses the jQuery library version 1.3.2 bundled with Wordpress. Works with jQuery 1.4.2 too.
|
| 50 |
The picture I used for the screenshots was designed by <a href="http://wallpapers.vintage.it/">Davide Vicariotto</a>
|
| 164 |
I'll include new FAQs in every new version. Promise.
|
| 165 |
|
| 166 |
== Changelog ==
|
| 167 |
+
= 3.6 (2010-09-12) =
|
| 168 |
+
* CHANGE: Update of Colorbox library to version 1.3.9 which fixes lots of bugs. Most notably the "0 by 0" bug in Chrome.
|
| 169 |
+
|
| 170 |
= 3.5 (2010-06-16) =
|
| 171 |
* NEW: Ukrainian translation by <a href="http://www.politcult.com/">Yuri Kryzhanivskyi</a>
|
| 172 |
* NEW: Italian translation by <a href="http://erkinson.altervista.org/">Erkinson</a>
|
