root / trunk / web / dojo / dijit / tree / ForestStoreModel.js
History | View | Annotate | Download (2.38 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dijit.tree.ForestStoreModel"]){ |
||
9 | dojo._hasResource["dijit.tree.ForestStoreModel"]=true; |
||
10 | dojo.provide("dijit.tree.ForestStoreModel");
|
||
11 | dojo.require("dijit.tree.TreeStoreModel");
|
||
12 | dojo.declare("dijit.tree.ForestStoreModel",dijit.tree.TreeStoreModel,{rootId:"$root$",rootLabel:"ROOT",query:null,constructor:function(_1){ |
||
13 | this.root={store:this,root:true,id:_1.rootId,label:_1.rootLabel,children:_1.rootChildren}; |
||
14 | },mayHaveChildren:function(_2){ |
||
15 | return _2===this.root||this.inherited(arguments); |
||
16 | },getChildren:function(_3,_4,_5){ |
||
17 | if(_3===this.root){ |
||
18 | if(this.root.children){ |
||
19 | _4(this.root.children);
|
||
20 | }else{
|
||
21 | this.store.fetch({query:this.query,onComplete:dojo.hitch(this,function(_6){ |
||
22 | this.root.children=_6;
|
||
23 | _4(_6); |
||
24 | }),onError:_5});
|
||
25 | } |
||
26 | }else{
|
||
27 | this.inherited(arguments); |
||
28 | } |
||
29 | },isItem:function(_7){ |
||
30 | return (_7===this.root)?true:this.inherited(arguments); |
||
31 | },fetchItemByIdentity:function(_8){ |
||
32 | if(_8.identity==this.root.id){ |
||
33 | var _9=_8.scope?_8.scope:dojo.global;
|
||
34 | if(_8.onItem){
|
||
35 | _8.onItem.call(_9,this.root);
|
||
36 | } |
||
37 | }else{
|
||
38 | this.inherited(arguments); |
||
39 | } |
||
40 | },getIdentity:function(_a){ |
||
41 | return (_a===this.root)?this.root.id:this.inherited(arguments); |
||
42 | },getLabel:function(_b){ |
||
43 | return (_b===this.root)?this.root.label:this.inherited(arguments); |
||
44 | },newItem:function(_c,_d,_e){ |
||
45 | if(_d===this.root){ |
||
46 | this.onNewRootItem(_c);
|
||
47 | return this.store.newItem(_c); |
||
48 | }else{
|
||
49 | return this.inherited(arguments); |
||
50 | } |
||
51 | },onNewRootItem:function(_f){ |
||
52 | },pasteItem:function(_10,_11,_12,_13,_14){ |
||
53 | if(_11===this.root){ |
||
54 | if(!_13){
|
||
55 | this.onLeaveRoot(_10);
|
||
56 | } |
||
57 | } |
||
58 | dijit.tree.TreeStoreModel.prototype.pasteItem.call(this,_10,_11===this.root?null:_11,_12===this.root?null:_12,_13,_14); |
||
59 | if(_12===this.root){ |
||
60 | this.onAddToRoot(_10);
|
||
61 | } |
||
62 | },onAddToRoot:function(_15){ |
||
63 | },onLeaveRoot:function(_16){ |
||
64 | },_requeryTop:function(){ |
||
65 | var _17=this.root.children||[]; |
||
66 | this.store.fetch({query:this.query,onComplete:dojo.hitch(this,function(_18){ |
||
67 | this.root.children=_18;
|
||
68 | if(_17.length!=_18.length||dojo.some(_17,function(_19,idx){ |
||
69 | return _18[idx]!=_19;
|
||
70 | })){ |
||
71 | this.onChildrenChange(this.root,_18); |
||
72 | } |
||
73 | })}); |
||
74 | },onNewItem:function(_1a,_1b){ |
||
75 | this._requeryTop();
|
||
76 | this.inherited(arguments); |
||
77 | },onDeleteItem:function(_1c){ |
||
78 | if(dojo.indexOf(this.root.children,_1c)!=-1){ |
||
79 | this._requeryTop();
|
||
80 | } |
||
81 | this.inherited(arguments); |
||
82 | }}); |
||
83 | } |