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');
});
Constructs a history manager with the given source graph. The history manager is used to manager history through the browser like most typical applications. By pushing and restoring states, the user can revisit different actions and views of several graphs.
A couple of important notes however. History is only managed once the user enters Thinkmap. Because of the asynchronous nature of Thinkmap datasources, the amount of entities that can be visited, and limitations of browser history size, Thinkmap cannot save history once the user leaves the page. So although states will be in the browser history, pressing forward/back buttons will have no effect as the data was not serialized once the user left the page.
the main graph used to back all history. Ideally, this is the most high level graph used by Thinkmap. It is typically the graph that handles server side queries and has one or more datasources attached to it. All other graphs in the application typically are a subset of this graph.
the maximum number of history to keep on the stack. The default is 20.
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');
});
Adds a graph that will have its history be managed. These types of graphs are typically trees, display, and smaller graphs that should be restored as the user navigates history.
the graph to add to the history manager
return this history manager
Moves the history back one. This is the same as pressing the back button in the browser
Moves the history forward one. This is the same as pressing the forward button in the browser.
Pushes and saves a new history state on the history manager. This method takes a snapshot of all the graphs the history manager is currently managing and adds the state onto the browsers history queue.
optional state data that should be saved along with the graphs snapshot. This is useful for restoring some additional data that may be helpful when restoring a history state.
Add a listener to this EventSource
the name of the event to listen for
the callback to add
this eventsource
Dispatch an event from this EventSource, supplying arguments to the listeners via an Array, rather than var-args.
the name of the event to dispatch
this EventSource
Dispatch an event from this EventSource
the name of the event to dispatch
optional arguments sent to the event listeners
this EventSource
Fire an event from this EventSource
the name of the event to dispatch
optional arguments sent to the event listeners
this EventSource
Remove a listener from this EventSource
the name of the event to remove the listener for
the callback to remove
this eventsource
Add a listener to this EventSource
the name of the event to listen for
the callback
this eventsource
Add a listener to this EventSource, which will be called at most once and will be removed the first time the given event fires.
the name of the event to listen for
the callback to add
this eventsource
Remove a listener from this EventSource
the name of the event to remove the listener for
the callback to remove
this eventsource
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.
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.
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.