3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Imgorg.AlbumTree = Ext.extend(Ext.tree.TreePanel,{
9 initComponent: function() {
11 loader: new Ext.ux.tree.DirectTreeLoader({
14 root: new Ext.tree.TreeNode({
23 containerScroll: true,
26 ddGroup: 'organizerDD',
27 notifyDrop: this.onNotifyDrop.createDelegate(this)
30 Imgorg.AlbumTree.superclass.initComponent.call(this);
31 this.loader.load(this.root);
33 this.editor = new Ext.tree.TreeEditor(this, {
35 blankText: 'A name is required',
38 this.editor.on('complete', this.onEditComplete, this);
39 this.on('contextmenu', this.onContextMenu, this);
42 onContextMenu: function(node, e) {
45 this.contMenu = new Ext.menu.Menu({
49 var node = this.currentNode;
51 Ext.fly(node.ui.elNode).ghost('l', {
52 callback: function() {
53 Imgorg.ss.Albums.remove({
57 }, scope: node, duration: 0.4
64 this.currentNode = node;
65 this.contMenu.showAt(e.getXY());
68 onNotifyDrop: function(src, e, data) {
69 var nodes = data.nodes;
71 for (var i = 0;i < nodes.length;i++) {
72 nodeIds.push(nodes[i].id);
74 this.addToAlbum(nodeIds, this.dropZone.dragOverData.target.attributes.id);
75 return true; // cancell repair anim
78 addToAlbum: function(nodes, album) {
79 Imgorg.ss.Images.addToAlbum({
85 addAlbum: function() {
87 var node = root.appendChild(new Ext.tree.TreeNode({
92 this.getSelectionModel().select(node);
94 setTimeout(function(){
96 ge.startEdit(node.ui.textNode);
100 onEditComplete: function(editor, newVal, oldVal) {
101 var n = editor.editNode;
102 Imgorg.ss.Albums.addOrUpdate({node: n.id, text: newVal, id: n.attributes.id});
105 Ext.reg('img-albumtree', Imgorg.AlbumTree);
107 Ext.ns('Ext.ux.tree');
108 Ext.ux.tree.DirectTreeLoader = Ext.extend(Ext.tree.TreeLoader,{
113 load : function(node, callback){
114 this.requestData(node, callback);
117 requestData : function(node, callback){
118 if(this.fireEvent("beforeload", this, node, callback) !== false){
121 }, this.processResponse.createDelegate(this, [node, callback], true));
123 // if the load is cancelled, make sure we notify
124 // the node that we are done
125 if(typeof callback == "function"){
131 processResponse : function(res, trans, node, callback){
134 for(var i = 0, len = res.length; i < len; i++){
135 var n = this.createNode(res[i]);
141 if(typeof callback == "function"){
142 callback(this, node);
145 this.handleFailure(res);