API
FileDownload
Parameters
elementHTMLElement DOM element for component instantiation and scopeoptionsObject (optional, default{})options.translationToggleSelectorString Selector for toggling translatoins section (optional, default'[data-ecl-file-translation-toggle]')options.translationContainerSelectorString Selector for translations section container (optional, default'[data-ecl-file-translation-container]')options.attachClickListenerBoolean Whether or not to bind click events on toggle (optional, defaulttrue)
init
Initialise component.
destroy
Destroy component.
handleClickOnToggle
Parameters
eEvent
autoInit
Parameters
rootHTMLElement DOM element for component instantiation and scope$1Object (optional, default{})$1.FILE_DOWNLOAD(optional, default{})
Returns FileDownload An instance of FileDownload.
Setup
There are 2 ways to initialise the component.
Automatic
Add data-ecl-auto-init="FileDownload" attribute to component's markup:
<div class="ecl-file" data-ecl-file data-ecl-auto-init="FileDownload">...</div>
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-file on the page:
var elt = document.querySelector('[data-ecl-file]');
var file = new ECL.FileDownload(elt);
file.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-file]');
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();