Timeglider Widget: The Kitchen Sink

For full documentation, please go to http://timeglider.com/widget/?p=api. If you have questions, email Michael: michael@timeglider.com

initial loaded callback: ....

In the widget options, defining "loaded" with a function will call that function once all data is loaded and the first rendering of the timeline occurs

// inside of widget options
...
"loaded":function() { $(".loaded").html("loaded callback!"); },
...

navigation

  • zoom in
  • zoom out
  • pan to left
  • pan to right
tg_instance.zoom(-1);
tg_instance.zoom(1);

// setting pan buttons
tg_instance.panButton($(".pan-left"), "left");
tg_instance.panButton($(".pan-right"), "right");

goTo

Set date and zoom level.

  • Sept 11, 2001
  • Today
tg_instance.goTo("2001-09-11 08:24:00",22);

Go to today, at current zoom:

tg_instance.goTo("today");

getScope

At any time, you can grab the current focus and other information about the visible scope of the timeline, as well as the reach of loaded timelines.

var scope = tg.instance.getScope()
  • Call it to see info below:

...

addEvent

Scroll to right side of timeline to add an event: You should see "New Event" with red star icon showing up. It's given a random importance value.

  • addEvent
var obj = {
	id:"new_event_id",
	title:"New Event!",
	startdate:"today", // or YYYY-MM-DD format
	importance:32,
	icon:"star_red.png",
	timelines:["js_history"]
}
			
tg_instance.addEvent(obj, true);

updateEvent

Update event will, in this case change the title of "Slow death of Flash", to "Flash struggles...".

var updatedEventModel = {
	id:"deathofflash",
	title: "Flash struggles to survive in the age of HTML5."
}

tg_instance.updateEvent(updatedEventModel);

reloadTimeline (with updated data)

Make a visible change to json/js_history.json, then click on the reload button.

  • reload
tg_instance.reloadTimeline("js_history", "json/js_history.json");

loadTimeline

Using an ajax request, load a new timeline into view.

  • load:

refresh and adjustNow

Refresh is a simple re-rendering of the timeline that may need to occur after changes of internal data view states. Usually refresh() is taken care of automatically (by the mediator) when zoom level changes or if one sets a specific date with goTo().

adjustNow() will renew dates for events that had "now" (perpetually current) as their initial values, setting them to the current time.