meta-lightbox/src/js/app.js

45 lines
957 B
JavaScript
Raw Permalink Normal View History

2019-11-25 06:59:54 +01:00
/*
2019-11-27 06:09:35 +01:00
* MetaLightbox
2019-11-25 06:59:54 +01:00
* https://tony.twma.pro
*
*/
2022-05-03 20:58:33 +02:00
import Events from './_events'
import MetaWindow from './window'
2021-02-24 10:38:08 +01:00
2023-02-20 15:50:40 +01:00
let container = document.getElementById('MetaLightboxApp');
2021-08-04 00:55:06 +02:00
if (!container) {
2023-02-20 15:50:40 +01:00
console.warn(`MetaWindow: missing container #MetaLightboxApp - create new one`);
container = document.createElement("div");
container.setAttribute("id", "MetaLightboxApp");
document.querySelector("body").append(container);
2021-08-04 00:55:06 +02:00
}
2021-01-25 12:15:33 +01:00
2021-08-04 00:55:06 +02:00
const init = () => {
2022-05-03 20:58:33 +02:00
let ui = window.MetaWindow
2021-11-12 07:05:17 +01:00
if (typeof ui === 'undefined') {
ui = new MetaWindow({
target: container,
2022-05-03 20:58:33 +02:00
})
2021-11-12 07:05:17 +01:00
2022-05-03 20:58:33 +02:00
window.MetaWindow = ui
2021-11-12 07:05:17 +01:00
}
2022-05-03 20:58:33 +02:00
ui.init()
}
2021-02-24 10:38:08 +01:00
2022-05-03 20:58:33 +02:00
window.addEventListener(`${Events.LOADEDANDREADY}`, init)
window.addEventListener(`${Events.AJAX}`, init)
window.addEventListener('MetaWindow.initLinks', init)
2021-02-24 10:38:08 +01:00
2022-05-03 20:58:33 +02:00
/* function importAll(r) {
2021-08-04 00:57:03 +02:00
return r.keys().map(r);
2021-08-04 00:55:06 +02:00
}
2021-02-24 10:38:08 +01:00
2021-08-04 00:55:06 +02:00
const images = importAll(
2021-08-04 00:57:03 +02:00
require.context('../img/', false, /\.(png|jpe?g|svg)$/),
2022-05-03 20:58:33 +02:00
); */
2021-02-24 10:38:08 +01:00
2022-05-03 20:58:33 +02:00
export default MetaWindow