Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / image / FlickrBadge.js @ 12

History | View | Annotate | Download (1.83 KB)

1 9 andrej.cim
/*
2
        Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
3
        Available via Academic Free License >= 2.1 OR the modified BSD license.
4
        see: http://dojotoolkit.org/license for details
5
*/
6
7
8
if(!dojo._hasResource["dojox.image.FlickrBadge"]){
9
dojo._hasResource["dojox.image.FlickrBadge"]=true;
10
dojo.provide("dojox.image.FlickrBadge");
11
dojo.require("dojox.image.Badge");
12
dojo.require("dojox.data.FlickrRestStore");
13
dojo.declare("dojox.image.FlickrBadge",dojox.image.Badge,{children:"a.flickrImage",userid:"",username:"",setid:"",tags:"",searchText:"",target:"",apikey:"8c6803164dbc395fb7131c9d54843627",_store:null,postCreate:function(){
14
if(this.username&&!this.userid){
15
var _1=dojo.io.script.get({url:"http://www.flickr.com/services/rest/",preventCache:true,content:{format:"json",method:"flickr.people.findByUsername",api_key:this.apikey,username:this.username},callbackParamName:"jsoncallback"});
16
_1.addCallback(this,function(_2){
17
if(_2.user&&_2.user.nsid){
18
this.userid=_2.user.nsid;
19
if(!this._started){
20
this.startup();
21
}
22
}
23
});
24
}
25
},startup:function(){
26
if(this._started){
27
return;
28
}
29
if(this.userid){
30
var _3={userid:this.userid};
31
if(this.setid){
32
_3["setid"]=this.setid;
33
}
34
if(this.tags){
35
_3.tags=this.tags;
36
}
37
if(this.searchText){
38
_3.text=this.searchText;
39
}
40
var _4=arguments;
41
this._store=new dojox.data.FlickrRestStore({apikey:this.apikey});
42
this._store.fetch({count:this.cols*this.rows,query:_3,onComplete:dojo.hitch(this,function(_5){
43
dojo.forEach(_5,function(_6){
44
var a=dojo.doc.createElement("a");
45
dojo.addClass(a,"flickrImage");
46
a.href=this._store.getValue(_6,"link");
47
if(this.target){
48
a.target=this.target;
49
}
50
var _7=dojo.doc.createElement("img");
51
_7.src=this._store.getValue(_6,"imageUrlThumb");
52
dojo.style(_7,{width:"100%",height:"100%"});
53
a.appendChild(_7);
54
this.domNode.appendChild(a);
55
},this);
56
dojox.image.Badge.prototype.startup.call(this,_4);
57
})});
58
}
59
}});
60
}