0
0
Fork 0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-10 02:50:39 +00:00
BookStackApp_BookStack/resources/assets/js/components/index.js
2017-08-06 18:01:49 +01:00

21 lines
No EOL
630 B
JavaScript

let componentMapping = {
'dropdown': require('./dropdown'),
};
window.components = {};
let componentNames = Object.keys(componentMapping);
for (let i = 0, len = componentNames.length; i < len; i++) {
let name = componentNames[i];
let elems = document.querySelectorAll(`[${name}]`);
if (elems.length === 0) continue;
let component = componentMapping[name];
if (typeof window.components[name] === "undefined") window.components[name] = [];
for (let j = 0, jLen = elems.length; j < jLen; j++) {
let instance = new component(elems[j]);
window.components[name].push(instance);
}
}