]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * @class Ext.org.AlbumTree\r | |
3 | * @extends Ext.tree.Panel\r | |
4 | * @xtype albumtree\r | |
5 | *\r | |
6 | * This class implements the "My Albums" tree. In addition, this class provides the ability\r | |
7 | * to add new albums and accept dropped items from the {@link Ext.org.ImageView}.\r | |
8 | */\r | |
9 | Ext.define('Ext.org.AlbumTree', {\r | |
10 | extend: 'Ext.tree.Panel',\r | |
11 | alias : 'widget.albumtree',\r | |
12 | \r | |
13 | title: 'My Albums',\r | |
14 | animate: true,\r | |
15 | rootVisible: false,\r | |
16 | \r | |
17 | viewConfig: {\r | |
18 | plugins: [{\r | |
19 | ddGroup: 'organizerDD',\r | |
20 | ptype : 'treeviewdragdrop',\r | |
21 | displayField: 'name'\r | |
22 | }]\r | |
23 | },\r | |
24 | \r | |
25 | displayField: 'name',\r | |
26 | \r | |
27 | initComponent: function() {\r | |
28 | this.count = 1;\r | |
29 | \r | |
30 | this.tbar = [\r | |
31 | {\r | |
32 | text: 'New Album',\r | |
33 | iconCls: 'album-btn',\r | |
34 | scope: this,\r | |
35 | handler: this.addAlbum\r | |
36 | }\r | |
37 | ];\r | |
38 | \r | |
39 | this.store = Ext.create('Ext.data.TreeStore', {\r | |
40 | fields: ['name'],\r | |
41 | \r | |
42 | root: {\r | |
43 | name: 'Root',\r | |
44 | allowDrop: false,\r | |
45 | expanded: true,\r | |
46 | children: [\r | |
47 | {\r | |
48 | name : 'Album 1',\r | |
49 | iconCls: 'album-btn',\r | |
50 | children: []\r | |
51 | }\r | |
52 | ]\r | |
53 | }\r | |
54 | });\r | |
55 | \r | |
56 | this.callParent();\r | |
57 | },\r | |
58 | \r | |
59 | /**\r | |
60 | * Adds a new album node to the root\r | |
61 | */\r | |
62 | addAlbum: function() {\r | |
63 | var root = this.store.getRoot();\r | |
64 | this.count++;\r | |
65 | \r | |
66 | root.appendChild({\r | |
67 | name: 'Album ' + this.count,\r | |
68 | iconCls: 'album-btn',\r | |
69 | children: []\r | |
70 | });\r | |
71 | }\r | |
72 | }); |