public/javascripts/Rwiki/TreePanel.js in rwiki-0.2.3 vs public/javascripts/Rwiki/TreePanel.js in rwiki-0.2.4

- old
+ new

@@ -36,11 +36,11 @@ this.filter = new Rwiki.TreePanel.Filter(this); this.root.expand(); new Ext.tree.TreeSorter(this, { - folderSort: false + folderSort: true }); var self = this; toolbar.on('expandAll', function() { @@ -53,11 +53,11 @@ toolbar.on('filterFieldChanged', function(text) { self.filter.filterTree(text); }); - this.addEvents('pageSelected'); + this.addEvents('rwiki:pageSelected'); }, initEvents: function() { Rwiki.TreePanel.superclass.initEvents.apply(this, arguments); @@ -67,10 +67,17 @@ this.on('rwiki:folderCreated', this.onFolderCreated); this.on('rwiki:pageCreated', this.onPageCreated); this.on('rwiki:nodeRenamed', this.onNodeRenamed); this.on('rwiki:nodeDeleted', this.onNodeDeleted); this.on('beforemovenode', this.onBeforeMoveNode); + + this.relayEvents(Rwiki.NodeManager.getInstance(), [ + 'rwiki:pageLoaded', + 'rwiki:folderCreated', + 'rwiki:pageCreated', + 'rwiki:nodeRenamed', + 'rwiki:nodeDeleted']); }, onContextMenu: function(node, e) { if (!this.contextMenu) return; @@ -81,17 +88,16 @@ this.contextMenu.show(node, e.getXY()); }, onClick: function(node) { if (!node.isLeaf()) return; - - var path = node.getPath(); - this.fireEvent('pageSelected', path); + var page = new Rwiki.Node({ path: node.getPath() }); + this.fireEvent('rwiki:pageSelected', page); }, - onPageLoaded: function(data) { - var node = this.findNodeByPath(data.path); + onPageLoaded: function(page) { + var node = this.findNodeByPath(page.getPath()); if (node) { node.select(); } }, @@ -107,30 +113,28 @@ var parentNode = this.findNodeByPath(data.parentPath); parentNode.expand(); parentNode.appendChild(node); }, - onPageCreated: function(data) { - var node = new Rwiki.TreePanel.Node({ - baseName: data.baseName, - text: data.baseName.replace(new RegExp('\.txt$'), ''), + onPageCreated: function(page) { + var treeNode = new Rwiki.TreePanel.Node({ + baseName: page.getBaseName(), + text: page.getTitle(), cls: 'page', expandable: false, leaf: true }); - var parentNode = this.findNodeByPath(data.parentPath); + var parentNode = this.findNodeByPath(page.getParentPath()); parentNode.expand(); - parentNode.appendChild(node); - node.select(); + parentNode.appendChild(treeNode); + treeNode.select(); }, - onNodeRenamed: function(data) { - var node = this.findNodeByPath(data.oldPath); - node.setBaseName(data.baseName); - - var title = data.baseName.replace(new RegExp('\.txt$'), ''); - node.setText(title); + onNodeRenamed: function(page) { + var treeNode = this.findNodeByPath(page.getData().oldPath); + treeNode.setBaseName(page.getBaseName()); + treeNode.setText(page.getTitle()); }, onNodeDeleted: function(data) { var path = data.path; var node = this.findNodeByPath(path);