Sha256: 1a4395bed09248be663be67f0eebfc6f0ded386967541b9e02405097657fe8fb

Contents?: true

Size: 1.47 KB

Versions: 355

Compression:

Stored size: 1.47 KB

Contents

document.addEventListener('direct-upload:initialize', (event) => {
  const { target, detail } = event
  const { id, file } = detail

  target.insertAdjacentHTML(
    'beforebegin',
    `
    <div id="direct-upload-${id}" class="direct-upload direct-upload--pending">
      <div id="direct-upload-progress-${id}" class="direct-upload__progress" style="width: 0%"></div>
      <span class="direct-upload__filename"></span>
    </div>
  `,
  )
  target.previousElementSibling.querySelector(
    '.direct-upload__filename',
  ).textContent = file.name
})

document.addEventListener('direct-upload:start', (event) => {
  const { id } = event.detail
  const element = document.getElementById(`direct-upload-${id}`)
  element.classList.remove('direct-upload--pending')
})

document.addEventListener('direct-upload:progress', (event) => {
  const { id, progress } = event.detail
  const progressElement = document.getElementById(
    `direct-upload-progress-${id}`,
  )
  progressElement.style.width = `${progress}%`
})

document.addEventListener('direct-upload:error', (event) => {
  event.preventDefault()
  const { id, error } = event.detail
  const element = document.getElementById(`direct-upload-${id}`)
  element.classList.add('direct-upload--error')
  element.setAttribute('title', error)
})

document.addEventListener('direct-upload:end', (event) => {
  const { id } = event.detail
  const element = document.getElementById(`direct-upload-${id}`)
  element.classList.add('direct-upload--complete')
})

Version data entries

355 entries across 355 versions & 1 rubygems

Version Path
avo-3.14.3 app/javascript/js/active-storage.js
avo-3.14.2 app/javascript/js/active-storage.js
avo-3.14.1 app/javascript/js/active-storage.js
avo-3.14.0 app/javascript/js/active-storage.js
avo-3.13.7 app/javascript/js/active-storage.js
avo-3.13.6 app/javascript/js/active-storage.js
avo-3.13.5 app/javascript/js/active-storage.js
avo-3.13.4 app/javascript/js/active-storage.js
avo-3.13.3 app/javascript/js/active-storage.js
avo-3.13.2 app/javascript/js/active-storage.js
avo-3.13.1 app/javascript/js/active-storage.js
avo-3.13.0 app/javascript/js/active-storage.js
avo-2.53.0 app/javascript/js/active-storage.js
avo-3.12.0 app/javascript/js/active-storage.js
avo-3.11.10 app/javascript/js/active-storage.js
avo-3.11.9 app/javascript/js/active-storage.js
avo-3.11.8 app/javascript/js/active-storage.js
avo-3.11.7 app/javascript/js/active-storage.js
avo-3.11.6 app/javascript/js/active-storage.js
avo-3.11.5 app/javascript/js/active-storage.js