Sha256: da21fb6385491a780c38fc3c3ff64d5c51a41fc54761535e64d9f782a55dab34

Contents?: true

Size: 994 Bytes

Versions: 16

Compression:

Stored size: 994 Bytes

Contents

class UnlinkButton 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.linked = this.linked
    this.innerHTML = '<i class="icon ri-link-unlink-m ri-fw"></i>'
  }

  handleEvent(event) {
    if (this.linked) {
      this.linked = false
      this.blur()
      this.dispatchEvent(new CustomEvent("alchemy:unlink", { bubbles: true }))
    }
    event.preventDefault()
  }

  set linked(isLinked) {
    if (isLinked) {
      this.classList.replace("disabled", "linked")
      this.removeAttribute("tabindex")
    } else {
      this.classList.replace("linked", "disabled")
      this.setAttribute("tabindex", "-1")
    }
  }

  get linked() {
    return this.classList.contains("linked")
  }
}

customElements.define("alchemy-unlink-button", UnlinkButton, {
  extends: "button"
})

Version data entries

16 entries across 16 versions & 1 rubygems

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