Sha256: 27fefb47f1e2b460e526a1478303ccfc447ba9827f6c827ecddadca82ad19b8c

Contents?: true

Size: 1.11 KB

Versions: 17

Compression:

Stored size: 1.11 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 = '<i class="icon ri-link-m ri-fw"></i>'
  }

  handleEvent(event) {
    const dialog = new Alchemy.LinkDialog(this)
    dialog.open()
    event.preventDefault()
  }

  setLink(url, title, target, type) {
    this.classList.add("linked")
    this.dispatchEvent(
      new CustomEvent("alchemy:link", {
        bubbles: true,
        detail: { url, title, target, type }
      })
    )
  }

  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

17 entries across 17 versions & 1 rubygems

Version Path
alchemy_cms-7.1.13 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.12 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.11 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.10 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.9 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.8 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.7 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.6 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.5 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.4 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.3 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.2 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.1 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.0 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.0.pre.rc1 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.0.pre.b2 app/javascript/alchemy_admin/components/link_buttons/link_button.js
alchemy_cms-7.1.0.pre.b1 app/javascript/alchemy_admin/components/link_buttons/link_button.js