-/*\r
- * Ext JS Library 2.2.1\r
- * Copyright(c) 2006-2009, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
-\r
-/*\r
- * Ext JS Library 2.0\r
- * Copyright(c) 2006-2007, Ext JS, LLC.\r
- * licensing@extjs.com\r
- * \r
- * http://extjs.com/license\r
- */\r
- \r
+/*!
+ * Ext JS Library 3.0.3
+ * Copyright(c) 2006-2009 Ext JS, LLC
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
var ImageChooser = function(config){\r
this.config = config;\r
}\r
ImageChooser.prototype = {\r
// cache data by image name for easy lookup\r
lookup : {},\r
- \r
+\r
show : function(el, callback){\r
if(!this.win){\r
this.initTemplates();\r
- \r
+\r
this.store = new Ext.data.JsonStore({\r
url: this.config.url,\r
root: 'images',\r
}\r
});\r
this.store.load();\r
- \r
+\r
var formatSize = function(data){\r
if(data.size < 1024) {\r
return data.size + " bytes";\r
return (Math.round(((data.size*10) / 1024))/10) + " KB";\r
}\r
};\r
- \r
+\r
var formatData = function(data){\r
data.shortName = data.name.ellipse(15);\r
data.sizeString = formatSize(data);\r
this.lookup[data.name] = data;\r
return data;\r
};\r
- \r
+\r
this.view = new Ext.DataView({\r
tpl: this.thumbTemplate,\r
singleSelect: true,\r
},\r
prepareData: formatData.createDelegate(this)\r
});\r
- \r
+\r
var cfg = {\r
title: 'Choose an Image',\r
id: 'img-chooser-dlg',\r
valueField: 'name',\r
lazyInit: false,\r
value: 'name',\r
- store: new Ext.data.SimpleStore({\r
+ store: new Ext.data.ArrayStore({\r
fields: ['name', 'desc'],\r
data : [['name', 'Name'],['size', 'File Size'],['lastmod', 'Last Modified']]\r
}),\r
Ext.apply(cfg, this.config);\r
this.win = new Ext.Window(cfg);\r
}\r
- \r
+\r
this.reset();\r
this.win.show(el);\r
this.callback = callback;\r
this.animateTarget = el;\r
},\r
- \r
+\r
initTemplates : function(){\r
this.thumbTemplate = new Ext.XTemplate(\r
'<tpl for=".">',\r
'</tpl>'\r
);\r
this.thumbTemplate.compile();\r
- \r
+\r
this.detailsTemplate = new Ext.XTemplate(\r
'<div class="details">',\r
'<tpl for=".">',\r
);\r
this.detailsTemplate.compile();\r
},\r
- \r
+\r
showDetails : function(){\r
var selNode = this.view.getSelectedNodes();\r
var detailEl = Ext.getCmp('img-detail-panel').body;\r
detailEl.update('');\r
}\r
},\r
- \r
+\r
filter : function(){\r
var filter = Ext.getCmp('filter');\r
this.view.store.filter('name', filter.getValue());\r
this.view.select(0);\r
},\r
- \r
+\r
sortImages : function(){\r
var v = Ext.getCmp('sortSelect').getValue();\r
this.view.store.sort(v, v == 'name' ? 'asc' : 'desc');\r
this.view.select(0);\r
},\r
- \r
+\r
reset : function(){\r
if(this.win.rendered){\r
Ext.getCmp('filter').reset();\r
this.view.store.clearFilter();\r
this.view.select(0);\r
},\r
- \r
+\r
doCallback : function(){\r
var selNode = this.view.getSelectedNodes()[0];\r
var callback = this.callback;\r
}\r
});\r
},\r
- \r
+\r
onLoadException : function(v,o){\r
- this.view.getEl().update('<div style="padding:10px;">Error loading images.</div>'); \r
+ this.view.getEl().update('<div style="padding:10px;">Error loading images.</div>');\r
}\r
};\r
\r