Version Description
- Added: Option to group automatically activated links
- Optimized: Lightbox caption retrieval
Download this release
Release Info
Developer | Archetyped |
Plugin | Simple Lightbox |
Version | 1.2 |
Comparing to | |
See all releases |
Code changes from version 1.1 to 1.2
- js/dev/lightbox.js +22 -6
- js/lib.js +19 -18
- main.php +2 -2
- model.php +9 -5
- readme.txt +5 -0
- screenshot-1.gif +0 -0
js/dev/lightbox.js
CHANGED
@@ -1,12 +1,16 @@
|
|
1 |
// -----------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2 |
//
|
3 |
-
// Lightbox Slideshow v1.1
|
4 |
// by Justin Barkhuff - http://www.justinbarkhuff.com/lab/lightbox_slideshow/
|
5 |
-
//
|
6 |
//
|
7 |
// Largely based on Lightbox v2.02
|
8 |
// by Lokesh Dhakar - http://huddletogether.com/projects/lightbox2/
|
9 |
-
//
|
10 |
//
|
11 |
// Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
|
12 |
//
|
@@ -259,7 +263,19 @@ var Lightbox = {
|
|
259 |
}
|
260 |
}
|
261 |
},
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
//
|
264 |
// start()
|
265 |
// Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
|
@@ -282,7 +298,7 @@ var Lightbox = {
|
|
282 |
// if image is NOT part of a group..
|
283 |
if(rel == this.relAttribute){
|
284 |
// add single image to imageArray
|
285 |
-
imageTitle =
|
286 |
this.imageArray.push({'link':imageLink.getAttribute('href'), 'title':imageTitle});
|
287 |
this.startImage = 0;
|
288 |
} else {
|
@@ -292,7 +308,7 @@ var Lightbox = {
|
|
292 |
for (var i=0; i<els.length; i++){
|
293 |
var el = els[i];
|
294 |
if (el.getAttribute('href') && (el.getAttribute('rel') == rel)){
|
295 |
-
imageTitle =
|
296 |
this.imageArray.push({'link':el.getAttribute('href'),'title':imageTitle});
|
297 |
if(el == imageLink){
|
298 |
this.startImage = this.imageArray.length-1;
|
1 |
// -----------------------------------------------------------------------------------
|
2 |
+
//
|
3 |
+
// Simple Lightbox
|
4 |
+
// by Archetyped - http://archetyped.com/tools/simple-lightbox/
|
5 |
+
// Updated: 2010-06-11
|
6 |
//
|
7 |
+
// Largely based on Lightbox Slideshow v1.1
|
8 |
// by Justin Barkhuff - http://www.justinbarkhuff.com/lab/lightbox_slideshow/
|
9 |
+
// 2007/08/15
|
10 |
//
|
11 |
// Largely based on Lightbox v2.02
|
12 |
// by Lokesh Dhakar - http://huddletogether.com/projects/lightbox2/
|
13 |
+
// 2006/03/31
|
14 |
//
|
15 |
// Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
|
16 |
//
|
263 |
}
|
264 |
}
|
265 |
},
|
266 |
+
|
267 |
+
getCaption: function(imageLink) {
|
268 |
+
var caption = imageLink.title || '';
|
269 |
+
if ( caption == '' ) {
|
270 |
+
var inner = $(imageLink).getElementsBySelector('img').first();
|
271 |
+
if ( inner )
|
272 |
+
caption = inner.getAttribute('alt') || inner.getAttribute('title');
|
273 |
+
if ( !caption )
|
274 |
+
caption = imageLink.innerHTML.stripTags() || imageLink.href || '';
|
275 |
+
}
|
276 |
+
return caption;
|
277 |
+
},
|
278 |
+
|
279 |
//
|
280 |
// start()
|
281 |
// Display overlay and lightbox. If image is part of a set, add siblings to imageArray.
|
298 |
// if image is NOT part of a group..
|
299 |
if(rel == this.relAttribute){
|
300 |
// add single image to imageArray
|
301 |
+
imageTitle = this.getCaption(imageLink);
|
302 |
this.imageArray.push({'link':imageLink.getAttribute('href'), 'title':imageTitle});
|
303 |
this.startImage = 0;
|
304 |
} else {
|
308 |
for (var i=0; i<els.length; i++){
|
309 |
var el = els[i];
|
310 |
if (el.getAttribute('href') && (el.getAttribute('rel') == rel)){
|
311 |
+
imageTitle = this.getCaption(el);
|
312 |
this.imageArray.push({'link':el.getAttribute('href'),'title':imageTitle});
|
313 |
if(el == imageLink){
|
314 |
this.startImage = this.imageArray.length-1;
|
js/lib.js
CHANGED
@@ -124,7 +124,8 @@ b){if(!a)return 0;if(a=="vertical")return(this.offset[1]+b.offsetHeight-this.yco
|
|
124 |
Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},c||{});a=$(a);var d=Position.page(a);b=$(b);var e=[0,0],f=null;if(Element.getStyle(b,"position")=="absolute"){f=Position.offsetParent(b);e=Position.page(f)}if(f==document.body){e[0]-=document.body.offsetLeft;e[1]-=document.body.offsetTop}if(c.setLeft)b.style.left=d[0]-e[0]+c.offsetLeft+"px";if(c.setTop)b.style.top=d[1]-e[1]+c.offsetTop+"px";if(c.setWidth)b.style.width=a.offsetWidth+"px";if(c.setHeight)b.style.height=
|
125 |
a.offsetHeight+"px"},absolutize:function(a){a=$(a);if(a.style.position!="absolute"){Position.prepare();var b=Position.positionedOffset(a),c=b[1];b=b[0];var d=a.clientWidth,e=a.clientHeight;a._originalLeft=b-parseFloat(a.style.left||0);a._originalTop=c-parseFloat(a.style.top||0);a._originalWidth=a.style.width;a._originalHeight=a.style.height;a.style.position="absolute";a.style.top=c+"px";a.style.left=b+"px";a.style.width=d+"px";a.style.height=e+"px"}},relativize:function(a){a=$(a);if(a.style.position!=
|
126 |
"relative"){Position.prepare();a.style.position="relative";var b=parseFloat(a.style.top||0)-(a._originalTop||0),c=parseFloat(a.style.left||0)-(a._originalLeft||0);a.style.top=b+"px";a.style.left=c+"px";a.style.height=a._originalHeight;a.style.width=a._originalWidth}}};
|
127 |
-
if(Prototype.Browser.WebKit)Position.cumulativeOffset=function(a){var b=0,c=0;do{b+=a.offsetTop||0;c+=a.offsetLeft||0;if(a.offsetParent==document.body)if(Element.getStyle(a,"position")=="absolute")break;a=a.offsetParent}while(a);return[c,b]};Element.addMethods();
|
|
|
128 |
Element.collectTextNodes=function(a){return $A($(a).childNodes).collect(function(b){return b.nodeType==3?b.nodeValue:b.hasChildNodes()?Element.collectTextNodes(b):""}).flatten().join("")};Element.collectTextNodesIgnoreClass=function(a,b){return $A($(a).childNodes).collect(function(c){return c.nodeType==3?c.nodeValue:c.hasChildNodes()&&!Element.hasClassName(c,b)?Element.collectTextNodesIgnoreClass(c,b):""}).flatten().join("")};
|
129 |
Element.setContentZoom=function(a,b){a=$(a);a.setStyle({fontSize:b/100+"em"});Prototype.Browser.WebKit&&window.scrollBy(0,0);return a};Element.getInlineOpacity=function(a){return $(a).style.opacity||""};Element.forceRerendering=function(a){try{a=$(a);var b=document.createTextNode(" ");a.appendChild(b);a.removeChild(b)}catch(c){}};Array.prototype.call=function(){var a=arguments;this.each(function(b){b.apply(this,a)})};
|
130 |
var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},tagifyText:function(a){if(typeof Builder=="undefined")throw"Effect.tagifyText requires including script.aculo.us' builder.js library";var b="position:relative";if(Prototype.Browser.IE)b+=";zoom:1";a=$(a);$A(a.childNodes).each(function(c){if(c.nodeType==3){c.nodeValue.toArray().each(function(d){a.insertBefore(Builder.node("span",{style:b},
|
@@ -179,8 +180,7 @@ a*1E3)/1E3+c.unit;this.element.setStyle(b,true)}});Effect.Transform=Class.create
|
|
179 |
Object.extend(Effect.Transform.prototype,{initialize:function(a,b){this.tracks=[];this.options=b||{};this.addTracks(a)},addTracks:function(a){a.each(function(b){var c=$H(b).values().first();this.tracks.push($H({ids:$H(b).keys().first(),effect:Effect.Morph,options:{style:c}}))}.bind(this));return this},play:function(){return new Effect.Parallel(this.tracks.map(function(a){return[$(a.ids)||$$(a.ids)].flatten().map(function(b){return new a.effect(b,Object.extend({sync:true},a.options))})}).flatten(),
|
180 |
this.options)}});Element.CSS_PROPERTIES=$w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex");
|
181 |
Element.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;String.prototype.parseStyle=function(){var a=document.createElement("div");a.innerHTML='<div style="'+this+'"></div>';var b=a.childNodes[0].style,c=$H();Element.CSS_PROPERTIES.each(function(d){if(b[d])c[d]=b[d]});if(Prototype.Browser.IE&&this.indexOf("opacity")>-1)c.opacity=this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];return c};Element.morph=function(a,b,c){new Effect.Morph(a,Object.extend({style:b},c||{}));return a};
|
182 |
-
["getInlineOpacity","forceRerendering","setContentZoom","collectTextNodes","collectTextNodesIgnoreClass","morph"].each(function(a){Element.Methods[a]=Element[a]});Element.Methods.visualEffect=function(a,b,c){s=b.dasherize().camelize();effect_class=s.charAt(0).toUpperCase()+s.substring(1);new Effect[effect_class](a,c);return $(a)};Element.addMethods();var
|
183 |
-
$A(document.getElementsByTagName("script")).findAll(function(b){return b.src&&b.src.match(/scriptaculous\.js(\?.*)?$/)}).each(function(b){var c=b.src.replace(/scriptaculous\.js(\?.*)?$/,"");b=b.src.match(/\?.*load=([a-z,]*)/);(b?b[1]:"builder,effects,dragdrop,controls,slider,sound").split(",").each(function(d){Scriptaculous.require(c+d+".js")})})}};Scriptaculous.load();var Lightbox={activeImage:null,badObjects:["select","object","embed"],container:null,enableSlideshow:null,groupName:null,imageArray:[],options:null,overlayDuration:null,overlayOpacity:null,playSlides:null,refTags:["a","area"],relAttribute:null,resizeDuration:null,slideShowTimer:null,startImage:null,initialize:function(a){if(document.getElementsByTagName){this.options=$H({animate:true,autoPlay:true,borderSize:10,containerID:document,enableSlideshow:true,googleAnalytics:false,imageDataLocation:"south",
|
184 |
initImage:"",loop:true,overlayDuration:0.2,overlayOpacity:0.8,prefix:"",relAttribute:"lightbox",resizeSpeed:7,showGroupName:false,slideTime:4,strings:{closeLink:"close",loadingMsg:"loading",nextLink:"next »",prevLink:"« prev",startSlideshow:"start slideshow",stopSlideshow:"stop slideshow",numDisplayPrefix:"Image",numDisplaySeparator:"of"}}).merge(a);if(this.options.animate){this.overlayDuration=Math.max(this.options.overlayDuration,0);this.options.resizeSpeed=Math.max(Math.min(this.options.resizeSpeed,
|
185 |
10),1);this.resizeDuration=(11-this.options.resizeSpeed)*0.15}else this.resizeDuration=this.overlayDuration=0;this.enableSlideshow=this.options.enableSlideshow;this.overlayOpacity=Math.max(Math.min(this.options.overlayOpacity,1),0);this.playSlides=this.options.autoPlay;this.container=$(this.options.containerID);this.relAttribute=this.options.relAttribute;this.updateImageList();var b=this.container!=document?this.container:document.getElementsByTagName("body").item(0);a=document.createElement("div");
|
186 |
a.setAttribute("id",this.getID("overlay"));a.style.display="none";b.appendChild(a);Event.observe(a,"click",this.end.bindAsEventListener(this));a=document.createElement("div");a.setAttribute("id",this.getID("lightbox"));a.style.display="none";b.appendChild(a);b=document.createElement("div");b.setAttribute("id",this.getID("imageDataContainer"));b.className=this.getID("clearfix");var c=document.createElement("div");c.setAttribute("id",this.getID("imageData"));b.appendChild(c);var d=document.createElement("div");
|
@@ -189,18 +189,19 @@ e.appendChild(d);Event.observe(d,"click",this.showPrev.bindAsEventListener(this)
|
|
189 |
e=document.createElement("div");e.setAttribute("id",this.getID("close"));c.appendChild(e);c=document.createElement("a");c.setAttribute("id",this.getID("closeLink"));c.setAttribute("href","javascript:void(0);");c.innerHTML=this.options.strings.closeLink;e.appendChild(c);Event.observe(c,"click",this.end.bindAsEventListener(this));this.options.imageDataLocation=="north"&&a.appendChild(b);e=document.createElement("div");e.setAttribute("id",this.getID("outerImageContainer"));a.appendChild(e);c=document.createElement("div");
|
190 |
c.setAttribute("id",this.getID("imageContainer"));e.appendChild(c);e=document.createElement("img");e.setAttribute("id",this.getID("lightboxImage"));c.appendChild(e);e=document.createElement("div");e.setAttribute("id",this.getID("hoverNav"));c.appendChild(e);d=document.createElement("a");d.setAttribute("id",this.getID("prevLinkImg"));d.setAttribute("href","javascript:void(0);");e.appendChild(d);Event.observe(d,"click",this.showPrev.bindAsEventListener(this));d=document.createElement("a");d.setAttribute("id",
|
191 |
this.getID("nextLinkImg"));d.setAttribute("href","javascript:void(0);");e.appendChild(d);Event.observe(d,"click",this.showNext.bindAsEventListener(this));e=document.createElement("div");e.setAttribute("id",this.getID("loading"));c.appendChild(e);c=document.createElement("a");c.setAttribute("id",this.getID("loadingLink"));c.setAttribute("href","javascript:void(0);");c.innerHTML=this.options.strings.loadingMsg;e.appendChild(c);Event.observe(c,"click",this.end.bindAsEventListener(this));this.options.imageDataLocation!=
|
192 |
-
"north"&&a.appendChild(b);this.options.initImage!=""&&this.start($(this.options.initImage))}},updateImageList:function(){for(var a,b,c,d=0;d<this.refTags.length;d++){b=this.container.getElementsByTagName(this.refTags[d]);for(var e=0;e<b.length;e++){a=b[e];c=String(a.getAttribute("rel"));if(a.getAttribute("href")&&c.toLowerCase().match(this.relAttribute))a.onclick=function(){Lightbox.start(this);return false}}}},
|
193 |
-
"px"});new Effect.Appear(this.getID("overlay"),{duration:this.overlayDuration,from:0,to:this.overlayOpacity});this.imageArray=[];this.groupName=null;var c=a.getAttribute("rel"),d="";if(c==this.relAttribute){d=
|
194 |
-
g.getAttribute("
|
195 |
-
|
196 |
-
c.width*100,e=(b+this.options.borderSize*2)/c.height*100,f=c.width-this.options.borderSize*2-a;c=c.height-this.options.borderSize*2-b;c!=0&&new Effect.Scale(this.getID("outerImageContainer"),e,{scaleX:false,duration:this.resizeDuration,queue:"front"});f!=0&&new Effect.Scale(this.getID("outerImageContainer"),d,{scaleY:false,
|
197 |
-
"px"});$(this.getID("nextLinkImg")).setStyle({height:b+"px"});$(this.getID("imageDataContainer")).setStyle({width:a+this.options.borderSize*2+"px"});this.showImage()},showImage:function(){$(this.getID("loading")).hide();new Effect.Appear(this.getID("lightboxImage"),{duration:0.5,queue:"end",afterFinish:function(){Lightbox.updateDetails()}});
|
198 |
-
if(this.imageArray.length>1){var a=this.options.strings.numDisplayPrefix+" "+eval(this.activeImage+1)+" "+this.options.strings.numDisplaySeparator+" "+this.imageArray.length;if(this.options.showGroupName&&this.groupName!="")a+=" "+this.options.strings.numDisplaySeparator+" "+this.groupName;$(this.getID("numberDisplay")).update(a).show();this.enableSlideshow
|
199 |
-
{sync:true}),new Effect.Appear(this.getID("imageDataContainer"),{sync:true})],{duration:0.65,afterFinish:function(){Lightbox.updateNav()}})},updateNav:function(){if(this.imageArray.length>1){$(this.getID("hoverNav")).show();if(this.enableSlideshow)this.playSlides?this.startSlideShow():this.stopSlideShow()}this.enableKeyboardNav()},startSlideShow:function(){this.playSlides=
|
200 |
-
stopSlideShow:function(){this.playSlides=false;this.slideShowTimer&&this.slideShowTimer.stop();$(this.getID("slideShowControl")).update(this.options.strings.startSlideshow)},toggleSlideShow:function(){this.playSlides?this.stopSlideShow():this.startSlideShow()},pauseSlideShow:function(){this.slideShowTimer&&this.slideShowTimer.stop()},
|
201 |
-
this.activeImage==this.imageArray.length-1?this.changeImage(0):this.changeImage(this.activeImage+1)}},showPrev:function(){if(this.imageArray.length>1)this.activeImage==0?this.changeImage(this.imageArray.length-1):this.changeImage(this.activeImage-1)},showFirst:function(){this.imageArray.length>1&&this.changeImage(0)},
|
202 |
-
""},keyboardAction:function(a){keycode=a==null?event.keyCode:a.which;key=String.fromCharCode(keycode).toLowerCase();if(key=="x"||key=="o"||key=="c")Lightbox.end();else if(key=="p"||key=="%")Lightbox.showPrev();else if(key=="n"||key=="'")Lightbox.showNext();else if(key=="f")Lightbox.showFirst();
|
203 |
-
1==this.activeImage?0:this.activeImage+1;nextImage=new Image;nextImage.src=this.imageArray[a].link;a=this.activeImage==0?this.imageArray.length-1:this.activeImage-1;prevImage=new Image;prevImage.src=this.imageArray[a].link},end:function(){this.disableKeyboardNav();this.pauseSlideShow();$(this.getID("lightbox")).hide();
|
204 |
-
for(var d=0;d<a.length;d++)$(a[d]).setStyle({visibility:"visible"})}},hideBadObjects:function(){for(var a,b=Lightbox.badObjects,c=0;c<b.length;c++){a=document.getElementsByTagName(b[c]);for(var d=0;d<a.length;d++)$(a[d]).setStyle({visibility:"hidden"})}},pause:function(a){var b=new Date;for(a=
|
205 |
-
document.documentElement.scrollLeft;b=document.documentElement.scrollTop}else if(document.body){a=document.body.scrollLeft;b=document.body.scrollTop}return{x:a,y:b}},getPageSize:function(){var a,b,c,d;if(window.innerHeight&&window.scrollMaxY){a=document.body.scrollWidth;b=window.innerHeight+
|
206 |
-
self.innerWidth;d=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){c=document.documentElement.clientWidth;d=document.documentElement.clientHeight}else if(document.body){c=document.body.clientWidth;d=document.body.clientHeight}return{pageWidth:a<
|
|
124 |
Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},c||{});a=$(a);var d=Position.page(a);b=$(b);var e=[0,0],f=null;if(Element.getStyle(b,"position")=="absolute"){f=Position.offsetParent(b);e=Position.page(f)}if(f==document.body){e[0]-=document.body.offsetLeft;e[1]-=document.body.offsetTop}if(c.setLeft)b.style.left=d[0]-e[0]+c.offsetLeft+"px";if(c.setTop)b.style.top=d[1]-e[1]+c.offsetTop+"px";if(c.setWidth)b.style.width=a.offsetWidth+"px";if(c.setHeight)b.style.height=
|
125 |
a.offsetHeight+"px"},absolutize:function(a){a=$(a);if(a.style.position!="absolute"){Position.prepare();var b=Position.positionedOffset(a),c=b[1];b=b[0];var d=a.clientWidth,e=a.clientHeight;a._originalLeft=b-parseFloat(a.style.left||0);a._originalTop=c-parseFloat(a.style.top||0);a._originalWidth=a.style.width;a._originalHeight=a.style.height;a.style.position="absolute";a.style.top=c+"px";a.style.left=b+"px";a.style.width=d+"px";a.style.height=e+"px"}},relativize:function(a){a=$(a);if(a.style.position!=
|
126 |
"relative"){Position.prepare();a.style.position="relative";var b=parseFloat(a.style.top||0)-(a._originalTop||0),c=parseFloat(a.style.left||0)-(a._originalLeft||0);a.style.top=b+"px";a.style.left=c+"px";a.style.height=a._originalHeight;a.style.width=a._originalWidth}}};
|
127 |
+
if(Prototype.Browser.WebKit)Position.cumulativeOffset=function(a){var b=0,c=0;do{b+=a.offsetTop||0;c+=a.offsetLeft||0;if(a.offsetParent==document.body)if(Element.getStyle(a,"position")=="absolute")break;a=a.offsetParent}while(a);return[c,b]};Element.addMethods();var Scriptaculous={Version:"1.7.1_beta3",require:function(a){document.write('<script type="text/javascript" src="'+a+'"><\/script>')},REQUIRED_PROTOTYPE:"1.5.1",load:function(){function a(b){b=b.split(".");return parseInt(b[0])*1E5+parseInt(b[1])*1E3+parseInt(b[2])}if(typeof Prototype=="undefined"||typeof Element=="undefined"||typeof Element.Methods=="undefined"||a(Prototype.Version)<a(Scriptaculous.REQUIRED_PROTOTYPE))throw"script.aculo.us requires the Prototype JavaScript framework >= "+Scriptaculous.REQUIRED_PROTOTYPE;
|
128 |
+
$A(document.getElementsByTagName("script")).findAll(function(b){return b.src&&b.src.match(/scriptaculous\.js(\?.*)?$/)}).each(function(b){var c=b.src.replace(/scriptaculous\.js(\?.*)?$/,"");b=b.src.match(/\?.*load=([a-z,]*)/);(b?b[1]:"builder,effects,dragdrop,controls,slider,sound").split(",").each(function(d){Scriptaculous.require(c+d+".js")})})}};Scriptaculous.load();String.prototype.parseColor=function(a){var b="#";if(this.slice(0,4)=="rgb("){var c=this.slice(4,this.length-1).split(","),d=0;do b+=parseInt(c[d]).toColorPart();while(++d<3)}else if(this.slice(0,1)=="#"){if(this.length==4)for(d=1;d<4;d++)b+=(this.charAt(d)+this.charAt(d)).toLowerCase();if(this.length==7)b=this.toLowerCase()}return b.length==7?b:a||this};
|
129 |
Element.collectTextNodes=function(a){return $A($(a).childNodes).collect(function(b){return b.nodeType==3?b.nodeValue:b.hasChildNodes()?Element.collectTextNodes(b):""}).flatten().join("")};Element.collectTextNodesIgnoreClass=function(a,b){return $A($(a).childNodes).collect(function(c){return c.nodeType==3?c.nodeValue:c.hasChildNodes()&&!Element.hasClassName(c,b)?Element.collectTextNodesIgnoreClass(c,b):""}).flatten().join("")};
|
130 |
Element.setContentZoom=function(a,b){a=$(a);a.setStyle({fontSize:b/100+"em"});Prototype.Browser.WebKit&&window.scrollBy(0,0);return a};Element.getInlineOpacity=function(a){return $(a).style.opacity||""};Element.forceRerendering=function(a){try{a=$(a);var b=document.createTextNode(" ");a.appendChild(b);a.removeChild(b)}catch(c){}};Array.prototype.call=function(){var a=arguments;this.each(function(b){b.apply(this,a)})};
|
131 |
var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},tagifyText:function(a){if(typeof Builder=="undefined")throw"Effect.tagifyText requires including script.aculo.us' builder.js library";var b="position:relative";if(Prototype.Browser.IE)b+=";zoom:1";a=$(a);$A(a.childNodes).each(function(c){if(c.nodeType==3){c.nodeValue.toArray().each(function(d){a.insertBefore(Builder.node("span",{style:b},
|
180 |
Object.extend(Effect.Transform.prototype,{initialize:function(a,b){this.tracks=[];this.options=b||{};this.addTracks(a)},addTracks:function(a){a.each(function(b){var c=$H(b).values().first();this.tracks.push($H({ids:$H(b).keys().first(),effect:Effect.Morph,options:{style:c}}))}.bind(this));return this},play:function(){return new Effect.Parallel(this.tracks.map(function(a){return[$(a.ids)||$$(a.ids)].flatten().map(function(b){return new a.effect(b,Object.extend({sync:true},a.options))})}).flatten(),
|
181 |
this.options)}});Element.CSS_PROPERTIES=$w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex");
|
182 |
Element.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;String.prototype.parseStyle=function(){var a=document.createElement("div");a.innerHTML='<div style="'+this+'"></div>';var b=a.childNodes[0].style,c=$H();Element.CSS_PROPERTIES.each(function(d){if(b[d])c[d]=b[d]});if(Prototype.Browser.IE&&this.indexOf("opacity")>-1)c.opacity=this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];return c};Element.morph=function(a,b,c){new Effect.Morph(a,Object.extend({style:b},c||{}));return a};
|
183 |
+
["getInlineOpacity","forceRerendering","setContentZoom","collectTextNodes","collectTextNodesIgnoreClass","morph"].each(function(a){Element.Methods[a]=Element[a]});Element.Methods.visualEffect=function(a,b,c){s=b.dasherize().camelize();effect_class=s.charAt(0).toUpperCase()+s.substring(1);new Effect[effect_class](a,c);return $(a)};Element.addMethods();var Lightbox={activeImage:null,badObjects:["select","object","embed"],container:null,enableSlideshow:null,groupName:null,imageArray:[],options:null,overlayDuration:null,overlayOpacity:null,playSlides:null,refTags:["a","area"],relAttribute:null,resizeDuration:null,slideShowTimer:null,startImage:null,initialize:function(a){if(document.getElementsByTagName){this.options=$H({animate:true,autoPlay:true,borderSize:10,containerID:document,enableSlideshow:true,googleAnalytics:false,imageDataLocation:"south",
|
|
|
184 |
initImage:"",loop:true,overlayDuration:0.2,overlayOpacity:0.8,prefix:"",relAttribute:"lightbox",resizeSpeed:7,showGroupName:false,slideTime:4,strings:{closeLink:"close",loadingMsg:"loading",nextLink:"next »",prevLink:"« prev",startSlideshow:"start slideshow",stopSlideshow:"stop slideshow",numDisplayPrefix:"Image",numDisplaySeparator:"of"}}).merge(a);if(this.options.animate){this.overlayDuration=Math.max(this.options.overlayDuration,0);this.options.resizeSpeed=Math.max(Math.min(this.options.resizeSpeed,
|
185 |
10),1);this.resizeDuration=(11-this.options.resizeSpeed)*0.15}else this.resizeDuration=this.overlayDuration=0;this.enableSlideshow=this.options.enableSlideshow;this.overlayOpacity=Math.max(Math.min(this.options.overlayOpacity,1),0);this.playSlides=this.options.autoPlay;this.container=$(this.options.containerID);this.relAttribute=this.options.relAttribute;this.updateImageList();var b=this.container!=document?this.container:document.getElementsByTagName("body").item(0);a=document.createElement("div");
|
186 |
a.setAttribute("id",this.getID("overlay"));a.style.display="none";b.appendChild(a);Event.observe(a,"click",this.end.bindAsEventListener(this));a=document.createElement("div");a.setAttribute("id",this.getID("lightbox"));a.style.display="none";b.appendChild(a);b=document.createElement("div");b.setAttribute("id",this.getID("imageDataContainer"));b.className=this.getID("clearfix");var c=document.createElement("div");c.setAttribute("id",this.getID("imageData"));b.appendChild(c);var d=document.createElement("div");
|
189 |
e=document.createElement("div");e.setAttribute("id",this.getID("close"));c.appendChild(e);c=document.createElement("a");c.setAttribute("id",this.getID("closeLink"));c.setAttribute("href","javascript:void(0);");c.innerHTML=this.options.strings.closeLink;e.appendChild(c);Event.observe(c,"click",this.end.bindAsEventListener(this));this.options.imageDataLocation=="north"&&a.appendChild(b);e=document.createElement("div");e.setAttribute("id",this.getID("outerImageContainer"));a.appendChild(e);c=document.createElement("div");
|
190 |
c.setAttribute("id",this.getID("imageContainer"));e.appendChild(c);e=document.createElement("img");e.setAttribute("id",this.getID("lightboxImage"));c.appendChild(e);e=document.createElement("div");e.setAttribute("id",this.getID("hoverNav"));c.appendChild(e);d=document.createElement("a");d.setAttribute("id",this.getID("prevLinkImg"));d.setAttribute("href","javascript:void(0);");e.appendChild(d);Event.observe(d,"click",this.showPrev.bindAsEventListener(this));d=document.createElement("a");d.setAttribute("id",
|
191 |
this.getID("nextLinkImg"));d.setAttribute("href","javascript:void(0);");e.appendChild(d);Event.observe(d,"click",this.showNext.bindAsEventListener(this));e=document.createElement("div");e.setAttribute("id",this.getID("loading"));c.appendChild(e);c=document.createElement("a");c.setAttribute("id",this.getID("loadingLink"));c.setAttribute("href","javascript:void(0);");c.innerHTML=this.options.strings.loadingMsg;e.appendChild(c);Event.observe(c,"click",this.end.bindAsEventListener(this));this.options.imageDataLocation!=
|
192 |
+
"north"&&a.appendChild(b);this.options.initImage!=""&&this.start($(this.options.initImage))}},updateImageList:function(){for(var a,b,c,d=0;d<this.refTags.length;d++){b=this.container.getElementsByTagName(this.refTags[d]);for(var e=0;e<b.length;e++){a=b[e];c=String(a.getAttribute("rel"));if(a.getAttribute("href")&&c.toLowerCase().match(this.relAttribute))a.onclick=function(){Lightbox.start(this);return false}}}},getCaption:function(a){var b=a.title||"";if(b==""){var c=$(a).getElementsBySelector("img").first();
|
193 |
+
if(c)b=c.getAttribute("alt")||c.getAttribute("title");b||(b=a.innerHTML.stripTags()||a.href||"")}return b},start:function(a){this.hideBadObjects();var b=this.getPageSize();$(this.getID("overlay")).setStyle({height:b.pageHeight+"px"});new Effect.Appear(this.getID("overlay"),{duration:this.overlayDuration,from:0,to:this.overlayOpacity});this.imageArray=[];this.groupName=null;var c=a.getAttribute("rel"),d="";if(c==this.relAttribute){d=this.getCaption(a);this.imageArray.push({link:a.getAttribute("href"),
|
194 |
+
title:d});this.startImage=0}else{for(var e=this.container.getElementsByTagName(a.tagName),f=0;f<e.length;f++){var g=e[f];if(g.getAttribute("href")&&g.getAttribute("rel")==c){d=this.getCaption(g);this.imageArray.push({link:g.getAttribute("href"),title:d});if(g==a)this.startImage=this.imageArray.length-1}}this.groupName=c.substring(this.relAttribute.length+1,c.length-1)}a=this.getPageScroll().y+b.winHeight/15;$(this.getID("lightbox")).setStyle({top:a+"px"}).show();this.changeImage(this.startImage)},
|
195 |
+
changeImage:function(a){this.activeImage=a;this.disableKeyboardNav();this.pauseSlideShow();$(this.getID("loading")).show();$(this.getID("lightboxImage")).hide();$(this.getID("hoverNav")).hide();$(this.getID("imageDataContainer")).hide();$(this.getID("numberDisplay")).hide();$(this.getID("detailsNav")).hide();var b=new Image;b.onload=function(){$(Lightbox.getID("lightboxImage")).src=b.src;Lightbox.resizeImageContainer(b.width,b.height)};b.src=this.imageArray[this.activeImage].link;this.options.googleAnalytics&&
|
196 |
+
urchinTracker(this.imageArray[this.activeImage].link)},resizeImageContainer:function(a,b){var c=$(this.getID("outerImageContainer")).getDimensions(),d=(a+this.options.borderSize*2)/c.width*100,e=(b+this.options.borderSize*2)/c.height*100,f=c.width-this.options.borderSize*2-a;c=c.height-this.options.borderSize*2-b;c!=0&&new Effect.Scale(this.getID("outerImageContainer"),e,{scaleX:false,duration:this.resizeDuration,queue:"front"});f!=0&&new Effect.Scale(this.getID("outerImageContainer"),d,{scaleY:false,
|
197 |
+
delay:this.resizeDuration,duration:this.resizeDuration});if(c==0&&f==0)navigator.appVersion.indexOf("MSIE")!=-1?this.pause(250):this.pause(100);$(this.getID("prevLinkImg")).setStyle({height:b+"px"});$(this.getID("nextLinkImg")).setStyle({height:b+"px"});$(this.getID("imageDataContainer")).setStyle({width:a+this.options.borderSize*2+"px"});this.showImage()},showImage:function(){$(this.getID("loading")).hide();new Effect.Appear(this.getID("lightboxImage"),{duration:0.5,queue:"end",afterFinish:function(){Lightbox.updateDetails()}});
|
198 |
+
this.preloadNeighborImages()},updateDetails:function(){$(this.getID("caption")).show();$(this.getID("caption")).update(this.imageArray[this.activeImage].title);if(this.imageArray.length>1){var a=this.options.strings.numDisplayPrefix+" "+eval(this.activeImage+1)+" "+this.options.strings.numDisplaySeparator+" "+this.imageArray.length;if(this.options.showGroupName&&this.groupName!="")a+=" "+this.options.strings.numDisplaySeparator+" "+this.groupName;$(this.getID("numberDisplay")).update(a).show();this.enableSlideshow||
|
199 |
+
$(this.getID("slideShowControl")).hide();$(this.getID("detailsNav")).show()}new Effect.Parallel([new Effect.SlideDown(this.getID("imageDataContainer"),{sync:true}),new Effect.Appear(this.getID("imageDataContainer"),{sync:true})],{duration:0.65,afterFinish:function(){Lightbox.updateNav()}})},updateNav:function(){if(this.imageArray.length>1){$(this.getID("hoverNav")).show();if(this.enableSlideshow)this.playSlides?this.startSlideShow():this.stopSlideShow()}this.enableKeyboardNav()},startSlideShow:function(){this.playSlides=
|
200 |
+
true;this.slideShowTimer=new PeriodicalExecuter(function(a){Lightbox.showNext();a.stop()},this.options.slideTime);$(this.getID("slideShowControl")).update(this.options.strings.stopSlideshow)},stopSlideShow:function(){this.playSlides=false;this.slideShowTimer&&this.slideShowTimer.stop();$(this.getID("slideShowControl")).update(this.options.strings.startSlideshow)},toggleSlideShow:function(){this.playSlides?this.stopSlideShow():this.startSlideShow()},pauseSlideShow:function(){this.slideShowTimer&&this.slideShowTimer.stop()},
|
201 |
+
showNext:function(){if(this.imageArray.length>1){if(!this.options.loop&&(this.activeImage==this.imageArray.length-1&&this.startImage==0||this.activeImage+1==this.startImage))return this.end();this.activeImage==this.imageArray.length-1?this.changeImage(0):this.changeImage(this.activeImage+1)}},showPrev:function(){if(this.imageArray.length>1)this.activeImage==0?this.changeImage(this.imageArray.length-1):this.changeImage(this.activeImage-1)},showFirst:function(){this.imageArray.length>1&&this.changeImage(0)},
|
202 |
+
showLast:function(){this.imageArray.length>1&&this.changeImage(this.imageArray.length-1)},enableKeyboardNav:function(){document.onkeydown=this.keyboardAction},disableKeyboardNav:function(){document.onkeydown=""},keyboardAction:function(a){keycode=a==null?event.keyCode:a.which;key=String.fromCharCode(keycode).toLowerCase();if(key=="x"||key=="o"||key=="c")Lightbox.end();else if(key=="p"||key=="%")Lightbox.showPrev();else if(key=="n"||key=="'")Lightbox.showNext();else if(key=="f")Lightbox.showFirst();
|
203 |
+
else if(key=="l")Lightbox.showLast();else key=="s"&&Lightbox.imageArray.length>0&&Lightbox.options.enableSlideshow&&Lightbox.toggleSlideShow()},preloadNeighborImages:function(){var a=this.imageArray.length-1==this.activeImage?0:this.activeImage+1;nextImage=new Image;nextImage.src=this.imageArray[a].link;a=this.activeImage==0?this.imageArray.length-1:this.activeImage-1;prevImage=new Image;prevImage.src=this.imageArray[a].link},end:function(){this.disableKeyboardNav();this.pauseSlideShow();$(this.getID("lightbox")).hide();
|
204 |
+
new Effect.Fade(this.getID("overlay"),{duration:this.overlayDuration});this.showBadObjects()},showBadObjects:function(){for(var a,b=Lightbox.badObjects,c=0;c<b.length;c++){a=document.getElementsByTagName(b[c]);for(var d=0;d<a.length;d++)$(a[d]).setStyle({visibility:"visible"})}},hideBadObjects:function(){for(var a,b=Lightbox.badObjects,c=0;c<b.length;c++){a=document.getElementsByTagName(b[c]);for(var d=0;d<a.length;d++)$(a[d]).setStyle({visibility:"hidden"})}},pause:function(a){var b=new Date;for(a=
|
205 |
+
b.getTime()+a;;){b=new Date;if(b.getTime()>a)return}},getPageScroll:function(){var a,b;if(self.pageYOffset){a=self.pageXOffset;b=self.pageYOffset}else if(document.documentElement&&document.documentElement.scrollTop){a=document.documentElement.scrollLeft;b=document.documentElement.scrollTop}else if(document.body){a=document.body.scrollLeft;b=document.body.scrollTop}return{x:a,y:b}},getPageSize:function(){var a,b,c,d;if(window.innerHeight&&window.scrollMaxY){a=document.body.scrollWidth;b=window.innerHeight+
|
206 |
+
window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){a=document.body.scrollWidth;b=document.body.scrollHeight}else{a=document.body.offsetWidth;b=document.body.offsetHeight}if(self.innerHeight){c=self.innerWidth;d=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){c=document.documentElement.clientWidth;d=document.documentElement.clientHeight}else if(document.body){c=document.body.clientWidth;d=document.body.clientHeight}return{pageWidth:a<
|
207 |
+
c?c:a,pageHeight:b<d?d:b,winWidth:c,winHeight:d}},getID:function(a){return this.options.prefix+a}};
|
main.php
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Simple Lightbox
|
4 |
-
Plugin URI:
|
5 |
Description: Customizable Lightbox for Wordpress
|
6 |
-
Version: 1.
|
7 |
Author: Archetyped
|
8 |
Author URI: http://archetyped.com
|
9 |
*/
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Simple Lightbox
|
4 |
+
Plugin URI: http://archetyped.com/tools/simple-lightbox/
|
5 |
Description: Customizable Lightbox for Wordpress
|
6 |
+
Version: 1.2
|
7 |
Author: Archetyped
|
8 |
Author URI: http://archetyped.com
|
9 |
*/
|
model.php
CHANGED
@@ -35,6 +35,7 @@ class SLB_Lightbox extends SLB_Base {
|
|
35 |
'enabled_single' => array(true, 'Enable on Single Posts/Pages'),
|
36 |
'enabled_archive' => array(true, 'Enable on Archive Pages (tags, categories, etc.)'),
|
37 |
'activate_links' => array(true, 'Automatically setup for all links to images on page'),
|
|
|
38 |
'autostart' => array(true, 'Automatically Start Slideshow'),
|
39 |
'duration' => array(6, 'Slide Duration (Seconds)', array('size' => 3, 'maxlength' => 3)),
|
40 |
'loop' => array(true, 'Loop through images'),
|
@@ -202,17 +203,20 @@ class SLB_Lightbox extends SLB_Base {
|
|
202 |
$js_code = array();
|
203 |
//Activate links on page
|
204 |
if ( $this->get_option_value('activate_links') ) {
|
|
|
205 |
ob_start();
|
206 |
?>
|
207 |
-
$$('a[href$=".jpg"]:not([rel~="lightbox"])','a[href$=".jpeg"]:not([rel~="lightbox"])','a[href$=".gif"]:not([rel~="lightbox"])','a[href$=".png"]:not([rel~="lightbox"])').each(function(el){var rel=(el.rel.length > 0) ? el.rel + ' ' : '';el.rel=rel + '
|
208 |
<?php
|
209 |
$js_code[] = ob_get_clean();
|
210 |
}
|
211 |
//Get options
|
212 |
-
$options
|
213 |
-
|
214 |
-
|
215 |
-
|
|
|
|
|
216 |
$lb_obj = array();
|
217 |
foreach ($options as $option => $val) {
|
218 |
if ($val === TRUE || $val == 'on')
|
35 |
'enabled_single' => array(true, 'Enable on Single Posts/Pages'),
|
36 |
'enabled_archive' => array(true, 'Enable on Archive Pages (tags, categories, etc.)'),
|
37 |
'activate_links' => array(true, 'Automatically setup for all links to images on page'),
|
38 |
+
'group_links' => array(true, 'Group automatically activated links (for displaying as a slideshow)'),
|
39 |
'autostart' => array(true, 'Automatically Start Slideshow'),
|
40 |
'duration' => array(6, 'Slide Duration (Seconds)', array('size' => 3, 'maxlength' => 3)),
|
41 |
'loop' => array(true, 'Loop through images'),
|
203 |
$js_code = array();
|
204 |
//Activate links on page
|
205 |
if ( $this->get_option_value('activate_links') ) {
|
206 |
+
$rel = ( $this->get_option_value('group_links') ) ? 'lightbox[' . $this->get_prefix() . ']' : 'lightbox';
|
207 |
ob_start();
|
208 |
?>
|
209 |
+
$$('a[href$=".jpg"]:not([rel~="lightbox"])','a[href$=".jpeg"]:not([rel~="lightbox"])','a[href$=".gif"]:not([rel~="lightbox"])','a[href$=".png"]:not([rel~="lightbox"])').each(function(el){if (! /(^|\b)lightbox\[.+\]($|\b)/i.test(el.rel)){var rel=(el.rel.length > 0) ? el.rel + ' ' : '';el.rel=rel + '<?php echo $rel; ?>';}});
|
210 |
<?php
|
211 |
$js_code[] = ob_get_clean();
|
212 |
}
|
213 |
//Get options
|
214 |
+
$options = array(
|
215 |
+
'autoPlay' => $this->get_option_value('autostart'),
|
216 |
+
'slideTime' => $this->get_option_value('duration'),
|
217 |
+
'loop' => $this->get_option_value('loop'),
|
218 |
+
'overlayOpacity' => $this->get_option_value('overlay_opacity')
|
219 |
+
);
|
220 |
$lb_obj = array();
|
221 |
foreach ($options as $option => $val) {
|
222 |
if ($val === TRUE || $val == 'on')
|
readme.txt
CHANGED
@@ -17,6 +17,7 @@ Options for customizing the lightbox behavior are located in the **Settings > Me
|
|
17 |
* Enable/Disable Lightbox Functionality (Default: Enabled)
|
18 |
* Enable Lightbox depending on Page Type (Home, Pages, Archive, etc.)
|
19 |
* Automatically activate lightbox for links to images on page (no need to add `rel="lightbox"` attribute to link)
|
|
|
20 |
* Automatically Start Slideshow (Default: Enabled)
|
21 |
* Slide Duration (Seconds) (Default: 6)
|
22 |
* Loop through images (Default: Enabled)
|
@@ -46,6 +47,10 @@ Send your questions to wp@archetyped.com
|
|
46 |
1. Lightbox Options
|
47 |
|
48 |
== Changelog ==
|
|
|
|
|
|
|
|
|
49 |
= 1.1 =
|
50 |
* Added: Enable/disable lightbox functionality by page type (Home, Pages/Posts, Archive, etc.)
|
51 |
* Added: Automatically activate lightbox functionality for image links
|
17 |
* Enable/Disable Lightbox Functionality (Default: Enabled)
|
18 |
* Enable Lightbox depending on Page Type (Home, Pages, Archive, etc.)
|
19 |
* Automatically activate lightbox for links to images on page (no need to add `rel="lightbox"` attribute to link)
|
20 |
+
* Group automatically-activated links (play as a slideshow)
|
21 |
* Automatically Start Slideshow (Default: Enabled)
|
22 |
* Slide Duration (Seconds) (Default: 6)
|
23 |
* Loop through images (Default: Enabled)
|
47 |
1. Lightbox Options
|
48 |
|
49 |
== Changelog ==
|
50 |
+
= 1.2 =
|
51 |
+
* Added: Option to group automatically activated links
|
52 |
+
* Optimized: Lightbox caption retrieval
|
53 |
+
|
54 |
= 1.1 =
|
55 |
* Added: Enable/disable lightbox functionality by page type (Home, Pages/Posts, Archive, etc.)
|
56 |
* Added: Automatically activate lightbox functionality for image links
|
screenshot-1.gif
CHANGED
Binary file
|