summaryrefslogtreecommitdiffstats
path: root/public/js/layout.js
blob: 0ea5d64b674520911154c342bd3ca42ff88680df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* Icinga PDF Export | (c) 2021 Icinga GmbH | GPLv2 */

"use strict";

class Layout
{
    static #plugins = [];

    static registerPlugin(name, plugin) {
        this.#plugins.push([name, plugin]);
    }

    apply() {
        for (let [name, plugin] of Layout.#plugins) {
            try {
                plugin();
            } catch (error) {
                console.error('Layout plugin ' + name + ' failed to run: ' + error);
            }
        }

        this.finish();
    }

    finish() {
        document.documentElement.dataset.layoutReady = 'yes';
        document.dispatchEvent(new CustomEvent('layout-ready', {
            cancelable: false,
            bubbles: false
        }));
    }
}