/** * jQuery plugin * Picasa Web Albums inline integration * * by Eugene Bond * http://bondariev.info/category/web/picasaweb/ */ jQuery.picasaweb = { _static: 1, cache: {}, // 72,144,288,576,640 options: {width_m: "288", width_s: "144"}, init: function(rule, options) { if (options) jQuery.extend(jQuery.picasaweb.options, options); var rule = rule || "a"; $(rule).each( function() { if (this.picasaWasHere) return; var h = this.href, re = /^http:\/\/picasaweb.google.([a-z\.]+)\/(.*)$/i, m = h.match(re), ga; if (m) { ga = m[2].split('/'); this.picasaGallery = ga[0]; this.picasaAlbum = ga[1]; this.picasaDomain = m[1]; this.picasaId = this.picasaAlbum + "_" + jQuery.picasaweb._static++; jQuery.picasaweb.cache[h] = this; jQuery.picasaweb.picasaCall.apply(this); } this.picasaWasHere = true; } ); }, picasaCall: function() { var call = "http://picasaweb.google."+this.picasaDomain+"/data/feed/api/user/" + this.picasaGallery; if (this.picasaAlbum) call = call + "/album/" + this.picasaAlbum; else return; // Return for now. Later will grab an albums also var a = this; window['_f_'+a.picasaId] = function(data) { $.picasaweb.picasaAlbum(data, a); } call = call + "?alt=json-in-script&callback=" + '_f_'+a.picasaId; document.open(); document.write(''); document.close(); }, _getAlternate: function(a) { return $.grep(a, function(n,i) {return n.rel=="alternate"})[0].href; }, picasaAlbum: function(json, link) { var data = json.feed, i, a; a = link || false; if (!a) { for (i=0; i'); } t = e[0].summary["$t"] || e[0].title["$t"]; $(a).after('

'+data.title["$t"]+'

'+data.subtitle["$t"]+'
'+t+'
    '+u.join("")+'
'); $(a).hide(); $("#picasa-album-"+a.picasaId+" .picasa-photos a").click(function(event) { event.stopPropagation(); event.preventDefault(); $("#picasa-album-"+a.picasaId+" #picasa-loader").height($("#picasa-album-"+a.picasaId+" .picasa-preview a img").height()); $("#picasa-album-"+a.picasaId+" #picasa-loader").width($("#picasa-album-"+a.picasaId+" .picasa-preview a img").width()); $("#picasa-album-"+a.picasaId+" #picasa-loader").show(); $("#picasa-album-"+a.picasaId+" .picasa-photo-summary").html(this.title); $("#picasa-album-"+a.picasaId+" .picasa-preview a img").hide(); $("#picasa-album-"+a.picasaId+" .picasa-preview a").attr("href", this.rel); $("#picasa-album-"+a.picasaId+" .picasa-preview a img").attr("src", this.href); }); $("#picasa-album-"+a.picasaId+" .picasa-preview a img").bind("load", function() {$("#picasa-album-"+a.picasaId+" #picasa-loader").hide(); $("#picasa-album-"+a.picasaId+" .picasa-preview a img").show();}); } }