src/app/core/application/menu.js
class Menu {
constructor() {
this.tools = [];
$("#tools").empty();
}
add(component) {
this.tools.push(component);
}
refresh() {
this.tools
.filter(component => {
return component.created == undefined;
})
.forEach(component => {
if (component != undefined && component.created) return;
component.created = true;
const options = component.options;
$("#tools").append(`<button id="btn-${options.id}"
class="tool icon icon-${options.icon} fadeInRight">
<span> ${options.title} </span></button>`);
$("body").on(
"click",
`#btn-${options.id}`,
component.click.bind(component)
);
});
}
}
export const menu = new Menu();