...

View Full Version : variable



bobz
06-01-2006, 04:26 PM
hello,

goodday.whats does the following variable represent? I don understand this part. please give some suggestions here.




var webFXTreeHandler ={
idCounter : 0,
idPrefix : "webfx-tree-object-",
all : {},
behavior : null,
selected : null,
onSelect : null, /* should be part of tree, not handler */
getId : function() { return this.idPrefix + this.idCounter++; },
toggle : function (oItem) { this.all[oItem.id.replace('-plus','').replace('-icon','')].toggle(); },
select : function (oItem) { this.all[oItem.id.replace('-icon','')].select(); },
focus : function (oItem) { this.all[oItem.id.replace('-anchor','').replace('-plus','')].focus(); },
blur : function (oItem) { this.all[oItem.id.replace('-anchor','')].blur(); },
keydown : function (oItem, e) { return this.all[oItem.id].keydown(e.keyCode); },
cookies : new WebFXCookie(),
insertHTMLBeforeEnd : function (oElement, sHTML) {
if (oElement.insertAdjacentHTML != null) {
oElement.insertAdjacentHTML("BeforeEnd", sHTML)
return;
}
var df; // DocumentFragment
var r = oElement.ownerDocument.createRange();
r.selectNodeContents(oElement);
r.collapse(false);
df = r.createContextualFragment(sHTML);
oElement.appendChild(df);
},

/*
* Following functionality has been added to original library for CRN usage
*/
expandPathToRoot: function(oItem) {
var obj = oItem;
var nodesToOpen = new Array();

// prepare the list of nodes that have to be expanded
while (obj.parentNode.id && obj.parentNode.id.search("webfx-tree-object")==0) {
obj = obj.parentNode;
if (obj.style.display == 'none') {
nodesToOpen[nodesToOpen.length] = obj.id.replace('-cont','');
}
}

// expand the nodes in reverted order (from root to node)
for (var i=nodesToOpen.length-1; i>=0; i--) {
webFXTreeHandler.toggle(document.getElementById(nodesToOpen[i]));
}
},

focusCurrentElement: function() {
webFXTreeHandler.selected.focus();
},

getNextSibling: function(oItem) {
if (oItem.parentNode) {
var allSiblings = null;
if (oItem.parentNode.id.indexOf('-cont')>-1) {
allSiblings = oItem.parentNode.children;
} else {
//
// this happends when page is opened from a bookmark
//
allSiblings = document.getElementById(oItem.parentNode.id+'-cont').children;
}

if (allSiblings && allSiblings.length) {
//
// find oItem on the children list
//
var oItemIndex = -1;
for (oItemIndex=0; oItemIndex<allSiblings.length; oItemIndex++) {
//
// find oItem on the children list
//
if (allSiblings[oItemIndex].id == oItem.id) {
break;
}
}
//
// find next element after oItem
//
if (oItemIndex >= 0) {
for (var i=oItemIndex+1; i<allSiblings.length; i++) {
if (allSiblings[i].id.indexOf('webfx-tree-object')>-1
&& allSiblings[i].id.indexOf('-cont') == -1) {
return allSiblings[i];
}
}
}
}
}
return null;
},

getAllSiblings: function(oItem) {
var allSiblings = null;
if (oItem.parentNode) {
if (oItem.parentNode.id.indexOf('-cont')>-1) {
allSiblings = oItem.parentNode.children;
} else {
//
// this happends when page is opened from a bookmark
//
allSiblings = document.getElementById(oItem.parentNode.id+'-cont').children;
}
}
return allSiblings;
},

getItemIndex: function(oItem, siblingsArray) {
var oItemIndex = -1;
if (oItem && siblingsArray && siblingsArray.length) {
for (oItemIndex=0; oItemIndex<siblingsArray.length; oItemIndex++) {
//
// find oItem on the children list
//
if (siblingsArray[oItemIndex].id == oItem.id) {
break;
}
}
}
return oItemIndex;
},

getSiblingsAfter: function(oItem) {
var result = new Array();

var allSiblings = webFXTreeHandler.getAllSiblings(oItem);

if (allSiblings) {
var oItemIndex = webFXTreeHandler.getItemIndex(oItem, allSiblings);
//
// get all elements after oItem
//
if (oItemIndex >= 0) {
for (var i=oItemIndex+1; i<allSiblings.length; i++) {
if (allSiblings[i].id.indexOf('webfx-tree-object')>-1
&& allSiblings[i].id.indexOf('-cont') == -1) {
result[result.length] = allSiblings[i];
}
}
}
}
return result;
},

getSiblingsBefore: function(oItem) {
var result = new Array();

var allSiblings = webFXTreeHandler.getAllSiblings(oItem);

if (allSiblings) {
var oItemIndex = webFXTreeHandler.getItemIndex(oItem, allSiblings);
//
// get all elements after oItem
//
if (oItemIndex >= 0) {
for (var i=oItemIndex-1; i>=0; i--) {
if (allSiblings[i].id.indexOf('webfx-tree-object')>-1
&& allSiblings[i].id.indexOf('-cont') == -1) {
result[result.length] = allSiblings[i];
}
}
}
}
return result;
},

markAsSelected: function(oItem) {
document.getElementById(oItem.id + '-anchor').className = 'selected';
},

removeSelection: function(oItem) {
document.getElementById(oItem.id + '-anchor').className = '';
}
}

cheers

vwphillips
06-01-2006, 04:58 PM
posting the same question on muliple sites is VERY bad practice and wastes my and others time



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum