Download node_modules/@materializecss/materialize/js/component.js from Leon4gr45/matomo: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/node_modules/%40materializecss/materialize/js/component.js
- Command line
-
hf download hf://spaces/Leon4gr45/matomo/node_modules/@materializecss/materialize/js/component.js
-
curl -L -o component.js https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/node_modules/%40materializecss/materialize/js/component.js
1.1 kB
| class Component { | |
| /** | |
| * Generic constructor for all components | |
| * @constructor | |
| * @param {Element} el | |
| * @param {Object} options | |
| */ | |
| constructor(classDef, el, options) { | |
| // Display error if el is valid HTML Element | |
| if (!(el instanceof Element)) { | |
| console.error(Error(el + ' is not an HTML Element')); | |
| } | |
| // If exists, destroy and reinitialize in child | |
| let ins = classDef.getInstance(el); | |
| if (!!ins) { | |
| ins.destroy(); | |
| } | |
| this.el = el; | |
| this.$el = cash(el); | |
| } | |
| /** | |
| * Initializes components | |
| * @param {class} classDef | |
| * @param {Element | NodeList | jQuery} els | |
| * @param {Object} options | |
| */ | |
| static init(classDef, els, options) { | |
| let instances = null; | |
| if (els instanceof Element) { | |
| instances = new classDef(els, options); | |
| } else if (!!els && (els.jquery || els.cash || els instanceof NodeList)) { | |
| let instancesArr = []; | |
| for (let i = 0; i < els.length; i++) { | |
| instancesArr.push(new classDef(els[i], options)); | |
| } | |
| instances = instancesArr; | |
| } | |
| return instances; | |
| } | |
| } | |