API
Timeline
Parameters
elementHTMLElement DOM element for component instantiation and scopeoptionsObject (optional, default{})options.buttonSelectorString (optional, default'[data-ecl-timeline-button]')options.labelSelectorString (optional, default'[data-ecl-label]')options.labelExpandedString (optional, default'data-ecl-label-expanded')options.labelCollapsedString (optional, default'data-ecl-label-collapsed')options.attachClickListenerBoolean Whether or not to bind click events (optional, defaulttrue)
init
Initialise component.
destroy
Destroy component.
handleClickOnButton
Expand timeline if not such already.
autoInit
Parameters
rootHTMLElement DOM element for component instantiation and scope$1Object (optional, default{})$1.TIMELINE(optional, default{})
Returns Timeline An instance of Timeline.
Setup
There are 2 ways to initialise the component.
Automatic
Add data-ecl-auto-init="Timeline" attribute to component's markup:
<ol class="ecl-timeline" data-ecl-timeline="true" data-ecl-auto-init="Timeline">
...
</ol>
Use the ECL library's autoInit() (ECL.autoInit()) when your page is ready or other custom event you want to hook onto.
Manual
Get target element, create an instance and invoke init().
Given you have 1 element with an attribute data-ecl-timeline on the page:
var elt = document.querySelector('[data-ecl-timeline]');
var timeline = new ECL.Timeline(elt);
timeline.init();
Retrieve an existing instance
If an existing instance needs to be updated, it can be retrieved this way:
var elt = document.querySelector('[data-ecl-timeline]');
var instance = ECL.components.get(elt);
To update an existing instance, you can run destroy() and init() on this instance, like this:
instance.destroy();
instance.init();