src/modules/structureTree.js
function selectNode($node, selectContents, multiselect, external) {
        var id = $node.attr('name');
        
        _removeCustomClasses();
        
        // clear other selections if not multiselect
        if (!multiselect) {
            if (tree.currentlySelectedNodes.indexOf(id) != -1) {
                tree.currentlySelectedNodes = [id];
            } else {
                tree.currentlySelectedNodes = [];
            }
        }
        
        if (id) {
            var isEntity = w.entitiesManager.getEntity(id) !== undefined;
            var aChildren = $node.children('a');
            
            if (isEntity) {
                tree.currentlySelectedNodes = [];
                aChildren.addClass('nodeSelected').removeClass('contentsSelected');
                if (tree.currentlySelectedEntity !== id) {
                    tree.currentlySelectedEntity = id;
                    tree.selectionType = null;
                    
                    if (!external) {
                        ignoreSelect = true;
                        w.entitiesManager.highlightEntity(id, null, true);
                    }
                }
            } else if (w.structs[id] != null) {
                tree.currentlySelectedEntity = null;
                if (tree.currentlySelectedNodes.indexOf(id) != -1 && !external) {
                    // already selected node, toggle selection type
                    selectContents = !selectContents;
                } else {
                    tree.currentlySelectedNodes.push(id);
                }
                
                if (selectContents) {
                    aChildren.addClass('contentsSelected').removeClass('nodeSelected');
                } else {
                    aChildren.addClass('nodeSelected').removeClass('contentsSelected');
                }
                
                tree.selectionType = selectContents ? tree.CONTENTS_SELECTED : tree.NODE_SELECTED;

                if (!external) {
                    if (w.structs[id]._tag == w.header) {
                        w.dialogManager.show('header');
                    } else {
                        ignoreSelect = true; // set to true so tree.highlightNode code isn't run by editor's onNodeChange handler
                        w.selectStructureTag(tree.currentlySelectedNodes, selectContents);
                    }
                }
            } 
        }
    }
function selectNode($node, selectContents, multiselect, external) {
        var id = $node.attr('name');
        
        _removeCustomClasses();
        
        // clear other selections if not multiselect
        if (!multiselect) {
            if (tree.currentlySelectedNodes.indexOf(id) != -1) {
                tree.currentlySelectedNodes = [id];
            } else {
                tree.currentlySelectedNodes = [];
            }
        }
        
        if (id) {
            var isEntity = w.entitiesManager.getEntity(id) !== undefined;
            var aChildren = $node.children('a');
            
            if (isEntity) {
                tree.currentlySelectedNodes = [];
                aChildren.addClass('nodeSelected').removeClass('contentsSelected');
                if (tree.currentlySelectedEntity !== id) {
                    tree.currentlySelectedEntity = id;
                    tree.selectionType = null;
                    
                    if (!external) {
                        ignoreSelect = true;
                        w.entitiesManager.highlightEntity(id, null, true);
                    }
                }
            } else if (w.structs[id] != null) {
                tree.currentlySelectedEntity = null;
                if (tree.currentlySelectedNodes.indexOf(id) != -1 && !external) {
                    // already selected node, toggle selection type
                    selectContents = !selectContents;
                } else {
                    tree.currentlySelectedNodes.push(id);
                }
                
                if (selectContents) {
                    aChildren.addClass('contentsSelected').removeClass('nodeSelected');
                } else {
                    aChildren.addClass('nodeSelected').removeClass('contentsSelected');
                }
                
                tree.selectionType = selectContents ? tree.CONTENTS_SELECTED : tree.NODE_SELECTED;

                if (!external) {
                    if (w.structs[id]._tag == w.header) {
                        w.dialogManager.show('header');
                    } else {
                        ignoreSelect = true; // set to true so tree.highlightNode code isn't run by editor's onNodeChange handler
                        w.selectStructureTag(tree.currentlySelectedNodes, selectContents);
                    }
                }
            } 
        }
    }
function selectNode ( $node , selectContents , multiselect , external ) { var id = $node . attr ( 'name' ) ; _removeCustomClasses ( ) ; // clear other selections if not multiselect if ( ! multiselect ) { if ( tree . currentlySelectedNodes . indexOf ( id ) != - 1 ) { tree . currentlySelectedNodes = [ id ] ; } else { tree . currentlySelectedNodes = [ ] ; } } if ( id ) { var isEntity = w . entitiesManager . getEntity ( id ) !== undefined ; var aChildren = $node . children ( 'a' ) ; if ( isEntity ) { tree . currentlySelectedNodes = [ ] ; aChildren . addClass ( 'nodeSelected' ) . removeClass ( 'contentsSelected' ) ; if ( tree . currentlySelectedEntity !== id ) { tree . currentlySelectedEntity = id ; tree . selectionType = null ; if ( ! external ) { ignoreSelect = true ; w . entitiesManager . highlightEntity ( id , null , true ) ; } } } else if ( w . structs [ id ] != null ) { tree . currentlySelectedEntity = null ; if ( tree . currentlySelectedNodes . indexOf ( id ) != - 1 && ! external ) { // already selected node, toggle selection type selectContents = ! selectContents ; } else { tree . currentlySelectedNodes . push ( id ) ; } if ( selectContents ) { aChildren . addClass ( 'contentsSelected' ) . removeClass ( 'nodeSelected' ) ; } else { aChildren . addClass ( 'nodeSelected' ) . removeClass ( 'contentsSelected' ) ; } tree . selectionType = selectContents ? tree . CONTENTS_SELECTED : tree . NODE_SELECTED ; if ( ! external ) { if ( w . structs [ id ] . _tag == w . header ) { w . dialogManager . show ( 'header' ) ; } else { ignoreSelect = true ; // set to true so tree.highlightNode code isn't run by editor's onNodeChange handler w . selectStructureTag ( tree . currentlySelectedNodes , selectContents ) ; } } } } }
Performs actual selection of a tree node
@param {Element} $node A jquery node (LI) in the tree
@param {Boolean} selectContents True to select contents
@param {Boolean} multiselect True if ctrl or select was held when selecting
@param {Boolean} external True if selectNode came from outside structureTree, i.e. tree.selectNode
Performs actual selection of a tree node