Diffstat (limited to 'frontend/beta/js/YUI-extensions/tree/AsyncTreeNode.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/YUI-extensions/tree/AsyncTreeNode.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/frontend/beta/js/YUI-extensions/tree/AsyncTreeNode.js b/frontend/beta/js/YUI-extensions/tree/AsyncTreeNode.js new file mode 100644 index 0000000..5d48b00 --- a/dev/null +++ b/frontend/beta/js/YUI-extensions/tree/AsyncTreeNode.js | |||
@@ -0,0 +1,58 @@ | |||
1 | YAHOO.ext.tree.AsyncTreeNode = function(config){ | ||
2 | this.loaded = false; | ||
3 | this.loading = false; | ||
4 | YAHOO.ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments); | ||
5 | this.events['beforeload'] = true; | ||
6 | this.events['load'] = true; | ||
7 | }; | ||
8 | YAHOO.extendX(YAHOO.ext.tree.AsyncTreeNode, YAHOO.ext.tree.TreeNode, { | ||
9 | expand : function(deep, anim, callback){ | ||
10 | if(this.loading){ // if an async load is already running, waiting til it's done | ||
11 | var timer; | ||
12 | var f = function(){ | ||
13 | if(!this.loading){ // done loading | ||
14 | clearInterval(timer); | ||
15 | this.expand(deep, anim, callback); | ||
16 | } | ||
17 | }.createDelegate(this); | ||
18 | timer = setInterval(f, 200); | ||
19 | } | ||
20 | if(!this.loaded){ | ||
21 | if(this.fireEvent('beforeload', this) === false){ | ||
22 | return; | ||
23 | } | ||
24 | this.loading = true; | ||
25 | this.ui.beforeLoad(this); | ||
26 | var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader(); | ||
27 | if(loader){ | ||
28 | loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback])); | ||
29 | return; | ||
30 | } | ||
31 | } | ||
32 | YAHOO.ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback); | ||
33 | }, | ||
34 | |||
35 | isLoading : function(){ | ||
36 | return this.loading; | ||
37 | }, | ||
38 | |||
39 | loadComplete : function(deep, anim, callback){ | ||
40 | this.loading = false; | ||
41 | this.loaded = true; | ||
42 | this.ui.afterLoad(this); | ||
43 | this.fireEvent('load', this); | ||
44 | this.expand(deep, anim, callback); | ||
45 | }, | ||
46 | |||
47 | isLoaded : function(){ | ||
48 | return this.loaded; | ||
49 | }, | ||
50 | |||
51 | hasChildNodes : function(){ | ||
52 | if(!this.isLeaf() && !this.loaded){ | ||
53 | return true; | ||
54 | }else{ | ||
55 | return YAHOO.ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this); | ||
56 | } | ||
57 | } | ||
58 | }); | ||