123456789101112131415161718192021 |
- class Menu {
- constructor() {
- this.tools = [];
- }
- add(tool) {
- this.tools.push(tool);
- }
- refresh() {
- $("#tools").empty();
- this.tools.forEach(tool => {
- $("#tools").append(`<button
- id="btn-${tool.id}"
- class="tool icon icon-${tool.id}">
- <span> ${tool.title} </span></button>`);
- $("body").on("click", `#btn-${tool.id}`, () => {
- tool.click(tool.object);
- });
- });
- }
- }
- export const menu = new Menu();
|