(obj1: x, obj2: y, menu: HTMLDivElement)
| 54 | return this.visible.call(obj1, obj2); |
| 55 | } |
| 56 | makeContextHTML(obj1: x, obj2: y, menu: HTMLDivElement) { |
| 57 | if (!this.isVisible(obj1, obj2)) { |
| 58 | return; |
| 59 | } |
| 60 | |
| 61 | const intext = document.createElement("button"); |
| 62 | intext.classList.add("contextbutton"); |
| 63 | intext.append(this.textContent(obj1, obj2)); |
| 64 | |
| 65 | intext.disabled = !!this.enabled && !this.enabled.call(obj1, obj2); |
| 66 | |
| 67 | if (this.icon) { |
| 68 | if ("src" in this.icon) { |
| 69 | const icon = document.createElement("img"); |
| 70 | icon.classList.add("svgicon"); |
| 71 | icon.src = this.icon.src; |
| 72 | intext.append(icon); |
| 73 | } else if ("css" in this.icon) { |
| 74 | const icon = document.createElement("span"); |
| 75 | icon.classList.add(this.icon.css, "svgicon"); |
| 76 | switch (this.color) { |
| 77 | case "red": |
| 78 | icon.style.background = "var(--red)"; |
| 79 | break; |
| 80 | case "blue": |
| 81 | icon.style.background = "var(--blue)"; |
| 82 | break; |
| 83 | } |
| 84 | intext.append(icon); |
| 85 | } else { |
| 86 | intext.append(this.icon.html); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | switch (this.color) { |
| 91 | case "red": |
| 92 | intext.style.color = "var(--red)"; |
| 93 | break; |
| 94 | case "blue": |
| 95 | intext.style.color = "var(--blue)"; |
| 96 | break; |
| 97 | } |
| 98 | |
| 99 | intext.onclick = (e) => { |
| 100 | e.preventDefault(); |
| 101 | e.stopImmediatePropagation(); |
| 102 | removeAni(menu); |
| 103 | this.onClick.call(obj1, obj2, e); |
| 104 | }; |
| 105 | |
| 106 | menu.append(intext); |
| 107 | } |
| 108 | textContent(x: x, y: y) { |
| 109 | if (this.text instanceof Function) { |
| 110 | return this.text.call(x, y); |
nothing calls this directly
no test coverage detected