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.13.0.pre.rc.5 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.PLAY1602lightboxoverlapnitrobug5781 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.13.0.pre.rc.4 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.playrailsinputmaskissue5775 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.PLAY1602lightboxoverlapnitrobugzindextoken5751 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.13.0.pre.rc.3 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.PLAY1865reactdatepickerreinitializingbug5732 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.play1862buttondisabledlinkbug5716 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.play1862buttondisabledlinkbug5714 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.13.0.pre.rc.2 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.13.0.pre.rc.1 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.13.0.pre.rc.0 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.advancedtablealignmentfixes5693 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.testingwithfas5689 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.testingwithfas5686 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.play1828updateviteversion5680 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.PLAY1602lightboxoverlapnitrobug5655 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.PBNTR720railscarddraggable5649 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.12.0.pre.alpha.PLAY1602lightboxoverlapnitrobug5646 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js
playbook_ui-14.11.1.pre.alpha.PBNTR440enableglobalpropspbformwith5624 app/pb_kits/playbook/pb_fixed_confirmation_toast/index.js