API
Timeline2
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.TIMELINE2(optional, default{})
Returns Timeline2 An instance of Timeline2.
Setup
There are 2 ways to initialise the component.
Automatic
Add data-ecl-auto-init="Timeline2" attribute to component's markup:
<ol
class="ecl-timeline2"
data-ecl-timeline="true"
data-ecl-auto-init="Timeline2"
>
...
</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-timeline2 on the page:
var elt = document.querySelector('[data-ecl-timeline2]');
var timeline2 = new ECL.Timeline2(elt);
timeline2.init();