Sha256: 69262ead28b5fb6a5f31dbd4513ad9bc70b9d21d61908c8400b06c0e6d0096a0

Contents?: true

Size: 888 Bytes

Versions: 934

Compression:

Stored size: 888 Bytes

Contents

import PbEnhancedElement from '../pb_enhanced_element'

export default class PbFixedConfirmationToast extends PbEnhancedElement {
  static get selector() {
    return '.remove_toast'
  }

  connect() {
    this.self = this.element
    this.autoCloseToast(this.self)

    this.self.addEventListener('click', () => {
      this.removeToast(this.self)
    })
  }

  removeToast(elem) {
    elem.parentNode.removeChild(elem)
  }

  autoCloseToast(element) {
    const classListValues = element.classList.value
    const hasAutoCloseClass = classListValues.includes('auto_close')

    if (hasAutoCloseClass) {
      const classList = classListValues.split(' ')
      const autoCloseValue = classList[classList.length - 1].split('_')[2]
      const autoCloseIntValue = parseInt(autoCloseValue)

      setTimeout(() => {
        this.removeToast(element)
      }, autoCloseIntValue)
    }
  }
}

Version data entries

934 entries across 934 versions & 1 rubygems

Version Path
playbook_ui-14.10.0.pre.alpha.PLAY1750pbcontenttagkitbutton5308 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.1 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.0.pre.rc.17 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.0 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.0.pre.rc.16 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.10.0.pre.alpha.play16825301 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.0.pre.rc.15 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.0.pre.rc.14 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.0.pre.rc.13 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.0.pre.rc.12 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5274 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.10.0.pre.alpha.play1465attempt25272 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.10.0.pre.alpha.play16825244 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.0.pre.rc.11 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.0.pre.rc.10 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5214 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5213 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5210 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5208 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.10.0.pre.alpha.play1662cssbargraph5207 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js