thinkmap.graph.history.HistoryManager

extends:
Jump To: Members Events

Examples:

Create a history manager that manages the history of a display var graph = new thinkmap.graph.Graph(); var display = new thinkmap.display.Display(); graph.datasource('/moviedb.tas'); var historyManager = new thinkmap.graph.history.HistoryManager(graph); historyManager.add(display); function center(entity) { graph.query('node','edge','node') .execute(entity) .onresult(display.add) .oncomplete(function(results) { display.retainOnly(results); historyManager.pushState(); }); } //configure optional history listener historyManager.addEventListener('popstate',function(state) { console.log('history restored'); });

Constructor

Instance Methods

Defined in thinkmap.graph.history.HistoryManager:

Events

snapshot : function ( Object )

this event is fired when the history manager has a new state pushed on via its pushState method. The single parameter is a data object which contains two properties: hid which is the unique identifier for this history state. The second property is 'state' which contains any additional data that should be stored in the browsers history object along with the current state of the graphs.

This event is very useful when there are several elements that aren't not graphs but need to capture some history. These event listeners that are added for this reason should append their data directly the state property of the data object which they will then be able to access via the popstate event.

popstate : function ( Object )

this event is fired when the history manager needs to restore a state (typically from the user pressing the forward/back buttons of the browser). The single parameter is the same data object that was passed into the the snapshot event. There is a hid property and a state property. The state property should contain any additioanl data that was stored along with either the pushState or snapshot event.

rebuild : function ( )

fired when the history manager is rebuilding history for the graphs. This can typically be ignored by most developers as it is mainly used internally by the history manager.