3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
7 Imgorg.AlbumTree = Ext.extend(Ext.tree.TreePanel,{
8 initComponent: function() {
10 loader: new Ext.ux.tree.DirectTreeLoader({
13 root: new Ext.tree.TreeNode({
22 containerScroll: true,
25 ddGroup: 'organizerDD',
26 notifyDrop: this.onNotifyDrop.createDelegate(this)
29 Imgorg.AlbumTree.superclass.initComponent.call(this);
30 this.loader.load(this.root);
32 this.editor = new Ext.tree.TreeEditor(this, {
34 blankText: 'A name is required',
37 this.editor.on('complete', this.onEditComplete, this);
38 this.on('contextmenu', this.onContextMenu, this);
41 onContextMenu: function(node, e) {
44 this.contMenu = new Ext.menu.Menu({
48 var node = this.currentNode;
50 Ext.fly(node.ui.elNode).ghost('l', {
51 callback: function() {
52 Imgorg.ss.Albums.remove({
56 }, scope: node, duration: 0.4
63 this.currentNode = node;
64 this.contMenu.showAt(e.getXY());
67 onNotifyDrop: function(src, e, data) {
68 var nodes = data.nodes;
70 for (var i = 0;i < nodes.length;i++) {
71 nodeIds.push(nodes[i].id);
73 this.addToAlbum(nodeIds, this.dropZone.dragOverData.target.attributes.id);
74 return true; // cancell repair anim
77 addToAlbum: function(nodes, album) {
78 Imgorg.ss.Images.addToAlbum({
84 addAlbum: function() {
86 var node = root.appendChild(new Ext.tree.TreeNode({
91 this.getSelectionModel().select(node);
93 setTimeout(function(){
95 ge.startEdit(node.ui.textNode);
99 onEditComplete: function(editor, newVal, oldVal) {
100 var n = editor.editNode;
101 Imgorg.ss.Albums.addOrUpdate({node: n.id, text: newVal, id: n.attributes.id});
104 Ext.reg('img-albumtree', Imgorg.AlbumTree);
106 Ext.ns('Ext.ux.tree');
107 Ext.ux.tree.DirectTreeLoader = Ext.extend(Ext.tree.TreeLoader,{
112 load : function(node, callback){
113 this.requestData(node, callback);
116 requestData : function(node, callback){
117 if(this.fireEvent("beforeload", this, node, callback) !== false){
120 }, this.processResponse.createDelegate(this, [node, callback], true));
122 // if the load is cancelled, make sure we notify
123 // the node that we are done
124 if(typeof callback == "function"){
130 processResponse : function(res, trans, node, callback){
133 for(var i = 0, len = res.length; i < len; i++){
134 var n = this.createNode(res[i]);
140 if(typeof callback == "function"){
141 callback(this, node);
144 this.handleFailure(res);