summaryrefslogtreecommitdiff
path: root/frontend/beta/js/YUI-extensions/tree/AsyncTreeNode.js
Side-by-side diff
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.js58
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 @@
+YAHOO.ext.tree.AsyncTreeNode = function(config){
+ this.loaded = false;
+ this.loading = false;
+ YAHOO.ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
+ this.events['beforeload'] = true;
+ this.events['load'] = true;
+};
+YAHOO.extendX(YAHOO.ext.tree.AsyncTreeNode, YAHOO.ext.tree.TreeNode, {
+ expand : function(deep, anim, callback){
+ if(this.loading){ // if an async load is already running, waiting til it's done
+ var timer;
+ var f = function(){
+ if(!this.loading){ // done loading
+ clearInterval(timer);
+ this.expand(deep, anim, callback);
+ }
+ }.createDelegate(this);
+ timer = setInterval(f, 200);
+ }
+ if(!this.loaded){
+ if(this.fireEvent('beforeload', this) === false){
+ return;
+ }
+ this.loading = true;
+ this.ui.beforeLoad(this);
+ var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
+ if(loader){
+ loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback]));
+ return;
+ }
+ }
+ YAHOO.ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback);
+ },
+
+ isLoading : function(){
+ return this.loading;
+ },
+
+ loadComplete : function(deep, anim, callback){
+ this.loading = false;
+ this.loaded = true;
+ this.ui.afterLoad(this);
+ this.fireEvent('load', this);
+ this.expand(deep, anim, callback);
+ },
+
+ isLoaded : function(){
+ return this.loaded;
+ },
+
+ hasChildNodes : function(){
+ if(!this.isLeaf() && !this.loaded){
+ return true;
+ }else{
+ return YAHOO.ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
+ }
+ }
+});