Opening and Closing Folders
Let's review the last lines of the initializeDocument function:
//The tree starts in full display if (!STARTALLOPEN) if (browserVersion > 0) { // close the whole tree clickOnNode(0) // open the root folder clickOnNode(0) }
As you can see, the clickOnNode function does what you'd expect a user's mouse click to do: If a folder is open, clickOnNode closes it, and if the folder is closed, clickOnNode opens it. Let's take a look at it in Example 22-9.
Example 22-9. clickOnNode function
function clickOnNode(folderId) { var clickedFolder = 0 var state = 0 clickedFolder = indexOfEntries[folderId] state = clickedFolder.isOpen ... |
Get Advanced JavaScript™: Insights and Innovative Techniques now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.