Sha256: db9fb775da2111f26e848616dad0b4be2c0c056abb633be5045275d184cc7a4f

Contents?: true

Size: 1017 Bytes

Versions: 54

Compression:

Stored size: 1017 Bytes

Contents

/* eslint-disable camelcase */
import { StreamActions } from '@hotwired/turbo'
import { saveAs } from 'file-saver'

// TODO: move these to the avo_filters gem

StreamActions.close_filters_dropdown = function () {
  document.querySelector('.filters-dropdown-selector').classList.add('hidden')
}

StreamActions.open_filter = function () {
  const id = this.getAttribute('unique-id')
  setTimeout(() => {
    document.querySelector(`[data-filter-id="${id}"] .pill`).click()
  }, 150)
}
// END TODO: move these to the avo_filters gem

// https://stackoverflow.com/a/77850750/9067704
StreamActions.download = function () {
  const byteCharacters = atob(this.getAttribute('content'))
  const byteNumbers = new Array(byteCharacters.length)
  for (let i = 0; i < byteCharacters.length; i++) {
    byteNumbers[i] = byteCharacters.charCodeAt(i)
  }
  const byteArray = new Uint8Array(byteNumbers)

  saveAs(
    new Blob(
      [byteArray],
    ),
    this.getAttribute('filename'),
  )
}

window.StreamActions = StreamActions

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
avo-3.17.9.tw4 app/javascript/js/custom-stream-actions.js
avo-3.17.9 app/javascript/js/custom-stream-actions.js
avo-3.17.8.tw4 app/javascript/js/custom-stream-actions.js
avo-3.17.8 app/javascript/js/custom-stream-actions.js
avo-3.17.7 app/javascript/js/custom-stream-actions.js
avo-3.17.6.tw4 app/javascript/js/custom-stream-actions.js
avo-3.17.6 app/javascript/js/custom-stream-actions.js
avo-3.17.5 app/javascript/js/custom-stream-actions.js
avo-3.17.4 app/javascript/js/custom-stream-actions.js
avo-3.17.3 app/javascript/js/custom-stream-actions.js
avo-3.17.5.tw4 app/javascript/js/custom-stream-actions.js
avo-3.17.4.tw4 app/javascript/js/custom-stream-actions.js
avo-3.17.3.tw4 app/javascript/js/custom-stream-actions.js
avo-3.17.2.tw4 app/javascript/js/custom-stream-actions.js
avo-3.17.2 app/javascript/js/custom-stream-actions.js
avo-3.17.1.tw4 app/javascript/js/custom-stream-actions.js
avo-3.17.1 app/javascript/js/custom-stream-actions.js
avo-3.17.0 app/javascript/js/custom-stream-actions.js
avo-3.16.6 app/javascript/js/custom-stream-actions.js
avo-3.16.5 app/javascript/js/custom-stream-actions.js