Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: variable

  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    variable

    hello,

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

    Code:
        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
    regards.

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    posting the same question on muliple sites is VERY bad practice and wastes my and others time
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •