API
Timeline
Parameters
element
HTMLElement DOM element for component instantiation and scopeoptions
Object (optional, default{}
)options.buttonSelector
String (optional, default'[data-ecl-timeline-button]'
)options.labelSelector
String (optional, default'[data-ecl-label]'
)options.labelExpanded
String (optional, default'data-ecl-label-expanded'
)options.labelCollapsed
String (optional, default'data-ecl-label-collapsed'
)options.attachClickListener
Boolean Whether or not to bind click events (optional, defaulttrue
)
init
Initialise component.
destroy
Destroy component.
handleClickOnButton
Expand timeline if not such already.
autoInit
Parameters
root
HTMLElement DOM element for component instantiation and scope$1
Object (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();