1 |
- function yox_picasa(){var f=jQuery,l=/http:\/\/picasaweb\.google\.\w+\/([^\/#\?]+)\/?([^\/#\?]+)?(\?([^#]*))?/;this.getImagesData=function(d,j){function m(a,d,c){for(var a=parseInt(a),g=d.length-1;g>=0;g--){var e=d[g];if(a>=e)return c?g<d.length-1?d[g+1]:e:e}return a}function n(b,c){var e=c==="album",g=[];jQuery.each(b.feed.entry,function(d,b){var c=e?b.title.$t+" ("+b.gphoto$numphotos.$t+" images)":b.summary.$t;if(!a.filter||c.match(a.filter)){var f=b.media$group.media$content[0],c={thumbnailSrc:b.media$group.media$thumbnail[1].url, link:b.link[1].href,media:{src:f.url,title:c,alt:c,width:f.width,height:f.height}};if(e)c.data={album:b.gphoto$name.$t};g.push(c)}});if(h.filter){var f=Yox.getUrlData(d.dataUrl);delete f.queryFields.filter;d.dataUrl=Yox.urlDataToPath(f)}d.dataSourceOptions&&d.dataSourceOptions.filter&&delete d.dataSourceOptions.filter;return g}var i=[94,110,128,200,220,288,320,400,512,576,640,720,800,912,1024,1152,1280,1440,1600],h={};if(d.dataUrl){var c=d.dataUrl.match(l);if(c&&c.length>1){h.user=c[1];if(c[2])h.album= c[2];c[4]&&f.extend(h,Yox.queryToJson(c[4]))}}var a=jQuery.extend({},{url:"http://picasaweb.google.com/data/feed/api/",setThumbnail:!0,setSingleAlbumThumbnails:!0,setTitle:!0,alt:"json",thumbsize:64},h,d.dataSourceOptions);if(a.user&&!a.album&&!a.q)a.thumbsize=104;if(a.tags)a.tag=a.tags;a.album==""&&delete a.album;var c=screen.width>screen.height?screen.width:screen.height,k=a.imgmax&&f.inArray(a.imgmax,i)==-1?a.imgmax:null;if(!a.imgmax||k||c<a.imgmax)a.imgmax=m(k||c,i,a.roundSizeUp);if(a.filter&& typeof a.filter==="string")a.filter=RegExp(a.filter,"i");var i=function(){var b=a.url;a.user&&a.user!="lh"?(b+="user/"+a.user,a.album&&(b+="/album/"+a.album)):b+="all";return b}(a),e={};if(d.onLoadBegin)d.onLoadBegin();f.jsonp({url:i,async:!1,dataType:"jsonp",data:a,callbackParameter:"callback",success:function(b){console.log(b);if(!b.feed.entry||b.feed.entry.length==0){if(d.onNoData)d.onNoData()}else{var c=b.feed.entry[0].category[0].term.match(/.*#(.*)/)[1];c==="album"&&f.extend(e,{title:b.feed.title.$t, createGroups:!0});e.images=n(b,c);if(b.feed.title)e.title=b.feed.title.$t;e.images.length>0&&a.setThumbnail&&!a.setSingleAlbumThumbnails&&f.extend(e,{isGroup:!0,link:b.feed.link[1].href,thumbnailSrc:b.feed.icon.$t,title:b.feed.title.$t});j&&j(e);if(d.onLoadComplete)d.onLoadComplete()}},error:function(){if(d.onLoadError)d.onLoadError("Picasa plugin encountered an error while retrieving data")}})}};
|