12345678910111213141516171819 |
- 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);
- });
- }
- }
- export const menu = new Menu();
|