2 * Ext JS Library 0.30
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
9 ListTree = function(config){
\r
10 ListTree.superclass.constructor.call(this, Ext.apply({
\r
13 //rootVisible:false,
\r
20 cmargins: '3 3 3 3',
\r
26 this.on('contextmenu', this.onContextMenu, this);
\r
28 Ext.extend(ListTree, Ext.tree.TreePanel, {
\r
30 initComponent : function(){
\r
32 tx.actions.newList,
\r
33 tx.actions.deleteList,
\r
35 tx.actions.newFolder,
\r
36 tx.actions.deleteFolder
\r
39 this.loader = new ListLoader({
\r
40 store: tx.data.lists
\r
42 ListTree.superclass.initComponent.call(this);
\r
44 var root = new Ext.tree.AsyncTreeNode({
\r
48 iconCls: 'icon-folder',
\r
53 this.setRootNode(root);
\r
55 this.editor = new Ext.tree.TreeEditor(this, {
\r
57 blankText:'A name is required',
\r
60 this.editor.shadow = false;
\r
62 this.editor.on('beforecomplete', function(ed, value, startValue){
\r
63 var node = ed.editNode;
\r
64 value = Ext.util.Format.htmlEncode(value);
\r
65 var r = this.store.getById(node.id);
\r
66 r.set('listName', value);
\r
67 //ed.editing = false;
\r
72 this.sorter = new Ext.tree.TreeSorter(this, {
\r
77 getActiveFolderId : function(){
\r
78 var sm = this.selModel;
\r
79 var n = sm.getSelectedNode();
\r
81 return n.attributes.isFolder ? n.id : n.attributes.parentId;
\r
86 onContextMenu : function(node, e){
\r
87 if(!this.menu){ // create context menu on first right click
\r
88 this.menu = new Ext.menu.Menu({
\r
92 iconCls:'icon-edit',
\r
96 this.ctxNode.select();
\r
97 tx.actions.newTask.execute();
\r
100 iconCls:'icon-list-new',
\r
103 handler:function(){
\r
104 this.ctxNode.select();
\r
105 tx.actions.newList.execute();
\r
108 iconCls:'icon-folder-new',
\r
111 handler:function(){
\r
112 this.ctxNode.select();
\r
113 tx.actions.newFolder.execute();
\r
117 iconCls:'icon-list-delete',
\r
119 handler:function(){
\r
120 this.removeList(this.ctxNode);
\r
124 this.menu.on('hide', this.onContextHide, this);
\r
127 this.ctxNode.ui.removeClass('x-node-ctx');
\r
128 this.ctxNode = null;
\r
130 this.ctxNode = node;
\r
131 this.ctxNode.ui.addClass('x-node-ctx');
\r
133 this.menu.items.get(1).setVisible(!!node.attributes.isFolder);
\r
134 this.menu.items.get(2).setVisible(!!node.attributes.isFolder);
\r
135 this.menu.items.get(0).setVisible(!node.attributes.isFolder);
\r
137 this.menu.showAt(e.getXY());
\r
140 onContextHide : function(){
\r
142 this.ctxNode.ui.removeClass('x-node-ctx');
\r
143 this.ctxNode = null;
\r
147 startEdit : function(node, select){
\r
148 if(typeof node == 'string'){
\r
149 node = this.getNodeById(node);
\r
151 if(select === true){
\r
154 var ed = this.editor;
\r
155 setTimeout(function(){
\r
156 ed.editNode = node;
\r
157 ed.startEdit(node.ui.textNode);
\r
161 removeList : function(s){
\r
162 if (s && s.attributes.editable) {
\r
163 Ext.Msg.confirm('Confirm', 'Are you sure you want to delete "' + Ext.util.Format.htmlEncode(s.text) + '"?', function(btn){
\r
164 if (btn == 'yes') {
\r
165 if (s.nextSibling) {
\r
166 s.nextSibling.select();
\r
169 if (s.previousSibling) {
\r
170 s.previousSibling.select();
\r
172 s.parentNode.removeChild(s);
\r
173 tx.data.lists.remove(this.store.getById(s.id));
\r
174 tx.data.tasks.removeList(s.id);
\r