Created
December 18, 2010 17:38
-
-
Save cmilfont/746691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="template" style="display:none;"> | |
<tpl for="."> | |
<div style="width:250px; float:left; background-color:#777777; margin: 5px;"> | |
<img src={profile_image_url} /> | |
<span> | |
<a title="{name}" href="http://twitter.com/#!/{screen_name}"><strong>{screen_name}</strong></a> | |
<span>{name}</span> | |
</span> | |
<div>{description}</div> | |
</div> | |
</tpl> | |
</div> | |
<div id="palestrantes"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.XTemplate.from = function(el){ | |
el = Ext.getDom(el); | |
var string = el.value || el.innerHTML; | |
string = string.replace(/%7B/g, "{").replace(/%7D/g, "}").replace(/%21/g, "!"); | |
return new Ext.XTemplate(string); | |
}; | |
if(!Array.prototype.add) { | |
Array.prototype.add = function(item) { | |
this[this.length] = item; | |
return this; | |
}; | |
}; | |
var TwitterReader = new Ext.data.JsonReader({ | |
idProperty: 'id', root: 'users', totalProperty: 'results', | |
fields: [ | |
{name: 'description', mapping: 'description'}, | |
{name: 'profile_image_url', mapping: 'profile_image_url'}, | |
{name: 'name', mapping: 'name'}, | |
{name: 'screen_name', mapping: 'screen_name'} | |
] | |
}); | |
var TwitterProxy = new Ext.data.ScriptTagProxy({ | |
url: 'http://api.twitter.com/1/cmilfont/braziljs/members.json', restful: true | |
}); | |
var store = new Ext.data.Store({ reader: TwitterReader, proxy: TwitterProxy }); | |
Ext.onReady(function(){ | |
Ext.QuickTips.init(); | |
data = []; | |
store.load({ | |
callback: function(records, options, sucess) { | |
this.each(function(record){ | |
data.add({ | |
name: record.get("name"), | |
screen_name: record.get("screen_name"), | |
description: record.get("description"), | |
profile_image_url: record.get("profile_image_url") | |
}); | |
}); | |
var tpl = Ext.XTemplate.from("template"); | |
tpl.compile(); | |
tpl.append("palestrantes", data); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment