diff options
Diffstat (limited to 'js/dojo-1.6/dojox/image/FlickrBadge.xd.js')
| -rw-r--r-- | js/dojo-1.6/dojox/image/FlickrBadge.xd.js | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/js/dojo-1.6/dojox/image/FlickrBadge.xd.js b/js/dojo-1.6/dojox/image/FlickrBadge.xd.js new file mode 100644 index 0000000..8b5df10 --- /dev/null +++ b/js/dojo-1.6/dojox/image/FlickrBadge.xd.js @@ -0,0 +1,122 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.image.FlickrBadge"],
+["require", "dojox.image.Badge"],
+["require", "dojox.data.FlickrRestStore"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.image.FlickrBadge"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.image.FlickrBadge"] = true;
+dojo.provide("dojox.image.FlickrBadge");
+
+dojo.require("dojox.image.Badge");
+dojo.require("dojox.data.FlickrRestStore");
+
+dojo.declare("dojox.image.FlickrBadge", dojox.image.Badge, {
+ children: "a.flickrImage",
+
+ // userid: String
+ // If you know your Flickr userid, you can set it to prevent a call to fetch the id
+ userid: "",
+
+ // username: String
+ // Your Flickr username
+ username: "",
+
+ // setid: String
+ // The id of the set to display
+ setid: "",
+
+ // tags: String|Array
+ // A comma separated list of tags or an array of tags to grab from Flickr
+ tags: "",
+
+ // searchText: String
+ // Free text search. Photos who's title, description, or tags contain the text will be displayed
+ searchText: "",
+
+ // target: String
+ // Where to display the pictures when clicked on. Valid values are the same as the target attribute
+ // of the A tag.
+ target: "",
+
+ apikey: "8c6803164dbc395fb7131c9d54843627",
+ _store: null,
+
+ postCreate: function(){
+ if(this.username && !this.userid){
+ var def = 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"
+ });
+ def.addCallback(this, function(data){
+ if(data.user && data.user.nsid){
+ this.userid = data.user.nsid;
+ if(!this._started){
+ this.startup();
+ }
+ }
+ });
+ }
+ },
+
+ startup: function(){
+ if(this._started){ return; }
+ if(this.userid){
+ var query = {
+ userid: this.userid
+ };
+ if(this.setid){
+ query["setid"] = this.setid;
+ }
+ if(this.tags){
+ query.tags = this.tags;
+ }
+ if(this.searchText){
+ query.text = this.searchText;
+ }
+ var args = arguments;
+ this._store = new dojox.data.FlickrRestStore({ apikey: this.apikey });
+ this._store.fetch({
+ count: this.cols * this.rows,
+ query: query,
+ onComplete: dojo.hitch(this, function(items){
+ dojo.forEach(items, function(item){
+ var a = dojo.doc.createElement("a");
+ dojo.addClass(a, "flickrImage");
+ a.href = this._store.getValue(item, "link");
+ if(this.target){
+ a.target = this.target;
+ }
+
+ var img = dojo.doc.createElement("img");
+ img.src = this._store.getValue(item, "imageUrlThumb");
+ dojo.style(img, {
+ width: "100%",
+ height: "100%"
+ });
+
+ a.appendChild(img);
+ this.domNode.appendChild(a);
+ }, this);
+ dojox.image.Badge.prototype.startup.call(this, args);
+ })
+ });
+ }
+ }
+});
+
+}
+
+}};});
|
