Sha256: 2756741106019c6cd2322c4e6f429e564acc18bfe0584b09cdbf0649ee17f215
Contents?: true
Size: 1.41 KB
Versions: 12
Compression:
Stored size: 1.41 KB
Contents
class LinkButton extends HTMLButtonElement { constructor() { super() this.addEventListener("click", this) this.classList.add("icon_button") // Prevent accidental form submits if this component is wrapped inside a form this.setAttribute("type", "button") this.innerHTML = '<alchemy-icon name="link" icon-style="m"></alchemy-icon>' } handleEvent(event) { const dialog = new Alchemy.LinkDialog({ url: this.linkUrl, title: this.linkTitle, target: this.linkTarget, type: this.linkClass }) dialog.open().then((link) => this.setLink(link)) event.preventDefault() } setLink(link) { if (link.url === "") { this.classList.remove("linked") this.dispatchEvent(new CustomEvent("alchemy:unlink", { bubbles: true })) } else { this.classList.add("linked") this.dispatchEvent( new CustomEvent("alchemy:link", { bubbles: true, detail: link }) ) } } get linkUrl() { return this.linkButtons.linkUrlField.value } get linkTitle() { return this.linkButtons.linkTitleField.value } get linkTarget() { return this.linkButtons.linkTargetField.value } get linkClass() { return this.linkButtons.linkClassField.value } get linkButtons() { return this.closest("alchemy-link-buttons") } } customElements.define("alchemy-link-button", LinkButton, { extends: "button" })
Version data entries
12 entries across 12 versions & 1 rubygems