/* * File version $Revision: 17 $ * Last modified $Date : $ * Papirfly extensions to the xTREE Cross Browser Tree Widget by WebFX stored in the file xtree.js * Please avoid making changes to the original file; make your changes here and make sure that * this file gets included after the original. * * NB! I hope you remember to branch this file in SourceSafe before making your changes! */ // Override: new default file names. // New option (autoSlam) to automatically close nodes as they loose focus to other nodes. // New option (showRoot) to display root node or not. var webFXTreeConfig = { rootIcon : '/internet/SkrettingAustralia/webInternet.nsf/blank.gif', openRootIcon :'/internet/SkrettingAustralia/webInternet.nsf/blank.gif', folderIcon : '/internet/SkrettingAustralia/webInternet.nsf/blank.gif', openFolderIcon : '/internet/SkrettingAustralia/webInternet.nsf/blank.gif', fileIcon : '/internet/SkrettingAustralia/webInternet.nsf/blank.gif', iIcon : '/internet/SkrettingAustralia/webInternet.nsf/blank.gif', lIcon : '/internet/SkrettingAustralia/webInternet.nsf/blank.gif', lMinusIcon : '/internet/SkrettingAustralia/webInternet.nsf/minus.gif', lPlusIcon : '/internet/SkrettingAustralia/webInternet.nsf/plus.gif', tIcon : '/internet/SkrettingAustralia/webInternet.nsf/blank.gif', tMinusIcon : '/internet/SkrettingAustralia/webInternet.nsf/minus.gif', tPlusIcon : '/internet/SkrettingAustralia/webInternet.nsf/plus.gif', blankIcon : '/internet/SkrettingAustralia/webInternet.nsf/blank.gif', defaultText : 'Tree Item', defaultAction : 'javascript:void(0);', defaultBehavior : 'classic', usePersistence : false, autoSlam : false, showRoot : false }; /* * WebFXTreeAbstractNode class */ // New: collapse all siblings for this node WebFXTreeAbstractNode.prototype.collapseSiblings = function() { if (!this.parentNode) return; for (var i = 0; i < this.parentNode.childNodes.length; i++) { if (this != this.parentNode.childNodes[i] && this.parentNode.childNodes[i].childNodes.length) { this.parentNode.childNodes[i].collapse(true); } } } /* // New: collapse all nodes in the same generation as this node WebFXTreeAbstractNode.prototype.collapseMyGeneration = function() { if (!this.parentNode) return; for (var i = 0; i < webFXTreeHandler.idCounter; i++) { var that = webFXTreeHandler.all[xxxxx]; if (this != this.parentNode.childNodes[i] && this.parentNode.childNodes[i].childNodes.length) { this.parentNode.childNodes[i].collapse(true); } } } */ // Override: collapse open node(s) after toggling this one if autoSlam options are on. WebFXTreeAbstractNode.prototype.toggle = function() { if (this.folder) { if (this.open) { this.collapse(); } else { this.expand(); } } if (webFXTreeConfig.autoSlam) this.collapseSiblings(); //this.collapseMyGeneration(); } // Override: don't collapse pre-expanded nodes. WebFXTreeAbstractNode.prototype.doCollapse = function() { if (this.jammed) return false; if (webFXTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = this.icon; } if (this.childNodes.length) { document.getElementById(this.id + '-cont').style.display = 'none'; } this.open = false; if (webFXTreeConfig.usePersistence) webFXTreeHandler.cookies.setCookie(this.id.substr(18,this.id.length - 18), '0'); } /* * WebFXTree class */ // Override: generate an additional
for use in our custom css file (xtree_papirfly.css). // Override: replace "ondblclick" with onclick". // Override: Don't produce HTML for root folder - keep it invisible. WebFXTree.prototype.toString = function() { var str = "
"; if (webFXTreeConfig.showRoot) { str += "
"; str += ""; str += "" + this.text + "
"; } else { str += ""; } str += "
"; for (var i = 0; i < this.childNodes.length; i++) { str += this.childNodes[i].toString(i, this.childNodes.length); } str += "
"; this.rendered = true; return str; }; // New prototype property - class name WebFXTree.prototype.setClass = function (sClass) { this.className = sClass; } /* * WebFXTreeItem class */ // Override: generate a custom class (if requested) for use in our custom css file (xtree_papirfly.css). // Override: replace "ondblclick" with onclick". // Override: pre-expand jammed nodes. // Removed: deleted onclick from plus-img. // New: added indent class to plus-img. WebFXTreeItem.prototype.toString = function (nItem, nItemCount, nTarget) { var foo = this.parentNode; var indent = ''; if (nItem + 1 == nItemCount) { this.parentNode._last = true; } var i = 0; while (foo.parentNode) { foo = foo.parentNode; indent = "" + indent; i++; } this._level = i; if (this.childNodes.length) { this.folder = 1; } else { this.open = false; } if (this.jammed) { this.open = true; } if ((this.folder) || (webFXTreeHandler.behavior != 'classic')) { if (!this.icon) { this.icon = webFXTreeConfig.folderIcon; } if (!this.openIcon) { this.openIcon = webFXTreeConfig.openFolderIcon; } } else if (!this.icon) { this.icon = webFXTreeConfig.fileIcon; } var label = this.text.replace(//g, '>'); var str = "
"; str += indent; str += "" str += "" + label + "
"; str += "
"; for (var i = 0; i < this.childNodes.length; i++) { str += this.childNodes[i].toString(i,this.childNodes.length); } str += "
"; this.plusIcon = ((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon); this.minusIcon = ((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon); return str; } // New prototype property - class name WebFXTreeItem.prototype.setClass = function (sClass) { this.className = sClass; } // New prototype property - whether node can be opened/closed (default) or permanently jammed open. WebFXTreeItem.prototype.jam = function () { this.jammed = true; } // Override: we need to stop navigation to the parent of top level nodes as they do not have a visible/selectable parent. WebFXTreeItem.prototype.keydown = function(key) { if ((key == 39) && (this.folder)) { if (!this.open) { this.expand(); } else { this.getFirst().select(); } return false; } else if (key == 37) { if (this.open) { this.collapse(); } //else { this.parentNode.select(); } // OK it's a hack but it works (TimT). return false; } else if (key == 40) { if (this.open) { this.getFirst().select(); } else { var sib = this.getNextSibling(); if (sib) { sib.select(); } } return false; } else if (key == 38) { this.getPreviousSibling().select(); return false; } return true; }