TimelineJS API

Categories

Component ID

2628044

Component name

TimelineJS API

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Downloads

558

Component created

Component changed

Component body

Developer API for generating and rendering data using the TimelineJS3 library.

E.g.


use Drupal	imelinejs_apiTimelineData;
use Drupal	imelinejs_apiTimelineSlide;
use Drupal	imelinejs_apiTimelineEra;
use Drupal	imelinejs_apiTimelineTitle;
use Drupal	imelinejs_apiTimelinerenderer;

$data = new TimelineData();

$date = TimelineDate::createFromDateString('now');
$text = new TimelineText('Headline text', 'Long text');
$event = new TimelineSlide($date, $text, 'My Group');

$data->addEvent($event);

// A URL to be AJAX loaded can also be passed instead of data object.
// The callback should return the same data as you'd get by calling
// TimelineData::toArray(). So data should be created in the same way
// and returned from the callback as JSON.
$renderer = new TimelineRenderer('unique-id', $data);

// Drupal render array with correct timeline JS data, #attached libraries, 
// and markup.
$build = $renderer->render();