/** * Galleria Picasa Plugin 2012-04-04 * http://galleria.io * * Licensed under the MIT license * https://raw.github.com/aino/galleria/master/LICENSE * */(function(a){Galleria.requires(1.25,"The Picasa Plugin requires Galleria version 1.2.5 or later.");var b=Galleria.utils.getScriptPath();Galleria.Picasa=function(){this.options={max:30,imageSize:"medium",thumbSize:"thumb",complete:function(){}}},Galleria.Picasa.prototype={constructor:Galleria.Picasa,search:function(a,b){return this._call("search","all",{q:a},b)},user:function(a,b){return this._call("user","user/"+a,b)},useralbum:function(a,b,c){return this._call("useralbum","user/"+a+"/album/"+b,c)},setOptions:function(b){return a.extend(this.options,b),this},_call:function(b,c,d,e){c="https://picasaweb.google.com/data/feed/api/"+c+"?",typeof d=="function"&&(e=d,d={});var f=this;d=a.extend({kind:"photo",access:"public","max-results":this.options.max,thumbsize:this._getSizes().join(","),alt:"json-in-script",callback:"?"},d),a.each(d,function(a,b){c+="&"+a+"="+b});var g=!1;return Galleria.utils.wait({until:function(){return g},success:function(){f._parse.call(f,g.feed.entry,e)},error:function(){var a="";b=="user"?a="user not found.":b=="useralbum"&&(a="album or user not found."),Galleria.raise("Picasa request failed"+(a?": "+a:"."))},timeout:5e3}),a.getJSON(c,function(a){g=a}),f},_getSizes:function(){var b=this,c={small:"72c",thumb:"104u",medium:"640u",big:"1024u",original:"1600u"},d=b.options,e={},f,g=[32,48,64,72,94,104,110,128,144,150,160,200,220,288,320,400,512,576,640,720,800,912,1024,1152,1280,1440,1600];return a(["thumbSize","imageSize"]).each(function(){d[this]in c?e[this]=c[d[this]]:(f=Galleria.utils.parseValue(d[this]),f>1600?f=1600:a.each(g,function(a){if(f").css({width:48,height:48,opacity:.7,background:"#000 url("+b+"loader.gif) no-repeat 50% 50%"});if(f.length){if(typeof Galleria.Picasa.prototype[f[0]]!="function")return Galleria.raise(f[0]+" method not found in Picasa plugin"),c.apply(this,e);if(!f[1])return Galleria.raise("No picasa argument found"),c.apply(this,e);window.setTimeout(function(){d.$("target").append(i)},100),g=new Galleria.Picasa,typeof d._options.picasaOptions=="object"&&g.setOptions(d._options.picasaOptions);var j=[];if(f[0]=="useralbum"){j=f[1].split("/");if(j.length!=2){Galleria.raise("Picasa useralbum not correctly formatted (should be [user]/[album])");return}}else j.push(f[1]);j.push(function(a){d._data=a,i.remove(),d.trigger(Galleria.DATA),g.options.complete.call(g,a)}),g[f[0]].apply(g,j)}else c.apply(this,e)}})(jQuery);