// Click the tree node.
treeMenu.on('click', function (node, event) {
if (node.isLeaf()) {
var href = node.attributes.href;
// Modify the location of current url.
window.location.href = '#' + href;
addExampleTab(node);
// Don't response to this tree node's default behavior.
event.stopEvent();
}
});
(function pageFirstLoad() {
var currentHash = window.location.hash.substr(1);
var level1Nodes = treeMenu.getRootNode().childNodes;
for (var i = 0; i < level1Nodes.length; i++) {
var level2Nodes = level1Nodes[i].childNodes;
for (var j = 0; j < level2Nodes.length; j++) {
var currentNode = level2Nodes[j];
if (currentNode.attributes.href === currentHash) {
level1Nodes[i].expand();
// We must retrieve this node again, because currentNode doesn't has parentNode property.
var foundNode = treeMenu.getNodeById(currentNode.id);
foundNode.select();
addExampleTab(foundNode);
return;
}
}
}
})();