Commit 10f3b77a authored by IngridHaas's avatar IngridHaas
Browse files

maintain africa tour

parent 2fd14351
......@@ -292,13 +292,32 @@
"heading": 39,
"icon": 2.0
} ,
{
"monolith": "laatste vitrine",
"url": "images/leuven_tour/plinthite.jpg",
"notes": "pic",
"pitch":-6,
"pano": "a61Npy-PHokAAAQvOiPUPg",
"heading":42,
"icon": 1.0
} ,
{
"monolith": "laatste vitrine",
"url": "images/leuven_tour/bauxiet-ra.jpg",
"notes": "pic",
"pitch":-6,
"pano": "a61Npy-PHokAAAQvOiPUPg",
"heading":50,
"icon": 1.0
} ,
{
"monolith": "vitrine",
"url": "images/leuven_tour/",
"monolith": "laatste vitrine",
"url": "images/leuven_tour/bauxiet-rv.jpg",
"notes": "pic",
"pitch":17,
"pitch":-8,
"pano": "a61Npy-PHokAAAQvOiPUPg",
"heading":85,
"heading":50,
"icon": 1.0
} ,
{
......
EASYBOX v1.4 README
====================
Lightweight easy to use lightbox clone for jQuery
Based on Slimbox2 by Christophe Beyls <http://www.digitalia.be>
Copyright (C) 2011 by Vincent Wochnik
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Project homepage:
http://code.google.com/p/easybox/
Easybox requires the jQuery library (version 1.7 or more recent) to be installed on your website in order to work properly.
You can remove or customize the provided autoload code block by editing the easybox.min.js file.
When deploying easybox.js, you MUST always preserve the copyright notice at the beginning of the file.
For more information, please read the documentation on the official project page.
TODO LIST
----------
* Edit handlers.js, make .abort functionality
* Use new Image() .complete
* DONE Move loadingIndicator show() after loaded()
* DONE Optimize $.easybox
* DONE Make easybox "use strict";
* DONE Create a HTML5 compatible autoloader
* DONE Fix long captions
* DONE Fix noNavigation issue
* DONE Added resource handlers
<!DOCTYPE html>
<html>
<head>
<title>EasyBox example page</title>
<script type="text/javascript" src="easybox/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="easybox/jquery.mousewheel.min.js"></script>
<script type="text/javascript" src="easybox/distrib.min.js"></script>
<link rel="stylesheet" href="easybox/styles/dark/easybox.min.css" type="text/css" media="screen" />
<style type="text/css">
body { background-color: #101012; font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #fff; }
hr { visibility: hidden; clear: both; }
a { font-weight: bold; color: #e0e0ff; text-decoration: none; }
#wrapper { margin: 0 auto; padding: 16px; max-width: 520px; }
ul#gallery { padding: 0; margin: 0; list-style: none; }
ul#gallery li { display: block; float: left; margin: 0 4px 4px 0; }
ul#gallery li img { display: block; padding: 0; margin: 0; }
</style>
<script type="application/json" id="easyOptions">
{"gallery1":{"slideshow": 5000, "autoClose": 5000},"lightbox-vimeo1": {"loopVideos": true},"lightbox-gallery2": {"slideshow": 5000, "autoClose": 5000},"lightbox-vimeo2": {"loopVideos": true},"lightbox-slide": {"slideshow": 10000}}
</script>
</head>
<body>
<div id="wrapper">
<h1>Easybox example page</h1>
<p>EasyBox is a lightbox clone based on the light-weight Slimbox2 script. It offers a variety of additional features such as:</p>
<p><ul><li>displaying YouTube and Vimeo videos,</li>
<li>displaying inline content,</li>
<li>displaying iFrames and</li>
<li>better animations</li>
<li>Theme support</li></ul></p>
<h2>Examples</h2>
<h3>Images</h3>
<p><ul id="gallery">
<li><a href="img/example1.jpg" title="Image 1" class="lightbox" data-group="gallery1"><img src="img/example1thmb.jpg" /></a></li>
<li><a href="img/example2.gif" title="Image 2" class="lightbox" data-group="gallery1"><img src="img/example2thmb.jpg" /></a></li>
<li><a href="img/example3.png" title="Image 3" class="lightbox" data-group="gallery1"><img src="img/example3thmb.jpg" /></a></li>
<li><a href="img/example4.jpg" title="Image 4" class="lightbox" data-group="gallery1"><img src="img/example4thmb.jpg" /></a></li>
</ul></p>
<hr />
<h3>Various elements</h3>
<p><a href="http://www.youtube.com/watch?v=XJFmh6W1Jjo" class="lightbox" title="Example YouTube video">Click here</a> to view a YouTube video inside EasyBox.</p>
<p><a href="http://vimeo.com/27359051" class="lightbox" title="Example Vimeo video">Click here</a> to view a Vimeo video inside EasyBox.</p>
<p><a href="http://www.example.com" class="lightbox" title="Example iFrame">Click here</a> to view an iFrame inside EasyBox.</p>
</div>
</body>
</html>
/*
Easybox v1.4 - Lightweight easy to use lightbox clone for jQuery
Based on Slimbox2 by Christophe Beyls <http://www.digitalia.be>
*/
/android|iphone|ipod|series60|symbian|windows ce|blackberry|msie 6/i.test(navigator.userAgent)||jQuery(function(a){a("a.lightbox").easybox({/* custom options here */},null,function(a){return this==a||-1!=this.className.indexOf("lightbox")&&this.hasAttribute("data-group")&&this.getAttribute("data-group")==a.getAttribute("data-group")},function(b){var c={};if(a("#easyOptions").length){var f=a.parseJSON(a("#easyOptions").html()),d=b.getAttribute("data-group");a.each(f,function(e,b){if("global"==e||"string"==typeof d&&e==d)c=
a.extend(c,b)})}return c})});
/*
Easybox v1.4 - Lightweight easy to use lightbox clone for jQuery
Based on Slimbox2 by Christophe Beyls <http://www.digitalia.be>
*/
(function(x,Q,b){function B(a){if(q||0>a||a>=d.length)return!1;C();i=a;k=(i||(c.loop?d.length:0))-1;f=(i+1)%d.length||(c.loop?0:-1);c.preloadNext&&(0<=k&&D(d[k]),0<=f&&D(d[f]));d[i].loaded||b(y).show();D(d[i]);return!1}function Z(){var a=d[i];b(y).hide();a.error?b(e).addClass("error").width(c.errorSize[0]).height(c.errorSize[1]):(!c.hideCaption&&a.caption.length&&b(l).html(a.caption).css({display:""}),b(e).width(a.width).height(a.height));!c.hideCaption&&1<d.length&&c.counterText.length&&b(m).html(c.counterText.replace(/{x}/,
i+1).replace(/{y}/,d.length)).css({display:""});q=!0;b(e).css({visibility:"hidden",display:""});R([e.offsetWidth,e.offsetHeight],-1,c.resizeDuration);b(g).queue(function(j){b(e).css({visibility:"",display:"none"});a.error||(b(a.obj).appendTo(e),a.handler.show(a),E=!0);S();b(e).fadeIn(c.fadeDuration,$);q=!1;j()})}function R(a,j,aa){h=a.slice();var d={};if(g.offsetHeight!=a[1]||g.offsetWidth!=a[0])d={height:a[1],marginTop:-a[1]/2,width:a[0],marginLeft:-a[0]/2};if(-1<j)d.opacity=j;b(g).animate(d,aa,
c.resizeEasing)}function $(){if(!c.hideBottom){if(!c.hideButtons){if((0<=k||0<=f)&&!c.noNavigation)b(F).css({display:""}),b([l,m]).addClass("nav"),0>k&&b(G).addClass("disabled"),0>f&&b(H).addClass("disabled");0<c.slideshow&&!c.noToggleSlideshow&&b(r).css({display:""});c.noClose||b(I).css({display:""})}b(s).fadeIn(c.captionFadeDuration);b(g).animate({height:h[1]+s.offsetHeight},c.captionFadeDuration,c.resizeEasing)}}function C(){T();if(0<=i){var a=d[i];!a.error&&E&&a.handler.hide(a)}b([e,l,m]).html("");
b([s,e]).stop(!0,!0);b([y,s,e,F,l,m,r,I]).hide();b(g).stop(!0).css({width:h[0],height:h[1],marginLeft:-h[0]/2,marginTop:-h[1]/2,opacity:""});b([e,l,m,G,H]).removeClass();E=q=!1}function J(){if(!n)return!1;C();i=k=f=-1;K();U(0);for(var a=0;a<d.length;++a){var j=d[a];!j.loaded&&j.loading&&j.handler.abort(j)}b(L).stop().fadeOut(c.fadeDuration);R([h[0]/2,h[1]/2],0,c.fadeDuration);b(g).queue(function(a){b(g).css({left:"",top:""}).hide();b(r).removeClass("disabled");n=t=o=!1;a()});return!1}function u(){t=
!0;return B(k)}function v(){t=!1;return B(f)}function M(){return q||c.noClose?!1:J()}function V(){if(c.noToggleSlideshow)return!1;o=!o;t=!1;b(r).toggleClass("disabled",o);o?T():S();return!1}function S(){if(!o){if(c.slideshow&&null==p)if(t){if(0<=k)return p=setTimeout(u,c.slideshow),!1}else if(0<=f)return p=setTimeout(v,c.slideshow),!1;c.autoClose&&null==w&&(w=setTimeout(J,c.autoClose))}return!1}function T(){null!=p&&(clearTimeout(p),p=null);null!=w&&(clearTimeout(w),w=null)}function D(a){a.loaded&&
N(a);if(!a.loading){a.loading=!0;for(var b=z.length-1;0<=b;--b)if(z[b].identify(a)){a.handler=z[b];a.handler.preLoad(a,function(){N(a)});return}a.error=!0;N(a)}}function N(a){if(!a.loaded&&(a.loaded=!0,!a.error)){if(!a.width||!a.height)a.width=c.defaultContentSize[0],a.height=c.defaultContentSize[1];if(a.height>c.maximumContentSize[1])a.width=Math.round(c.maximumContentSize[1]*a.width/a.height),a.height=c.maximumContentSize[1];if(a.width>c.maximumContentSize[0])a.height=Math.round(c.maximumContentSize[0]/
a.width*a.height),a.width=c.maximumContentSize[0];a.handler.postLoad(a)}d[i]==a&&Z()}function ba(a){z.push(b.extend({identify:function(){return!1},preLoad:function(a,b){b()},postLoad:function(){},abort:function(){},show:function(){},hide:function(){}},a))}function U(a){a?b("object:visible").add("embed").each(function(a,b){O[a]=[b,b.style.visibility];b.style.visibility="hidden"}):(b.each(O,function(a,b){b[0].style.visibility=b[1]}),O=[]);a=a?"bind":"unbind";b(Q)[a]("keydown",ca);if(b.fn.mousewheel)b(x)[a]("mousewheel",
da);b(g)[a]("mousedown",ea)[a]("mousemove",W)[a]("mouseup",K);b(x)[a]("mousemove",W)[a]("mouseup",K)}function ca(a){var a=a.keyCode,j=b.inArray;return 0<=j(a,c.closeKeys)?M():0<=j(a,c.nextKeys)&&!c.noNavigation?v():0<=j(a,c.previousKeys)&&!c.noNavigation?u():0<=j(a,c.toggleSlideshowKeys)&&0<c.slideshow?V():!c.preventOtherKeys}function da(a,b){return 0<b&&!c.noNavigation?u():0>b&&!c.noNavigation?v():!1}function ea(a){return c.dragDrop?(A=!0,b(g).css({cursor:"pointer"}),X=a.pageX-b(this).position().left,
Y=a.pageY-b(this).position().top,!1):!0}function W(a){if(c.dragDrop&&A){var d=a.pageX-b(x).scrollLeft()-X,a=a.pageY-b(x).scrollTop()-Y;b(g).css({left:d+"px",top:a+"px"});return!1}return!0}function K(){A&&(A=!1,b(g).css({cursor:""}));return!0}var P={loop:!1,preloadNext:!0,dragDrop:!0,hideBottom:!1,hideCaption:!1,hideButtons:!1,noNavigation:!1,noClose:!1,noToggleSlideshow:!1,overlayOpacity:0.8,resizeDuration:400,resizeEasing:"easybox",fadeDuration:400,initCenterSize:[250,250],errorSize:[320,180],defaultContentSize:[960,
720],maximumContentSize:[1280,720],captionFadeDuration:200,slideshow:0,autoClose:0,counterText:"{x} of {y}",closeKeys:[27],previousKeys:[37],nextKeys:[39],toggleSlideshowKeys:[32],preventOtherKeys:!0},z=[],c,d,i=-1,k=-1,f=-1,h,O=[],t=!1,o=!1,A=!1,X=0,Y=0,n=!1,q,E,p=null,w=null,L,g,e,F,G,H,r,I,s,l,m,y;b(function(){b(Q.body).append(b([L=b('<div id="easyOverlay" />').click(M)[0],g=b('<div id="easyCenter" />').append([e=b('<div id="easyContainer" />')[0],y=b('<div id="easyLoadingIndicator" />')[0],s=
b('<div id="easyBottom" />').append([F=b('<div id="easyNavigation" />').append([G=b('<a id="easyPrevLink" href="#" />').click(u)[0],H=b('<a id="easyNextLink" href="#" />').click(v)[0]])[0],I=b('<a id="easyCloseLink" href="#" />').click(M)[0],r=b('<a id="easySlideLink" href="#" />').click(V)[0],l=b('<div id="easyCaption" />')[0],m=b('<div id="easyNumber" />')[0]])[0]])[0]]).css("display","none"))});b.fn.easybox=function(a,c,d,g){var c=c||function(a){var b={url:a.href,caption:a.title};if(a.hasAttribute("data-width"))b.width=
a.getAttribute("data-width");if(a.hasAttribute("data-height"))b.height=a.getAttribute("data-height");return b},d=d||function(a){return this==a},g=g||function(){return{}},e=this;return e.unbind("click").click(function(){var i=this,k=0,f,h=0,l;f=b.grep(e,function(a,b){return d.call(i,a,b)});for(l=f.length;h<l;++h)f[h]==i&&(k=h),f[h]=c(f[h],h);return b.easybox(f,k,b.extend({},a,g(i)))})};var fa=b.easybox=function(a,f,e){if(n)return!1;c=b.extend({},P,e);d=[];for(e=0;e<a.length;e++)d.push(b.extend({caption:"",
width:0,height:0},a[e],{handler:null,loaded:!1,loading:!1,error:!1,obj:null}));if(d.length)return n=!0,1>=d.length&&b.extend(c,{loop:!1,slideshow:0}),h=c.initCenterSize.slice(),C(),U(1),b(g).show(),b(L).css({opacity:c.overlayOpacity}).fadeIn(c.fadeDuration,function(){B(Math.min(d.length-1,f||0))}),!1};b.extend(fa,{previous:function(){return 0<=k?!u():!1},next:function(){return 0<=f?!v():!1},hasPrevious:function(){return 0<=k},hasNext:function(){return 0<=f},close:function(){return n?!J():!1},isOpen:function(){return n},
defaults:function(a){P=b.extend(P,a)},resourceHandler:function(a){ba(a)}});b.easing.easybox=function(a){return 0.7>a?1.2*Math.pow(a/0.7,2):1.2-0.2*Math.sqrt((a-0.7)/(1-0.7))}})(window,document,jQuery);
/*
Easybox v1.4 - Lightweight easy to use lightbox clone for jQuery
Based on Slimbox2 by Christophe Beyls <http://www.digitalia.be>
*/
(function(f,g,b){b(function(){b.easybox&&(b.easybox.resourceHandler({identify:function(a){return a.url?!0:!1},postLoad:function(a){a.obj=b('<iframe width="'+a.width+'" height="'+a.height+'" src="'+a.url+'" frameborder="0"></iframe>')[0]}}),b.easybox.resourceHandler({identify:function(a){return a.html?!0:!1},postLoad:function(a){a.obj=b('<div style="width:'+a.width+"px;height:"+a.height+'px">'+a.html+"</div>")[0]}}),b.easybox.resourceHandler({identify:function(a){if(!a.url)return!1;var c=/^(.*)\#([A-Za-z0-9\-_]*)$/i.exec(a.url);
return null!=c&&b("#"+c[2]).length?(a.id=c[2],!0):!1},preLoad:function(a,c){var d=b("#"+a.id)[0];d?(a.width=a.width||b(d).width(),a.height=a.height||b(d).height(),a.obj=d):a.error=!0;c()},postLoad:function(a){a.parent=b(a.obj).parent()[0];a.display=b(a.obj).css("display")},show:function(a){b(a.obj).css("display","block")},hide:function(a){b(a.parent).append(b(a.obj).css("display",a.display))}}),b.easybox.resourceHandler({identify:function(a){return!a.url?!1:/(\.jpg|\.jpeg|\.png|\.gif)$/i.test(a.url)},
preLoad:function(a,b){var d=new Image;d.onload=function(){a.width=a.width||this.width;a.height=a.height||this.height;b()};d.onerror=function(){a.error=!0;b()};d.src=a.url},postLoad:function(a){a.obj=b('<img src="'+a.url+'" style="display:block;width:'+a.width+"px;height:"+a.height+'px" alt="'+a.caption+'" />')[0]}}),b.easybox.resourceHandler({identify:function(a){return!a.url?!1:/(\.mpg|\.mpeg|\.mp4|\.ogv|\.webm|\.flv)$/i.test(a.url)},postLoad:function(a){a.obj=b('<div style="overflow:hidden;width:'+
a.width+"px;height:"+a.height+'px" />')[0]},show:function(a){var c=!!b.fn.flowplayer;b(a.obj).append(b('<video src="'+a.url+'" width="'+a.width+'" height="'+a.height+'"'+(!c?' controls="controls"':"")+" />"));c&&b(a.obj).flowplayer()}}),b.easybox.resourceHandler({identify:function(a){if(!a.url)return!1;var b=/^http\:\/\/www\.youtube\.com\/watch\?v=([A-Za-z0-9\-_]*)(&(.*))?$/i.exec(a.url);return null!=b?(a.id=b[1],!0):!1},preLoad:function(a,c){b.ajax("http://gdata.youtube.com/feeds/api/videos/"+a.id+
"?v=2&alt=jsonc",{type:"GET",dataType:"jsonp",timeout:2E3,error:function(b,e){if("abort"!=e)a.error=!0,c()},success:function(b){!b.error&&b.data&&"allowed"==b.data.accessControl.embed?(b="widescreen"==b.data.aspectRatio,a.height=a.height||720,a.width=Math.round(a.height*(b?16/9:4/3))):a.error=!0;c()}})},postLoad:function(a){a.obj=b('<iframe src="http://www.youtube.com/embed/'+a.id+'?version=3&autohide=1&autoplay=1&rel=0" width="'+a.width+'" height="'+a.height+'" frameborder="0"></iframe>')[0]}}),
b.easybox.resourceHandler({identify:function(a){if(!a.url)return!1;var b=/^http\:\/\/vimeo\.com\/([0-9]*)(.*)?$/i.exec(a.url);return null!=b?(a.id=b[1],!0):!1},preLoad:function(a,c){b.ajax("http://vimeo.com/api/v2/video/"+a.id+".json",{type:"GET",dataType:"jsonp",timeout:2E3,error:function(b,e){if("abort"!=e)a.error=!0,c()},success:function(b){if(b.length)if("anywhere"==b[0].embed_privacy||"approved"==b[0].embed_privacy){if(b[0].width&&b[0].height)a.width=b[0].width,a.height=b[0].height}else a.error=
!0;c()}})},postLoad:function(a){a.obj=b('<iframe src="http://player.vimeo.com/video/'+a.id+'?title=0&byline=0&portrait=0&autoplay=true" width="'+a.width+'" height="'+a.height+'" frameborder="0"></iframe>')[0]}}),b.easybox.resourceHandler({identify:function(a){if(!a.url)return!1;var b=/^http\:\/\/www\.dailymotion\.com\/video\/([A-Za-z0-9]*)(.*)?$/i.exec(a.url);return null!=b?(a.id=b[1],!0):!1},preLoad:function(a,c){b.ajax("https://api.dailymotion.com/video/"+a.id+"?fields=allow_embed,aspect_ratio",
{type:"GET",dataType:"jsonp",timeout:2E3,error:function(b,e){if("abort"!=e)a.error=!0,c()},success:function(b){b.allow_embed?(b=b.aspect_ratio,a.height=a.height||720,a.width=Math.round(a.height*b)):a.error=!0;c()}})},postLoad:function(a){a.obj=b('<iframe src="http://www.dailymotion.com/embed/video/'+a.id+'?autoplay=1" width="'+a.width+'" height="'+a.height+'" frameborder="0"></iframe>')[0]}}))})})(window,document,jQuery);
/*
Easybox v1.4 - Lightweight easy to use lightbox clone for jQuery
Based on Slimbox2 by Christophe Beyls <http://www.digitalia.be>
Copyright (C) 2011 by Vincent Wochnik
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
(function(wnd, doc, $) {
"use strict";
// Global options
var defaults = {
loop: false, // navigate between first and last image
preloadNext: true, // preloads previous and next resources if true
dragDrop: true, // enable window drag and drop
hideBottom: false, // hide bottom container
hideCaption: false, // hide caption and number
hideButtons: false, // hide buttons
noNavigation: false, // disable navigation
noClose: false, // disable close, only autoclose works
noToggleSlideshow: false, // prevent user disabling slideshow
overlayOpacity: 0.8, // opacity of the overlay from 0 to 1
resizeDuration: 400, // box resize duration
resizeEasing: 'easybox', // resize easing method; 'swing' = default
fadeDuration: 400, // image fade-in duration
initCenterSize: [250, 250], // initial size of window
errorSize: [320, 180], // error container size
defaultContentSize: [960, 720],
maximumContentSize: [1280, 720],
captionFadeDuration: 200, // caption fade duration
slideshow: 0, // slideshow interval; 0 = disable slideshows
autoClose: 0, // close after x milliseconds; 0 = disable autoClose
counterText: "{x} of {y}", // counter text; {x} replaced with current image number; {y} replaced with total image count
closeKeys: [27], // array of keycodes to close easybox, default: Esc (27), 'x' (88), 'c' (67)
previousKeys: [37], // array of keycodes to navigate to the previous image, default: Left arrow (37), 'p' (80)
nextKeys: [39], // array of keycodes to navigate to the next image, default: Right arrow (39), 'n' (78)
toggleSlideshowKeys: [32], // array of keycodees to enable/disable slideshow
preventOtherKeys: true // prevents handling of other keys
};
var resourceHandlers = [], options, resources, activeIndex = -1, prevIndex = -1, nextIndex = -1, centerSize,
hiddenElements = [], slideshowDirection = false, slideshowOff = false,
// drag and drop vars
dragging = false, dragOffX = 0, dragOffY = 0,
// state variables and timeouts
open = false, busy, shown, slideshowTimeout = null, closeTimeout = null,
// DOM elements
overlay, center, container, navLinks, prevLink, nextLink, slideLink, closeLink, bottom, caption, number, loadingIndicator;
/*
Initialization
*/
$(function() {
$(doc.body).append(
$([
overlay = $('<div id="easyOverlay" />').click(userClose)[0],
center = $('<div id="easyCenter" />').append([
container = $('<div id="easyContainer" />')[0],
loadingIndicator = $('<div id="easyLoadingIndicator" />')[0],
bottom = $('<div id="easyBottom" />').append([
navLinks = $('<div id="easyNavigation" />').append([
prevLink = $('<a id="easyPrevLink" href="#" />').click(previous)[0],
nextLink = $('<a id="easyNextLink" href="#" />').click(next)[0]
])[0],
closeLink = $('<a id="easyCloseLink" href="#" />').click(userClose)[0],
slideLink = $('<a id="easySlideLink" href="#" />').click(toggleSlide)[0],
caption = $('<div id="easyCaption" />')[0],
number = $('<div id="easyNumber" />')[0]
])[0]
])[0]
]).css("display", "none")
);
});
/*
options: Optional options object given to $.easybox function
linkMapper: Optional function taking a link DOM element and an index as arguments and returning an array containing 2 elements:
the image URL and the image caption (may contain HTML)
linksFilter: Optional function taking a link DOM element and an index as arguments and returning true if the element is part of
the image collection that will be shown on click, false if not. "this" refers to the element that was clicked.
This function must always return true when the DOM element argument is "this".
This function must not return true when the rel tags of the DOM element and *this* are not equal.
dynamicoptions: Optional function taking a link DOM element and returns an options object which is then added to the objects object
passed as first parameter and then passed to EasyBox.
*/
$.fn.easybox = function(_options, linkMapper, linksFilter, dynamicOptions) {
linkMapper = linkMapper || function(el) {
var obj = {url: el.href, caption: el.title};
if (el.hasAttribute("data-width")) obj.width = el.getAttribute("data-width");
if (el.hasAttribute("data-height")) obj.height = el.getAttribute("data-height");
return obj;
};
linksFilter = linksFilter || function(el) {
return (this == el);
};
dynamicOptions = dynamicOptions || function(link) {
return {};
};
var links = this;
return links.unbind("click").click(function() {
// Build the list of resources that will be displayed
var link = this, startIndex = 0, filteredLinks, i = 0, len;
filteredLinks = $.grep(links, function(el, i) {
return linksFilter.call(link, el, i);
});
// We cannot use jQuery.map() because it flattens the returned array
for (len = filteredLinks.length; i < len; ++i) {
if (filteredLinks[i] == link) startIndex = i;
filteredLinks[i] = linkMapper(filteredLinks[i], i);
}
return $.easybox(filteredLinks, startIndex, $.extend({}, _options, dynamicOptions(link)));
});
};
/*
API
*/
var E = $.easybox = easybox;
$.extend(E, {
previous: function() { return (prevIndex >= 0) ? !previous() : false },
next: function() { return (nextIndex >= 0) ? !next() : false },
hasPrevious: function() { return (prevIndex >= 0); },
hasNext: function() { return (nextIndex >= 0); },
close: function() { return (open) ? !close() : false },
isOpen: function() { return open; },
defaults: function(def) { defaults = $.extend(defaults, def); },
resourceHandler: function(h) { addResourceHandler(h); }
});
function easybox(res, startIndex, opts) {
if (open)
return false;
// complete options
options = $.extend({}, defaults, opts);
// fill resources array
resources = [];
for (var i = 0; i < res.length; i++) {
resources.push($.extend({caption: "", width: 0, height: 0},
res[i], {handler: null, loaded: false, loading: false, error: false, obj: null}));
}
if (!resources.length)
return;
open = true;
// set loop option
if (resources.length <= 1)
$.extend(options, {loop: false, slideshow: 0});
// initializing center
centerSize = options.initCenterSize.slice();
stop();
setup(1);
$(center).show();
$(overlay).css({opacity: options.overlayOpacity}).fadeIn(options.fadeDuration, function() {
change(Math.min(resources.length-1, startIndex || 0));
});
return false;
}
/*
Change resource
*/
function change(index) {
if ((busy) || (index < 0) || (index >= resources.length))
return false;
// reset everything
stop();
activeIndex = index;
prevIndex = (activeIndex || (options.loop ? resources.length : 0)) - 1;
nextIndex = ((activeIndex + 1) % resources.length) || (options.loop ? 0 : -1);
if (options.preloadNext) {
if (prevIndex >= 0)
load(resources[prevIndex]);
if (nextIndex >= 0)
load(resources[nextIndex]);
}
if (!resources[activeIndex].loaded)
$(loadingIndicator).show();
load(resources[activeIndex]);
return false;
}
/*
Animates the box
Called by change()
*/
function animateBox() {
var r = resources[activeIndex];
$(loadingIndicator).hide();
if (!r.error) {
// set caption
if ((!options.hideCaption) && (r.caption.length))
$(caption).html(r.caption).css({display: ''});
// resize container
$(container).width(r.width).height(r.height);
} else {
// error class and sizing
$(container).addClass("error").width(options.errorSize[0]).height(options.errorSize[1]);
}
// set number text
if ((!options.hideCaption) && (resources.length > 1) && (options.counterText.length))
$(number).html(options.counterText.replace(/{x}/, activeIndex + 1).replace(/{y}/, resources.length)).css({display: ''});
// retrieve center dimensions
busy = true;
$(container).css({visibility: "hidden", display: ""});
animateCenter([container.offsetWidth, container.offsetHeight], -1, options.resizeDuration);
// gets executed after animation effect
$(center).queue(function(next) {
$(container).css({visibility: "", display: "none"});
if (!r.error) {
$(r.obj).appendTo(container);
r.handler.show(r);
shown = true;
}
setTimers();
$(container).fadeIn(options.fadeDuration, animateCaption);
busy = false;
next();
});
}
function animateCenter(size, opacity, duration) {
centerSize = size.slice();
var p = {};
// resize center
if ((center.offsetHeight != size[1]) || (center.offsetWidth != size[0]))
p = {height: size[1], marginTop: -size[1]/2, width: size[0], marginLeft: -size[0]/2};
if (opacity > -1)
p.opacity = opacity;
$(center).animate(p, duration, options.resizeEasing);
}
/*
Animates the caption
Called by animateBox() when finished
*/
function animateCaption() {
if (options.hideBottom)
return;
if (!options.hideButtons) {
if (((prevIndex >= 0) || (nextIndex >= 0)) && (!options.noNavigation)) {
$(navLinks).css({display: ''});
$([caption, number]).addClass("nav");
if (prevIndex < 0) $(prevLink).addClass("disabled");
if (nextIndex < 0) $(nextLink).addClass("disabled");
}
if ((options.slideshow > 0) && (!options.noToggleSlideshow))
$(slideLink).css({display: ''});
if (!options.noClose)
$(closeLink).css({display: ''});
}
// fade in
$(bottom).fadeIn(options.captionFadeDuration);
$(center).animate({height: centerSize[1]+bottom.offsetHeight}, options.captionFadeDuration, options.resizeEasing);
}
/*
Stops all animation and resets the box to a clear state
Called by close() and change()
*/
function stop() {
stopTimers();
if (activeIndex >= 0) {
var r = resources[activeIndex];
if ((!r.error) && (shown))
r.handler.hide(r);
}
// reset everything
$([container, caption, number]).html("");
$([bottom, container]).stop(true, true);
$([loadingIndicator, bottom, container, navLinks, caption, number, slideLink, closeLink]).hide();
$(center).stop(true).css({width: centerSize[0], height: centerSize[1], marginLeft: -centerSize[0]/2, marginTop: -centerSize[1]/2, opacity: ""});
$([container, caption, number, prevLink, nextLink]).removeClass();
shown = busy = false;
}
function reset() {
$(center).css({left: '', top: ''}).hide();
$(slideLink).removeClass('disabled');
slideshowDirection = slideshowOff = false;
}
/*
Closes the box
*/
function close() {