Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / examples / organizer / ImageView.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.org.ImageView
17  * @extends Ext.view.View
18  * @xtype imageview
19  *
20  * This class implements the "My Images" view (the images in the organizer). This class
21  * incorporates {@link Ext.ux.DataView.Draggable Draggable} to enable dragging items as
22  * well as {@link Ext.ux.DataView.DragSelector DragSelector} to allow multiple selection
23  * by simply clicking and dragging the mouse.
24  */
25 Ext.define('Ext.org.ImageView', {
26     extend: 'Ext.view.View',
27     alias : 'widget.imageview',
28     requires: ['Ext.data.Store'],
29     mixins: {
30         dragSelector: 'Ext.ux.DataView.DragSelector',
31         draggable   : 'Ext.ux.DataView.Draggable'
32     },
33     
34     tpl: [
35         '<tpl for=".">',
36             '<div class="thumb-wrap">',
37                 '<div class="thumb">',
38                     (!Ext.isIE6? '<img src="../view/chooser/icons/{thumb}" />' : 
39                     '<div style="width:76px;height:76px;filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'../view/chooser/icons/{thumb}\')"></div>'),
40                 '</div>',
41                 '<span>{name}</span>',
42             '</div>',
43         '</tpl>'
44     ],
45     
46     itemSelector: 'div.thumb-wrap',
47     multiSelect: true,
48     singleSelect: false,
49     cls: 'x-image-view',
50     autoScroll: true,
51     
52     initComponent: function() {
53         this.store = Ext.create('Ext.data.Store', {
54             autoLoad: true,
55             fields: ['name', 'thumb', {name: 'leaf', defaultValue: true}],
56             proxy: {
57                 type: 'ajax',
58                 url : '../view/chooser/icons.json',
59                 reader: {
60                     type: 'json',
61                     root: ''
62                 }
63             }
64         });
65         
66         this.mixins.dragSelector.init(this);
67         this.mixins.draggable.init(this, {
68             ddConfig: {
69                 ddGroup: 'organizerDD'
70             },
71             ghostTpl: [
72                 '<tpl for=".">',
73                     '<img src="../view/chooser/icons/{thumb}" />',
74                     '<tpl if="xindex % 4 == 0"><br /></tpl>',
75                 '</tpl>',
76                 '<div class="count">',
77                     '{[values.length]} images selected',
78                 '<div>'
79             ]
80         });
81         
82         this.callParent();
83     }
84 });