Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / examples / view / chooser.js
index 4f8cfc9..9b28d76 100644 (file)
@@ -1,19 +1,9 @@
-/*\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.0
+ * 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
@@ -21,11 +11,11 @@ var ImageChooser = function(config){
 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
@@ -39,7 +29,7 @@ ImageChooser.prototype = {
                            }\r
                        });\r
                        this.store.load();\r
-                       \r
+\r
                        var formatSize = function(data){\r
                        if(data.size < 1024) {\r
                            return data.size + " bytes";\r
@@ -47,7 +37,7 @@ ImageChooser.prototype = {
                            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
@@ -55,7 +45,7 @@ ImageChooser.prototype = {
                        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
@@ -73,7 +63,7 @@ ImageChooser.prototype = {
                                },\r
                                prepareData: formatData.createDelegate(this)\r
                        });\r
-                   \r
+\r
                        var cfg = {\r
                        title: 'Choose an Image',\r
                        id: 'img-chooser-dlg',\r
@@ -116,7 +106,7 @@ ImageChooser.prototype = {
                                        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
@@ -151,13 +141,13 @@ ImageChooser.prototype = {
                        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
@@ -167,7 +157,7 @@ ImageChooser.prototype = {
                        '</tpl>'\r
                );\r
                this.thumbTemplate.compile();\r
-               \r
+\r
                this.detailsTemplate = new Ext.XTemplate(\r
                        '<div class="details">',\r
                                '<tpl for=".">',\r
@@ -183,7 +173,7 @@ ImageChooser.prototype = {
                );\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
@@ -199,19 +189,19 @@ ImageChooser.prototype = {
                    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
@@ -220,7 +210,7 @@ ImageChooser.prototype = {
            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
@@ -232,9 +222,9 @@ ImageChooser.prototype = {
                        }\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