/*
Copyright (c) 2004-2005, The Dojo Foundation
All Rights Reserved.
Licensed under the Academic Free License version 2.1 or above OR the
modified BSD license. For more information on Dojo licensing, see:
http://dojotoolkit.org/community/licensing.shtml
*/
dojo.provide("dojo.widget.EditorTreeNode");
dojo.require("dojo.event.*");
dojo.require("dojo.dnd.*");
dojo.require("dojo.fx.html");
dojo.require("dojo.io.*");
dojo.require("dojo.widget.Container");
dojo.require("dojo.widget.Tree");
// make it a tag
dojo.widget.tags.addParseTreeHandler("dojo:EditorTreeNode");
dojo.widget.EditorTreeNode = function() {
dojo.widget.HtmlWidget.call(this);
}
dojo.inherits(dojo.widget.EditorTreeNode, dojo.widget.HtmlWidget);
dojo.lang.extend(dojo.widget.EditorTreeNode, {
widgetType: "EditorTreeNode",
loadStates: {
UNCHECKED: 1,
LOADING: 2,
LOADED: 3
},
isContainer: true,
domNode: null,
continerNode: null,
templateString: '
',
//childIconSrc: null,
childIconSrc: null,
childIconFolderSrc: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/closed.gif").toString(), // for under root parent item child icon,
childIconDocumentSrc: dojo.uri.dojoUri("src/widget/templates/images/EditorTree/document.gif").toString(), // for under root parent item child icon,
childIcon: null,
// an icon left from childIcon: imgs[-2].
// if +/- for folders, blank for leaves
expandIcon: null,
title: "",
isFolder: "",
labelNode: null, // the item label
titleNode: null, // the item title
imgs: null, // an array of icons imgs
rowNode: null, // the tr
tree: null,
parentNode: null,
depth: 0,
isFirstNode: false,
isLastNode: false,
isExpanded: false,
booted: false,
state: null, // after creation will change to loadStates: "loaded/loading/unchecked"
domNodeInitialized: false, // domnode is initialized with icons etc
initialize: function(args, frag){
this.state = this.loadStates.UNCHECKED
//this.domNode.treeNode = this; // domNode knows about its treeNode owner. E.g for DnD
},
/**
* Change visible node depth by appending/prepending with blankImgs
* @param depthDiff Integer positive => move right, negative => move left
*/
adjustDepth: function(depthDiff) {
for(var i=0; i0) {
for(var i=0; i= this.imgs.length-2) return;
this.imgs[idx].style.backgroundImage = 'url(' + src + ')';
},
updateIconTree: function(){
this.tree.updateIconTree.call(this);
},
expand: function(){
if (this.children.length) this.showChildren();
this.isExpanded = true;
this.updateIcons();
},
collapse: function(){
this.hideChildren();
this.isExpanded = false;
this.updateIcons();
},
hideChildren: function(){
if (this.booted){
this.tree.toggler.hide(this.containerNode);
}else{
this.containerNode.style.display = 'none';
}
},
showChildren: function(){
if (this.booted){
this.tree.toggler.show(this.containerNode);
}
else {
this.containerNode.style.display = 'block';
}
},
startMe: function(){
this.booted = true;
for(var i=0; i