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.0.1.beta19 app/javascript/js/active-storage.js
avo-3.0.1.beta24 app/javascript/js/active-storage.js
avo-3.0.1.beta15 app/javascript/js/active-storage.js
avo-3.0.1.beta16 app/javascript/js/active-storage.js
avo-3.0.1.beta14 app/javascript/js/active-storage.js
avo-3.0.1.beta12 app/javascript/js/active-storage.js
avo-3.0.1.beta13 app/javascript/js/active-storage.js
avo-3.0.1.beta10 app/javascript/js/active-storage.js
avo-3.0.1.beta11 app/javascript/js/active-storage.js
avo-3.0.0.pre19 app/javascript/js/active-storage.js
avo-3.0.1.beta8 app/javascript/js/active-storage.js
avo-3.0.1.beta9 app/javascript/js/active-storage.js
avo-3.0.1.beta6 app/javascript/js/active-storage.js
avo-3.0.1.beta7 app/javascript/js/active-storage.js
avo-3.0.1.beta5 app/javascript/js/active-storage.js
avo-3.0.1.beta2 app/javascript/js/active-storage.js
avo-3.0.1.beta4 app/javascript/js/active-storage.js
avo-3.0.1.beta3 app/javascript/js/active-storage.js
avo-3.0.0.beta1 app/javascript/js/active-storage.js
avo-3.0.1.beta1 app/javascript/js/active-storage.js