Skip to content
Browse files

some small improvements

  • Loading branch information...
1 parent 233d82f commit 3f3649a95c515155eb58dfbf9197747638fd2745 @kristianmandrup committed Dec 6, 2012
View
49 README.md
@@ -159,18 +159,51 @@ See [galleria.io](http://galleria.io) for more info.
[quick start](http://galleria.io/docs/getting_started/quick_start/)
-```javascript
- Galleria.loadTheme('gallery/galleria/classic.min.js');
+```css
+#galleria {
+ width: 700px;
+ height: 400px;
+ background: white
+}
+```
- // configure
- Galleria.configure({
- imageCrop: true,
- transition: 'fade'
- });
+Important: You need to specify the width and height of the galleria container object in your CSS (here the `#galleria` DOM node). Otherwise you will get a trace error!
- Galleria.run('#galleria');
+```javascript
+Galleria.loadTheme('gallery/galleria/classic.js');
+
+// or simply
+Galleria.loadNamedTheme('classic');
+
+// or for asset path
+Galleria.loadAssetTheme('classic');
+
+// Then configure
+Galleria.configure({
+ imageCrop: true,
+ transition: 'fade',
+ log: true,
+ // better handle image paths in assets folder!
+ assets: true,
+ // if pic can't be loaded use this one as fallback
+ dummy: '/assets/photos/dummy.png'
+});
+
+Galleria.run('#galleria');
```
+*Troubleshooting a javascript gallery*
+
+Many of the Javascript galleries don't play very well with Rails and the asset pipeline as they expect a pretty simple application file structure/setup.
+
+As an example, in order to make *galleria* work, I had to add a `normalizeSrc` method, which ensures that it looks for an image of the form `/assets/...` when configured with `assets: true` (See `Galleria.configure` options).
+
+You might well encounter similar troubles. Another potential problem is browser caching, where you might well have to add a timestamp to the image url. Something like:
+
+`my/image.png?235325325323232`
+
+In some cases you might wanna hide the image tags and only execute/initialize the gallery when the images have finished loading, fx via the `imagesLoaded` jQuery plugin. Good luck!
+
### Model Configuration
The engine comes with a RGallery::Photos` model which can encapsulate your photos for display and allows you to group photos in multiple pages.
View
3 lib/rails-gallery/engine.rb
@@ -2,8 +2,7 @@ module RailsGallery
module Rails
class Engine < ::Rails::Engine
initializer 'rails gallery' do
- puts "Adding RailsGallery::ViewHelper"
-
+ # puts "Adding RailsGallery::ViewHelper"
ActionView::Base.send :include, RailsGallery::ViewHelper
end
end
View
5,926 vendor/assets/javascripts/gallery/galleria-1.2.8.js
0 additions, 5,926 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
9 vendor/assets/javascripts/gallery/galleria-1.2.8.min.js
@@ -1,9 +0,0 @@
-/**
- * Galleria v 1.2.8 2012-08-09
- * http://galleria.io
- *
- * Licensed under the MIT license
- * https://raw.github.com/aino/galleria/master/LICENSE
- *
- */(function(a){var b,c=this,d=c.document,e=a(d),f=a(c),g=Array.prototype,h=1.28,i=!0,j=3e4,k=!1,l=navigator.userAgent.toLowerCase(),m=c.location.hash.replace(/#\//,""),n=function(){},o=function(){return!1},p=function(){var a=3,c=d.createElement("div"),e=c.getElementsByTagName("i");do c.innerHTML="<!--[if gt IE "+ ++a+"]><i></i><![endif]-->";while(e[0]);return a>4?a:b}(),q=function(){return{html:d.documentElement,body:d.body,head:d.getElementsByTagName("head")[0],title:d.title}},r="data ready thumbnail loadstart loadfinish image play pause progress fullscreen_enter fullscreen_exit idle_enter idle_exit rescale lightbox_open lightbox_close lightbox_image",s=function(){var b=[];return a.each(r.split(" "),function(a,c){b.push(c),/_/.test(c)&&b.push(c.replace(/_/g,""))}),b}(),t=function(b){var c;return typeof b!="object"?b:(a.each(b,function(d,e){/^[a-z]+_/.test(d)&&(c="",a.each(d.split("_"),function(a,b){c+=a>0?b.substr(0,1).toUpperCase()+b.substr(1):b}),b[c]=e,delete b[d])}),b)},u=function(b){return a.inArray(b,s)>-1?Galleria[b.toUpperCase()]:b},v={youtube:{reg:/https?:\/\/(?:[a-zA_Z]{2,3}.)?(?:youtube\.com\/watch\?)((?:[\w\d\-\_\=]+&amp;(?:amp;)?)*v(?:&lt;[A-Z]+&gt;)?=([0-9a-zA-Z\-\_]+))/i,embed:function(a){return"http://www.youtube.com/embed/"+a},getThumb:function(b,c,d){d=d||n,a.getJSON("http://gdata.youtube.com/feeds/api/videos/"+b+"?v=2&alt=json-in-script&callback=?",function(a){try{c(a.entry.media$group.media$thumbnail[0].url)}catch(b){d()}}).error(d)}},vimeo:{reg:/https?:\/\/(?:www\.)?(vimeo\.com)\/(?:hd#)?([0-9]+)/i,embed:function(a){return"http://player.vimeo.com/video/"+a},getThumb:function(b,c,d){d=d||n,a.getJSON("http://vimeo.com/api/v2/video/"+b+".json?callback=?",function(a){try{c(a[0].thumbnail_medium)}catch(b){d()}}).error(d)}},dailymotion:{reg:/https?:\/\/(?:www\.)?(dailymotion\.com)\/video\/([^_]+)/,embed:function(a){return"http://www.dailymotion.com/embed/video/"+a},getThumb:function(b,c,d){d=d||n,a.getJSON("https://api.dailymotion.com/video/"+b+"?fields=thumbnail_medium_url&callback=?",function(a){try{c(a.thumbnail_medium_url)}catch(b){d()}}).error(d)}}},w=function(a){var b;for(var c in v){b=a&&a.match(v[c].reg);if(b&&b.length)return{id:b[2],provider:c}}return!1},x={support:function(){var a=q().html;return a.requestFullscreen||a.mozRequestFullScreen||a.webkitRequestFullScreen}(),callback:n,enter:function(a,b){this.instance=a,this.callback=b||n;var c=q().html;c.requestFullscreen?c.requestFullscreen():c.mozRequestFullScreen?c.mozRequestFullScreen():c.webkitRequestFullScreen&&c.webkitRequestFullScreen()},exit:function(a){this.callback=a||n,d.exitFullscreen?d.exitFullscreen():d.mozCancelFullScreen?d.mozCancelFullScreen():d.webkitCancelFullScreen&&d.webkitCancelFullScreen()},instance:null,listen:function(){if(!this.support)return;var a=function(){if(!x.instance)return;var a=x.instance._fullscreen;d.fullscreen||d.mozFullScreen||d.webkitIsFullScreen?a._enter(x.callback):a._exit(x.callback)};d.addEventListener("fullscreenchange",a,!1),d.addEventListener("mozfullscreenchange",a,!1),d.addEventListener("webkitfullscreenchange",a,!1)}},y=[],z=[],A=!1,B=!1,C=[],D=function(b){Galleria.theme=b,a.each(C,function(a,b){b._initialized||b._init.call(b)})},E=function(){return{clearTimer:function(b){a.each(Galleria.get(),function(){this.clearTimer(b)})},addTimer:function(b){a.each(Galleria.get(),function(){this.addTimer(b)})},array:function(a){return g.slice.call(a,0)},create:function(a,b){b=b||"div";var c=d.createElement(b);return c.className=a,c},getScriptPath:function(b){b=b||a("script:last").attr("src");var c=b.split("/");return c.length==1?"":(c.pop(),c.join("/")+"/")},animate:function(){var b=function(a){var b="transition WebkitTransition MozTransition OTransition".split(" "),d;if(c.opera)return!1;for(d=0;b[d];d++)if(typeof a[b[d]]!="undefined")return b[d];return!1}((d.body||d.documentElement).style),e={MozTransition:"transitionend",OTransition:"oTransitionEnd",WebkitTransition:"webkitTransitionEnd",transition:"transitionend"}[b],f={_default:[.25,.1,.25,1],galleria:[.645,.045,.355,1],galleriaIn:[.55,.085,.68,.53],galleriaOut:[.25,.46,.45,.94],ease:[.25,0,.25,1],linear:[.25,.25,.75,.75],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]},g=function(b,c,d){var e={};d=d||"transition",a.each("webkit moz ms o".split(" "),function(){e["-"+this+"-"+d]=c}),b.css(e)},h=function(a){g(a,"none","transition"),Galleria.WEBKIT&&Galleria.TOUCH&&(g(a,"translate3d(0,0,0)","transform"),a.data("revert")&&(a.css(a.data("revert")),a.data("revert",null)))},i,j,k,l,m,o,p;return function(d,q,r){r=a.extend({duration:400,complete:n,stop:!1},r),d=a(d);if(!r.duration){d.css(q),r.complete.call(d[0]);return}if(!b){d.animate(q,r);return}r.stop&&(d.unbind(e),h(d)),i=!1,a.each(q,function(a,b){p=d.css(a),E.parseValue(p)!=E.parseValue(b)&&(i=!0),d.css(a,p)});if(!i){c.setTimeout(function(){r.complete.call(d[0])},r.duration);return}j=[],k=r.easing in f?f[r.easing]:f._default,l=" "+r.duration+"ms"+" cubic-bezier("+k.join(",")+")",c.setTimeout(function(b,c,d,e){return function(){b.one(c,function(a){return function(){h(a),r.complete.call(a[0])}}(b));if(Galleria.WEBKIT&&Galleria.TOUCH){m={},o=[0,0,0],a.each(["left","top"],function(a,c){c in d&&(o[a]=E.parseValue(d[c])-E.parseValue(b.css(c))+"px",m[c]=d[c],delete d[c])});if(o[0]||o[1])b.data("revert",m),j.push("-webkit-transform"+e),g(b,"translate3d("+o.join(",")+")","transform")}a.each(d,function(a,b){j.push(a+e)}),g(b,j.join(",")),b.css(d)}}(d,e,q,l),2)}}(),removeAlpha:function(a){if(p<9&&a){var b=a.style,c=a.currentStyle,d=c&&c.filter||b.filter||"";/alpha/.test(d)&&(b.filter=d.replace(/alpha\([^)]*\)/i,""))}},forceStyles:function(b,c){b=a(b),b.attr("style")&&b.data("styles",b.attr("style")).removeAttr("style"),b.css(c)},revertStyles:function(){a.each(E.array(arguments),function(b,c){c=a(c),c.removeAttr("style"),c.attr("style",""),c.data("styles")&&c.attr("style",c.data("styles")).data("styles",null)})},moveOut:function(a){E.forceStyles(a,{position:"absolute",left:-1e4})},moveIn:function(){E.revertStyles.apply(E,E.array(arguments))},elem:function(b){return b instanceof a?{$:b,dom:b[0]}:{$:a(b),dom:b}},hide:function(a,b,c){c=c||n;var d=E.elem(a),e=d.$;a=d.dom,e.data("opacity")||e.data("opacity",e.css("opacity"));var f={opacity:0};if(b){var g=p<9&&a?function(){E.removeAlpha(a),a.style.visibility="hidden",c.call(a)}:c;E.animate(a,f,{duration:b,complete:g,stop:!0})}else p<9&&a?(E.removeAlpha(a),a.style.visibility="hidden"):e.css(f)},show:function(a,b,c){c=c||n;var d=E.elem(a),e=d.$;a=d.dom;var f=parseFloat(e.data("opacity"))||1,g={opacity:f};if(b){p<9&&(e.css("opacity",0),a.style.visibility="visible");var h=p<9&&a?function(){g.opacity==1&&E.removeAlpha(a),c.call(a)}:c;E.animate(a,g,{duration:b,complete:h,stop:!0})}else p<9&&g.opacity==1&&a?(E.removeAlpha(a),a.style.visibility="visible"):e.css(g)},optimizeTouch:function(){var b,c,d,e,f={},g=function(b){b.preventDefault(),f=a.extend({},b,!0)},h=function(){this.evt=f},i=function(){this.handler.call(b,this.evt)};return function(f){a(f).bind("touchend",function(f){b=f.target,e=!0;while(b.parentNode&&b!=f.currentTarget&&e)c=a(b).data("events"),d=a(b).data("fakes"),c&&"click"in c?(e=!1,f.preventDefault(),a(b).click(g).click(),c.click.pop(),a.each(c.click,h),a(b).data("fakes",c.click),delete c.click):d&&(e=!1,f.preventDefault(),a.each(d,i)),b=b.parentNode})}}(),wait:function(b){b=a.extend({until:o,success:n,error:function(){Galleria.raise("Could not complete wait function.")},timeout:3e3},b);var d=E.timestamp(),e,f,g=function(){f=E.timestamp(),e=f-d;if(b.until(e))return b.success(),!1;if(typeof b.timeout=="number"&&f>=d+b.timeout)return b.error(),!1;c.setTimeout(g,10)};c.setTimeout(g,10)},toggleQuality:function(a,b){if(p!==7&&p!==8||!a||a.nodeName.toUpperCase()!="IMG")return;typeof b=="undefined"&&(b=a.style.msInterpolationMode==="nearest-neighbor"),a.style.msInterpolationMode=b?"bicubic":"nearest-neighbor"},insertStyleTag:function(a){var b=d.createElement("style");q().head.appendChild(b);if(b.styleSheet)b.styleSheet.cssText=a;else{var c=d.createTextNode(a);b.appendChild(c)}},loadScript:function(b,c){var d=!1,e=a("<script>").attr({src:b,async:!0}).get(0);e.onload=e.onreadystatechange=function(){!d&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")&&(d=!0,e.onload=e.onreadystatechange=null,typeof c=="function"&&c.call(this,this))},q().head.appendChild(e)},parseValue:function(a){if(typeof a=="number")return a;if(typeof a=="string"){var b=a.match(/\-?\d|\./g);return b&&b.constructor===Array?b.join("")*1:0}return 0},timestamp:function(){return(new Date).getTime()},loadCSS:function(c,e,f){var g,h;a("link[rel=stylesheet]").each(function(){if((new RegExp(c)).test(this.href))return g=this,!1}),typeof e=="function"&&(f=e,e=b),f=f||n;if(g)return f.call(g,g),g;h=d.styleSheets.length;if(a("#"+e).length)a("#"+e).attr("href",c),h--;else{g=a("<link>").attr({rel:"stylesheet",href:c,id:e}).get(0);var i=a('link[rel="stylesheet"], style');i.length?i.get(0).parentNode.insertBefore(g,i[0]):q().head.appendChild(g);if(p&&h>=31){Galleria.raise("You have reached the browser stylesheet limit (31)",!0);return}}if(typeof f=="function"){var j=a("<s>").attr("id","galleria-loader").hide().appendTo(q().body);E.wait({until:function(){return j.height()==1},success:function(){j.remove(),f.call(g,g)},error:function(){j.remove(),Galleria.raise("Theme CSS could not load after 20 sec. Please download the latest theme at http://galleria.io/customer/",!0)},timeout:2e4})}return g}}}(),F=function(){var b=function(b,c,d,e){var f=this.getOptions("easing"),g=this.getStageWidth(),h={left:g*(b.rewind?-1:1)},i={left:0};d?(h.opacity=0,i.opacity=1):h.opacity=1,a(b.next).css(h),E.animate(b.next,i,{duration:b.speed,complete:function(a){return function(){c(),a.css({left:0})}}(a(b.next).add(b.prev)),queue:!1,easing:f}),e&&(b.rewind=!b.rewind),b.prev&&(h={left:0},i={left:g*(b.rewind?1:-1)},d&&(h.opacity=1,i.opacity=0),a(b.prev).css(h),E.animate(b.prev,i,{duration:b.speed,queue:!1,easing:f,complete:function(){a(this).css("opacity",0)}}))};return{active:!1,init:function(a,b,c){F.effects.hasOwnProperty(a)&&F.effects[a].call(this,b,c)},effects:{fade:function(b,c){a(b.next).css({opacity:0,left:0}).show(),E.animate(b.next,{opacity:1},{duration:b.speed,complete:c}),b.prev&&(a(b.prev).css("opacity",1).show(),E.animate(b.prev,{opacity:0},{duration:b.speed}))},flash:function(b,c){a(b.next).css({opacity:0,left:0}),b.prev?E.animate(b.prev,{opacity:0},{duration:b.speed/2,complete:function(){E.animate(b.next,{opacity:1},{duration:b.speed,complete:c})}}):E.animate(b.next,{opacity:1},{duration:b.speed,complete:c})},pulse:function(b,c){b.prev&&a(b.prev).hide(),a(b.next).css({opacity:0,left:0}).show(),E.animate(b.next,{opacity:1},{duration:b.speed,complete:c})},slide:function(a,c){b.apply(this,E.array(arguments))},fadeslide:function(a,c){b.apply(this,E.array(arguments).concat([!0]))},doorslide:function(a,c){b.apply(this,E.array(arguments).concat([!1,!0]))}}}}();x.listen(),Galleria=function(){var d=this;this._options={},this._playing=!1,this._playtime=5e3,this._active=null,this._queue={length:0},this._data=[],this._dom={},this._thumbnails=[],this._layers=[],this._initialized=!1,this._firstrun=!1,this._stageWidth=0,this._stageHeight=0,this._target=b,this._binds=[],this._id=parseInt(Math.random()*1e4,10);var g="container stage images image-nav image-nav-left image-nav-right info info-text info-title info-description thumbnails thumbnails-list thumbnails-container thumb-nav-left thumb-nav-right loader counter tooltip",h="current total";a.each(g.split(" "),function(a,b){d._dom[b]=E.create("galleria-"+b)}),a.each(h.split(" "),function(a,b){d._dom[b]=E.create("galleria-"+b,"span")});var i=this._keyboard={keys:{UP:38,DOWN:40,LEFT:37,RIGHT:39,RETURN:13,ESCAPE:27,BACKSPACE:8,SPACE:32},map:{},bound:!1,press:function(a){var b=a.keyCode||a.which;b in i.map&&typeof i.map[b]=="function"&&i.map[b].call(d,a)},attach:function(a){var b,c;for(b in a)a.hasOwnProperty(b)&&(c=b.toUpperCase(),c in i.keys?i.map[i.keys[c]]=a[b]:i.map[c]=a[b]);i.bound||(i.bound=!0,e.bind("keydown",i.press))},detach:function(){i.bound=!1,i.map={},e.unbind("keydown",i.press)}},j=this._controls={0:b,1:b,active:0,swap:function(){j.active=j.active?0:1},getActive:function(){return j[j.active]},getNext:function(){return j[1-j.active]}},k=this._carousel={next:d.$("thumb-nav-right"),prev:d.$("thumb-nav-left"),width:0,current:0,max:0,hooks:[],update:function(){var b=0,c=0,e=[0];a.each(d._thumbnails,function(d,f){f.ready&&(b+=f.outerWidth||a(f.container).outerWidth(!0),e[d+1]=b,c=Math.max(c,f.outerHeight||a(f.container).outerHeight(!0)))}),d.$("thumbnails").css({width:b,height:c}),k.max=b,k.hooks=e,k.width=d.$("thumbnails-list").width(),k.setClasses(),d.$("thumbnails-container").toggleClass("galleria-carousel",b>k.width),k.width=d.$("thumbnails-list").width()},bindControls:function(){var a;k.next.bind("click",function(b){b.preventDefault();if(d._options.carouselSteps==="auto"){for(a=k.current;a<k.hooks.length;a++)if(k.hooks[a]-k.hooks[k.current]>k.width){k.set(a-2);break}}else k.set(k.current+d._options.carouselSteps)}),k.prev.bind("click",function(b){b.preventDefault();if(d._options.carouselSteps==="auto")for(a=k.current;a>=0;a--){if(k.hooks[k.current]-k.hooks[a]>k.width){k.set(a+2);break}if(a===0){k.set(0);break}}else k.set(k.current-d._options.carouselSteps)})},set:function(a){a=Math.max(a,0);while(k.hooks[a-1]+k.width>=k.max&&a>=0)a--;k.current=a,k.animate()},getLast:function(a){return(a||k.current)-1},follow:function(a){if(a===0||a===k.hooks.length-2){k.set(a);return}var b=k.current;while(k.hooks[b]-k.hooks[k.current]<k.width&&b<=k.hooks.length)b++;a-1<k.current?k.set(a-1):a+2>b&&k.set(a-b+k.current+2)},setClasses:function(){k.prev.toggleClass("disabled",!k.current),k.next.toggleClass("disabled",k.hooks[k.current]+k.width>=k.max)},animate:function(a){k.setClasses();var b=k.hooks[k.current]*-1;if(isNaN(b))return;E.animate(d.get("thumbnails"),{left:b},{duration:d._options.carouselSpeed,easing:d._options.easing,queue:!1})}},l=this._tooltip={initialized:!1,open:!1,timer:"tooltip"+d._id,swapTimer:"swap"+d._id,init:function(){l.initialized=!0;var a=".galleria-tooltip{padding:3px 8px;max-width:50%;background:#ffe;color:#000;z-index:3;position:absolute;font-size:11px;line-height:1.3;opacity:0;box-shadow:0 0 2px rgba(0,0,0,.4);-moz-box-shadow:0 0 2px rgba(0,0,0,.4);-webkit-box-shadow:0 0 2px rgba(0,0,0,.4);}";E.insertStyleTag(a),d.$("tooltip").css({opacity:.8,visibility:"visible",display:"none"})},move:function(a){var b=d.getMousePosition(a).x,c=d.getMousePosition(a).y,e=d.$("tooltip"),f=b,g=c,h=e.outerHeight(!0)+1,i=e.outerWidth(!0),j=h+15,k=d.$("container").width()-i-2,l=d.$("container").height()-h-2;!isNaN(f)&&!isNaN(g)&&(f+=10,g-=30,f=Math.max(0,Math.min(k,f)),g=Math.max(0,Math.min(l,g)),c<j&&(g=j),e.css({left:f,top:g}))},bind:function(b,c){if(Galleria.TOUCH)return;l.initialized||l.init();var e=function(){d.$("container").unbind("mousemove",l.move),d.clearTimer(l.timer),d.$("tooltip").stop().animate({opacity:0},200,function(){d.$("tooltip").hide(),d.addTimer(l.swapTimer,function(){l.open=!1},1e3)})},f=function(b,c){l.define(b,c),a(b).hover(function(){d.clearTimer(l.swapTimer),d.$("container").unbind("mousemove",l.move).bind("mousemove",l.move).trigger("mousemove"),l.show(b),d.addTimer(l.timer,function(){d.$("tooltip").stop().show().animate({opacity:1}),l.open=!0},l.open?0:500)},e).click(e)};typeof c=="string"?f(b in d._dom?d.get(b):b,c):a.each(b,function(a,b){f(d.get(a),b)})},show:function(b){b=a(b in d._dom?d.get(b):b);var e=b.data("tt"),f=function(a){c.setTimeout(function(a){return function(){l.move(a)}}(a),10),b.unbind("mouseup",f)};e=typeof e=="function"?e():e;if(!e)return;d.$("tooltip").html(e.replace(/\s/,"&nbsp;")),b.bind("mouseup",f)},define:function(b,c){if(typeof c!="function"){var e=c;c=function(){return e}}b=a(b in d._dom?d.get(b):b).data("tt",c),l.show(b)}},m=this._fullscreen={scrolled:0,crop:b,transition:b,active:!1,keymap:d._keyboard.map,parseCallback:function(b,c){return F.active?function(){typeof b=="function"&&b();var e=d._controls.getActive(),f=d._controls.getNext();d._scaleImage(f),d._scaleImage(e),c&&d._options.trueFullscreen&&a(e.container).add(f.container).trigger("transitionend")}:b},enter:function(a){a=m.parseCallback(a,!0),d._options.trueFullscreen&&x.support?x.enter(d,a):m._enter(a)},_enter:function(c){m.active=!0,E.hide(d.getActiveImage()),d.$("container").addClass("fullscreen"),m.scrolled=f.scrollTop(),E.forceStyles(d.get("container"),{position:"fixed",top:0,left:0,width:"100%",height:"100%",zIndex:1e4});var e={height:"100%",overflow:"hidden",margin:0,padding:0},g=d.getData(),h=d._options;E.forceStyles(q().html,e),E.forceStyles(q().body,e),m.keymap=a.extend({},d._keyboard.map),d.attachKeyboard({escape:d.exitFullscreen,right:d.next,left:d.prev}),m.crop=h.imageCrop,h.fullscreenCrop!=b&&(h.imageCrop=h.fullscreenCrop);if(g&&g.big&&g.image!==g.big){var i=new Galleria.Picture,j=i.isCached(g.big),k=d.getIndex(),l=d._thumbnails[k];d.trigger({type:Galleria.LOADSTART,cached:j,rewind:!1,index:k,imageTarget:d.getActiveImage(),thumbTarget:l,galleriaData:g}),i.load(g.big,function(b){d._scaleImage(b,{complete:function(b){d.trigger({type:Galleria.LOADFINISH,cached:j,index:k,rewind:!1,imageTarget:b.image,thumbTarget:l});var c=d._controls.getActive().image;c&&a(c).width(b.image.width).height(b.image.height).attr("style",a(b.image).attr("style")).attr("src",b.image.src)}})})}d.rescale(function(){d.addTimer(!1,function(){E.show(d.getActiveImage()),typeof c=="function"&&c.call(d)},100),d.trigger(Galleria.FULLSCREEN_ENTER)}),f.resize(function(){m.scale()})},scale:function(){d.rescale()},exit:function(a){a=m.parseCallback(a),d._options.trueFullscreen&&x.support?x.exit(a):m._exit(a)},_exit:function(a){m.active=!1,E.hide(d.getActiveImage()),d.$("container").removeClass("fullscreen"),E.revertStyles(d.get("container"),q().html,q().body),c.scrollTo(0,m.scrolled),d.detachKeyboard(),d.attachKeyboard(m.keymap),d._options.imageCrop=m.crop;var b=d.getData().big,e=d._controls.getActive().image;!d.getData().iframe&&e&&b&&b==e.src&&c.setTimeout(function(a){return function(){e.src=a}}(d.getData().image),1),d.rescale(function(){d.addTimer(!1,function(){E.show(d.getActiveImage()),typeof a=="function"&&a.call(d),f.trigger("resize")},50),d.trigger(Galleria.FULLSCREEN_EXIT)}),f.unbind("resize",m.scale)}},n=this._idle={trunk:[],bound:!1,active:!1,add:function(b,c,d,e){if(!b)return;n.bound||n.addEvent(),b=a(b),typeof d=="boolean"&&(e=d,d={}),d=d||{};var f={},g;for(g in c)c.hasOwnProperty(g)&&(f[g]=b.css(g));b.data("idle",{from:a.extend(f,d),to:c,complete:!0,busy:!1}),e?b.css(c):n.addTimer(),n.trunk.push(b)},remove:function(b){b=a(b),a.each(n.trunk,function(a,c){c&&c.length&&!c.not(b).length&&(b.css(b.data("idle").from),n.trunk.splice(a,1))}),n.trunk.length||(n.removeEvent(),d.clearTimer(n.timer))},addEvent:function(){n.bound=!0,d.$("container").bind("mousemove click",n.showAll),d._options.idleMode=="hover"&&d.$("container").bind("mouseleave",n.hide)},removeEvent:function(){n.bound=!1,d.$("container").bind("mousemove click",n.showAll),d._options.idleMode=="hover"&&d.$("container").unbind("mouseleave",n.hide)},addTimer:function(){if(d._options.idleMode=="hover")return;d.addTimer("idle",function(){n.hide()},d._options.idleTime)},hide:function(){if(!d._options.idleMode||d.getIndex()===!1||d.getData().iframe)return;d.trigger(Galleria.IDLE_ENTER);var b=n.trunk.length;a.each(n.trunk,function(a,c){var e=c.data("idle");if(!e)return;c.data("idle").complete=!1,E.animate(c,e.to,{duration:d._options.idleSpeed,complete:function(){a==b-1&&(n.active=!1)}})})},showAll:function(){d.clearTimer("idle"),a.each(n.trunk,function(a,b){n.show(b)})},show:function(b){var c=b.data("idle");if(!n.active||!c.busy&&!c.complete)c.busy=!0,d.trigger(Galleria.IDLE_EXIT),d.clearTimer("idle"),E.animate(b,c.from,{duration:d._options.idleSpeed/2,complete:function(){n.active=!0,a(b).data("idle").busy=!1,a(b).data("idle").complete=!0}});n.addTimer()}},o=this._lightbox={width:0,height:0,initialized:!1,active:null,image:null,elems:{},keymap:!1,init:function(){d.trigger(Galleria.LIGHTBOX_OPEN);if(o.initialized)return;o.initialized=!0;var b="overlay box content shadow title info close prevholder prev nextholder next counter image",c={},e=d._options,f="",g="position:absolute;",h="lightbox-",i={overlay:"position:fixed;display:none;opacity:"+e.overlayOpacity+";filter:alpha(opacity="+e.overlayOpacity*100+");top:0;left:0;width:100%;height:100%;background:"+e.overlayBackground+";z-index:99990",box:"position:fixed;display:none;width:400px;height:400px;top:50%;left:50%;margin-top:-200px;margin-left:-200px;z-index:99991",shadow:g+"background:#000;width:100%;height:100%;",content:g+"background-color:#fff;top:10px;left:10px;right:10px;bottom:10px;overflow:hidden",info:g+"bottom:10px;left:10px;right:10px;color:#444;font:11px/13px arial,sans-serif;height:13px",close:g+"top:10px;right:10px;height:20px;width:20px;background:#fff;text-align:center;cursor:pointer;color:#444;font:16px/22px arial,sans-serif;z-index:99999",image:g+"top:10px;left:10px;right:10px;bottom:30px;overflow:hidden;display:block;",prevholder:g+"width:50%;top:0;bottom:40px;cursor:pointer;",nextholder:g+"width:50%;top:0;bottom:40px;right:-1px;cursor:pointer;",prev:g+"top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;left:20px;display:none;text-align:center;color:#000;font:bold 16px/36px arial,sans-serif",next:g+"top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;right:20px;left:auto;display:none;font:bold 16px/36px arial,sans-serif;text-align:center;color:#000",title:"float:left",counter:"float:right;margin-left:8px;"},j=function(b){return b.hover(function(){a(this).css("color","#bbb")},function(){a(this).css("color","#444")})},k={};p&&p>7&&(i.nextholder+="background:#000;filter:alpha(opacity=0);",i.prevholder+="background:#000;filter:alpha(opacity=0);"),a.each(i,function(a,b){f+=".galleria-"+h+a+"{"+b+"}"}),f+=".galleria-"+h+"box.iframe .galleria-"+h+"prevholder,"+".galleria-"+h+"box.iframe .galleria-"+h+"nextholder{"+"width:100px;height:100px;top:50%;margin-top:-70px}",E.insertStyleTag(f),a.each(b.split(" "),function(a,b){d.addElement("lightbox-"+b),c[b]=o.elems[b]=d.get("lightbox-"+b)}),o.image=new Galleria.Picture,a.each({box:"shadow content close prevholder nextholder",info:"title counter",content:"info image",prevholder:"prev",nextholder:"next"},function(b,c){var d=[];a.each(c.split(" "),function(a,b){d.push(h+b)}),k[h+b]=d}),d.append(k),a(c.image).append(o.image.container),a(q().body).append(c.overlay,c.box),E.optimizeTouch(c.box),j(a(c.close).bind("click",o.hide).html("&#215;")),a.each(["Prev","Next"],function(b,d){var e=a(c[d.toLowerCase()]).html(/v/.test(d)?"&#8249;&nbsp;":"&nbsp;&#8250;"),f=a(c[d.toLowerCase()+"holder"]);f.bind("click",function(){o["show"+d]()});if(p<8||Galleria.TOUCH){e.show();return}f.hover(function(){e.show()},function(a){e.stop().fadeOut(200)})}),a(c.overlay).bind("click",o.hide),Galleria.IPAD&&(d._options.lightboxTransitionSpeed=0)},rescale:function(b){var c=Math.min(f.width()-40,o.width),e=Math.min(f.height()-60,o.height),g=Math.min(c/o.width,e/o.height),h=Math.round(o.width*g)+40,i=Math.round(o.height*g)+60,j={width:h,height:i,"margin-top":Math.ceil(i/2)*-1,"margin-left":Math.ceil(h/2)*-1};b?a(o.elems.box).css(j):a(o.elems.box).animate(j,{duration:d._options.lightboxTransitionSpeed,easing:d._options.easing,complete:function(){var b=o.image,c=d._options.lightboxFadeSpeed;d.trigger({type:Galleria.LIGHTBOX_IMAGE,imageTarget:b.image}),a(b.container).show(),a(b.image).animate({opacity:1},c),E.show(o.elems.info,c)}})},hide:function(){o.image.image=null,f.unbind("resize",o.rescale),a(o.elems.box).hide(),E.hide(o.elems.info),d.detachKeyboard(),d.attachKeyboard(o.keymap),o.keymap=!1,E.hide(o.elems.overlay,200,function(){a(this).hide().css("opacity",d._options.overlayOpacity),d.trigger(Galleria.LIGHTBOX_CLOSE)})},showNext:function(){o.show(d.getNext(o.active))},showPrev:function(){o.show(d.getPrev(o.active))},show:function(b){o.active=b=typeof b=="number"?b:d.getIndex()||0,o.initialized||o.init(),o.keymap||(o.keymap=a.extend({},d._keyboard.map),d.attachKeyboard({escape:o.hide,right:o.showNext,left:o.showPrev})),f.unbind("resize",o.rescale);var e=d.getData(b),g=d.getDataLength(),h=d.getNext(b),i,j,k;E.hide(o.elems.info);try{for(k=d._options.preload;k>0;k--)j=new Galleria.Picture,i=d.getData(h),j.preload("big"in i?i.big:i.image),h=d.getNext(h)}catch(l){}o.image.isIframe=!!e.iframe,a(o.elems.box).toggleClass("iframe",!!e.iframe),o.image.load(e.iframe||e.big||e.image,function(d){o.width=d.isIframe?a(c).width():d.original.width,o.height=d.isIframe?a(c).height():d.original.height,a(d.image).css({width:d.isIframe?"100%":"100.1%",height:d.isIframe?"100%":"100.1%",top:0,zIndex:99998,opacity:0,visibility:"visible"}),o.elems.title.innerHTML=e.title||"",o.elems.counter.innerHTML=b+1+" / "+g,f.resize(o.rescale),o.rescale()}),a(o.elems.overlay).show().css("visibility","visible"),a(o.elems.box).show()}},r=this._timer={trunk:{},add:function(a,b,d,e){a=a||(new Date).getTime(),e=e||!1,this.clear(a);if(e){var f=b;b=function(){f(),r.add(a,b,d)}}this.trunk[a]=c.setTimeout(b,d)},clear:function(a){var b=function(a){c.clearTimeout(this.trunk[a]),delete this.trunk[a]},d;if(!!a&&a in this.trunk)b.call(this,a);else if(typeof a=="undefined")for(d in this.trunk)this.trunk.hasOwnProperty(d)&&b.call(this,d)}};return this},Galleria.prototype={constructor:Galleria,init:function(c,d){var e=this;d=t(d),this._original={target:c,options:d,data:null},this._target=this._dom.target=c.nodeName?c:a(c).get(0),this._original.html=this._target.innerHTML,z.push(this);if(!this._target){Galleria.raise("Target not found",!0);return}return this._options={autoplay:!1,carousel:!0,carouselFollow:!0,carouselSpeed:400,carouselSteps:"auto",clicknext:!1,dailymotion:{foreground:"%23EEEEEE",highlight:"%235BCEC5",background:"%23222222",logo:0,hideInfos:1},dataConfig:function(a){return{}},dataSelector:"img",dataSort:!1,dataSource:this._target,debug:b,dummy:b,easing:"galleria",extend:function(a){},fullscreenCrop:b,fullscreenDoubleTap:!0,fullscreenTransition:b,height:0,idleMode:!0,idleTime:3e3,idleSpeed:200,imageCrop:!1,imageMargin:0,imagePan:!1,imagePanSmoothness:12,imagePosition:"50%",imageTimeout:b,initialTransition:b,keepSource:!1,layerFollow:!0,lightbox:!1,lightboxFadeSpeed:200,lightboxTransitionSpeed:200,linkSourceImages:!0,maxScaleRatio:b,minScaleRatio:b,overlayOpacity:.85,overlayBackground:"#0b0b0b",pauseOnInteraction:!0,popupLinks:!1,preload:2,queue:!0,responsive:!0,show:0,showInfo:!0,showCounter:!0,showImagenav:!0,swipe:!0,thumbCrop:!0,thumbEventType:"click",thumbFit:!0,thumbMargin:0,thumbQuality:"auto",thumbDisplayOrder:!0,thumbnails:!0,touchTransition:b,transition:"fade",transitionInitial:b,transitionSpeed:400,trueFullscreen:!0,useCanvas:!1,vimeo:{title:0,byline:0,portrait:0,color:"aaaaaa"},wait:5e3,width:"auto",youtube:{modestbranding:1,autohide:1,color:"white",hd:1,rel:0,showinfo:0}},this._options.initialTransition=this._options.initialTransition||this._options.transitionInitial,d&&d.debug===!1&&(i=!1),d&&typeof d.imageTimeout=="number"&&(j=d.imageTimeout),d&&typeof d.dummy=="string"&&(k=d.dummy),a(this._target).children().hide(),typeof Galleria.theme=="object"?this._init():C.push(this),this},_init:function(){var b=this,e=this._options;if(this._initialized)return Galleria.raise("Init failed: Gallery instance already initialized."),this;this._initialized=!0;if(!Galleria.theme)return Galleria.raise("Init failed: No theme found.",!0),this;a.extend(!0,e,Galleria.theme.defaults,this._original.options,Galleria.configure.options),function(a){if(!("getContext"in a)){a=null;return}B=B||{elem:a,context:a.getContext("2d"),cache:{},length:0}}(d.createElement("canvas")),this.bind(Galleria.DATA,function(){Galleria.QUIRK&&Galleria.raise("Your page is in Quirks mode, Galleria may not render correctly. Please validate your HTML."),this._original.data=this._data,this.get("total").innerHTML=this.getDataLength();var a=this.$("container");b._options.height<2&&(b._ratio=b._options.height);var d={width:0,height:0},e=function(){return b.$("stage").height()};E.wait({until:function(){return d=b._getWH(),a.width(d.width).height(d.height),e()&&d.width&&d.height>50},success:function(){b._width=d.width,b._height=d.height,b._ratio=b._ratio||d.height/d.width,Galleria.WEBKIT?c.setTimeout(function(){b._run()},1):b._run()},error:function(){e()?Galleria.raise("Could not extract sufficient width/height of the gallery container. Traced measures: width:"+d.width+"px, height: "+d.height+"px.",!0):Galleria.raise("Could not extract a stage height from the CSS. Traced height: "+e()+"px.",!0)},timeout:typeof this._options.wait=="number"?this._options.wait:!1})}),this.append({"info-text":["info-title","info-description"],info:["info-text"],"image-nav":["image-nav-right","image-nav-left"],stage:["images","loader","counter","image-nav"],"thumbnails-list":["thumbnails"],"thumbnails-container":["thumb-nav-left","thumbnails-list","thumb-nav-right"],container:["stage","thumbnails-container","info","tooltip"]}),E.hide(this.$("counter").append(this.get("current"),d.createTextNode(" / "),this.get("total"))),this.setCounter("&#8211;"),E.hide(b.get("tooltip")),this.$("container").addClass(Galleria.TOUCH?"touch":"notouch"),a.each(new Array(2),function(c){var d=new Galleria.Picture;a(d.container).css({position:"absolute",top:0,left:0}).prepend(b._layers[c]=a(E.create("galleria-layer")).css({position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:2})[0]),b.$("images").append(d.container),b._controls[c]=d}),this.$("images").css({position:"relative",top:0,left:0,width:"100%",height:"100%"}),this.$("thumbnails, thumbnails-list").css({overflow:"hidden",position:"relative"}),this.$("image-nav-right, image-nav-left").bind("click",function(a){e.clicknext&&a.stopPropagation(),e.pauseOnInteraction&&b.pause();var c=/right/.test(this.className)?"next":"prev";b[c]()}),a.each(["info","counter","image-nav"],function(a,c){e["show"+c.substr(0,1).toUpperCase()+c.substr(1).replace(/-/,"")]===!1&&E.moveOut(b.get(c.toLowerCase()))}),this.load(),!e.keepSource&&!p&&(this._target.innerHTML=""),this.get("errors")&&this.appendChild("target","errors"),this.appendChild("target","container");if(e.carousel){var g=0,h=e.show;this.bind(Galleria.THUMBNAIL,function(){this.updateCarousel(),++g==this.getDataLength()&&typeof h=="number"&&h>0&&this._carousel.follow(h)})}return e.responsive&&f.bind("resize",function(){b.isFullscreen()||b.resize()}),e.swipe&&(function(a){var c=[0,0],d=[0,0],e=30,f=100,g=!1,h=0,i,j={start:"touchstart",move:"touchmove",stop:"touchend"},k=function(a){return a.originalEvent.touches?a.originalEvent.touches[0]:a},l=function(a){if(a.originalEvent.touches&&a.originalEvent.touches.length>1)return;i=k(a),d=[i.pageX,i.pageY],c[0]||(c=d),Math.abs(c[0]-d[0])>10&&a.preventDefault()},m=function(i){a.unbind(j.move,l);if(i.originalEvent.touches&&i.originalEvent.touches.length||g){g=!g;return}E.timestamp()-h<1e3&&Math.abs(c[0]-d[0])>e&&Math.abs(c[1]-d[1])<f&&(i.preventDefault(),b[c[0]>d[0]?"next":"prev"]()),c=d=[0,0]};a.bind(j.start,function(b){if(b.originalEvent.touches&&b.originalEvent.touches.length>1)return;i=k(b),h=E.timestamp(),c=d=[i.pageX,i.pageY],a.bind(j.move,l).one(j.stop,m)})}(b.$("images")),e.fullscreenDoubleTap&&this.$("stage").bind("touchstart",function(){var a,c,d,e,f,g,h=function(a){return a.originalEvent.touches?a.originalEvent.touches[0]:a};return function(i){g=Galleria.utils.timestamp(),c=h(i).pageX,d=h(i).pageY;if(g-a<500&&c-e<20&&d-f<20){b.toggleFullscreen(),i.preventDefault(),b.$("stage").unbind("touchend",arguments.callee);return}a=g,e=c,f=d}}())),E.optimizeTouch(this.get("container")),a.each(Galleria.on.binds,function(c,d){a.inArray(d.hash,b._binds)==-1&&b.bind(d.type,d.callback)}),this},addTimer:function(){return this._timer.add.apply(this._timer,E.array(arguments)),this},clearTimer:function(){return this._timer.clear.apply(this._timer,E.array(arguments)),this},_getWH:function(){var b=this.$("container"),c=this.$("target"),d=this,e={},f;return a.each(["width","height"],function(a,g){d._options[g]&&typeof d._options[g]=="number"?e[g]=d._options[g]:(f=[E.parseValue(b.css(g)),E.parseValue(c.css(g)),b[g](),c[g]()],d["_"+g]||f.splice(f.length,E.parseValue(b.css("min-"+g)),E.parseValue(c.css("min-"+g))),e[g]=Math.max.apply(Math,f))}),d._ratio&&(e.height=e.width*d._ratio),e},_createThumbnails:function(b){this.get("total").innerHTML=this.getDataLength();var e,f,g,h,i,j=this,k=this
-._options,l=b?this._data.length-b.length:0,m=l,n=[],o=0,q=p<8?"http://upload.wikimedia.org/wikipedia/commons/c/c0/Blank.gif":"data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D",r=function(){var a=j.$("thumbnails").find(".active");return a.length?a.find("img").attr("src"):!1}(),s=typeof k.thumbnails=="string"?k.thumbnails.toLowerCase():null,t=function(a){return d.defaultView&&d.defaultView.getComputedStyle?d.defaultView.getComputedStyle(f.container,null)[a]:i.css(a)},u=function(b,c,d){return function(){a(d).append(b),j.trigger({type:Galleria.THUMBNAIL,thumbTarget:b,index:c,galleriaData:j.getData(c)})}},w=function(b){k.pauseOnInteraction&&j.pause();var c=a(b.currentTarget).data("index");j.getIndex()!==c&&j.show(c),b.preventDefault()},x=function(b,c){a(b.container).css("visibility","visible"),j.trigger({type:Galleria.THUMBNAIL,thumbTarget:b.image,index:b.data.order,galleriaData:j.getData(b.data.order)}),typeof c=="function"&&c.call(j,b)},y=function(b,c){b.scale({width:b.data.width,height:b.data.height,crop:k.thumbCrop,margin:k.thumbMargin,canvas:k.useCanvas,complete:function(b){var d=["left","top"],e=["Width","Height"],f,g,h=j.getData(b.index),i=h.thumb.split(":");a.each(e,function(c,e){f=e.toLowerCase(),(k.thumbCrop!==!0||k.thumbCrop===f)&&k.thumbFit&&(g={},g[f]=b[f],a(b.container).css(g),g={},g[d[c]]=0,a(b.image).css(g)),b["outer"+e]=a(b.container)["outer"+e](!0)}),E.toggleQuality(b.image,k.thumbQuality===!0||k.thumbQuality==="auto"&&b.original.width<b.width*3),h.iframe&&i.length==2&&i[0]in v?v[i[0]].getThumb(i[1],function(a){return function(d){a.src=d,x(b,c)}}(b.image)):k.thumbDisplayOrder&&!b.lazy?a.each(n,function(a,b){if(a===o&&b.ready&&!b.displayed){o++,b.displayed=!0,x(b,c);return}}):x(b,c)}})};b||(this._thumbnails=[],this.$("thumbnails").empty());for(;this._data[l];l++)g=this._data[l],e=g.thumb||g.image,k.thumbnails!==!0&&s!="lazy"||!g.thumb&&!g.image?g.iframe||s==="empty"||s==="numbers"?(f={container:E.create("galleria-image"),image:E.create("img","span"),ready:!0},s==="numbers"&&a(f.image).text(l+1),g.iframe&&a(f.image).addClass("iframe"),this.$("thumbnails").append(f.container),c.setTimeout(u(f.image,l,f.container),50+l*20)):f={container:null,image:null}:(f=new Galleria.Picture(l),f.index=l,f.displayed=!1,f.lazy=!1,f.video=!1,this.$("thumbnails").append(f.container),i=a(f.container),i.css("visibility","hidden"),f.data={width:E.parseValue(t("width")),height:E.parseValue(t("height")),order:l,src:e},k.thumbFit&&k.thumbCrop!==!0?i.css({width:"auto",height:"auto"}):i.css({width:f.data.width,height:f.data.height}),h=e.split(":"),h.length==2&&h[0]in v?(f.video=!0,f.ready=!0,f.load(q,{height:f.data.height,width:f.data.height*1.25},y)):s=="lazy"?(i.addClass("lazy"),f.lazy=!0,f.load(q,{height:f.data.height,width:f.data.width})):f.load(e,y),k.preload==="all"&&f.preload(g.image)),a(f.container).add(k.keepSource&&k.linkSourceImages?g.original:null).data("index",l).bind(k.thumbEventType,w).data("thumbload",y),r===e&&a(f.container).addClass("active"),this._thumbnails.push(f);return n=this._thumbnails.slice(m),this},lazyLoad:function(b,c){var d=b.constructor==Array?b:[b],e=this,f=this.$("thumbnails").children().filter(function(){return a(this).data("lazy-src")}),g=0;return a.each(d,function(b,f){if(f>e._thumbnails.length-1)return;var h=e._thumbnails[f],i=h.data,j=i.src.split(":"),k=function(){++g==d.length&&typeof c=="function"&&c.call(e)},l=a(h.container).data("thumbload");h.video?l.call(e,h,k):h.load(i.src,function(a){l.call(e,a,k)})}),this},lazyLoadChunks:function(a,b){var d=this.getDataLength(),e=0,f=0,g=[],h=[],i=this;b=b||0;for(;e<d;e++){h.push(e);if(++f==a||e==d-1)g.push(h),f=0,h=[]}var j=function(a){var d=g.shift();d&&c.setTimeout(function(){i.lazyLoad(d,function(){j(!0)})},b&&a?b:0)};return j(!1),this},_run:function(){var d=this;d._createThumbnails(),E.wait({timeout:1e4,until:function(){return Galleria.OPERA&&d.$("stage").css("display","inline-block"),d._stageWidth=d.$("stage").width(),d._stageHeight=d.$("stage").height(),d._stageWidth&&d._stageHeight>50},success:function(){y.push(d),E.show(d.get("counter")),d._options.carousel&&d._carousel.bindControls(),d._options.autoplay&&(d.pause(),typeof d._options.autoplay=="number"&&(d._playtime=d._options.autoplay),d._playing=!0);if(d._firstrun){d._options.autoplay&&d.trigger(Galleria.PLAY),typeof d._options.show=="number"&&d.show(d._options.show);return}d._firstrun=!0,Galleria.History&&Galleria.History.change(function(a){isNaN(a)?c.history.go(-1):d.show(a,b,!0)}),d.trigger(Galleria.READY),Galleria.theme.init.call(d,d._options),a.each(Galleria.ready.callbacks,function(a,b){typeof b=="function"&&b.call(d,d._options)}),d._options.extend.call(d,d._options),/^[0-9]{1,4}$/.test(m)&&Galleria.History?d.show(m,b,!0):d._data[d._options.show]&&d.show(d._options.show),d._options.autoplay&&d.trigger(Galleria.PLAY)},error:function(){Galleria.raise("Stage width or height is too small to show the gallery. Traced measures: width:"+d._stageWidth+"px, height: "+d._stageHeight+"px.",!0)}})},load:function(b,c,d){var e=this,f=this._options;return this._data=[],this._thumbnails=[],this.$("thumbnails").empty(),typeof c=="function"&&(d=c,c=null),b=b||f.dataSource,c=c||f.dataSelector,d=d||f.dataConfig,/^function Object/.test(b.constructor)&&(b=[b]),b.constructor===Array?this.validate(b)?this._data=b:Galleria.raise("Load failed: JSON Array not valid."):(c+=",.video,.iframe",a(b).find(c).each(function(b,c){c=a(c);var f={},g=c.parent(),h=g.attr("href"),i=g.attr("rel");h&&(c[0].nodeName=="IMG"||c.hasClass("video"))&&w(h)?f.video=h:h&&c.hasClass("iframe")?f.iframe=h:f.image=f.big=h,i&&(f.big=i),a.each("big title description link layer".split(" "),function(a,b){c.data(b)&&(f[b]=c.data(b))}),e._data.push(a.extend({title:c.attr("title")||"",thumb:c.attr("src"),image:c.attr("src"),big:c.attr("src"),description:c.attr("alt")||"",link:c.attr("longdesc"),original:c.get(0)},f,d(c)))})),typeof f.dataSort=="function"?g.sort.call(this._data,f.dataSort):f.dataSort=="random"&&this._data.sort(function(){return Math.round(Math.random())-.5}),this.getDataLength()&&this._parseData().trigger(Galleria.DATA),this},_parseData:function(){var b=this,c;return a.each(this._data,function(d,e){c=b._data[d],"thumb"in e==0&&(c.thumb=e.image),!1 in e&&(c.big=e.image);if("video"in e){var f=w(e.video);if(f){c.iframe=v[f.provider].embed(f.id)+function(){if(typeof b._options[f.provider]=="object"){var c="?",d=[];return a.each(b._options[f.provider],function(a,b){d.push(a+"="+b)}),f.provider=="youtube"&&(d=["wmode=opaque"].concat(d)),c+d.join("&")}return""}(),delete c.video;if(!("thumb"in c)||!c.thumb)c.thumb=f.provider+":"+f.id}}}),this},destroy:function(){return this.get("target").innerHTML=this._original.html,this.clearTimer(),this},splice:function(){var a=this,b=E.array(arguments);return c.setTimeout(function(){g.splice.apply(a._data,b),a._parseData()._createThumbnails()},2),a},push:function(){var a=this,b=E.array(arguments);return b.length==1&&b[0].constructor==Array&&(b=b[0]),c.setTimeout(function(){g.push.apply(a._data,b),a._parseData()._createThumbnails(b)},2),a},_getActive:function(){return this._controls.getActive()},validate:function(a){return!0},bind:function(a,b){return a=u(a),this.$("container").bind(a,this.proxy(b)),this},unbind:function(a){return a=u(a),this.$("container").unbind(a),this},trigger:function(b){return b=typeof b=="object"?a.extend(b,{scope:this}):{type:u(b),scope:this},this.$("container").trigger(b),this},addIdleState:function(a,b,c,d){return this._idle.add.apply(this._idle,E.array(arguments)),this},removeIdleState:function(a){return this._idle.remove.apply(this._idle,E.array(arguments)),this},enterIdleMode:function(){return this._idle.hide(),this},exitIdleMode:function(){return this._idle.showAll(),this},enterFullscreen:function(a){return this._fullscreen.enter.apply(this,E.array(arguments)),this},exitFullscreen:function(a){return this._fullscreen.exit.apply(this,E.array(arguments)),this},toggleFullscreen:function(a){return this._fullscreen[this.isFullscreen()?"exit":"enter"].apply(this,E.array(arguments)),this},bindTooltip:function(a,b){return this._tooltip.bind.apply(this._tooltip,E.array(arguments)),this},defineTooltip:function(a,b){return this._tooltip.define.apply(this._tooltip,E.array(arguments)),this},refreshTooltip:function(a){return this._tooltip.show.apply(this._tooltip,E.array(arguments)),this},openLightbox:function(){return this._lightbox.show.apply(this._lightbox,E.array(arguments)),this},closeLightbox:function(){return this._lightbox.hide.apply(this._lightbox,E.array(arguments)),this},getActiveImage:function(){return this._getActive().image||b},getActiveThumb:function(){return this._thumbnails[this._active].image||b},getMousePosition:function(a){return{x:a.pageX-this.$("container").offset().left,y:a.pageY-this.$("container").offset().top}},addPan:function(b){if(this._options.imageCrop===!1)return;b=a(b||this.getActiveImage());var c=this,d=b.width()/2,e=b.height()/2,f=parseInt(b.css("left"),10),g=parseInt(b.css("top"),10),h=f||0,i=g||0,j=0,k=0,l=!1,m=E.timestamp(),n=0,o=0,q=function(a,c,d){if(a>0){o=Math.round(Math.max(a*-1,Math.min(0,c)));if(n!==o){n=o;if(p===8)b.parent()["scroll"+d](o*-1);else{var e={};e[d.toLowerCase()]=o,b.css(e)}}}},r=function(a){if(E.timestamp()-m<50)return;l=!0,d=c.getMousePosition(a).x,e=c.getMousePosition(a).y},s=function(a){if(!l)return;j=b.width()-c._stageWidth,k=b.height()-c._stageHeight,f=d/c._stageWidth*j*-1,g=e/c._stageHeight*k*-1,h+=(f-h)/c._options.imagePanSmoothness,i+=(g-i)/c._options.imagePanSmoothness,q(k,i,"Top"),q(j,h,"Left")};return p===8&&(b.parent().scrollTop(i*-1).scrollLeft(h*-1),b.css({top:0,left:0})),this.$("stage").unbind("mousemove",r).bind("mousemove",r),this.addTimer("pan"+c._id,s,50,!0),this},proxy:function(a,b){return typeof a!="function"?n:(b=b||this,function(){return a.apply(b,E.array(arguments))})},removePan:function(){return this.$("stage").unbind("mousemove"),this.clearTimer("pan"+this._id),this},addElement:function(b){var c=this._dom;return a.each(E.array(arguments),function(a,b){c[b]=E.create("galleria-"+b)}),this},attachKeyboard:function(a){return this._keyboard.attach.apply(this._keyboard,E.array(arguments)),this},detachKeyboard:function(){return this._keyboard.detach.apply(this._keyboard,E.array(arguments)),this},appendChild:function(a,b){return this.$(a).append(this.get(b)||b),this},prependChild:function(a,b){return this.$(a).prepend(this.get(b)||b),this},remove:function(a){return this.$(E.array(arguments).join(",")).remove(),this},append:function(a){var b,c;for(b in a)if(a.hasOwnProperty(b))if(a[b].constructor===Array)for(c=0;a[b][c];c++)this.appendChild(b,a[b][c]);else this.appendChild(b,a[b]);return this},_scaleImage:function(b,c){b=b||this._controls.getActive();if(!b)return;var d=this,e,f=function(b){a(b.container).children(":first").css({top:Math.max(0,E.parseValue(b.image.style.top)),left:Math.max(0,E.parseValue(b.image.style.left)),width:E.parseValue(b.image.width),height:E.parseValue(b.image.height)})};return c=a.extend({width:this._stageWidth,height:this._stageHeight,crop:this._options.imageCrop,max:this._options.maxScaleRatio,min:this._options.minScaleRatio,margin:this._options.imageMargin,position:this._options.imagePosition},c),this._options.layerFollow&&this._options.imageCrop!==!0?typeof c.complete=="function"?(e=c.complete,c.complete=function(){e.call(b,b),f(b)}):c.complete=f:a(b.container).children(":first").css({top:0,left:0}),b.scale(c),this},updateCarousel:function(){return this._carousel.update(),this},resize:function(c,d){typeof c=="function"&&(d=c,c=b),c=a.extend({width:0,height:0},c);var e=this,f=this.$("container");return a.each(c,function(a,b){b||(f[a]("auto"),c[a]=e._getWH()[a])}),a.each(c,function(a,b){f[a](b)}),this.rescale(d)},rescale:function(a,c,d){var e=this;typeof a=="function"&&(d=a,a=b);var f=function(){e._stageWidth=a||e.$("stage").width(),e._stageHeight=c||e.$("stage").height(),e._scaleImage(),e._options.carousel&&e.updateCarousel(),e.trigger(Galleria.RESCALE),typeof d=="function"&&d.call(e)};return f.call(e),this},refreshImage:function(){return this._scaleImage(),this._options.imagePan&&this.addPan(),this},show:function(a,b,c){if(a===!1||!this._options.queue&&this._queue.stalled)return;a=Math.max(0,Math.min(parseInt(a,10),this.getDataLength()-1)),b=typeof b!="undefined"?!!b:a<this.getIndex(),c=c||!1;if(!c&&Galleria.History){Galleria.History.set(a.toString());return}return this._active=a,g.push.call(this._queue,{index:a,rewind:b}),this._queue.stalled||this._show(),this},_show:function(){var d=this,e=this._queue[0],f=this.getData(e.index);if(!f)return;var h=f.iframe||(this.isFullscreen()&&"big"in f?f.big:f.image),i=this._controls.getActive(),j=this._controls.getNext(),k=j.isCached(h),l=this._thumbnails[e.index],m=function(){a(j.image).trigger("mouseup")},n=function(b,e,f,h,i){return function(){var j;F.active=!1,d._queue.stalled=!1,E.toggleQuality(e.image,d._options.imageQuality),d._layers[d._controls.active].innerHTML="",a(f.container).css({zIndex:0,opacity:0}).show(),f.isIframe&&a(f.container).find("iframe").remove(),d.$("container").toggleClass("iframe",!!b.iframe),a(e.container).css({zIndex:1,left:0,top:0}).show(),d._controls.swap(),d._options.imagePan&&d.addPan(e.image),(b.link||d._options.lightbox||d._options.clicknext)&&a(e.image).css({cursor:"pointer"}).bind("mouseup",function(){if(d._options.clicknext&&!Galleria.TOUCH){d._options.pauseOnInteraction&&d.pause(),d.next();return}if(b.link){d._options.popupLinks?j=c.open(b.link,"_blank"):c.location.href=b.link;return}d._options.lightbox&&d.openLightbox()}),g.shift.call(d._queue),d._queue.length&&d._show(),d._playCheck(),d.trigger({type:Galleria.IMAGE,index:h.index,imageTarget:e.image,thumbTarget:i.image,galleriaData:b})}}(f,j,i,e,l);this._options.carousel&&this._options.carouselFollow&&this._carousel.follow(e.index);if(this._options.preload){var o,p,q=this.getNext(),r;try{for(p=this._options.preload;p>0;p--)o=new Galleria.Picture,r=d.getData(q),o.preload(this.isFullscreen()&&"big"in r?r.big:r.image),q=d.getNext(q)}catch(s){}}E.show(j.container),j.isIframe=!!f.iframe,a(d._thumbnails[e.index].container).addClass("active").siblings(".active").removeClass("active"),d.trigger({type:Galleria.LOADSTART,cached:k,index:e.index,rewind:e.rewind,imageTarget:j.image,thumbTarget:l.image,galleriaData:f}),j.load(h,function(c){var g=a(d._layers[1-d._controls.active]).html(f.layer||"").hide();d._scaleImage(c,{complete:function(c){"image"in i&&E.toggleQuality(i.image,!1),E.toggleQuality(c.image,!1),d._queue.stalled=!0,d.removePan(),d.setInfo(e.index),d.setCounter(e.index),f.layer&&(g.show(),(f.link||d._options.lightbox||d._options.clicknext)&&g.css("cursor","pointer").unbind("mouseup").mouseup(m)),d.trigger({type:Galleria.LOADFINISH,cached:k,index:e.index,rewind:e.rewind,imageTarget:c.image,thumbTarget:d._thumbnails[e.index].image,galleriaData:d.getData(e.index)});var h=d._options.transition;a.each({initial:i.image===null,touch:Galleria.TOUCH,fullscreen:d.isFullscreen()},function(a,c){if(c&&d._options[a+"Transition"]!==b)return h=d._options[a+"Transition"],!1});if(h in F.effects==0)n();else{var j={prev:i.container,next:c.container,rewind:e.rewind,speed:d._options.transitionSpeed||400};F.active=!0,F.init.call(d,h,j,n)}}})})},getNext:function(a){return a=typeof a=="number"?a:this.getIndex(),a===this.getDataLength()-1?0:a+1},getPrev:function(a){return a=typeof a=="number"?a:this.getIndex(),a===0?this.getDataLength()-1:a-1},next:function(){return this.getDataLength()>1&&this.show(this.getNext(),!1),this},prev:function(){return this.getDataLength()>1&&this.show(this.getPrev(),!0),this},get:function(a){return a in this._dom?this._dom[a]:null},getData:function(a){return a in this._data?this._data[a]:this._data[this._active]},getDataLength:function(){return this._data.length},getIndex:function(){return typeof this._active=="number"?this._active:!1},getStageHeight:function(){return this._stageHeight},getStageWidth:function(){return this._stageWidth},getOptions:function(a){return typeof a=="undefined"?this._options:this._options[a]},setOptions:function(b,c){return typeof b=="object"?a.extend(this._options,b):this._options[b]=c,this},play:function(a){return this._playing=!0,this._playtime=a||this._playtime,this._playCheck(),this.trigger(Galleria.PLAY),this},pause:function(){return this._playing=!1,this.trigger(Galleria.PAUSE),this},playToggle:function(a){return this._playing?this.pause():this.play(a)},isPlaying:function(){return this._playing},isFullscreen:function(){return this._fullscreen.active},_playCheck:function(){var a=this,b=0,c=20,d=E.timestamp(),e="play"+this._id;if(this._playing){this.clearTimer(e);var f=function(){b=E.timestamp()-d;if(b>=a._playtime&&a._playing){a.clearTimer(e),a.next();return}a._playing&&(a.trigger({type:Galleria.PROGRESS,percent:Math.ceil(b/a._playtime*100),seconds:Math.floor(b/1e3),milliseconds:b}),a.addTimer(e,f,c))};a.addTimer(e,f,c)}},setPlaytime:function(a){return this._playtime=a,this},setIndex:function(a){return this._active=a,this},setCounter:function(a){typeof a=="number"?a++:typeof a=="undefined"&&(a=this.getIndex()+1),this.get("current").innerHTML=a;if(p){var b=this.$("counter"),c=b.css("opacity");parseInt(c,10)===1?E.removeAlpha(b[0]):this.$("counter").css("opacity",c)}return this},setInfo:function(b){var c=this,d=this.getData(b);return a.each(["title","description"],function(a,b){var e=c.$("info-"+b);d[b]?e[d[b].length?"show":"hide"]().html(d[b]):e.empty().hide()}),this},hasInfo:function(a){var b="title description".split(" "),c;for(c=0;b[c];c++)if(!!this.getData(a)[b[c]])return!0;return!1},jQuery:function(b){var c=this,d=[];a.each(b.split(","),function(b,e){e=a.trim(e),c.get(e)&&d.push(e)});var e=a(c.get(d.shift()));return a.each(d,function(a,b){e=e.add(c.get(b))}),e},$:function(a){return this.jQuery.apply(this,E.array(arguments))}},a.each(s,function(a,b){var c=/_/.test(b)?b.replace(/_/g,""):b;Galleria[b.toUpperCase()]="galleria."+c}),a.extend(Galleria,{IE9:p===9,IE8:p===8,IE7:p===7,IE6:p===6,IE:p,WEBKIT:/webkit/.test(l),CHROME:/chrome/.test(l),SAFARI:/safari/.test(l)&&!/chrome/.test(l),QUIRK:p&&d.compatMode&&d.compatMode==="BackCompat",MAC:/mac/.test(navigator.platform.toLowerCase()),OPERA:!!c.opera,IPHONE:/iphone/.test(l),IPAD:/ipad/.test(l),ANDROID:/android/.test(l),TOUCH:"ontouchstart"in d}),Galleria.addTheme=function(b){b.name||Galleria.raise("No theme name specified"),typeof b.defaults!="object"?b.defaults={}:b.defaults=t(b.defaults);var d=!1,e;return typeof b.css=="string"?(a("link").each(function(a,c){e=new RegExp(b.css);if(e.test(c.href))return d=!0,D(b),!1}),d||a("script").each(function(a,f){e=new RegExp("galleria\\."+b.name.toLowerCase()+"\\."),e.test(f.src)&&(d=f.src.replace(/[^\/]*$/,"")+b.css,c.setTimeout(function(){E.loadCSS(d,"galleria-theme",function(){D(b)})},1))}),d||Galleria.raise("No theme CSS loaded")):D(b),b},Galleria.loadTheme=function(d,e){var f=!1,g=y.length,h=c.setTimeout(function(){Galleria.raise("Theme at "+d+" could not load, check theme path.",!0)},5e3);return Galleria.theme=b,E.loadScript(d,function(){c.clearTimeout(h);if(g){var b=[];a.each(Galleria.get(),function(c,d){var f=a.extend(d._original.options,{data_source:d._data},e);d.$("container").remove();var g=new Galleria;g._id=d._id,g.init(d._original.target,f),b.push(g)}),y=b}}),Galleria},Galleria.get=function(a){if(!!z[a])return z[a];if(typeof a!="number")return z;Galleria.raise("Gallery index "+a+" not found")},Galleria.configure=function(b,c){var d={};return typeof b=="string"&&c?(d[b]=c,b=d):a.extend(d,b),Galleria.configure.options=d,a.each(Galleria.get(),function(a,b){b.setOptions(d)}),Galleria},Galleria.configure.options={},Galleria.on=function(b,c){if(!b)return;c=c||n;var d=b+c.toString().replace(/\s/g,"")+E.timestamp();return a.each(Galleria.get(),function(a,e){e._binds.push(d),e.bind(b,c)}),Galleria.on.binds.push({type:b,callback:c,hash:d}),Galleria},Galleria.on.binds=[],Galleria.run=function(b,c){return a(b||"#galleria").galleria(c),Galleria},Galleria.addTransition=function(a,b){return F.effects[a]=b,Galleria},Galleria.utils=E,Galleria.log=function(){var b=E.array(arguments);if(!("console"in c&&"log"in c.console))return c.alert(b.join("<br>"));try{return c.console.log.apply(c.console,b)}catch(d){a.each(b,function(){c.console.log(this)})}},Galleria.ready=function(b){return typeof b!="function"?Galleria:(a.each(y,function(a,c){b.call(c,c._options)}),Galleria.ready.callbacks.push(b),Galleria)},Galleria.ready.callbacks=[],Galleria.raise=function(b,c){var d=c?"Fatal error":"Error",e=this,f={color:"#fff",position:"absolute",top:0,left:0,zIndex:1e5},g=function(b){var e='<div style="padding:4px;margin:0 0 2px;background:#'+(c?"811":"222")+'";>'+(c?"<strong>"+d+": </strong>":"")+b+"</div>";a.each(z,function(){var a=this.$("errors"),b=this.$("target");a.length||(b.css("position","relative"),a=this.addElement("errors").appendChild("target","errors").$("errors").css(f)),a.append(e)}),z.length||a("<div>").css(a.extend(f,{position:"fixed"})).append(e).appendTo(q().body)};if(i){g(b);if(c)throw new Error(d+": "+b)}else if(c){if(A)return;A=!0,c=!1,g("Gallery could not load.")}},Galleria.version=h,Galleria.requires=function(a,b){return b=b||"You need to upgrade Galleria to version "+a+" to use one or more components.",Galleria.version<a&&Galleria.raise(b,!0),Galleria},Galleria.Picture=function(b){this.id=b||null,this.image=null,this.container=E.create("galleria-image"),a(this.container).css({overflow:"hidden",position:"relative"}),this.original={width:0,height:0},this.ready=!1,this.isIframe=!1},Galleria.Picture.prototype={cache:{},show:function(){E.show(this.image)},hide:function(){E.moveOut(this.image)},clear:function(){this.image=null},isCached:function(a){return!!this.cache[a]},preload:function(b){a(new Image).load(function(a,b){return function(){b[a]=a}}(b,this.cache)).attr("src",b)},load:function(b,d,e){typeof d=="function"&&(e=d,d=null);if(this.isIframe){var f="if"+(new Date).getTime();return this.image=a("<iframe>",{src:b,frameborder:0,id:f,allowfullscreen:!0,css:{visibility:"hidden"}})[0],a(this.container).find("iframe,img").remove(),this.container.appendChild(this.image),a("#"+f).load(function(b,d){return function(){c.setTimeout(function(){a(b.image).css("visibility","visible"),typeof d=="function"&&d.call(b,b)},10)}}(this,e)),this.container}this.image=new Image;var g=0,h=!1,i=!1,j=a(this.container),l=a(this.image),m=function(){h?k?a(this).attr("src",k):Galleria.raise("Image not found: "+b):(h=!0,c.setTimeout(function(a,b){return function(){a.attr("src",b+"?"+E.timestamp())}}(a(this),b),50))},n=function(b,e,f){return function(){var g=function(){a(this).unbind("load"),b.original=d||{height:this.height,width:this.width},b.container.appendChild(this),b.cache[f]=f,typeof e=="function"&&c.setTimeout(function(){e.call(b,b)},1)};!this.width||!this.height?c.setTimeout(function(b){return function(){b.width&&b.height?g.call(b):i?Galleria.raise("Could not extract width/height from image: "+b.src+". Traced measures: width:"+b.width+"px, height: "+b.height+"px."):(a(new Image).load(n).attr("src",b.src),i=!0)}}(this),2):g.call(this)}}(this,e,b);return j.find("iframe,img").remove(),l.css("display","block"),E.hide(this.image),a.each("minWidth minHeight maxWidth maxHeight".split(" "),function(a,b){l.css(b,/min/.test(b)?"0":"none")}),l.load(n).error(m).attr("src",b),this.container},scale:function(c){var d=this;c=a.extend({width:0,height:0,min:b,max:b,margin:0,complete:n,position:"center",crop:!1,canvas:!1},c);if(this.isIframe){a(this.image).width(c.width).height(c.height).removeAttr("width").removeAttr("height"),a(this.container).width(c.width).height(c.height),c.complete.call(d,d);try{this.image.contentWindow&&a(this.image.contentWindow).trigger("resize")}catch(e){}return this.container}if(!this.image)return this.container;var f,g,h=a(d.container),i;return E.wait({until:function(){return f=c.width||h.width()||E.parseValue(h.css("width")),g=c.height||h.height()||E.parseValue(h.css("height")),f&&g},success:function(){var b=(f-c.margin*2)/d.original.width,e=(g-c.margin*2)/d.original.height,h=Math.min(b,e),j=Math.max(b,e),k={"true":j,width:b,height:e,"false":h,landscape:d.original.width>d.original.height?j:h,portrait:d.original.width<d.original.height?j:h},l=k[c.crop.toString()],m="";c.max&&(l=Math.min(c.max,l)),c.min&&(l=Math.max(c.min,l)),a.each(["width","height"],function(b,c){a(d.image)[c](d[c]=d.image[c]=Math.round(d.original[c]*l))}),a(d.container).width(f).height(g),c.canvas&&B&&(B.elem.width=d.width,B.elem.height=d.height,m=d.image.src+":"+d.width+"x"+d.height,d.image.src=B.cache[m]||function(a){B.context.drawImage(d.image,0,0,d.original.width*l,d.original.height*l);try{return i=B.elem.toDataURL(),B.length+=i.length,B.cache[a]=i,i}catch(b){return d.image.src}}(m));var n={},o={},p=function(b,c,e){var f=0;if(/\%/.test(b)){var g=parseInt(b,10)/100,h=d.image[c]||a(d.image)[c]();f=Math.ceil(h*-1*g+e*g)}else f=E.parseValue(b);return f},q={top:{top:0},left:{left:0},right:{left:"100%"},bottom:{top:"100%"}};a.each(c.position.toLowerCase().split(" "),function(a,b){b==="center"&&(b="50%"),n[a?"top":"left"]=b}),a.each(n,function(b,c){q.hasOwnProperty(c)&&a.extend(o,q[c])}),n=n.top?a.extend(n,o):o,n=a.extend({top:"50%",left:"50%"},n),a(d.image).css({position:"absolute",top:p(n.top,"height",g),left:p(n.left,"width",f)}),d.show(),d.ready=!0,c.complete.call(d,d)},error:function(){Galleria.raise("Could not scale image: "+d.image.src)},timeout:1e3}),this}},a.extend(a.easing,{galleria:function(a,b,c,d,e){return(b/=e/2)<1?d/2*b*b*b+c:d/2*((b-=2)*b*b+2)+c},galleriaIn:function(a,b,c,d,e){return d*(b/=e)*b+c},galleriaOut:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c}}),a.fn.galleria=function(b){var c=this.selector;return a(this).length?this.each(function(){a.data(this,"galleria")||a.data(this,"galleria",(new Galleria).init(this,b))}):(a(function(){a(c).length?a(c).galleria(b):Galleria.utils.wait({until:function(){return a(c).length},success:function(){a(c).galleria(b)},error:function(){Galleria.raise('Init failed: Galleria could not find the element "'+c+'".')},timeout:5e3})}),this)}})(jQuery);
View
73 vendor/assets/javascripts/gallery/galleria.js
@@ -815,6 +815,7 @@ var undef,
},
loadCSS : function( href, id, callback ) {
+ Galleria.log('load CSS:', href, id);
var link,
length;
@@ -889,6 +890,7 @@ var undef,
error: function() {
$loader.remove();
+ Galleria.log("Theme CSS likely didn't include the dummy #galleria-loader marker introduced and required since Galleria 1.2.8");
// If failed, tell the dev to download the latest theme
Galleria.raise( 'Theme CSS could not load after 20 sec. Please download the latest theme at http://galleria.io/customer/', true );
@@ -5036,6 +5038,8 @@ Galleria.addTheme = function( theme ) {
// look for manually added CSS
$('link').each(function( i, link ) {
+ Galleria.log('Trying to load Galleria theme from manually added CSS');
+
reg = new RegExp( theme.css );
if ( reg.test( link.href ) ) {
@@ -5051,12 +5055,23 @@ Galleria.addTheme = function( theme ) {
// else look for the absolute path and load the CSS dynamic
if ( !css ) {
+ Galleria.log('Trying to load Galleria theme CSS from absolute path');
$('script').each(function( i, script ) {
+ var themeName = theme.name.toLowerCase();
+ Galleria.log('Looking for Galleria theme:', themeName);
+
+ var matchExpr1 = 'galleria\\.' + themeName + '\\.';
+ var matchExpr2 = 'galleria\\/' + themeName + '\\.';
+
+ Galleria.log('Find match for:', matchExpr1, matchExpr2);
+ Galleria.log('In script src:', script.src);
// look for the theme script
- reg = new RegExp( 'galleria\\.' + theme.name.toLowerCase() + '\\.' );
- if( reg.test( script.src )) {
+ reg1 = new RegExp( matchExpr1 );
+ reg2 = new RegExp( matchExpr2 );
+ if( reg1.test(script.src) || reg2.test(script.src) ) {
+ Galleria.log('Theme match found!');
// we have a match
css = script.src.replace(/[^\/]*$/, '') + theme.css;
@@ -5094,6 +5109,15 @@ Galleria.addTheme = function( theme ) {
@returns Galleria
*/
+Galleria.loadNamedTheme = function(name, options) {
+ var prefix = 'gallery/galleria/';
+ Galleria.loadTheme(prefix + name + '.js');
+}
+
+Galleria.loadAssetTheme = function(name, options) {
+ var prefix = '/assets/gallery/galleria/';
+ Galleria.loadTheme(prefix + name + '.js');
+}
Galleria.loadTheme = function( src, options ) {
@@ -5296,6 +5320,9 @@ Galleria.utils = Utils;
*/
Galleria.log = function() {
+ if (Galleria.configure.options['log'] != true) {
+ return null;
+ }
var args = Utils.array( arguments );
if( 'console' in window && 'log' in window.console ) {
try {
@@ -5467,6 +5494,35 @@ Galleria.Picture.prototype = {
// the inherited cache object
cache: {},
+ normalizeSrc: function(src) {
+ Galleria.log('attempt normalize', src);
+
+ var normalizedSrc = src;
+
+ if (Galleria.configure.options.assets == true) {
+ var regAsAs = new RegExp('assets\\/assets');
+
+ if (regAsAs.test(src)) {
+ Galleria.log('Replace double assets/assets in image path');
+ normalizedSrc = src.replace("assets\/assets", "assets")
+ } else {
+ var regAs = new RegExp('assets\\/');
+ if (!regAs.test(src)) {
+ Galleria.log('Add missing assets in image path:', src);
+ normalizedSrc = 'assets/' + src;
+ }
+ }
+ // ensure image path is never relative to current page!
+ if (!new RegExp('^\\/').test(normalizedSrc)) {
+ normalizedSrc = '/' + normalizedSrc;
+ }
+ }
+ Galleria.log('normalized src to', normalizedSrc);
+
+ // var srcStamp = src + '?' + Utils.timestamp();
+ return normalizedSrc;
+ },
+
// show the image on stage
show: function() {
Utils.show( this.image );
@@ -5502,6 +5558,12 @@ Galleria.Picture.prototype = {
*/
preload: function( src ) {
+ Galleria.log('attempt preload', src);
+
+ var src = this.normalizeSrc(src);
+
+ Galleria.log('normalized', src);
+
$( new Image() ).load((function(src, cache) {
return function() {
cache[ src ] = src;
@@ -5521,11 +5583,17 @@ Galleria.Picture.prototype = {
*/
load: function(src, size, callback) {
+ Galleria.log('load image:', src, size);
+
+ var src = this.normalizeSrc(src);
+
+ Galleria.log('load normalized image:', src, size);
if ( typeof size == 'function' ) {
callback = size;
size = null;
}
+
if( this.isIframe ) {
var id = 'if'+new Date().getTime();
@@ -5856,6 +5924,7 @@ Galleria.Picture.prototype = {
}
};
+
// our own easings
$.extend( $.easing, {
View
2 vendor/assets/javascripts/gallery/galleria/classic.js
@@ -14,7 +14,7 @@
Galleria.addTheme({
name: 'classic',
author: 'Galleria',
- css: '/assets/gallery/galleria/classic.css',
+ css: 'classic.css',
defaults: {
transition: 'slide',
thumbCrop: 'height',
View
2 vendor/assets/javascripts/gallery/galleria/classic.min.js
@@ -5,4 +5,4 @@
* Licensed under the MIT license
* https://raw.github.com/aino/galleria/master/LICENSE
*
- */(function(a){Galleria.addTheme({name:"classic",author:"Galleria",css:"galleria.classic.css",defaults:{transition:"slide",thumbCrop:"height",_toggleInfo:!0},init:function(b){Galleria.requires(1.28,"This version of Classic theme requires Galleria 1.2.8 or later"),this.addElement("info-link","info-close"),this.append({info:["info-link","info-close"]});var c=this.$("info-link,info-close,info-text"),d=Galleria.TOUCH,e=d?"touchstart":"click";this.$("loader,counter").show().css("opacity",.4),d||(this.addIdleState(this.get("image-nav-left"),{left:-50}),this.addIdleState(this.get("image-nav-right"),{right:-50}),this.addIdleState(this.get("counter"),{opacity:0})),b._toggleInfo===!0?c.bind(e,function(){c.toggle()}):(c.show(),this.$("info-link, info-close").hide()),this.bind("thumbnail",function(b){d?a(b.thumbTarget).css("opacity",this.getIndex()?1:.6):(a(b.thumbTarget).css("opacity",.6).parent().hover(function(){a(this).not(".active").children().stop().fadeTo(100,1)},function(){a(this).not(".active").children().stop().fadeTo(400,.6)}),b.index===this.getIndex()&&a(b.thumbTarget).css("opacity",1))}),this.bind("loadstart",function(b){b.cached||this.$("loader").show().fadeTo(200,.4),this.$("info").toggle(this.hasInfo()),a(b.thumbTarget).css("opacity",1).parent().siblings().children().css("opacity",.6)}),this.bind("loadfinish",function(a){this.$("loader").fadeOut(200)})}})})(jQuery);
+ */(function(a){Galleria.addTheme({name:"classic",author:"Galleria",css:'classic.css',defaults:{transition:"slide",thumbCrop:"height",_toggleInfo:!0},init:function(b){Galleria.requires(1.28,"This version of Classic theme requires Galleria 1.2.8 or later"),this.addElement("info-link","info-close"),this.append({info:["info-link","info-close"]});var c=this.$("info-link,info-close,info-text"),d=Galleria.TOUCH,e=d?"touchstart":"click";this.$("loader,counter").show().css("opacity",.4),d||(this.addIdleState(this.get("image-nav-left"),{left:-50}),this.addIdleState(this.get("image-nav-right"),{right:-50}),this.addIdleState(this.get("counter"),{opacity:0})),b._toggleInfo===!0?c.bind(e,function(){c.toggle()}):(c.show(),this.$("info-link, info-close").hide()),this.bind("thumbnail",function(b){d?a(b.thumbTarget).css("opacity",this.getIndex()?1:.6):(a(b.thumbTarget).css("opacity",.6).parent().hover(function(){a(this).not(".active").children().stop().fadeTo(100,1)},function(){a(this).not(".active").children().stop().fadeTo(400,.6)}),b.index===this.getIndex()&&a(b.thumbTarget).css("opacity",1))}),this.bind("loadstart",function(b){b.cached||this.$("loader").show().fadeTo(200,.4),this.$("info").toggle(this.hasInfo()),a(b.thumbTarget).css("opacity",1).parent().siblings().children().css("opacity",.6)}),this.bind("loadfinish",function(a){this.$("loader").fadeOut(200)})}})})(jQuery);
View
4 vendor/assets/stylesheets/gallery/galleria/classic.css
@@ -59,7 +59,7 @@
right: 10px;
z-index: 2;
display: none;
- background: url(/assets/galleria/classic/loader.gif) no-repeat 2px 2px;
+ background: url(/assets/gallery/galleria/classic/loader.gif) no-repeat 2px 2px;
}
.galleria-info {
width: 50%;
@@ -212,6 +212,6 @@
.galleria-info-close,
.galleria-image-nav-left,
.galleria-image-nav-right {
- background-image: url(/assets/galleria/classic/map.png);
+ background-image: url(/assets/gallery/galleria/classic/map.png);
background-repeat: no-repeat;
}

0 comments on commit 3f3649a

Please sign in to comment.
Something went wrong with that request. Please try again.