Sha256: fc9c3ef545aaff98425ffe62aef13f092f562b47123b5e085c5d67d38c516f96

Contents?: true

Size: 636 Bytes

Versions: 38

Compression:

Stored size: 636 Bytes

Contents

import { Controller } from '@hotwired/stimulus'

// Connects to data-controller="clear-timeout"
export default class extends Controller {
  connect () {
    if (this.element.dataset.timeoutId) {
      this.element.dataset.timeoutId.split(',').forEach((el) => {
        this.clear(el)
      })
    } else {
      const headId = document.head.dataset.timeoutId
      if (headId) {
        headId.split(',').forEach((el) => {
          this.clear(el)
        })
      }
    }
    this.element.remove()
  }

  clear (id) {
    const timeoutId = parseInt(id)
    clearTimeout(timeoutId)
    console.log(`clearedTimeout: ${timeoutId}`)
  }
}

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
pg_rails-7.6.23 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.22 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.22.pre.3 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.22.pre.2 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.22.pre.1 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.11 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.10 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.9 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.8 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.7 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.6 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.5 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.4 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.3 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.2 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.21.pre.1 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.20 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.19 pg_layout/app/javascript/controllers/clear_timeout_controller.js
pg_rails-7.6.18 pg_layout/app/javascript/controllers/clear_timeout_controller.js