PersistentTree is built into AnimTree. It saves the tree state for your users so that as they navigate your site, the tree will always appear open to the right place. When a user returns to the site, the tree will be open as s/he left it.
You can make multiple trees "follow" the user around two ways.
activateMenu(sButtonId) in each pageput global.js on your server
modify LISTENER_SCRIPT_SRC and PERSISTENCE_MILLIS (optional)
call these functions in your document:
fireOnload( function() {
saveTreeOnUnload(treeId);
restoreTreeState(treeId, defaultButtonId);
});
put global.js on your server
Store global.js online with your other js files.
modify LISTENER_SCRIPT_SRC
and PERSISTENCE_MILLIS (optional)
in treeparams.js change:
var LISTENER_SCRIPT_SRC = "/res/js/global.js"; var MS_PER_DAY = 1000 * 60 * 60 * 24; var PERSISTENCE_MILLIS = 1 * MS_PER_DAY; // 1 day
PERSISTENCE_MILLIS is how long the tree
cookie is stored for. Tip: Use a negative number for a session
cookie (expires when the user closes the browser).
LISTENER_SCRIPT_SRC is the source for an
event listener script for
browsers that don't support event listener/attachEvent (mac IE).
call these in your document or in treeparams.js:
fireOnload( function() {
saveTreeOnUnload(treeId);
restoreTreeState(treeId, defaultButtonId);
});
This has already been done for you in treeparams.js.
Variable treeId is the id of the tree to save.
defaultButtonId is the id of the button to activate if
no menu is
activated, the id for defaultButtonId will be passed to
activateMenu.
You can see the source of function restoreTreeState.
Optionally, you can use a null defaultButton.
This means that no default button is activated,
but the tree will follow the user. You could put this in treeParams.js,
as I have done in the demos.
fireOnload( function() {
saveTreeOnUnload("nav");
restoreTreeState("nav", null);
});
Next in this tutorial: AnimTree Function Reference