/* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| BI and PM: prmt *| (C) Copyright IBM Corp. 2002, 2021 *| *| US Government Users Restricted Rights - Use, duplication or *| disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *| *+------------------------------------------------------------------------+ */ // Constants var giDRAW_BLOCKSIZE = 50; var giDRAW_INTERVAL = 50; var gsCTREE_checkbox = "checkbox"; var gsCTREE_click = "click"; var gsCTREE_contextmenu = "contextmenu"; var gsCTREE_dblclick = "dblclick"; var gsCTREE_dragRef = "dragRef"; var gsCTREE_dragTree = "dragTree"; var gsCTREE_drag = "drag"; var gsCTREE_dragend = "dragend"; var gsCTREE_dragstart = "dragstart"; var gsCTREE_icon = "icon"; var gsCTREE_img = "img"; var gsCTREE_indicator = "indicator"; var gsCTREE_indicatorSpan = "indicatorSpan"; var gsCTREE_keypress = "keypress"; var gsCTREE_label = "label"; var gsCTREE_labelText = "labelText"; var gsCTREE_middle = "middle"; var gsCTREE_nobr = "nobr"; var gsCTREE_onclick = "onclick"; var gsCTREE_oncontextmenu = "oncontextmenu"; var gsCTREE_ondblclick = "ondblclick"; var gsCTREE_ondrag = "ondrag"; var gsCTREE_ondragend = "ondragend"; var gsCTREE_ondragstart = "ondragstart"; var gsCTREE_onkeypress = "onkeypress"; var gsCTREE_toggle = "toggle_"; var gsCTREE_tree = "tree"; var gsCTREE_treeRef = "treeRef"; // Fix for COGCQ00685248 - Icon text is top-aligned in Firefox in Query Studio // changed this.m_oTREELINE.align = gsCTREE_middle; to // this.m_oTREELINE.className = CLS_TREE_TEXTICON_ALIGNFIX; // This fix aligns the Icon and the text correctly //TREE CONTROL // oPane: the HTML element where the tree will be rendered // oSubmit: the form control to submit selections to the server // bRequired: is this a required field [true|false] // bMultiSelect: can the user pick more than one value [true|false] // sRef: the name of this object // oImgTest: the image object used for validation handling // oErrorFeedback: object used to provide validation feedback // oBidi: object used to provide Bidi methods function CTree(oPane, oSubmit, bRequired, bMultiSelect, sRef, oImgTest, oErrorFeedback, sCVId, sStyle, oBidi) { this.contentLocale = null; this.setCVId(sCVId); this.m_style = sStyle; //html div element where adornments will be rendered this.m_oOuterPane = oPane; //html element where the tree will be rendered this.m_oPane = null; //create a root node for the tree //new nodes are added by calling the appendChild method for each node this.m_oRoot = new CTreeNode(null, tntRoot, true, 'root', 'root', false); this.m_oRoot.m_oTree = this; this.m_oRoot.setTreeRef(K_PRMT_sEMPTY); if (this.m_oOuterPane != null) { this.m_oOuterPane.setAttribute("role", "tree"); } this.m_oSubmit = oSubmit; this.m_bRequired = bRequired; //determine the selection mode for the tree if (bMultiSelect == false) { this.m_iSelectionMode = SINGLE_TREE_SELECTION; this.m_sSelectTreeUI = NORMAL_TREE; } else { this.m_iSelectionMode = DISCONTIGUOUS_TREE_SELECTION; this.m_sSelectTreeUI = CHECKBOX_TREE; } //check the state of the control? //this needs to happen after the nodes are added this.m_bValid = false; this.m_sRef = sRef; //maintain a list of selections this.m_sTreeProcessResult = K_PRMT_sEMPTY; this.m_oErrorFeedback = oErrorFeedback; //../prompting/images for handling errors this.m_oImgCheck = oImgTest; if (this.m_oImgCheck != null) { this.m_oImgErrorFalse= new Image(); this.m_oImgErrorFalse.src = ERROR_TIMED_SMALL_OFF; this.m_oImgErrorTrue = new Image(); this.m_oImgErrorTrue.src = ERROR_TIMED_SMALL; } this.m_bShowRootNode = false; this.m_bLoadOnTheFly = false; this.m_iIsLoading = 0; this.m_bForceSelectionAtLowestLevel = false; this.m_bAllowSelectionToggle = true; this.m_oAnchorNode = null; this.m_bAllowDragDrop = false; this.m_fOnDragStartFunc = null; this.m_fOnDragFunc = null; this.m_fOnDragEndFunc = null; this.m_fOnContextMenu = null; this.m_bTrackSelectionOrder = false; this.m_aSelectionOrder = new Array(); this.m_fSingleClickFunc = null; this.m_fDoubleClickFunc = null; this.m_bHideAdornments = false; this.m_bMustChangeDefault = false; this.m_bHideOuterTable = false; this.m_bRecursiveSelect = true; this.m_bPromptTree = false; this.m_iMaxValueCount = 5000; this.m_bShowPreviousValues = true; this.m_aAllSelections = null; this.m_iContainerWidth = null; this.m_iContainerHeight = null; this.m_bNodesCanHaveChildren = true; this.m_bIsDisabled = false; this.m_bHasBeenDrawn = false; this.m_oLastSelectedNode = null; this.m_itemTabIndex = 1; // A11Y check for Event Studio keyboard support if (typeof AccessibilityHandler != "undefined") { this.m_itemTabIndex = -1; } //skin folder this.m_sSkin = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); if (typeof gDispatcher != K_PRMT_sUNDEFINED) // Try to find global dispatcher object first { this.m_oDispatcher = gDispatcher; } else if (typeof CDispatcher != K_PRMT_sUNDEFINED) { this.m_oDispatcher = new CDispatcher(); } else { this.m_oDispatcher = null; } this.m_sServerPath = this.getGateway(); // DOM objects used to create child nodes. this.m_oTREELINE = document.createElement("IMG"); this.m_oTREELINE.src = TREE_I_ONLY; this.m_oTREELINE.className = CLS_TREE_TEXTICON_ALIGNFIX; this.m_oTREELINE.alt = ""; this.m_oTREELINE.setAttribute(gsCTREE_treeRef, gsCTREE_img); this.m_oDIVnewElement = document.createElement("DIV"); this.m_oNOBR = document.createElement("NOBR"); this.m_oNOBR.setAttribute(gsCTREE_treeRef, gsCTREE_nobr); this.m_oIcon = document.createElement("IMG"); this.m_oIcon.setAttribute(gsCTREE_treeRef, gsCTREE_img); this.m_oIndicatorSPAN = document.createElement("SPAN"); this.m_oIndicatorSPAN.style.paddingLeft = 3; this.m_oIndicatorIMG = document.createElement("IMG"); this.m_oIndicatorIMG.className = CLS_TREE_TEXTICON_ALIGNFIX; this.m_oTextSPAN = document.createElement("SPAN"); this.m_oToggleIMG = document.createElement("IMG"); this.m_oToggleIMG.className = CLS_TREE_TEXTICON_ALIGNFIX; this.m_oToggleIMG.onclick = null; this.m_oToggleIMG.src = TREE_L_ONLY; this.m_oToggleIMG.alt = ""; this.m_oCheckIMG = document.createElement("IMG"); this.m_oCheckIMG.className = CLS_TREE_TEXTICON_ALIGNFIX; this.m_oLabelSPAN = document.createElement("SPAN"); this.m_oLabelA = document.createElement("A"); this.m_oLabelA.className = CLS_TREE_TEXT_NO_LINK; if (window.ie11) { this.m_oLabelA.href = "#"; this.m_oLabelA.addEventListener("mouseover", function() {window.status=K_PRMT_sEMPTY;return true;}); this.m_oLabelA.addEventListener("mouseout", function() {window.status=K_PRMT_sEMPTY;return true;}); this.m_oLabelA.addEventListener("mouseup", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;}); this.m_oLabelA.addEventListener("mousedown", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;}); this.m_oLabelA.addEventListener("mousemove", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;}); this.m_oLabelA.addEventListener(gsCTREE_click, function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;}); } else if (window.ie) { this.m_oLabelA.href = "#"; this.m_oLabelA.attachEvent("onmouseover", function() {window.status=K_PRMT_sEMPTY;return true;}); this.m_oLabelA.attachEvent("onmouseout", function() {window.status=K_PRMT_sEMPTY;return true;}); this.m_oLabelA.attachEvent("onmouseup", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;}); this.m_oLabelA.attachEvent("onmousedown", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;}); this.m_oLabelA.attachEvent("onmousemove", function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;}); this.m_oLabelA.attachEvent(gsCTREE_onclick, function(e) {window.status=K_PRMT_sEMPTY;e.returnValue = false;}); } else { this.m_oLabelA.addEventListener("mouseover", function() {window.status=K_PRMT_sEMPTY;return false;}, true); this.m_oLabelA.addEventListener("mouseout", function() {window.status=K_PRMT_sEMPTY;return false;}, true); this.m_oLabelA.addEventListener("mouseup", function(e) {window.status=K_PRMT_sEMPTY;e.preventDefault();return false;}, true); this.m_oLabelA.addEventListener("mousedown", function(e) {window.status=K_PRMT_sEMPTY;e.preventDefault();return false;}, true); this.m_oLabelA.addEventListener("mousemove", function(e) {window.status=K_PRMT_sEMPTY;e.preventDefault();return false;}, true); this.m_oLabelA.addEventListener(gsCTREE_click, function(e) {window.status=K_PRMT_sEMPTY;e.preventDefault();return false;}, true); } this.m_oAncestry = null; this.m_oBidi = oBidi; this.cacheKeyPrefix = ""; this.bAllowStateCache = false; this.m_oTreeControl = null; } CTree.prototype = new CPromptControl(); CTree.prototype.setItemTabIndex = function(val) { this.m_itemTabIndex = val; } CTree.prototype.setAllowStateCache = function(bAllowStateCache, keyPrefix){ this.bAllowStateCache = bAllowStateCache; this.cacheKeyPrefix = keyPrefix; }; CTree.prototype.savePromptControlRef = function (oPromptControl) { this.m_oTreeControl = oPromptControl; }; // Set this to the tree's parameter name if this is a prompt control tree // getPromptValues OM function will be called automatically if this is a prompting tree CTree.prototype.setPromptingTree = function(val) { this.m_bPromptTree = val; }; CTree.prototype.setLocale = function(val) { this.contentLocale = val; }; CTree.prototype.setLabel = function(treeLabel){ if (treeLabel != null){ this.m_oOuterPane.setAttribute("aria-label", treeLabel); } }; CTree.prototype.getGateway = function() { var v_sGateway = document.location.pathname; var v_oCV = (this.getCV ? this.getCV() : null); if (v_oCV && v_oCV.getGateway) { v_sGateway = v_oCV.getGateway(); } return v_sGateway; }; CTree.prototype.getPromptingTree = function() { return this.m_bPromptTree; }; CTree.prototype.setDisabled = function(val) { this.m_bIsDisabled = val; }; CTree.prototype.getDisabled = function() { return this.m_bIsDisabled; }; CTree.prototype.setMaxValueCount = function(val) { this.m_iMaxValueCount = val; }; CTree.prototype.getMaxValueCount = function() { return this.m_iMaxValueCount; }; CTree.prototype.getHasBeenDrawn = function() { return this.m_bHasBeenDrawn; }; CTree.prototype.setContainerWidth = function(val) { this.m_iContainerWidth = val; }; CTree.prototype.getContainerWidth = function() { return this.m_iContainerWidth; }; CTree.prototype.setContainerHeight = function(val) { this.m_iContainerHeight = val; }; CTree.prototype.getContainerHeight = function() { return this.m_iContainerHeight; }; CTree.prototype.getStyle = function() { return this.m_style; }; //deprecated, use addToPrevSelArray CTree.prototype.addToPreviousSelections = function(val) { val = sDecodeU003( val ); if (this.m_aAllSelections == null) { this.m_aAllSelections = new Array(); } this.m_aAllSelections[this.m_aAllSelections.length] = val; }; //deprecated, use getPrevSelArray CTree.prototype.getPreviousSelections = function() { return this.m_aAllSelections; }; //deprecated, use clearPrevSelArray CTree.prototype.clearPreviousSelections = function() { this.clearPrevSelArray(); }; CTree.prototype.addToPrevSelArray = function(useVal, displayVal) { if (this.m_aAllSelections == null) { this.m_aAllSelections = new Array(); } useVal = sDecodeU003( useVal ); displayVal = sDecodeU003( displayVal ); this.m_aAllSelections[this.m_aAllSelections.length] = new Array (displayVal, useVal); }; CTree.prototype.removeFromPrevSelArray = function( v_sValue, v_sName ) { if (this.m_aAllSelections == null) { return; } for (var v_idxPS = 0; v_idxPS < this.m_aAllSelections.length; v_idxPS++) { var v_sUse = this.m_aAllSelections[v_idxPS]; var v_sDisplay = v_sUse; if ( typeof v_sUse == K_PRMT_sOBJECT && v_sUse.length ) { v_sDisplay = v_sUse[0]; v_sUse = v_sUse[1]; } if ( typeof v_sName == K_PRMT_sUNDEFINED ) { v_sName = v_sValue; } if ( v_sUse == v_sValue && v_sDisplay == v_sName ) { this.m_aAllSelections.splice( v_idxPS, 1 ); v_idxPS--; } } if (this.m_aAllSelections.length < 1) { this.m_aAllSelections = null; } }; CTree.prototype.getPrevSelArray = function() { return this.m_aAllSelections; }; CTree.prototype.clearPrevSelArray = function() { this.m_aAllSelections = null; this.m_oAncestry = null; }; CTree.prototype.setShowPreviousValues = function(val) { this.m_bShowPreviousValues = val; }; CTree.prototype.getShowPreviousValues = function() { return this.m_bShowPreviousValues; }; CTree.prototype.setSingleClickFunc = function(val) { this.m_fSingleClickFunc = val; }; CTree.prototype.getSingleClickFunc = function() { return this.m_fSingleClickFunc; }; CTree.prototype.setDoubleClickFunc = function(val) { this.m_fDoubleClickFunc = val; }; CTree.prototype.getDoubleClickFunc = function() { return this.m_fDoubleClickFunc; }; CTree.prototype.setLastSelectedNode = function(val) { this.m_oLastSelectedNode = val; }; CTree.prototype.getLastSelectedNode = function() { return this.m_oLastSelectedNode; }; CTree.prototype.addToSelectionOrder = function(node) { for (var i = 0; i < this.m_aSelectionOrder.length; i++) { if (this.m_aSelectionOrder[i] == node) { return; } } this.m_aSelectionOrder[this.m_aSelectionOrder.length] = node; }; CTree.prototype.removeFromSelectionOrder = function(node) { for (var i = 0; i < this.m_aSelectionOrder.length; i++) { if (this.m_aSelectionOrder[i] == node) { delete this.m_aSelectionOrder[i]; break; } } }; CTree.prototype.getSelectionOrder = function() { var tempArr = new Array(); for (var i = 0; i < this.m_aSelectionOrder.length; i++) { if (this.m_aSelectionOrder[i] != null) { tempArr[tempArr.length] = this.m_aSelectionOrder[i]; } } return tempArr; }; CTree.prototype.clearSelectionOrder = function() { this.m_aSelectionOrder = new Array(); }; CTree.prototype.setTrackSelectionOrder = function(val) { this.m_bTrackSelectionOrder = val; }; CTree.prototype.getTrackSelectionOrder = function() { return this.m_bTrackSelectionOrder; }; CTree.prototype.setContextMenu = function(val) { this.m_fOnContextMenu = val; }; CTree.prototype.getContextMenu = function() { return this.m_fOnContextMenu; }; CTree.prototype.setAllowDragDrop = function(val) { this.m_bAllowDragDrop = val; }; CTree.prototype.getAllowDragDrop = function() { return this.m_bAllowDragDrop; }; CTree.prototype.setOnDragEnd = function(val) { this.m_fOnDragEndFunc = val; }; CTree.prototype.getOnDragEnd = function() { return this.m_fOnDragEndFunc; }; CTree.prototype.setOnDragStart = function(val) { this.m_fOnDragStartFunc = val; }; CTree.prototype.getOnDragStart = function() { return this.m_fOnDragStartFunc; }; CTree.prototype.setOnDrag = function(val) { this.m_fOnDragFunc = val; }; CTree.prototype.getOnDrag = function() { return this.m_fOnDragFunc; }; CTree.prototype.setAnchorNode = function(val) { this.m_oAnchorNode = val; }; CTree.prototype.getAnchorNode = function() { return this.m_oAnchorNode; }; CTree.prototype.setMustChangeDefaultValue = function(val) { this.m_bMustChangeDefault = val; this.m_aDefaultSelNodes = new Array(); // flag to make sure selected values are only added to default selection array when control is created this.setDefaultSelectLock(true); }; CTree.prototype.getMustChangeDefaultValue = function() { return this.m_bMustChangeDefault; }; CTree.prototype.setAllowSelectionToggle = function(val) { this.m_bAllowSelectionToggle = val; }; CTree.prototype.getAllowSelectionToggle = function() { return this.m_bAllowSelectionToggle; }; CTree.prototype.setSelectTreeUI = function(val) { this.m_sSelectTreeUI = val; if (val == NORMAL_TREE) { this.setAllowSelectionToggle(false); } }; CTree.prototype.getSelectTreeUI = function() { return this.m_sSelectTreeUI; }; CTree.prototype.setRootNodeShowing = function(val) { this.m_bShowRootNode = val; }; CTree.prototype.getRootNodeShowing = function() { return this.m_bShowRootNode; }; CTree.prototype.setForceSelectionAtLowestLevel = function(val) { this.m_bForceSelectionAtLowestLevel = val; }; CTree.prototype.getForceSelectionAtLowestLevel = function() { return this.m_bForceSelectionAtLowestLevel; }; CTree.prototype.setLoadOnTheFlyFunction = function(funcVal) { this.m_bLoadOnTheFly = funcVal; }; CTree.prototype.getLoadOnTheFly = function() { return this.m_bLoadOnTheFly; }; CTree.prototype.setLoading = function(val) { if (val) { this.m_iIsLoading += 1; } else if (this.m_iIsLoading > 0) { this.m_iIsLoading -= 1; } }; CTree.prototype.getLoading = function() { return this.m_iIsLoading; }; //can any node (other than those at the root) contain other nodes CTree.prototype.nodesCanHaveChildren = function() { return this.m_bNodesCanHaveChildren; }; CTree.prototype.setNodesCanHaveChildren = function(val) { this.m_bNodesCanHaveChildren = val; }; //string return the javascript object name of the tree CTree.prototype.getName = function() { return this.m_sRef; }; //search paths are used to identify the correct node //CTree: return tree root node CTree.prototype.getRootNode = function() { return this.m_oRoot; }; //UI related CTree.prototype.drawAll = function() { if (this.m_oPane == null) { this.setupOuterTable(); } this.draw(this.getRootNode(), this.m_oPane); if (this.getDefaultSelectLock() == true && this.getMustChangeDefaultValue() == true) { this.setDefaultSelectLock(false); } }; CTree.prototype.setupOuterTable = function() { if (this.getHideOuterTable() == false) { this.drawOuterTable(); this.m_oPane = document.getElementById("treePane" + this.m_sRef); } else { this.m_oPane = this.m_oOuterPane; } if (window.ie) { this.m_oPane.onselectstart = function () {document.selection.empty(); return false;}; } }; CTree.prototype.setHideAdornments = function(val) { this.m_bHideAdornments = val; }; CTree.prototype.getHideAdornments = function() { return this.m_bHideAdornments; }; CTree.prototype.setHideOuterTable = function(val) { this.m_bHideOuterTable = val; }; CTree.prototype.getHideOuterTable = function() { return this.m_bHideOuterTable; }; CTree.prototype.getErrorFeedbackWidget = function() { return this.m_oErrorFeedback; }; CTree.prototype.setErrorFeedbackWidget = function(obj) { this.m_oErrorFeedback = obj; }; CTree.prototype.getImgCheck = function() { return this.m_oImgCheck; }; CTree.prototype.setImgCheck = function(obj) { this.m_oImgCheck = obj; }; CTree.prototype.setImgErrorFalse = function(path) { this.m_oImgErrorFalse= new Image(); this.m_oImgErrorFalse.src = path; }; CTree.prototype.setImgErrorTrue = function(path) { this.m_oImgErrorTrue = new Image(); this.m_oImgErrorTrue.src = path; }; CTree.prototype.setRecursiveSelect = function(val) { this.m_bRecursiveSelect = val; }; CTree.prototype.getRecursiveSelect = function() { return this.m_bRecursiveSelect; }; //select all the items in a tree CTree.prototype.selectAll = function () { this.getRootNode().setSelected(true, true); this.redraw(); this.checkData(); }; //remove any selections CTree.prototype.deSelectAll = function () { this.getRootNode().setSelected(false, true); this.clearPrevSelArray(); if (this.getTrackSelectionOrder()) { this.clearSelectionOrder(); } this.redraw(); this.checkData(); }; //redraw the tree CTree.prototype.redraw = function () { redrawChildren(this.getRootNode(),this.getName()); }; //integer enumeration: determine the selection mode for the tree (e.g. single select, multiple select) CTree.prototype.getSelectionMode = function() { return this.m_iSelectionMode; }; CTree.prototype.setSelectionMode = function(iSelectionMode) { this.m_iSelectionMode = iSelectionMode; }; //other get/set functions CTree.prototype.getRequired = function() { return this.m_bRequired; }; CTree.prototype.getDefaultSelectedNodes = function() { return this.m_aDefaultSelNodes; }; CTree.prototype.addDefaultSelectedNode = function(node) { this.m_aDefaultSelNodes[this.m_aDefaultSelNodes.length] = node; }; CTree.prototype.setDefaultSelectLock = function(val) { this.m_bSetDefaultSelection = val; }; CTree.prototype.getDefaultSelectLock = function() { return this.m_bSetDefaultSelection; }; /* When processing, start at the top to the tree iterate down a path if the there is at least one selected child (at any level). Stop when the current node is selected (regardless whether the children are selected or not). Note that only selected nodes appear in the selectChoices list (this is a flat list) */ CTree.prototype.preProcess = function () { //convert the data to XML and submit var sURLValues = K_PRMT_sEMPTY; this.m_sTreeProcessResult = K_PRMT_sEMPTY; //move recursively and render all children var children = this.getRootNode().getChildren(); if (children.length > 0) { for (var j = 0; j < children.length; j++) { this.processTree(children[j]); } } var prevSels = this.getPreviousSelections(); if (prevSels != null) { for (var i = 0; i < prevSels.length; i++) { if (typeof prevSels[i] == K_PRMT_sSTRING) //deprecated { this.m_sTreeProcessResult += ''; } else if (typeof prevSels[i] == K_PRMT_sOBJECT) { this.m_sTreeProcessResult += ''; } } } sURLValues += this.m_sTreeProcessResult; addSelectChoices(this.m_oSubmit, sURLValues); }; //loop through the tree recursively to build the tree CTree.prototype.processTree = function (node) { if (node.isSelected()) { var isSelectedAlready = false; var prevSels = this.getPreviousSelections(); if (prevSels != null) { var value = node.getValue(); for (var i = 0; i < prevSels.length; i++) { if ((typeof prevSels[i] == K_PRMT_sSTRING) && (prevSels[i] == value)) { isSelectedAlready = true; break; } else if ((typeof prevSels[i] == K_PRMT_sOBJECT) && (prevSels[i][1] == value)) { isSelectedAlready = true; // make sure the display value is set ( RSVP isn't setting it ) if ( !prevSels[i][0] ) { prevSels[i][0] = node.getName(); } break; } } } if (!isSelectedAlready) { this.m_sTreeProcessResult += ''; } } if (this.nodesCanHaveChildren() && node.hasSelectedChildren()) { //get any children var children = node.getChildren(); //move recursively and find all children for (var iChildCounter = 0; iChildCounter < children.length; iChildCounter++) { this.processTree(children[iChildCounter]); } } }; CTree.prototype.getSelectedLeafNodes = function (node) { if (!node) { node = this.getRootNode(); } var selectedNodes = new Array(); if (node.canHaveChildren() && node.hasSelectedChildren()) { //get any children var children = node.getChildren(); //move recursively and find all children for (var iChildCounter = 0; iChildCounter < children.length; iChildCounter++) { var theSelectedNodes = this.getSelectedLeafNodes(children[iChildCounter]); for (var i in theSelectedNodes) { selectedNodes[selectedNodes.length] = theSelectedNodes[i]; } } if(node.getTree().getSelectTreeUI() == CHECKBOX_TREE && node.getTree().getSelectionMode() == DISCONTIGUOUS_TREE_SELECTION && node.isSelected() && node.getNodeTypeObject().getRecursiveSelect() == false) { // can select this node separately from its children selectedNodes[selectedNodes.length] = node; } } else if (node.getNodeType() == TREE_ITEM && node.isSelected()) { selectedNodes[selectedNodes.length] = node; } return selectedNodes; }; CTree.prototype.getSelectedFolderNodes = function (node) { if (!node) { node = this.getRootNode(); } var selectedNodes = new Array(); if (node.canHaveChildren()) { if (node.getNodeType() == TREE_FOLDER && node.isSelected()) { selectedNodes[selectedNodes.length] = node; } //get any children var children = node.getChildren(); //move recursively and find all children for (var iChildCounter = 0; iChildCounter < children.length; iChildCounter++) { var theSelectedNodes = this.getSelectedFolderNodes(children[iChildCounter]); for (var i in theSelectedNodes) { selectedNodes[selectedNodes.length] = theSelectedNodes[i]; } } } return selectedNodes; }; CTree.prototype.getSelectedUnfetchedChildren = function () { var theFolderNodes = this.getSelectedFolderNodes(); var unfetchedChildren = false; for (var i in theFolderNodes) { if (this.m_bRecursiveSelect && theFolderNodes[i].getNodeTypeObject().getRecursiveSelect() && theFolderNodes[i].canHaveChildren() && !theFolderNodes[i].hasChildren()) { theFolderNodes[i].fetchChildren(); unfetchedChildren = true; } } return unfetchedChildren; }; //check whether the default value must be changed.. if yes, also check whether it has changed CTree.prototype.checkDefaultValid = function () { var selectionValid = true; var selectedNodes = new Array(); if (this.m_bMustChangeDefault) { selectedNodes = this.getSelectedLeafNodes(this.getRootNode()); selectedNodes = selectedNodes.concat(this.getSelectedFolderNodes(this.getRootNode())); // can potentially determine right away if selection is valid if (selectedNodes.length != this.getDefaultSelectedNodes().length) { return true; } var longArray, shortArray; if (selectedNodes.length > this.getDefaultSelectedNodes().length) { longArray = selectedNodes; shortArray = this.getDefaultSelectedNodes(); } else { longArray = this.getDefaultSelectedNodes(); shortArray = selectedNodes; } for (var i = 0; i < longArray.length; i++) { for (var j = 0; j < shortArray.length; j++) { if (shortArray[j].getId() == longArray[i].getId()) { selectionValid = false; break; } } if (selectionValid == true) { return true; } selectionValid = true; } return false; } return true; }; //called by observer notification when a Reprompt button is selected CTree.prototype.handleNotify = function() { this.cleanCacheValues(true); }; //check whether the user has selected a value CTree.prototype.checkData = function() { if ( this.m_oWrapper ) { return this.m_oWrapper.checkData(); } if (this.getDisabled() == true) { if (this.isRequired() == false) { this.m_bValid = true; this.checkPass(); } else { this.m_bValid = false; this.checkFail(); } } else if ((((this.isRequired() == false) || (this.getRootNode().hasSelectedChildren() == true)) && this.checkDefaultValid() == true) || this.getPreviousSelections() != null) { this.m_bValid = true; this.checkPass(); } else { this.m_bValid = false; this.checkFail(); } }; //render the validated state CTree.prototype.checkPass = function () { if ((this.m_oImgCheck != null) && (this.m_oImgCheck.src != this.m_oImgErrorFalse.src)) { this.m_oImgCheck.src = this.m_oImgErrorFalse.src; } if (this.m_oErrorFeedback) { this.m_oErrorFeedback.className ="clsFeedbackWidget"; } this.notify(); }; //render the validation error state CTree.prototype.checkFail = function () { if ((this.m_oImgCheck != null) && (this.m_oImgCheck.src != this.m_oImgErrorTrue.src)) { this.m_oImgCheck.src = this.m_oImgErrorTrue.src; } if (this.m_oErrorFeedback) { this.m_oErrorFeedback.className ="clsFeedbackWidgetParseError"; } this.notify(gFAIL, this); }; //set the control's validity CTree.prototype.setValid = function (bValid) { this.m_bValid = bValid; }; CTree.prototype.redrawNodeToggle = function (node, nodeId) { var newToggleIcon = document.getElementById(nodeId + gsCTREE_toggle + node.getTreeHierarchy()); if (newToggleIcon != null) { //pick what to draw if (node.isLast() == true && node.getParent().getMoreData() != true) { if (node.canHaveChildren() == true) { if (node.isOpen() == true) { newToggleIcon.src = TREE_L_MINUS; newToggleIcon.title = PMT_TRE_COLLAPSE; newToggleIcon.alt = PMT_TRE_COLLAPSE; } else { newToggleIcon.src = TREE_L_PLUS; newToggleIcon.title = PMT_TRE_EXPAND; newToggleIcon.alt = PMT_TRE_EXPAND; } newToggleIcon.tabIndex = this.m_itemTabIndex; newToggleIcon.onclick = toggle; if (window.ie11) { newToggleIcon.addEventListener(gsCTREE_keypress, toggle); } else if (window.ie) { newToggleIcon.attachEvent(gsCTREE_onkeypress, toggle); } else { newToggleIcon.addEventListener(gsCTREE_keypress, toggle, true); } } else { newToggleIcon.src = TREE_L_ONLY; newToggleIcon.alt = ""; newToggleIcon.onclick = null; } } else { if (node.canHaveChildren() == true) { if (node.isOpen() == true) { newToggleIcon.src = TREE_T_MINUS; newToggleIcon.title = PMT_TRE_COLLAPSE; newToggleIcon.alt = PMT_TRE_COLLAPSE; } else { newToggleIcon.src = TREE_T_PLUS; newToggleIcon.title = PMT_TRE_EXPAND; newToggleIcon.alt = PMT_TRE_EXPAND; } newToggleIcon.tabIndex = this.m_itemTabIndex; newToggleIcon.onclick = toggle; if (window.ie11) { newToggleIcon.addEventListener(gsCTREE_keypress, toggle); } else if (window.ie) { newToggleIcon.attachEvent(gsCTREE_onkeypress, toggle); } else { newToggleIcon.addEventListener(gsCTREE_keypress, toggle, true); } } else { newToggleIcon.src = TREE_T_ONLY; newToggleIcon.alt = ""; newToggleIcon.onclick = null; } } } }; CTree.prototype.drawLoading = function(node, nodeId) { var theElement = document.getElementById(nodeId); if (!theElement && node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false) { theElement = this.m_oPane; } if (theElement != null) { var newDivContainer = document.createElement("DIV"); newDivContainer.className = CLS_TREE_LEVEL; newDivContainer.id = this.getName() + node.getTreeRef() + "loading"; newDivContainer.style.width = "100%"; var newNobrLoadingContainer = document.createElement("NOBR"); this.drawTreeLines(node, newNobrLoadingContainer, node.getLevel() + 1); if (!(node.getNodeType() == TREE_ROOT && node.getTree().getRootNodeShowing() == false && node.getMoreData() != true)) { var newLIcon = document.createElement("IMG"); newLIcon.className = CLS_TREE_TEXTICON_ALIGNFIX; newLIcon.src = TREE_L_ONLY; newLIcon.alt=""; newNobrLoadingContainer.appendChild(newLIcon); } var newLoadingIcon = document.createElement("IMG"); newLoadingIcon.className = CLS_TREE_TEXTICON_ALIGNFIX; newLoadingIcon.src = TREE_LOADING; newNobrLoadingContainer.appendChild(newLoadingIcon); var newLabelContainer = document.createElement("SPAN"); newLabelContainer.className = CLS_TREE_NODE_UNSELECTED + K_PRMT_sSP + CLS_TREE_TEXT; //We need the localized string for "Loading..." here if (typeof PMT_TRE_TREE_LOADING != K_PRMT_sUNDEFINED) { var newLoadingText = document.createTextNode(PMT_TRE_TREE_LOADING); newLabelContainer.appendChild(newLoadingText); newLabelContainer.title = PMT_TRE_TREE_LOADING; } newNobrLoadingContainer.appendChild(newLabelContainer); newDivContainer.appendChild(newNobrLoadingContainer); theElement.appendChild(newDivContainer); } }; CTree.prototype.removeLoading = function(node) { var loadingDiv = document.getElementById(this.getName() + node.getTreeRef() + "loading"); if (!loadingDiv && node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false) { loadingDiv = this.m_oPane; } if (loadingDiv) { loadingDiv.parentNode.removeChild(loadingDiv); } }; CTree.prototype.drawMoreData = function(node, nodeId) { var theElement = document.getElementById(nodeId); if (!theElement && node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false) { theElement = this.m_oPane; } if (theElement != null) { var newDivContainer = document.createElement("DIV"); newDivContainer.className = CLS_TREE_LEVEL; newDivContainer.id = this.getName() + node.getTreeRef() + "moredata"; newDivContainer.style.width = "100%"; var newNobrMoreDataContainer = document.createElement("NOBR"); this.drawTreeLines(node, newNobrMoreDataContainer, node.getLevel() + 1); var newLIcon = document.createElement("IMG"); newLIcon.className = CLS_TREE_TEXTICON_ALIGNFIX; newLIcon.src = TREE_L_ONLY; newIcon.alt=""; newNobrMoreDataContainer.appendChild(newLIcon); var newMoreDataIcon = document.createElement("IMG"); newMoreDataIcon.className = CLS_TREE_TEXTICON_ALIGNFIX; newMoreDataIcon.src = TREE_MORE_DATA; newNobrMoreDataContainer.appendChild(newMoreDataIcon); var newLabelContainer = document.createElement("SPAN"); newLabelContainer.className = CLS_TREE_NODE_UNSELECTED + K_PRMT_sSP + CLS_TREE_TEXT_LINK; //We need the localized string for "More" here if (typeof PMT_TRE_MORE != K_PRMT_sUNDEFINED) { var newMoreDataText = document.createTextNode(PMT_TRE_MORE); newLabelContainer.appendChild(newMoreDataText); newLabelContainer.title = PMT_TRE_MORE; } newLabelContainer.id = this.getName() + node.getTreeRef() + "moredatalabel"; newLabelContainer.setAttribute(gsCTREE_tree, this.getName()); newLabelContainer.setAttribute(gsCTREE_treeRef, node.getTreeRef()); newLabelContainer.tabIndex = this.m_itemTabIndex; if (window.ie11) { newLabelContainer.addEventListener(gsCTREE_click, getMoreDataForTreeNode); newLabelContainer.addEventListener(gsCTREE_keypress, getMoreDataForTreeNode); } else if (window.ie) { newLabelContainer.attachEvent(gsCTREE_onclick, getMoreDataForTreeNode); newLabelContainer.attachEvent(gsCTREE_onkeypress, getMoreDataForTreeNode); } else { newLabelContainer.addEventListener(gsCTREE_click, getMoreDataForTreeNode, true); newLabelContainer.addEventListener(gsCTREE_keypress, getMoreDataForTreeNode, true); } newNobrMoreDataContainer.appendChild(newLabelContainer); newDivContainer.appendChild(newNobrMoreDataContainer); theElement.appendChild(newDivContainer); } }; CTree.prototype.removeMoreData = function(node) { var moreDataDiv = document.getElementById(this.getName() + node.getTreeRef() + "moredata"); if (!moreDataDiv && node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false) { moreDataDiv = this.m_oPane; } if (moreDataDiv) { moreDataDiv.parentNode.removeChild(moreDataDiv); } }; CTree.prototype.drawTreeLines = function(node, newElement, drawToLevel) { // put in appropriate spacers if (drawToLevel > 1) { for (var n = 1; n < drawToLevel; n++) { var spacerIcon = this.m_oTREELINE.cloneNode(true); var oParent = node.getParentAtLevel(n); if (oParent.isLast() == true && oParent.getParent().getMoreData() != true) { //if the parent was last spacerIcon.src = TREE_SPACE; spacerIcon.alt=""; } newElement.appendChild(spacerIcon); } } }; CTree.prototype.drawOuterTable = function() { if (this.m_oOuterPane != null) { var sId = this.m_sRef; var sStyle = this.getStyle(); var HTMLOut = "
" + ""; if (this.getHideAdornments() != true) { HTMLOut += ""; } HTMLOut += "" + "" + "
" + ""; if (this.getRequired() == true) { HTMLOut += "" + "" + ""; } HTMLOut += "" + "" + "" + "
" + "
" + "" + "" + "" + "" + ""; } if (this.getSelectionMode() != SINGLE_TREE_SELECTION) { HTMLOut += "" + "" + ""; } HTMLOut += "
"; if (this.getHideAdornments() != true) { HTMLOut += "
"; if (this.getSelectTreeUI() != CHECKBOX_TREE || this.getSelectionMode() != DISCONTIGUOUS_TREE_SELECTION) { HTMLOut += "" + PMT_UIM_SELECTALL + " "; } HTMLOut += "" + PMT_UIM_DESELECTALL + "" + "
" + "
"; this.m_oOuterPane.innerHTML = HTMLOut; if (this.getErrorFeedbackWidget() == null) { this.setErrorFeedbackWidget(document.getElementById("feedback_tree" + sId)); } if (this.getImgCheck() == null) { this.setImgCheck(document.getElementById("imgTest_tree" + sId)); if (this.getImgCheck() != null) { this.setImgErrorFalse(ERROR_TIMED_SMALL_OFF); this.setImgErrorTrue(ERROR_TIMED_SMALL); } } } }; CTree.prototype.draw = function(node, oParentElement) { if (node.getTree().getDisabled() == true) { return false; } var treeRef = node.getTreeRef(); var treeName = this.getName(); //if the node is the root node, removes the old root node so that the entire tree is redrawn //this takes care of the case where a loading tree is replaced with real data if (node.getNodeType() == TREE_ROOT) { var rootNode = document.getElementById(treeName); if (rootNode != null) { oParentElement.removeChild(rootNode); } oParentElement.setAttribute(gsCTREE_treeRef, treeRef); oParentElement.setAttribute(gsCTREE_tree, treeName); } var newElement = this.m_oDIVnewElement.cloneNode(true); if (this.getAllowDragDrop() == true && (this.getSelectTreeUI() == NORMAL_TREE || this.getSelectionMode() == SINGLE_TREE_SELECTION)) { if (window.ie11) { newElement.addEventListener(gsCTREE_dragstart, dragStartOnNode); newElement.addEventListener(gsCTREE_drag, dragOnNode); newElement.addEventListener(gsCTREE_dragend, dragEndOnNode); } else if (window.ie) { newElement.attachEvent(gsCTREE_ondragstart, dragStartOnNode); newElement.attachEvent(gsCTREE_ondrag, dragOnNode); newElement.attachEvent(gsCTREE_ondragend, dragEndOnNode); } else { newElement.setAttribute("draggable", "true"); newElement.addEventListener(gsCTREE_dragstart, dragStartOnNode); newElement.addEventListener(gsCTREE_drag, dragOnNode); newElement.addEventListener(gsCTREE_dragend, dragEndOnNode); } // Chrome browser require it for firing dragstart event properly. if (window.chrome) { newElement.addEventListener("mousemove", function(e) {cancelBub(e);}); } } newElement.setAttribute(gsCTREE_treeRef, treeRef); newElement.setAttribute(gsCTREE_tree, treeName); newElement.id = treeName + treeRef; if (!(node.getNodeType() == TREE_ROOT && this.getRootNodeShowing() == false)) { newElement.className = CLS_TREE_LEVEL; var newNobr = this.m_oNOBR.cloneNode(true); newNobr.setAttribute(gsCTREE_tree, treeName); newElement.appendChild(newNobr); this.drawTreeLines(node, newNobr, node.getLevel()); var newElementIcon = this.m_oIcon.cloneNode(true); newElementIcon.id = treeName + treeRef + gsCTREE_icon; newElementIcon.setAttribute(gsCTREE_dragRef, treeRef.toString()); newElementIcon.setAttribute(gsCTREE_dragTree, treeName); // put in the indicator if there is one var newElementIndicator = null; if (node.getIndicator() != null) { // create indicator span newElementIndicator = this.m_oIndicatorSPAN.cloneNode(true); newElementIndicator.id = treeName + treeRef + gsCTREE_indicatorSpan; newElementIndicator.setAttribute(gsCTREE_treeRef, treeRef); newElementIndicator.setAttribute(gsCTREE_dragRef, treeRef.toString()); newElementIndicator.setAttribute(gsCTREE_dragTree, treeName); newElementIndicator.setAttribute(gsCTREE_tree, treeName); // create the indicator image var newElementIndicatorImage = this.m_oIndicatorIMG.cloneNode(true); newElementIndicatorImage.id = treeName + treeRef + gsCTREE_indicator; newElementIndicatorImage.setAttribute(gsCTREE_treeRef, treeRef); newElementIndicatorImage.setAttribute(gsCTREE_dragRef, treeRef.toString()); newElementIndicatorImage.setAttribute(gsCTREE_dragTree, treeName); newElementIndicatorImage.setAttribute(gsCTREE_tree, treeName); // set the image newElementIndicatorImage.src = node.getIndicator(); // add this into the span newElementIndicator.appendChild(newElementIndicatorImage); } //get the current state var newElementText = this.m_oTextSPAN.cloneNode(true); newElementText.id = treeName + treeRef + gsCTREE_label; newElementText.setAttribute(gsCTREE_treeRef, treeRef); newElementText.setAttribute(gsCTREE_dragRef, treeRef.toString()); newElementText.setAttribute(gsCTREE_dragTree, treeName); newElementText.setAttribute(gsCTREE_tree, treeName); if (node.getTooltip() != false) { newElementText.title = this.bidiSafeText(node.getTooltip()); } else { newElementText.title = this.bidiSafeText(node.getName()); } newElementIcon.src = getIconSrc(node); var altText = node.getNodeTypeObject().m_sIconAltText; if (altText != null){ newElementIcon.alt = altText; } newElementIcon.className = CLS_TREE_TEXTICON_ALIGNFIX; newElement.setAttribute(gsCTREE_dragRef, treeRef.toString()); newElement.setAttribute(gsCTREE_dragTree, treeName); if (node.getNodeType() == TREE_ROOT) { newElementText.onclick = function() {return false;}; node.m_sTreeItemId = newElementText.id; } else { var newToggleIcon = this.m_oToggleIMG.cloneNode(true); //pick what to draw if (node.isLast() == true && node.getParent().getMoreData() != true) { if (node.canHaveChildren() == true) { if (node.isOpen() == true) { newToggleIcon.src = TREE_L_MINUS; newToggleIcon.title = PMT_TRE_COLLAPSE; newToggleIcon.alt = PMT_TRE_COLLAPSE; } else { newToggleIcon.src = TREE_L_PLUS; newToggleIcon.title = PMT_TRE_EXPAND; newToggleIcon.alt = PMT_TRE_EXPAND; } newToggleIcon.tabIndex = this.m_itemTabIndex; newToggleIcon.onclick = toggle; newToggleIcon.className = CLS_TRE_EXPAND_COLLAPSE_HOVER; if (window.ie11) { newToggleIcon.addEventListener(gsCTREE_keypress, toggle); } else if (window.ie) { newToggleIcon.attachEvent(gsCTREE_onkeypress, toggle); } else { newToggleIcon.addEventListener(gsCTREE_keypress, toggle, true); } } else { newToggleIcon.src = TREE_L_ONLY; newToggleIcon.alt=""; } } else { if (node.canHaveChildren() == true) { if (node.isOpen() == true) { newToggleIcon.src = TREE_T_MINUS; newToggleIcon.title = PMT_TRE_COLLAPSE; newToggleIcon.alt = PMT_TRE_COLLAPSE; } else { newToggleIcon.src = TREE_T_PLUS; newToggleIcon.title = PMT_TRE_EXPAND; newToggleIcon.alt = PMT_TRE_EXPAND; } newToggleIcon.tabIndex = this.m_itemTabIndex; newToggleIcon.onclick = toggle; newToggleIcon.className = CLS_TRE_EXPAND_COLLAPSE_HOVER; if (window.ie11) { newToggleIcon.addEventListener(gsCTREE_keypress, toggle); } else if (window.ie) { newToggleIcon.attachEvent(gsCTREE_onkeypress, toggle); } else { newToggleIcon.addEventListener(gsCTREE_keypress, toggle, true); } } else { newToggleIcon.src = TREE_T_ONLY; newToggleIcon.alt = ""; } } newToggleIcon.setAttribute(gsCTREE_treeRef, gsCTREE_img); newToggleIcon.id = treeName + treeRef + gsCTREE_toggle + node.getTreeHierarchy(); node.m_sToggleIconId = newToggleIcon.id; newNobr.appendChild(newToggleIcon); if ((node.getTree().getForceSelectionAtLowestLevel() == true && node.getNodeType() == TREE_ITEM) || (node.getTree().getForceSelectionAtLowestLevel() == false)) { newElementText.tabIndex = this.m_itemTabIndex; PRMTTreeUtils.f_addEvent(newElementText, gsCTREE_click, selectNode, true); if (node.getTree().getSingleClickFunc() != null) { if (window.ie11) { newElementText.addEventListener(gsCTREE_click, singleClickCaller, true); newElementText.addEventListener(gsCTREE_keypress, singleClickCaller, true); } else if (window.ie) { newElementText.attachEvent(gsCTREE_onclick, singleClickCaller); newElementText.attachEvent(gsCTREE_onkeypress, singleClickCaller); } else { newElementText.addEventListener(gsCTREE_click, singleClickCaller, true); newElementText.addEventListener(gsCTREE_keypress, singleClickCaller, true); } } if (node.getTree().getDoubleClickFunc() != null) { if (window.ie11) { newElementText.addEventListener(gsCTREE_dblclick, doubleClickCaller); } else if (window.ie) { newElementText.attachEvent(gsCTREE_ondblclick, doubleClickCaller); } else { newElementText.addEventListener(gsCTREE_dblclick, doubleClickCaller, true); // A11Y check for Event Studio keyboard support if (typeof AccessibilityHandler != "undefined") { newElementText.addEventListener(gsCTREE_keypress, doubleClickCaller, true); } } } newElementText.onmouseover = treeNodeMouseOver; newElementText.onmouseout = treeNodeMouseOut; if (window.ie11) { newElementText.addEventListener(gsCTREE_contextmenu, contextMenuCaller); newElementText.addEventListener(gsCTREE_keypress, selectNode); } else if (window.ie) { newElementText.attachEvent(gsCTREE_oncontextmenu, contextMenuCaller); newElementText.attachEvent(gsCTREE_onkeypress, selectNode); } else { newElementText.addEventListener(gsCTREE_contextmenu, contextMenuCaller, true); newElementText.addEventListener(gsCTREE_keypress, selectNode, true); } } //add a checkbox for multiselect trees if (this.getSelectionMode() != SINGLE_TREE_SELECTION && this.getSelectTreeUI() == CHECKBOX_TREE) { var newCheckBoxIcon = this.m_oCheckIMG.cloneNode(true); newCheckBoxIcon.src = getCheckBoxSrc(node); newCheckBoxIcon.setAttribute(gsCTREE_treeRef, gsCTREE_checkbox); newCheckBoxIcon.id = treeName + treeRef + gsCTREE_checkbox; //set up events if ((node.getTree().getForceSelectionAtLowestLevel() == true && node.getNodeType() == TREE_ITEM) || (node.getTree().getForceSelectionAtLowestLevel() == false)) { if (window.ie11) { newCheckBoxIcon.tabIndex = this.m_itemTabIndex; newCheckBoxIcon.onclick = selectNode; newCheckBoxIcon.addEventListener(gsCTREE_contextmenu, contextMenuCaller); newCheckBoxIcon.addEventListener(gsCTREE_keypress, selectNode); } else if (window.ie) { newCheckBoxIcon.tabIndex = this.m_itemTabIndex; newCheckBoxIcon.onclick = selectNode; newCheckBoxIcon.attachEvent(gsCTREE_oncontextmenu, contextMenuCaller); newCheckBoxIcon.attachEvent(gsCTREE_onkeypress, selectNode); } else { newCheckBoxIcon.addEventListener(gsCTREE_click, selectNode, true); newCheckBoxIcon.addEventListener(gsCTREE_contextmenu, contextMenuCaller, true); newCheckBoxIcon.addEventListener(gsCTREE_keypress, selectNode, true); } } newNobr.appendChild(newCheckBoxIcon); } } newElementText.setAttribute("role","treeitem"); if (this.contentLocale != null){ newElementText.setAttribute("lang",this.contentLocale); } //icon newElementText.appendChild(newElementIcon); // add the indicator if there is one if (newElementIndicator != null) { newElementText.appendChild(newElementIndicator); } //text var newElementLabelContainer = this.m_oLabelSPAN.cloneNode(true); newElementLabelContainer.id = treeName + treeRef + gsCTREE_labelText; newElementLabelContainer.className = getClassName(node, this); newElementLabelContainer.setAttribute(gsCTREE_treeRef, treeRef); newElementLabelContainer.setAttribute(gsCTREE_dragRef, treeRef.toString()); newElementLabelContainer.setAttribute(gsCTREE_dragTree, treeName); newElementLabelContainer.setAttribute(gsCTREE_tree, treeName); node.m_oLabelText = newElementLabelContainer; node.m_sTreeItemId = newElementLabelContainer.id; // A11Y check for Event Studio keyboard support if (typeof AccessibilityHandler != "undefined" && AccessibilityHandler.isEnabled()) { if(node.getNodeType() == TREE_ROOT || node.getParent().getLableText() == null && node.getIndex() == 0) { newElementLabelContainer.setAttribute("tabindex", "0"); } else { newElementLabelContainer.setAttribute("tabindex", "-1"); } newElementLabelContainer.setAttribute("role", "treeitem"); newElementText.removeAttribute("role"); } var newElementLabelLink = this.m_oLabelA.cloneNode(true); var newElementLabel = document.createTextNode(this.bidiSafeText(node.getName())); newElementLabelLink.appendChild(newElementLabel); newElementLabelLink.setAttribute("id", node.getTreeHierarchy()); var sStyle = this.getStyle(); newElementLabelLink.style.color= cssParser(sStyle,"color",true); newElementLabelLink.style.backgroundColor= cssParser(sStyle,"background-color",true); newElementLabelLink.style.fontFamily= cssParser(sStyle,"font-family",true); newElementLabelLink.style.fontSize= cssParser(sStyle,"font-size",true); newElementLabelLink.style.fontWeight= cssParser(sStyle,"font-weight",true); newElementLabelLink.style.fontStyle= cssParser(sStyle,"font-style",true); newElementLabelLink.style.fontVariant= cssParser(sStyle,"font-variant",true); newElementLabelLink.style.textAlign= cssParser(sStyle,"text-align",true); newElementLabelLink.style.textVariant= cssParser(sStyle,"text-variant",true); newElementLabelLink.style.textIndent= cssParser(sStyle,"text-indent",true); newElementLabelLink.style.textTransform= cssParser(sStyle,"text-transform",true); newElementLabelLink.setAttribute(gsCTREE_treeRef, treeRef); newElementLabelLink.setAttribute(gsCTREE_dragRef, treeRef.toString()); newElementLabelLink.setAttribute(gsCTREE_dragTree, treeName); newElementLabelLink.setAttribute(gsCTREE_tree, treeName); newElementLabelContainer.appendChild(newElementLabelLink); newElementText.appendChild(newElementLabelContainer); newNobr.appendChild(newElementText); if (node.isOpen()) { node.setRendered(true); } } oParentElement.appendChild(newElement); // A11Y check for Event Studio keyboard support if (typeof AccessibilityHandler != "undefined" && AccessibilityHandler.isEnabled()) { node.attachEvents(); } if (node.hasChildren() == true) { if (node.isOpen() == true) { //get any children var children = node.getChildren(); var parent = node.getParent(); // make sure setSelected is run only once, since it traverses through all the child nodes. if (node.isSelected() == true && parent != null && parent.isSelected() == false) { node.setSelected(true); } //move recursively and render all children for (var iChildCounter = 0; iChildCounter < children.length; iChildCounter++) { this.draw(children[iChildCounter], newElement); } } else { var unopenedSelectedChildren = this.hasUnopenedSelectedChild(node); if ((node.isSelected() == false) && unopenedSelectedChildren == true) { node.setHasSelectedChildren(true); node.updateNodeSelection(); } if (node.hasSelectedChildren() == true || unopenedSelectedChildren == true) { if (this.getSelectionMode() == CONTIGUOUS_TREE_SELECTION) { node.updateParent(); } else { node.partialSelectParent(); } } } } else { if ((node.getNodeType() == TREE_ROOT) && ((node.getTree().getPromptingTree() != false) || (node.getTree().getLoadOnTheFly() != false))) { node.setRendered(false); node.fetchChildren(); } else if ((node.isSelected() == true)) { if (this.getSelectionMode() == CONTIGUOUS_TREE_SELECTION) { node.updateParent(); } else { node.partialSelectParent(); } } } this.m_bHasBeenDrawn = true; }; //update selections //loop through the tree recursively to paint selections CTree.prototype.updateSelections = function (node, otherSelections) { if (typeof otherSelections == K_PRMT_sUNDEFINED) { otherSelections = false; } if (node.isSelected()) { if ((this.getForceSelectionAtLowestLevel() == true && otherSelections == false) || this.getSelectionMode() != SINGLE_TREE_SELECTION || (this.getSelectionMode() == SINGLE_TREE_SELECTION && otherSelections == false)) { //select all the children node.setSelected(true); //update the parent node.updateParent(); return true; } else { //unselect all the children node.setSelected(false); //update the parent node.updateParent(); return false; } } else { //get any children var children = node.getChildren(); //move recursively and check all children for (var iChildCounter = children.length - 1; iChildCounter >= 0; iChildCounter--) { if (this.updateSelections(children[iChildCounter], otherSelections)) { otherSelections = true; } } return otherSelections; } }; CTree.prototype.hasUnopenedSelectedChild = function (node) { //get any children var children = node.getChildren(); //move recursively and check if any children are selected for (var iChildCounter = children.length - 1; iChildCounter >= 0; iChildCounter--) { if (children[iChildCounter].isSelected() || this.hasUnopenedSelectedChild(children[iChildCounter])) { return true; } } return false; }; CTree.prototype.childrenReadyForNode = function (node) { var theNode = this.findTreeNode(this.getRootNode(), node); theNode.setLoading(false); this.setLoading(false); if (theNode.getShowUI()) { this.removeLoading(theNode); } var theNodeRef = this.getName() + theNode.getTreeRef(); if (theNode.getChildren().length > 0) { theNode.setCanHaveChildren(true); if (theNode.isOpen() && theNode.getRendered() == false && theNode.getShowUI()) { // get the parent element var oParentElement = document.getElementById(theNodeRef); gDrawChildren(theNode, oParentElement, function() { theNode.setRendered(true); if (theNode.getShowUI()) { var oTree = theNode.getTree(); oTree.redrawNodeToggle(theNode, theNodeRef); oTree.updateSelections(theNode, false); oTree.redraw(); oTree.checkData(); if (theNode.getMoreData() == true) { oTree.drawMoreData(theNode, theNodeRef); } } theNode.setShowUI(true); } ); return; } } else { theNode.setCanHaveChildren(false); } if (theNode.getShowUI()) { this.redrawNodeToggle(theNode, theNodeRef); theNode.getTree().updateSelections(theNode, false); theNode.getTree().redraw(); theNode.getTree().checkData(); if (theNode.getMoreData() == true) { this.drawMoreData(theNode, theNodeRef); } } theNode.setShowUI(true); }; CTree.prototype.findTreeNode = function (rootNode, node) { if (rootNode.m_sId != node.m_sId) { if (rootNode.hasChildren()) { var theChildren = rootNode.getChildren(); for (var i = 0; i < theChildren.length; i++) { var thisChild = this.findTreeNode(theChildren[i], node); if (thisChild != null) { return thisChild; } } } return null; } return rootNode; }; CTree.prototype.setRootNodeType = function(oTreeNodeType) { // we should make sure that the type is a rootNodeType if (oTreeNodeType != null && oTreeNodeType instanceof CTreeNodeType && oTreeNodeType.m_iType == TREE_ROOT) { this.m_oRoot.setNodeTypeObject(oTreeNodeType); } }; CTree.prototype.setWrapper = function( v_oWrapper ) { this.m_oWrapper = v_oWrapper; }; CTree.prototype.bidiSafeText = function( v_text ) { return (typeof this.m_oBidi != "undefined" && typeof this.m_oBidi["btdInjectUCCIntoStr"] != "undefined" ? this.m_oBidi.btdInjectUCCIntoStr( v_text ) : v_text); }; CTree.prototype.getTracking = function() { return this.m_oTreeControl.getTracking(); }; CTree.prototype.getConversation = function(){ var sConversation = K_PRMT_sEMPTY; var oCV = this.getCV(); if (oCV && typeof oCV.getConversation == K_PRMT_sFUNCTION) { sConversation = oCV.getConversation(); } else { // can't find ui.conversation in CCognosViewer, trying with a form var oForm = document.getElementById("formWarpRequest" + this.getCVId()); if (!oForm) { document.getElementById("formWarpRequest"); } if (oForm) { if (typeof oForm.elements["ui.conversation"] != K_PRMT_sUNDEFINED) { sConversation = oForm.elements["ui.conversation"].value; } } } return sConversation; }; CTree.prototype.getUniqueKey = function (key) { var promptKey = ""; var rootChildren = "root_children"; var sTrackingInfo = this.getTracking(); if (key.toUpperCase() == rootChildren.toUpperCase()) { if (this.bAllowStateCache) { // try to get cached prompt names var sPromptNames = this.m_oTreeControl.getCachedPromptNames(sTrackingInfo); var v_aPromptIds = []; var v_oPromptControlLookup = {}; var sMyself = this.m_oTreeControl.getName(); if ((sPromptNames != null) && (sPromptNames.length != 0)) { var aPromptNames = sPromptNames.split(":"); // get display values of prompts for (var i = 0; i < aPromptNames.length; i++) { // ignore myself if (aPromptNames[i] != sMyself) { v_aPromptIds.push(aPromptNames[i]); var sPromptDisplayValues = this.m_oTreeControl.getCachedDisplayValues(sTrackingInfo,aPromptNames[i]); v_oPromptControlLookup[aPromptNames[i]] = sPromptDisplayValues; } } // sort the ids v_aPromptIds.sort(); for (var i = 0; i < v_aPromptIds.length; i++) { promptKey += v_aPromptIds[i]; promptKey += "_"; promptKey += v_oPromptControlLookup[v_aPromptIds[i]]; } } } } return "PRMT_TREE_" + sTrackingInfo + promptKey + this.cacheKeyPrefix + key; } CTree.prototype.setCacheValue = function( key, value, bNoRetryWhenFull){ var uniqueKey = this.getUniqueKey(key); var valueToSet = value; var cachedValue = window.sessionStorage.getItem(uniqueKey); if (this.bAllowStateCache && window.sessionStorage){ try { if(cachedValue != null && cachedValue != valueToSet) // merge any new child values to the existing set of child values { valueToSet = PRMTTreeUtils.mergeChildrenInfo(cachedValue, valueToSet); } window.sessionStorage.setItem(uniqueKey, valueToSet); } catch(e) { // This could happen if we exceed the maximum of allowed storage size. if (!bNoRetryWhenFull){ // Try to recover by clear the cache and try to set the value again this.cleanCacheValues(); this.setCacheValue(key, valueToSet, true); } } } }; CTree.prototype.cleanCacheValues = function(removeAll){ if (this.bAllowStateCache && window.sessionStorage){ var currentKeyPrefix = "PRMT_TREE_" + this.getTracking(); for (var key in window.sessionStorage){ if (removeAll){ // In this case we want to dump the cache state because the Reprompt button has been selected if (key.indexOf("PRMT_TREE_") == 0){ window.sessionStorage.removeItem(key); } } else { // We only remove the entries with a different tracking number so that we don't affect the current tree state if (key.indexOf("PRMT_TREE_") == 0 && key.indexOf(currentKeyPrefix) == -1 ){ window.sessionStorage.removeItem(key); } } } } }; CTree.prototype.getCacheValue = function( key ){ var value = null; if (this.bAllowStateCache && window.sessionStorage){ var uniqueKey = this.getUniqueKey(key); value = window.sessionStorage.getItem(uniqueKey); } return value; }; CTree.prototype.removeCacheValue = function( key ){ var value = null; if (this.bAllowStateCache && window.sessionStorage){ var uniqueKey = this.getUniqueKey(key); value = window.sessionStorage.removeItem(uniqueKey); } return value; }; ///////////// //tree event handlers function toggle(evt, uiNode) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); //get UI Node if (!uiNode) { uiNode = getUINode(evt); } else { uiNode = getUINode(null, uiNode); } var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); //get the tree object var tree = uiNode.getAttribute(gsCTREE_tree).toString(); //get tree Node var node = getTreeNode(tree, uiNodeTreeRef); //toggle folders var k = 0, j = 0, children = null; if ((node.getTree().getPromptingTree() != false) || (typeof node.getTree().getLoadOnTheFly() == K_PRMT_sFUNCTION)) { if (((node.getTree().getPromptingTree() != false) && (typeof activeFetchingTreeNode == K_PRMT_sUNDEFINED || activeFetchingTreeNode == null)) || (typeof node.getTree().getLoadOnTheFly() == K_PRMT_sFUNCTION)) { if (node.isOpen() == false) { //shows either the children or the loading message for (k = 0; k < uiNode.childNodes.length; k ++) { if ((uiNode.childNodes[k].nodeType == 1) && (uiNode.childNodes[k].tagName != 'IMG') && (uiNode.childNodes[k].tagName != 'SPAN') && (uiNode.childNodes[k].tagName != 'NOBR')) { uiNode.childNodes[k].style.display = "block"; } } if (node.hasChildren()) { //draw the nodes if they haven't been rendered if (node.getRendered() == false) { gDrawChildren(node, uiNode, function() { node.setRendered(true); node.setOpen(true); updateToggleIcon(node, tree); } ); return; } } else { if (node.fetchChildren() == false) { return false; } } node.setOpen(true); } else { //hides either the children or the loading message for (k = 0; k < uiNode.childNodes.length; k ++) { if ((uiNode.childNodes[k].nodeType == 1) && (uiNode.childNodes[k].tagName != 'IMG') && (uiNode.childNodes[k].tagName != 'SPAN') && (uiNode.childNodes[k].tagName != 'NOBR')) { uiNode.childNodes[k].style.display = "none"; } } node.setOpen(false); } } else { return false; } } else { if (node.isOpen() == false) { for (k = 0; k < uiNode.childNodes.length; k ++) { if ((uiNode.childNodes[k].nodeType == 1) && (uiNode.childNodes[k].tagName != 'IMG') && (uiNode.childNodes[k].tagName != 'SPAN') && (uiNode.childNodes[k].tagName != 'NOBR')) { uiNode.childNodes[k].style.display = "block"; } } node.setOpen(true); //draw the nodes if they haven't been rendered if (node.getRendered() == false) { children = node.getChildren(); for (j = 0; j < children.length; j ++) { node.getTree().draw (children[j], uiNode); } node.setRendered(true); } } else { for (k = 0; k < uiNode.childNodes.length; k ++) { if ((uiNode.childNodes[k].nodeType == 1) && (uiNode.childNodes[k].tagName != 'IMG') && (uiNode.childNodes[k].tagName != 'SPAN') && (uiNode.childNodes[k].tagName != 'NOBR')) { uiNode.childNodes[k].style.display = "none"; } } node.setOpen(false); } } updateToggleIcon(node, tree); } function gDrawChildren(oNode, oParentUI, oFctWhenComplete, iStart) { var aChildren = oNode.getChildren(); var oTree = oNode.getTree(); if (!iStart) { iStart = 0; } var iMax = Math.min((iStart + giDRAW_BLOCKSIZE), aChildren.length); var idxChild = iStart; for (idxChild = iStart; idxChild < iMax; idxChild++) { oTree.draw(aChildren[idxChild], oParentUI); } if (idxChild < aChildren.length) { setTimeout( function () { gDrawChildren(oNode, oParentUI, oFctWhenComplete, idxChild); } , giDRAW_INTERVAL ); } else if (typeof oFctWhenComplete == K_PRMT_sFUNCTION) { oFctWhenComplete(); } } function updateToggleIcon(oNode, sTreeName) { //update the icons var icon = document.getElementById(sTreeName + oNode.getTreeRef() + gsCTREE_icon); if (icon) { icon.src = getIconSrc(oNode); var toggleIcon = document.getElementById(sTreeName + oNode.getTreeRef() + gsCTREE_toggle + oNode.getTreeHierarchy()); toggleIcon.src = getToggleSrc(oNode); toggleIcon.title = getToggleTitle(oNode); } } function treeContainerClicked(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); try { //get UI Node var uiNode = getUINode(evt); //get the tree object var tree = eval(uiNode.getAttribute(gsCTREE_tree).toString()); if (tree.getSelectTreeUI() != CHECKBOX_TREE) { tree.getRootNode().setSelected(false); } tree.setLastSelectedNode(null); tree.redraw(); tree.checkData(); } catch (e) { } } function contextMenuCaller(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); //get UI Node var uiNode = getUINode(evt); var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); //get the tree object var tree = uiNode.getAttribute(gsCTREE_tree).toString(); //get tree Node var node = getTreeNode(tree, uiNodeTreeRef); if (node.getTree().getContextMenu() != null) { var contextMenuFunc = node.getTree().getContextMenu(); contextMenuFunc(evt); cancelBub(evt); if((evt != null) && (typeof evt.preventDefault === "function")) { evt.preventDefault(); } return false; } } function singleClickCaller(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); if ((evt !== null) && (evt.keyCode != null) && (evt.keyCode != 13) && (evt.keyCode !== 0)) { return false; } //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); //get UI Node var uiNode = getUINode(evt); var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); //get the tree object var tree = uiNode.getAttribute(gsCTREE_tree).toString(); //get tree Node var node = getTreeNode(tree, uiNodeTreeRef); var singleClickFunc = node.getTree().getSingleClickFunc(); if (singleClickFunc != null) { singleClickFunc(evt); cancelBub(evt); if (!window.ie) { evt.preventDefault(); } return false; } } function doubleClickCaller(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); // A11Y check for Event Studio keyboard support if (typeof AccessibilityHandler != "undefined" && AccessibilityHandler.isEnabled() && evt.keyCode != 13 && evt.keyCode != null) { return false; } // For Event Studio Metadata tree items Enter key press if (typeof AccessibilityHandler != "undefined") { selectNode(evt); } //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); //get UI Node var uiNode = getUINode(evt); var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); //get the tree object var tree = uiNode.getAttribute(gsCTREE_tree).toString(); //get tree Node var node = getTreeNode(tree, uiNodeTreeRef); if (node.getTree().getDoubleClickFunc() != null) { var doubleClickFunc = node.getTree().getDoubleClickFunc(); doubleClickFunc(evt); cancelBub(evt); if (!window.ie) { evt.preventDefault(); } return false; } } function selectNode(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); if ((evt !== null) && (evt.keyCode != null) && (evt.keyCode != 13) && (evt.keyCode !== 0)) { return false; } //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); //get UI Node var uiNode = getUINode(evt); var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); //get the tree object var tree = uiNode.getAttribute(gsCTREE_tree).toString(); //get tree Node var node = getTreeNode(tree, uiNodeTreeRef); var oTree = node.getTree(); //handle multiple select if (oTree.getSelectionMode() != SINGLE_TREE_SELECTION) { if ((evt.ctrlKey == false) && (evt.shiftKey == false) && (oTree.getSelectTreeUI() != CHECKBOX_TREE)) { oTree.clearPreviousSelections(); } var normalTreeNeedsRedraw = ((oTree.getSelectTreeUI() == NORMAL_TREE) && (evt.ctrlKey == false) && (evt.shiftKey == false)); var unselectNode = ((oTree.getSelectTreeUI() == CHECKBOX_TREE) || ((oTree.getSelectTreeUI() == NORMAL_TREE) && ((oTree.getAllowSelectionToggle() == true) || ((oTree.getAllowSelectionToggle() == false) && (evt.ctrlKey == true))))); if (normalTreeNeedsRedraw) { oTree.getRootNode().setSelected(false); if (oTree.getTrackSelectionOrder()) { oTree.clearSelectionOrder(); } } //setSelected var nodeWasSelected = node.isSelected(); if ((oTree.getSelectTreeUI() == NORMAL_TREE) && (evt.shiftKey == true)) { var anchorNode = oTree.getAnchorNode(); if (anchorNode != null && node.getRootNode().hasSelectedChildren()) { if (node.getParent() == anchorNode.getParent()) { var anchorNodeIndex = anchorNode.getIndex(); var nodeIndex = node.getIndex(); var iCurrentNode = anchorNodeIndex; var iIncrement; if (anchorNodeIndex > nodeIndex) { iIncrement = -1; } else { iIncrement = 1; } //select all of the children between the anchor node and the selected node while (iCurrentNode != nodeIndex + iIncrement) { var siblingNode = node.getParent().m_oChildren[iCurrentNode]; siblingNode.setSelected(true); var oLabel = siblingNode.getLabel(tree); oLabel.className = getClassName(siblingNode, oTree); redrawChildren(siblingNode, tree); iCurrentNode += iIncrement; } } } } if (nodeWasSelected == true) { if (unselectNode) { node.setSelected(false); oTree.setLastSelectedNode(null); oTree.removeFromPrevSelArray( node.getValue(), node.getName() ); } } else { node.setSelected(true); oTree.setLastSelectedNode(node); } node.updateNodeSelection(); node.updateParent(); var label = node.getLabel(tree); label.className = getClassName(node, oTree); oTree.checkData(); if (normalTreeNeedsRedraw) { oTree.redraw(); oTree.checkData(); } else { redrawChildren(node, tree); redrawParents(node, tree); } if (unselectNode && nodeWasSelected) { oTree.setAnchorNode(null); } else { oTree.setAnchorNode(node); } } else { //single select remove all other selections oTree.clearPreviousSelections(); if (node.isSelected() == true && oTree.getAllowSelectionToggle() == true) { oTree.getRootNode().setSelected(false); oTree.setLastSelectedNode(null); } else { oTree.getRootNode().setSelected(false); node.setSelected(true); oTree.setLastSelectedNode(node); } node.updateParent(); oTree.redraw(); oTree.checkData(); } if (!window.ie) { evt.stopPropagation(); evt.preventDefault(); } return false; } function redrawChildren(node,tree) { //has the child node been rendered? //draw the nodes if they haven't been rendered if (node.getRendered() == true) { var children = node.getChildren(); var oTree = node.getTree(); var oParentUI = document.getElementById(tree + node.getTreeRef()); for (var j = 0; j < children.length; j++) { var oChild = children[j]; var label = oChild.getLabel(tree); if (label == null) { if (j > 0) { oTree.redrawNodeToggle(children[j - 1], tree + children[j - 1].getTreeRef()); } oTree.draw(oChild, oParentUI); if (node.isOpen() == false) { document.getElementById(tree + oChild.getTreeRef()).style.display = "none"; } } else { label.className = getClassName(oChild, oTree); if (oTree.getSelectionMode() != SINGLE_TREE_SELECTION) { if (oTree.getSelectTreeUI() == CHECKBOX_TREE) { var checkbox = oChild.getCheckbox(tree); if (checkbox) checkbox.src = getCheckBoxSrc(oChild); } } } redrawChildren(oChild,tree); } } } function redrawParents(node, tree) { var parentNode = node.getParent(); if (parentNode != null) { var label = parentNode.getLabel(tree); if (label != null) { label.className = getClassName(parentNode, parentNode.getTree()); if (node.getTree().getSelectionMode() != SINGLE_TREE_SELECTION) { if (parentNode.getTreeRef() != null && parentNode.getTreeRef().length !== 0) { if (node.getTree().getSelectTreeUI() == CHECKBOX_TREE) { var checkbox = parentNode.getCheckbox(tree); checkbox.src = getCheckBoxSrc(parentNode); } redrawParents(parentNode, tree); } } } } } function dragStartOnNode(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); var dragRef = (evt.srcElement) ? evt.srcElement.getAttribute(gsCTREE_dragRef) : ((evt.originalTarget) ? evt.originalTarget.getAttribute(gsCTREE_dragRef) : null); if (dragRef != null && typeof dragRef == K_PRMT_sSTRING && dragRef.length !== 0) { var uiNode = getUINode(evt); if (uiNode) { //get the tree object var tree = uiNode.getAttribute(gsCTREE_dragTree).toString(); //get tree Node var node = getTreeNode(tree, dragRef); var treeObj = node.getTree(); if (!node.isSelected()) { if ((evt.ctrlKey == false) && (evt.shiftKey == false)) { treeObj.getRootNode().setSelected(false); treeObj.clearPreviousSelections(); if (treeObj.getTrackSelectionOrder()) { treeObj.clearSelectionOrder(); } } //select all the children node.setSelected(true); //update the parent node.updateParent(); var label = node.getLabel(); label.className = getClassName(node, treeObj); if ((evt.ctrlKey == false) && (evt.shiftKey == false)) { treeObj.redraw(); treeObj.checkData(); } } var selectedNodes = treeObj.getSelectedFolderNodes(); selectedNodes = selectedNodes.concat(treeObj.getSelectedLeafNodes()); var selNodesStr = tree + "~~~~~"; for (var i = 0; i < selectedNodes.length; i++) { if (i > 0) { selNodesStr += "~~~"; } selNodesStr += selectedNodes[i].getTreeRef(); } evt.dataTransfer.setData("Text", selNodesStr); if (treeObj.getOnDragStart() != null) { var dragStartFunction = treeObj.getOnDragStart(); dragStartFunction(evt); } } } } function dragOnNode(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); var dragRef = (evt.srcElement) ? evt.srcElement.getAttribute(gsCTREE_dragRef) : ((evt.originalTarget) ? evt.originalTarget.getAttribute(gsCTREE_dragRef) : null); if (dragRef != null && typeof dragRef == K_PRMT_sSTRING && dragRef.length !== 0) { var uiNode = getUINode(evt); if (uiNode) { //get the tree object var tree = uiNode.getAttribute(gsCTREE_dragTree).toString(); //get tree Node var node = getTreeNode(tree, dragRef); var treeObj = node.getTree(); if (treeObj.getOnDrag() != null) { var dragFunction = treeObj.getOnDrag(); dragFunction(evt); } } } if (!window.ie) { evt.preventDefault(); } } function dragEndOnNode(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); var dragRef = (evt.srcElement) ? evt.srcElement.getAttribute(gsCTREE_dragRef) : ((evt.originalTarget) ? evt.originalTarget.getAttribute(gsCTREE_dragRef) : null); if (dragRef != null && typeof dragRef == K_PRMT_sSTRING && dragRef.length !== 0) { var uiNode = getUINode(evt); if (uiNode) { //get the tree object var tree = uiNode.getAttribute(gsCTREE_dragTree).toString(); //get tree Node var node = getTreeNode(tree, dragRef); var treeObj = node.getTree(); if (treeObj.getOnDragEnd() != null) { var dragEndFunction = treeObj.getOnDragEnd(); dragEndFunction(evt); } } } if (!window.ie) { evt.preventDefault(); } } ///////////////////// //utility functions //cancel any text selection function clearSelection() { if (typeof document.selection != K_PRMT_sUNDEFINED && typeof document.selection.createRange == K_PRMT_sFUNCTION && document.selection.createRange().text != K_PRMT_sEMPTY) { //IE specific document.selection.empty(); } else if (typeof window.getSelection == K_PRMT_sFUNCTION && typeof window.getSelection() == K_PRMT_sOBJECT) { //NS6 specific window.getSelection().removeAllRanges(); } } //find the element that the event occurred function getUINode (evt, uiNode) { if (!uiNode) { //get the element that trapped the event in a cross-browser fashion uiNode = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); } //check to see if this is a text node. while (uiNode.nodeType == 3) { //this is a text node, get the parent node uiNode = uiNode.parentNode; } var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); //bubble event to the correct node if ((uiNodeTreeRef == gsCTREE_img) || (uiNodeTreeRef == gsCTREE_label) || (uiNodeTreeRef == gsCTREE_checkbox)) { //pass the event from icon to the parent node uiNode = uiNode.parentNode; } uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); if (uiNodeTreeRef == gsCTREE_nobr) { //pass the event from icon to the parent node uiNode = uiNode.parentNode; } return uiNode; } //get the javascript treenode for a given tree //and tree reference function getTreeNode(tree, uiNodeTreeRef) { var node = null; if (uiNodeTreeRef != K_PRMT_sEMPTY) { //find the target tree node var arTreeNodeArray = uiNodeTreeRef.split(K_PRMT_sDOT); var treeNode = K_PRMT_sEMPTY; for (var k = 0; k < arTreeNodeArray.length; k++) { if (arTreeNodeArray[k] != K_PRMT_sEMPTY) { treeNode += ".m_oChildren[" + arTreeNodeArray[k] + "]"; } } node = eval(tree + ".getRootNode()" + treeNode); } else { node = eval(tree + ".getRootNode()"); } return node; } //return the appropriate classname for the given node function getClassName(node,tree) { var newClassName = CLS_TREE_NODE_UNSELECTED; //get the current state //the selection classnames only apply to single select trees if ((tree.getSelectionMode() == SINGLE_TREE_SELECTION || tree.getSelectTreeUI() == NORMAL_TREE) && tree.getRootNode() != node) { switch (node.getState()) { case NODE_PARTIAL: newClassName = CLS_TREE_NODE_PARTIAL; break; case NODE_SELECTED: newClassName = CLS_TREE_NODE_SELECTED; break; } } return newClassName; } //return appropriate checkbox image src for the given node function getCheckBoxSrc(node) { var newImageSrc = K_PRMT_sEMPTY; //get the current state switch (node.getState()) { case NODE_UNSELECTED: newImageSrc = CHECKBOX_UNSELECTED; break; case NODE_PARTIAL: newImageSrc = CHECKBOX_PARTIAL; break; case NODE_SELECTED: newImageSrc = CHECKBOX_SELECTED; break; } return newImageSrc; } function getIconSrc(node) { var newImageSrc = K_PRMT_sEMPTY; if (node.isOpen() == true) { newImageSrc = node.getNodeTypeObject().m_sIconOpenSrc; } else { newImageSrc = node.getNodeTypeObject().m_sIconSrc; } return newImageSrc; } function getIconAlign(node) { //node.getNodeTypeObject().m_sIconAlign; // Removed the attribute m_sIconAlign, for backward compatibility return gsCTREE_middle; } //return plus or minus icons for the given node function getToggleSrc(node) { if (node.isOpen() == true) { if (node.isLast() == true && node.getParent().getMoreData() != true) { return TREE_L_MINUS; } else { return TREE_T_MINUS; } } else { if (node.isLast() == true && node.getParent().getMoreData() != true) { return TREE_L_PLUS; } else { return TREE_T_PLUS; } } } //return plus or minus title for the given node function getToggleTitle(node) { if (node.isOpen() == true) { return PMT_TRE_COLLAPSE; } else { return PMT_TRE_EXPAND; } } function treeNodeMouseOver(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); //get UI Node var uiNode = getUINode(evt); var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); //get the tree object var tree = uiNode.getAttribute(gsCTREE_tree).toString(); //get tree Node var node = getTreeNode(tree, uiNodeTreeRef); window.status = K_PRMT_sEMPTY; if (node.getNodeTypeObject().getSelectable() && node.isSelected() == false && node.hasSelectedChildren() == false) { var label = node.getLabel(tree); label.className = CLS_TREE_NODE_HOVER; } } function treeNodeMouseOut(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); //get UI Node var uiNode = getUINode(evt); var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); //get the tree object var tree = uiNode.getAttribute(gsCTREE_tree).toString(); //get tree Node var node = getTreeNode(tree, uiNodeTreeRef); window.status = K_PRMT_sEMPTY; if (node.isSelected() == false && node.hasSelectedChildren() == false) { var label = node.getLabel(tree); label.className = CLS_TREE_NODE_UNSELECTED; } } ///////////////////////////////// // Tree node object // oParentTreeNode: the parent node - null for the root node // oTreeNodeType: the type of node, a TreeNodeType object (e.g. folder/leaf) // bOpenState: if this is a container, whether the the default state is open or closed [true|false] // name: the display value for the tree node // value: the use value for the tree node // bSelected: whether this node has been selected or not //Tree nodes function CTreeNode(oParentTreeNode, oTreeNodeType, bOpenState, sName, value, bSelected) { if (oTreeNodeType) { this.init(oParentTreeNode, oTreeNodeType, bOpenState, sName, value, bSelected); } } CTreeNode.prototype.init = function(oParentTreeNode, oTreeNodeType, bOpenState, sName, value, bSelected) { //id is the searchpath this.m_sId = this.generateId(); this.m_sName = sDecodeU003( sName ); this.m_sValue = sDecodeU003( value ); this.m_oChildren = []; this.m_iSelectedChildrenCount = 0; this.m_bOpen = bOpenState; //has this node been rendered? this.m_bRendered = bOpenState; //tree reference this.m_sTreeRef = null; if (oParentTreeNode != null) { this.m_oParentTreeNode = oParentTreeNode; this.setLevel(this.m_oParentTreeNode.getLevel() + 1); if (((this.getTree().getForceSelectionAtLowestLevel() == true && oTreeNodeType.m_iType == TREE_ITEM) || (this.getTree().getForceSelectionAtLowestLevel() == false)) && (this.getTree().getShowPreviousValues() == true)) { this.m_bSelected = bSelected; } else { this.m_bSelected = false; } this.m_oParentTreeNode.appendChild(this); var prevSels = this.getTree().getPreviousSelections(); if (prevSels != null) { for (var i = 0; i < prevSels.length; i++) { if ((typeof prevSels[i] == K_PRMT_sSTRING) && (prevSels[i] == this.m_sValue)) { this.m_bSelected = true; break; } else if ((typeof prevSels[i] == K_PRMT_sOBJECT) && (prevSels[i][1] == this.m_sValue)) { this.m_bSelected = true; break; } } } } else { this.m_oParentTreeNode = null; this.setLevel(0); this.m_bSelected = false; } //node type this.m_oTreeNodeType = oTreeNodeType; if (oTreeNodeType.m_isContainer == true && (oParentTreeNode != null && this.getTree().nodesCanHaveChildren() == true)) { this.setCanHaveChildren(true); } else { this.setCanHaveChildren(false); } this.m_bHasSelectedChildren = false; this.m_oRoot = null; this.m_bIsLoading = false; this.m_sToolTip = false; this.m_bIsMoreData = false; this.m_iSkipValueCount = 0; // default indicator - used for QoS this.m_sIndicator = null; this.allowUIForChildren = true; var v_oTree = this.getTree(); if ( v_oTree && v_oTree.m_oAncestry && v_oTree.m_oAncestry[this.m_sValue] ) { this.setHasSelectedChildren(true); } } CTreeNode.prototype.attachEvents = function() { var treeItem = this.getHTMLTreeItem(); if(treeItem == null) return; // just to be safe treeItem.onkeypress = this.onkeypress; treeItem.treeNode = eval(this); } CTreeNode.prototype.onkeypress = function(evt) { evt = (evt) ? evt : ((event) ? event : null); var keyCode = evt.keyCode || evt.which; var treeNode = this.treeNode; var parentNode = treeNode.getParent(); var toggleIcon = treeNode.getHTMLToggleIcon(); // check for root node if (parentNode == null) { // only for Down key if (keyCode == 40) { treeNode.getChild(0).getHTMLTreeItem().focus(); } // other key press do nothing } // check for Left key press else if (keyCode == 37) { if (treeNode.isOpen()) { toggleIcon.click(); } else if (parentNode.getHTMLTreeItem() != null) { parentNode.getHTMLTreeItem().focus(); if (parentNode != treeNode.getRootNode()) { parentNode.getHTMLToggleIcon().click(); } } } // check for Right key press else if (keyCode == 39) { if (!treeNode.isOpen()) { toggleIcon.click(); } } // check for Up and Down key press else if (keyCode == 38 || keyCode == 40) { var nextTreeNode = treeNode.getNextTreeNode(keyCode); if (nextTreeNode != null && nextTreeNode.getHTMLTreeItem() != null) { nextTreeNode.getHTMLTreeItem().focus(); } } } CTreeNode.prototype.getNextTreeNode = function(keyCode) { var current, next, first = 0; var parentNode = this.getParent(); var nextTreeNode = null; for (var i=0; i= 0; iParentLevel--) { oCurrentNode = oCurrentNode.getParent(); sHierarchyName = oCurrentNode.getName() + "_" + sHierarchyName; } return sHierarchyName; }; CTreeNode.prototype.setSkipValueCount = function(val) { this.m_iSkipValueCount = val; }; CTreeNode.prototype.getSkipValueCount = function() { return this.m_iSkipValueCount; }; CTreeNode.prototype.getTooltip = function () { return this.m_sToolTip; }; CTreeNode.prototype.setTooltip = function (val) { this.m_sToolTip = val; }; CTreeNode.prototype.getNodeTypeObject = function () { return this.m_oTreeNodeType; }; CTreeNode.prototype.setNodeTypeObject = function(oTreeNodeType) { this.m_oTreeNodeType = oTreeNodeType; }; CTreeNode.prototype.getNodeType = function () { return this.getNodeTypeObject().m_iType; }; CTreeNode.prototype.generateId = function () { return (Date.parse((new Date()).toString()) / 1000000) + Math.random(); }; CTreeNode.prototype.getRootNode = function () { if (this.m_oRoot == null) { var theRoot = this; while (theRoot.getLevel() != 0) { theRoot = theRoot.getParent(); } this.m_oRoot = theRoot; } return this.m_oRoot; }; CTreeNode.prototype.getTree = function () { return this.getRootNode().m_oTree; }; CTreeNode.prototype.getParentAtLevel = function (iLevel) { var parentAtLevel = this; var iCurrentLevel = this.getLevel(); if (this.getLevel() > iLevel) { for ( var j=iLevel; j < iCurrentLevel; j++) { parentAtLevel = parentAtLevel.getParent(); } } return parentAtLevel; }; CTreeNode.prototype.isLast = function () { if ((this.getParent() != null) && (this.getTreeRef() == this.getParent().m_oChildren[this.getParent().getChildrenLength() - 1].getTreeRef())) { return true; } else { return false; } }; CTreeNode.prototype.getCheckbox = function (sTreeRef) { if (!this.m_oCheckbox) { this.m_oCheckbox = document.getElementById(sTreeRef + this.getTreeRef() + gsCTREE_checkbox); } return this.m_oCheckbox; }; CTreeNode.prototype.getLabel = function (sTreeRef) { if (!this.m_oLabelText) { this.m_oLabelText = document.getElementById(sTreeRef + this.getTreeRef() + gsCTREE_labelText); } return this.m_oLabelText; }; //integer: has this tree node been rendered yet? CTreeNode.prototype.setLevel = function (iLevel) { this.m_oLevel = iLevel; }; CTreeNode.prototype.getLevel = function () { return this.m_oLevel; }; //boolean: has this tree node been rendered yet? CTreeNode.prototype.setRendered = function (bRendered) { this.m_bRendered = bRendered; }; CTreeNode.prototype.getRendered = function () { return this.m_bRendered; }; //treeRef: a comma separated list that uniquely identifies tree nodes CTreeNode.prototype.setTreeRef = function (sTreeRef) { this.m_sTreeRef = sTreeRef; }; CTreeNode.prototype.getTreeRef = function () { return this.m_sTreeRef; }; //boolean: returns whether the node has children or not CTreeNode.prototype.hasChildren = function () { if (this.getChildrenLength() > 0) { return true; } else { return false; } }; //container: can this node contain other nodes CTreeNode.prototype.canHaveChildren = function () { return this.m_bCanHaveChildren; }; CTreeNode.prototype.setCanHaveChildren = function (val) { this.m_bCanHaveChildren = val; }; //selected: user choice state for the node CTreeNode.prototype.isSelected = function () { return this.m_bSelected; }; //boolean: does this node have any selected children at any level? CTreeNode.prototype.setHasSelectedChildren = function (bSelectedChildren) { this.m_bHasSelectedChildren = bSelectedChildren; }; CTreeNode.prototype.hasSelectedChildren = function () { return this.m_bHasSelectedChildren; }; //recurse through the tree and select all children CTreeNode.prototype.setSelected = function (bSelected, bForceRecurs) { if (this.getNodeTypeObject().getSelectable()) { this.m_bSelected = bSelected; //add to default selected list only when tree is first rendered if (this.isSelected() && this.getTree().getDefaultSelectLock()) { this.getTree().addDefaultSelectedNode(this); } if (this.getTree().getTrackSelectionOrder()) { if (bSelected) { this.getTree().addToSelectionOrder(this); } else { this.getTree().removeFromSelectionOrder(this); } } } //select children too if (bForceRecurs == true || ((this.getTree().getSelectTreeUI() != CHECKBOX_TREE || this.getTree().getSelectionMode() != DISCONTIGUOUS_TREE_SELECTION) && (!bSelected || (this.getTree().getRecursiveSelect() && this.getNodeTypeObject().getRecursiveSelect())))) { this.setHasSelectedChildren(bSelected); for (var j=0; j < this.getChildrenLength(); j++) { this.m_oChildren[j].setSelected(bSelected, bForceRecurs); } } }; //Update this nodes childrens references to their position in the tree //this is called when removing nodes CTreeNode.prototype.updateTreeRefs = function () { var children = this.getChildren(); for (var j = 0; j < this.getChildrenLength(); j++) { var treeRef = K_PRMT_sEMPTY + children[j].getTreeRef(); var ref_replace_regex = /(\.{0,1})[0-9]+$/; treeRef = treeRef.replace(ref_replace_regex, "$1" + j); //re create the refs children[j].setTreeRef(treeRef); } }; //Update this node CTreeNode.prototype.update = function () { if (this.getTree().getSelectTreeUI() != CHECKBOX_TREE || this.getTree().getSelectionMode() != DISCONTIGUOUS_TREE_SELECTION) { this.m_bSelected = false; } var hasSelectedChildren = false; var iSelectedChildren = 0; var children = this.getChildren(); for (var j = 0; j < this.getChildrenLength(); j++) { if(children[j].isSelected() == true) { iSelectedChildren += 1; hasSelectedChildren = true; } else if(children[j].hasSelectedChildren()) { //parent.setHasSelectedChildren hasSelectedChildren = true; } } this.setSelectedChildrenCount(iSelectedChildren); this.setHasSelectedChildren(hasSelectedChildren); if (this.getNodeTypeObject().getRecursiveSelect() == true) { if ( this.getTree().getSelectionMode() == CONTIGUOUS_TREE_SELECTION && iSelectedChildren == this.getChildrenLength() && this.getNodeTypeObject().getFullChildSelectable() ) { this.m_bSelected = true; } this.updateNodeSelection(); } this.updateParent(); }; //Update the parent CTreeNode.prototype.updateParent = function () { var parent = this.getParent(); if (parent) { parent.update(); } }; //if it is known that a child is selected, just iterate through and partial select all parents CTreeNode.prototype.partialSelectParent = function () { var parent = this.getParent(); if (parent != null) { parent.setHasSelectedChildren(true); if (parent != this.getRootNode()) { parent.updateNodeSelection(); parent.partialSelectParent(); } } }; CTreeNode.prototype.updateNodeSelection = function () { if (this.getTree().getSelectTreeUI() == NORMAL_TREE) { if (this.getTree().getSelectionMode() == CONTIGUOUS_TREE_SELECTION && this.isSelected() == false && this.getNodeType() == TREE_FOLDER && this.getChildrenLength() == this.getSelectedChildrenCount()) { this.m_bSelected = true; } var label = this.getLabel(this.getTree().getName()); if (label != null) { label.className = getClassName(this, this.getTree()); } } else { var checkbox = this.getCheckbox(this.getTree().getName()); if (checkbox != null) { checkbox.src = getCheckBoxSrc(this); } } }; //open: specifies whether the children of a container node should be displayed CTreeNode.prototype.isOpen = function () { return this.m_bOpen; }; CTreeNode.prototype.setOpen = function (bOpen) { this.m_bOpen = bOpen; }; //string: return the id of the node CTreeNode.prototype.getId = function () { return this.m_sId; }; //string: return the name of the node CTreeNode.prototype.getName = function () { return this.m_sName; }; //void: set the name of the node CTreeNode.prototype.setName = function (name) { this.m_sName = name; }; //string: return the value of the node CTreeNode.prototype.getValue = function () { return this.m_sValue; }; //void: set the value of the node CTreeNode.prototype.setValue = function (value) { this.m_sValue = sDecodeU003( value ); }; //tree node array: return the children CTreeNode.prototype.getChildren = function () { return this.m_oChildren; }; //tree node array: return the children array length CTreeNode.prototype.getChildrenLength = function () { return this.m_oChildren.length; }; //tree node array: return the parent node CTreeNode.prototype.getParent = function () { return this.m_oParentTreeNode; }; //node manipulation functions CTreeNode.prototype.appendChild = function (obj) { var iAppendPos = this.getChildrenLength(); this.m_oChildren[iAppendPos] = obj; if (obj.isSelected() == true) { this.m_iSelectedChildrenCount += 1; } var newTreeRef; if (this.getTreeRef() != null && this.getTreeRef().length !== 0) { newTreeRef = this.getTreeRef() + K_PRMT_sDOT + iAppendPos; } else { newTreeRef = iAppendPos; } this.m_oChildren[iAppendPos].setTreeRef(newTreeRef); }; //take the passed node out of this node CTreeNode.prototype.removeChild = function (obj) { //is it a node we know if (!obj.m_sId) { return; } var iSize = this.getChildrenLength(); var oNewChildren = new Array(); for (var i = 0; i < iSize; i++) { if (obj.m_sId != this.m_oChildren[i].m_sId) { oNewChildren.push(this.m_oChildren[i]); } } //replace the children with the filtered results this.m_oChildren = oNewChildren; //rejig the tree refs this.updateTreeRefs(); }; //return the child at the appropriate position CTreeNode.prototype.getChild = function (index) { if (index >= 0 && index < this.getChildrenLength()) { return this.m_oChildren[index]; } return null; }; //take the passed node out of this node CTreeNode.prototype.removeChildren = function (childNodes) { //is it a node array? if (!childNodes || !childNodes.length || childNodes.length === 0) { return; } var oRef_map = new Object(); var i = 0; for (i = 0; i < childNodes.length; i++) { if (childNodes[i].m_sId) { oRef_map[childNodes[i].m_sId] = childNodes[i]; } } var oNewChildren = new Array(); for (i = 0; i < this.getChildrenLength(); i++) { if (!oRef_map[this.m_oChildren[i].m_sId]) { //this is saved from the bin oNewChildren.push(this.m_oChildren[i]); } } //replace the children with the filtered results this.m_oChildren = oNewChildren; //rejig the tree refs this.updateTreeRefs(); }; //remove this node from its parent CTreeNode.prototype.detach = function () { this.getParent().removeChild(this); }; CTreeNode.prototype.getSelectedChildrenCount = function () { return this.m_iSelectedChildrenCount; }; CTreeNode.prototype.setSelectedChildrenCount = function (count) { this.m_iSelectedChildrenCount = count; }; CTreeNode.prototype.addSelectedChildrenCount = function () { this.m_iSelectedChildrenCount = this.m_iSelectedChildrenCount + 1; }; CTreeNode.prototype.removeSelectedChildrenCount = function () { this.m_iSelectedChildrenCount = this.m_iSelectedChildrenCount - 1; }; //return the current state of the node CTreeNode.prototype.getState = function () { if (this.isSelected()) { return NODE_SELECTED; } else if (this.hasSelectedChildren() == true) { if ((this.getTree().getSelectionMode() == CONTIGUOUS_TREE_SELECTION) && (this.getSelectedChildrenCount() > 0) && (this.getSelectedChildrenCount() == this.getChildrenLength()) && this.getNodeTypeObject().getFullChildSelectable()) { return NODE_SELECTED; } else { return NODE_PARTIAL; } } return NODE_UNSELECTED; }; CTreeNode.prototype.setShowUI = function (showUI) { this.allowUIForChildren = showUI; }; CTreeNode.prototype.getShowUI = function() { return this.allowUIForChildren; }; CTreeNode.prototype.getResponseCacheKey = function(response){ return this.getValue() + "_children"; }; //fetch the children of the node CTreeNode.prototype.fetchChildren = function (bForceFetch) { var v_oTree = this.getTree(); if ( !v_oTree.nodesCanHaveChildren() && bForceFetch !== true) { return; } if (v_oTree.getPromptingTree() != false) { if ((typeof activeFetchingTreeNode == K_PRMT_sUNDEFINED || activeFetchingTreeNode == null) && (v_oTree.m_oDispatcher != null) && (this.getLoading() == false)) { this.setLoading(true); v_oTree.setLoading(true); if (this.getShowUI()) { this.setOpen(true); v_oTree.redrawNodeToggle(this, v_oTree.getName() + this.getTreeRef()); v_oTree.drawLoading(this, v_oTree.getName() + this.getTreeRef()); } activeFetchingTreeNode = this; var cachedResponse = SYSTEMPROPERTY_TREE_CACHE_IGNORE_PRIOR_RSVP_RESPONSES ? false : this.getTree().getCacheValue(this.getResponseCacheKey()); if (cachedResponse && !this.bShouldFetchChildren){ promptTreeCallback(cachedResponse); }else{ this.sendFetchChildrenRequest(); } } return true; } else if (typeof v_oTree.getLoadOnTheFly() == K_PRMT_sFUNCTION) { if (this.getLoading() == false) { this.setLoading(true); v_oTree.setLoading(true); if (this.getShowUI()) { this.setOpen(true); v_oTree.redrawNodeToggle(this, v_oTree.getName() + this.getTreeRef()); v_oTree.drawLoading(this, v_oTree.getName() + this.getTreeRef()); } var theFunction = v_oTree.getLoadOnTheFly(); theFunction(this); } return true; } else { this.setCanHaveChildren(false); if (this.getShowUI()) { v_oTree.redrawNodeToggle(this, v_oTree.getName() + this.getTreeRef()); } return false; } }; // If the tracking information is not available call sendFetchChildrenRequest // after a delay of WAIT_FOR_TRACKING_TIMEOUT_MS. There is also a retry count // just in case the tracking information is always empty. var WAIT_FOR_TRACKING_TIMEOUT_MS = 100; // 100 milliseconds var TRACKING_RETRY_CNT_MAX = 500; // 500 * 100 ms = 50 seconds worth of trying CTreeNode.prototype.sendFetchChildrenRequest = function( v_oParams, v_iRetryCount ) { // Call the XTS to load the prompting tree var cafContextId = K_PRMT_sEMPTY; // TODO var url = "b_action=xts.run&m=/prompting/promptTree.xts"; // Pass the m_tracking node var tracking_info = this.getTree().getTracking(); var sConversation = this.getTree().getConversation(); var retries = TRACKING_RETRY_CNT_MAX; if ( typeof v_iRetryCount != "undefined" ) { retries = v_iRetryCount; } if (tracking_info=="") { if ( retries > 0 ) { var _self = this; setTimeout( function() { _self.sendFetchChildrenRequest(v_oParams, retries-1); }, WAIT_FOR_TRACKING_TIMEOUT_MS ); return; } } if (cafContextId != K_PRMT_sEMPTY) { url += "&ui.cafcontextid=" + cafContextId; } if (this.getMoreData() == true) { url += "&skipValueCount=" + (this.getSkipValueCount() + this.getTree().getMaxValueCount()); } else { url += "&skipValueCount=" + this.getSkipValueCount(); } url += "&maximumValueCount=" + this.getTree().getMaxValueCount(); url += "¶mName=" + encodeURIComponent(this.getTree().getPromptingTree()); url += "&treeNodeName=" + this.getTree().getName() + this.getTreeRef(); if (this.getNodeType() != TREE_ROOT) { url += "&useValue=" + encodeURIComponent(this.getValue()); url += "&displayValue=" + encodeURIComponent(this.getName()); } if ( v_oParams ) { for( var v_sParamName in v_oParams ) { if ( v_sParamName == "m_tracking" ) { tracking_info = v_oParams[v_sParamName]; } else if ( v_sParamName == "ui.conversation" ) { sConversation = v_oParams[v_sParamName]; } else { url += "&" + v_sParamName + "=" + encodeURIComponent( v_oParams[v_sParamName] ); } } } url += "&m_tracking=" + tracking_info; url += "&ui.conversation=" + sConversation; var v_oRequest = this.getTree().m_oDispatcher.createRequest(this.getTree().getGateway(), url, promptTreeCallback); this.getTree().m_oDispatcher.setErrorHandlerFunction(treeErrorHandler); this.getTree().m_oDispatcher.dispatchRequest(v_oRequest); } CTreeNode.prototype.setLoading = function (val) { this.m_bIsLoading = val; }; CTreeNode.prototype.getLoading = function () { return this.m_bIsLoading; }; CTreeNode.prototype.setMoreData = function (val) { this.m_bIsMoreData = val; }; CTreeNode.prototype.getMoreData = function () { return this.m_bIsMoreData; }; CTreeNode.prototype.getIndex = function () { if (this.getParent() != null) { var children = this.getParent().getChildren(); for (var i = 0; i < children.length; i++) { if (children[i] == this) { return i; } } } else { return null; } }; /* CTreeNode.prototype.findCommonParent = function (otherNode) { var i = this.getParent(); var rootNode = this.getRootNode(); while(i != rootNode) { var otheri = otherNode.getParent(); while (otheri != rootNode) { if(otheri == i) return i; otheri = otheri.getParent(); } if(otheri == i) return i; i = i.getParent(); } return rootNode; } */ CTreeNode.prototype.setIndicator = function(sIndicatorSrc) { // set the indicator value this.m_sIndicator = sIndicatorSrc; }; CTreeNode.prototype.getIndicator = function() { // return the indicator value return this.m_sIndicator; }; //definitions for the types of nodes function CTreeNodeType(iType, isContainer, sIconSrc, sIconOpenSrc) { this.m_iType = iType; this.m_isContainer = isContainer; this.m_sIconSrc = sIconSrc; this.m_sIconOpenSrc = sIconOpenSrc; this.m_sIconAltText = null; this.m_bSelectable = true; this.m_bRecursiveSelect = true; this.m_bFullChildSelect = true; } CTreeNodeType.prototype.setSelectable = function(val) { this.m_bSelectable = val; }; CTreeNodeType.prototype.setAltText = function(altText) { this.m_sIconAltText = altText; }; CTreeNodeType.prototype.getSelectable = function() { return this.m_bSelectable; }; CTreeNodeType.prototype.setFullChildSelectable = function(val) { this.m_bFullChildSelect = val; }; CTreeNodeType.prototype.getFullChildSelectable = function() { return this.m_bFullChildSelect; }; CTreeNodeType.prototype.setRecursiveSelect = function(val) { this.m_bRecursiveSelect = val; }; CTreeNodeType.prototype.getRecursiveSelect = function() { return this.m_bRecursiveSelect; }; function handleWorking(response) { var responseArray = response.split('","'); var url = "b_action=xts.run&m=/prompting/promptTree.xts"; var cafContextId = K_PRMT_sEMPTY; // TODO if (cafContextId != K_PRMT_sEMPTY) { url += "&ui.cafcontextid=" + cafContextId; } var treeName = responseArray[1]; url += "&treeNodeName=" + treeName; url += "&doWait=1&m_tracking=" + responseArray[2]; //DO WE NEED TO GET PARAMETERS FROM SOMEWHERE??? Probably not // url += "&doWait=1&m_tracking=" + responseArray[2] + "¶meterValues=" + encodeURIComponent(cfgGet("parameterValues")); var treeNode = activeFetchingTreeNode; var request = treeNode.getTree().m_oDispatcher.createRequest(treeNode.getTree().getGateway(), url, promptTreeCallback); // alert("about to dispatch: [" + url + "]") treeNode.getTree().m_oDispatcher.dispatchRequest(request); } function cleanupActiveFetchingTreeNodeOnError() { var theNode = activeFetchingTreeNode; if (theNode) { var theTree = theNode.getTree(); if (theNode.getShowUI()) { theTree.removeLoading(theNode); } if (theNode.getChildren().length == 0) { theNode.setCanHaveChildren(false); } if (theNode.getShowUI()) { var theNodeRef = theTree.getName() + theNode.getTreeRef(); theTree.redrawNodeToggle(theNode, theNodeRef); theTree.updateSelections(theNode, false); theTree.redraw(); theTree.checkData(); } } activeFetchingTreeNode = null; } CTreeNode.prototype.createNewNode = function(treeNode, tntGeneric, name, value, isSelected) { new TreeNode(treeNode, tntGeneric, false, jsDecodeStr(name), jsDecodeStr(value), isSelected); }; CTreeNode.prototype.setFetchChildrenFlag = function(bShouldFetch) { this.bShouldFetchChildren = bShouldFetch; }; function promptTreeCallback(response, reRenderPage) { // web page(error, timeout, etc) or working response if (response != K_PRMT_sEMPTY && !PRMTTreeUtils.isChildrenInfo(response)) { var responseArray = response.split('","'); if (responseArray[0].substr(1) == "working") { setTimeout("handleWorking('" + response + "');", 100); } else { var v_oTree = activeFetchingTreeNode; if ( v_oTree ) { v_oTree = v_oTree.getTree(); } var v_oCV = ( v_oTree ? v_oTree.getCV() : null ); if ( v_oCV && v_oCV.sSkin && typeof response == K_PRMT_sSTRING ) { // add default CSS for this skin before the first tag. response = response.replace("\n -1)) ) { if ((responseArray.length - preDataLength) % 4 != 0) { return false; } for (var i = preDataLength; i < responseArray.length; i += 4) { var isSelected = false; if (jsDecodeStr(responseArray[i + 3]).charAt(0) == "t") { isSelected = true; } treeNode.createNewNode(treeNode, tntGeneric, responseArray[i + 1], responseArray[i + 2], isSelected); } } treeNode.setMoreData(moreData == "true"); if(moreData == "true") { treeNode.setFetchChildrenFlag(true); } treeNode.setSkipValueCount(skipValueCount); treeNode.getTree().setMaxValueCount(maxValueCount); treeNode.getTree().childrenReadyForNode(treeNode); } activeFetchingTreeNode = null; } else { cleanupActiveFetchingTreeNodeOnError(); } } function getMoreDataForTreeNode(evt) { //get the event in a cross-browser fashion evt = (evt) ? evt : ((event) ? event : null); // don't return when Enter, ArrowRight, ArrowUp or undefined keys are pressed if ((evt !== null) && (evt.keyCode != null) && (evt.keyCode != K_KEY_UP) && (evt.keyCode != K_KEY_RIGHT) && (evt.keyCode != K_KEY_ENTER) && (evt.keyCode !== 0) && (evt.keyCode != K_KEY_TAB || !evt.shiftKey)) { return false; } //cancel any text selection clearSelection(); //prevent the event from bubbling to other elements cancelBub(evt); //get UI Node var uiNode = null; if ( evt.target ) { uiNode = evt.target; } else if ( evt.srcElement ) { uiNode = evt.srcElement; } else { return false; } var uiNodeTreeRef = uiNode.getAttribute(gsCTREE_treeRef).toString(); //get the tree object var tree = uiNode.getAttribute(gsCTREE_tree).toString(); //get tree Node var node = getTreeNode(tree, uiNodeTreeRef); if (typeof activeFetchingTreeNode == K_PRMT_sUNDEFINED || activeFetchingTreeNode == null) { // expand the node when Enter or ArrowRight keys are pressed if (evt.keyCode == K_KEY_ENTER || evt.keyCode == K_KEY_RIGHT || evt.keyCode == 0 || evt.keyCode == null) { node.getTree().removeMoreData(node, node.getTree().getName() + node.getTreeRef()); node.fetchChildren(true); } var v_oTree = node.getTree(); if (v_oTree) { // if the pressed key is ArowUp then move the focus to the previous node which is the last sibling before More node // there will always be a previous node for a More node // do the same if the Shift+Tab keys are both pressed // otherwise, i.e. for ArrowRight, ArrowLeft, Enter, and undefined keys, move the focus to the parent node // there will always be a parent node for a More node // note that the user should be forced to collapse the parent node to navigate to its next sibling // the More link loses the focus but it should still be tab-able var moreDataNode = v_oTree.m_lastFocus; if (evt.keyCode == K_KEY_UP || (evt.keyCode == K_KEY_TAB && evt.shiftKey) || evt.keyCode == K_KEY_RIGHT || evt.keyCode == K_KEY_ENTER || evt.type == gsCTREE_click) { // the last child of 'node' is the node before More node v_oTree.f_moveFocus(null, node.getLastChild()); } else { v_oTree.f_moveFocus(null, node); } // make the more data node tab-able moreDataNode.tabIndex = 0; } } } function treeErrorHandler(errorStoppedAt, e) { // alert("errorHandler broke at: [" + errorStoppedAt + "]\nwith message: [" + e.message + "]\nin file: [" + e.fileName + "]\nat line: [" + e.lineNumber + "]"); } function CTree_clearIFramePopup() { var v_oIFrame = null; while( v_oIFrame = document.getElementById( 'CTree_IFramePOPUP' ) ) { v_oIFrame.parentNode.removeChild( v_oIFrame ); delete v_oIFrame; } G_CTREE_IFramePopupWindow = null; } function CTree_promptAction(sAction, sArg) { var v_oCV = PRMTTreeUtils.getCVObjectFromActiveTree(); if ( v_oTree ) { v_oTree = v_oTree.getTree(); } var v_oCV = ( v_oTree ? v_oTree.getCV() : null ); if ( sAction == K_ACTION_CANCEL ) { // we use setTimeout to start a different thread for the request. // Otherwise, the request aborts in Firefox when this function ends. setTimeout( v_oCV.promptAction.bind( v_oCV, sAction, sArg ), 10 ); } else { var aPreProcess = G_CTREE_IFramePopupWindow.getPreProcessControlArray(); if (aPreProcess) { G_CTREE_IFramePopupWindow.preProcessForm(aPreProcess); var ar = aPreProcess; var kCount = ar.length; var k = 0; var sXML = K_PRMT_sEMPTY; var v_oParams = {}; for (k=0; k' var reHTML = new RegExp("^<(!DOCTYPE )?html", "i"); var result = (sArg.match( reHTML )? true : false); return result; }, isChildrenInfo: function (sArg) { // children info is in JSON format inside a minimal html wrapper, the json content starts 'var j="CTree' var reHTML = new RegExp("j=\\[\"CTree", "i"); var result = (sArg.match( reHTML )? true : false); return result; }, mergeChildrenInfo: function(sArg1, sArg2) { //helper function to merge two different sets of children info for the same tree node into one html wrapper //1. extract child information from html wrapper in sArg2 //2. merge extracted child information with cached child info in sArg1 var retVal = ""; var parts = sArg1.split('","'); var cachedSkipValueCount = parseInt(jsDecodeStr(parts[2]), 10); var extractedVal = '","'; var childInfo = sArg2.split('","'); var responseSkipValueCount = parseInt(jsDecodeStr(childInfo[2]), 10); var newSkipValueCount = cachedSkipValueCount + responseSkipValueCount; parts[2] = jsEncodeStr(newSkipValueCount.toString()); retVal = parts.join('","'); var indexOfClosingTag = childInfo[childInfo.length - 1].lastIndexOf(""); childInfo[childInfo.length - 1] = childInfo[childInfo.length - 1].substring(0, indexOfClosingTag); childInfo = childInfo.splice(6, childInfo.length); for (var i = 0; i < childInfo.length; i++) { extractedVal += childInfo[i]; if(i != (childInfo.length - 1)) { extractedVal += '","'; } } retVal = retVal.replace("\"]", extractedVal + ""); return retVal; }, getCVObjectFromActiveTree: function () { var v_oTree = activeFetchingTreeNode; if ( v_oTree ) { v_oTree = v_oTree.getTree(); } var v_oCV = ( v_oTree ? v_oTree.getCV() : null ); return v_oCV; }, getIframeDoc: function (v_iFrame) { var v_oDoc = null; if (v_iFrame) { if (v_iFrame.contentDocument) { v_oDoc = v_iFrame.contentDocument; } else if (v_iFrame.contentWindow && v_iFrame.contentWindow.document) { v_oDoc = v_iFrame.contentWindow.document; } else if (v_iFrame.document) { v_oDoc = v_iFrame.document; } } return v_oDoc; }, f_iFramePopupExists: function() { var v_oIFrame = null; var result = false; v_oIFrame = document.getElementById( 'CTree_IFramePOPUP' ); if (v_oIFrame && v_oIFrame.reRender) { result = true; } return result; }, f_createTargetIFrame: function () { // create/recycle target iframe var v_sIFrameId = 'CTree_IFramePOPUPTarget'; //remove if exists var v_targetIframe = $(v_sIFrameId); if (v_targetIframe) { // and PRMTUtils.f_isDOMElem(v_alertDiv)) PRMTUtils.f_removeElement(v_targetIframe.parent); } // create a new one var v_oEle = document.createElement('DIV'); v_oEle.innerHTML = ''; document.body.appendChild(v_oEle); var iFrame = document.getElementById(v_sIFrameId); PRMTUtils.f_addEvent(iFrame, "load", PRMTTreeUtils.f_popupSubmitCallback); return v_sIFrameId; }, f_popupSubmitCallback: function () { var v_oIFrame = (window.ie?document.getElementById('CTree_IFramePOPUPTarget'):this); var v_oDoc = (v_oIFrame.contentDocument? v_oIFrame.contentDocument : (v_oIFrame.contentWindow? v_oIFrame.contentWindow.document : v_oIFrame.document) ); if (v_oDoc && v_oDoc.location && v_oDoc.location.href != "about:blank") { // extract response string var responseString = null; if (v_oDoc.implementation && v_oDoc.implementation.createDocument) { var v_oSerializer = new XMLSerializer(); responseString = v_oSerializer.serializeToString(v_oDoc); } else { // IE if (null != v_oDoc.body.parentNode.innerHTML) { responseString = v_oDoc.body.parentNode.innerHTML; } else { return; } } if (PRMTTreeUtils.isChildrenInfo(responseString)) { parent.CTree_clearIFramePopup(); parent.promptTreeCallback(responseString); } else { // check to skip double submit if (!parent.PRMTTreeUtils.f_iFramePopupExists()) { parent.promptTreeCallback(responseString, true); } } } } }; /** * Target the form in the popup iframe to a hidden iframe where we can parse the response */ var K_PRMT_WAIT_FOR_POPUP_TIMEOUT_MS = 100; // 100 milliseconds var K_PRMT_POPUP_RETRY_CNT_MAX = 500; // 500 * 100 ms = 50 seconds worth of trying PRMTTreeUtils.setPopupFormTarget = function(iframe, v_iRetryCount) { var v_iframeDoc = null; var v_aForms = null; var v_targetIframeId = null; try { v_iframeDoc = PRMTTreeUtils.getIframeDoc(iframe); if (v_iframeDoc && v_iframeDoc.getElementsByTagName) { v_aForms = v_iframeDoc.getElementsByTagName('form'); } var retries = K_PRMT_POPUP_RETRY_CNT_MAX; if ( typeof v_iRetryCount != "undefined" ) { retries = v_iRetryCount; } } catch(e) { // trace(e.message); } if ( v_aForms && v_aForms.length > 0 ) { v_targetIframeId = PRMTTreeUtils.f_createTargetIFrame(); var v_oForm = v_aForms[0]; v_oForm.setAttribute('target', v_targetIframeId); if (iframe.reRender) { iframe.removeAttribute('reRender'); } } else { if ( retries > 0 ) { setTimeout( function() { PRMTTreeUtils.setPopupFormTarget(iframe, retries-1); }, K_PRMT_WAIT_FOR_POPUP_TIMEOUT_MS ); return; } } }; function CTree_setPromptAction( v_oWin ) { var v_oCV = v_oWin.oCV; if ( v_oCV ) { G_CTREE_IFramePopupWindow = v_oWin; v_oCV.promptAction = CTree_promptAction; } if ( v_oWin.doCancel ) { v_oWin.doCancel = CTree_promptAction.bind( this, K_ACTION_CANCEL ); } } //skin folder var PROMPT_SKIN = (typeof getPromptSkin != K_PRMT_sUNDEFINED ? getPromptSkin() : K_PRMT_sDEFAULTSKIN); var PROMT_IMAGES = PROMPT_SKIN + "/prompting/images/"; //Constants var TREE_ROOT = 0; var TREE_FOLDER = 1; var TREE_ITEM = 2; //Selection Constants // Allow only a single node to be selected (default) var SINGLE_TREE_SELECTION = 0; // Allow multiple selections of visible nodes var DISCONTIGUOUS_TREE_SELECTION = 1; // Allow selection to span one vertical contiguous set of nodes var CONTIGUOUS_TREE_SELECTION = 2; //Tree Type Constant var NORMAL_TREE = "normalTree"; var CHECKBOX_TREE = "checkboxTree"; //Tree Classes var CLS_TREE_TEXT = "clsTreeText"; var CLS_TREE_TEXT_LINK = "clsTreeText aLink"; var CLS_TREE_TEXT_NO_LINK = "clsTreeText noLink"; var CLS_TREE_LEVEL = "clsTreeLevel"; var CLS_TREE_NODE_SELECTED = "clsTreeNode_selected"; var CLS_TREE_NODE_PARTIAL = "clsTreeNode_partial"; var CLS_TREE_NODE_UNSELECTED = "clsTreeNode_unselected"; var CLS_TREE_NODE_HOVER = "clsTreeNode_hover"; var CLS_TRE_EXPAND_COLLAPSE_HOVER = "clsExpandCollapseHover clsTextIconAlignFix"; var CLS_TREE_TEXTICON_ALIGNFIX = "clsTextIconAlignFix"; //tree node types var tntRoot = new CTreeNodeType(TREE_ROOT, true, PROMT_IMAGES + "icon_tree_folder_closed.gif", PROMT_IMAGES + "icon_tree_folder_open.gif"); var tntFolder = new CTreeNodeType(TREE_FOLDER, true, PROMT_IMAGES + "icon_tree_folder_closed.gif", PROMT_IMAGES + "icon_tree_folder_open.gif"); var tntLeaf = new CTreeNodeType(TREE_ITEM, false, PROMT_IMAGES + "icon_tree_leaf.gif", PROMT_IMAGES + "icon_tree_leaf.gif"); //tri-state checkboxes have the following states: // node is selected // node is not selected // node has some or all children that are selected var CHECKBOX_UNSELECTED = PROMT_IMAGES + "checkbox_unchecked.gif"; var CHECKBOX_PARTIAL = PROMT_IMAGES + "checkbox_mixed.gif"; var CHECKBOX_SELECTED = PROMT_IMAGES + "checkbox_checked.gif"; //Error state graphics var ERROR_TIMED_SMALL_OFF = PROMT_IMAGES + "error_timed_small_off.gif"; var ERROR_TIMED_SMALL = PROMT_IMAGES + "error_timed_small.gif"; var NODE_UNSELECTED = 0; var NODE_PARTIAL = 1; var NODE_SELECTED = 2; //line connector definitions var TREE_T_PLUS = PROMT_IMAGES + "icon_tree_Tplus.gif"; var TREE_T_MINUS = PROMT_IMAGES + "icon_tree_Tminus.gif"; var TREE_T_ONLY = PROMT_IMAGES + "icon_tree_T.gif"; var TREE_L_PLUS = PROMT_IMAGES + "icon_tree_Lplus.gif"; var TREE_L_MINUS = PROMT_IMAGES + "icon_tree_Lminus.gif"; var TREE_L_ONLY = PROMT_IMAGES + "icon_tree_L.gif"; var TREE_L_ONLY_RTL = PROMT_IMAGES + "icon_tree_L_rtl.gif"; var TREE_I_ONLY = PROMT_IMAGES + "icon_tree_I.gif"; var TREE_SPACE = PROMT_IMAGES + "icon_tree_white.gif"; //loading icon var TREE_LOADING = PROMT_IMAGES + "loading_timed.gif"; //more data icon var TREE_MORE_DATA = PROMT_IMAGES + "icon_more.gif"; var G_CTREE_IFramePopupWindow = null; // Event Studio is not loading externsions.js so repeating browser id if (typeof window.ie === 'undefined') { if (!!window.MSInputMethodContext && !!document.documentMode && (document.documentMode == 11)) { window.ie = window.ie11 = true; } else if (document.childNodes && !document.all && !navigator.taintEnabled && !!window.StyleMedia) { window.ie = window.ie11 = window.edge = true; } else if (document.all && !!window.atob) { window.ie = window['ie10'] = true; } else if (document.all && !!document.addEventListener) { window.ie = window['ie9'] = true; } else if (document.all && !!document.querySelector) { window.ie = window['ie8'] = true; } else if (document.all && !!window.XMLHttpRequest) { window.ie = window['ie7'] = true; } else if (document.all && !!document.compatMode) { window.ie = window['ie6'] = true; } else if (document.all) { window.ie = window['ie5'] = true; } };