Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / examples / view / chooser / IconBrowser.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * @class Ext.chooser.IconBrowser
17  * @extends Ext.view.View
18  * @author Ed Spencer
19  * 
20  * This is a really basic subclass of Ext.view.View. All we're really doing here is providing the template that dataview
21  * should use (the tpl property below), and a Store to get the data from. In this case we're loading data from a JSON
22  * file over AJAX.
23  */
24 Ext.define('Ext.chooser.IconBrowser', {
25     extend: 'Ext.view.View',
26     alias: 'widget.iconbrowser',
27     
28     uses: 'Ext.data.Store',
29     
30         singleSelect: true,
31     overItemCls: 'x-view-over',
32     itemSelector: 'div.thumb-wrap',
33     tpl: [
34         // '<div class="details">',
35             '<tpl for=".">',
36                 '<div class="thumb-wrap">',
37                     '<div class="thumb">',
38                     (!Ext.isIE6? '<img src="icons/{thumb}" />' : 
39                     '<div style="width:74px;height:74px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'icons/{thumb}\')"></div>'),
40                     '</div>',
41                     '<span>{name}</span>',
42                 '</div>',
43             '</tpl>'
44         // '</div>'
45     ],
46     
47     initComponent: function() {
48         this.store = Ext.create('Ext.data.Store', {
49             autoLoad: true,
50             fields: ['name', 'thumb', 'url', 'type'],
51             proxy: {
52                 type: 'ajax',
53                 url : 'icons.json',
54                 reader: {
55                     type: 'json',
56                     root: ''
57                 }
58             }
59         });
60         
61         this.callParent(arguments);
62         this.store.sort();
63     }
64 });