Sha256: 6a8c13836b7227108ad4fc28e41198a65c2908f78c6ba27942c2602682103806

Contents?: true

Size: 979 Bytes

Versions: 48

Compression:

Stored size: 979 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'),
  )
}

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
avo-3.11.4 app/javascript/js/custom-stream-actions.js
avo-3.11.3 app/javascript/js/custom-stream-actions.js
avo-3.11.2 app/javascript/js/custom-stream-actions.js
avo-3.11.1 app/javascript/js/custom-stream-actions.js
avo-3.11.0 app/javascript/js/custom-stream-actions.js
avo-3.10.10 app/javascript/js/custom-stream-actions.js
avo-3.10.9 app/javascript/js/custom-stream-actions.js
avo-3.10.8 app/javascript/js/custom-stream-actions.js
avo-3.10.7 app/javascript/js/custom-stream-actions.js
avo-3.10.6 app/javascript/js/custom-stream-actions.js
avo-3.10.5 app/javascript/js/custom-stream-actions.js
avo-3.10.4 app/javascript/js/custom-stream-actions.js
avo-3.10.3 app/javascript/js/custom-stream-actions.js
avo-3.10.2 app/javascript/js/custom-stream-actions.js
avo-3.10.1 app/javascript/js/custom-stream-actions.js
avo-3.10.0 app/javascript/js/custom-stream-actions.js
avo-3.9.2 app/javascript/js/custom-stream-actions.js
avo-3.9.1 app/javascript/js/custom-stream-actions.js
avo-3.8.2 app/javascript/js/custom-stream-actions.js
avo-3.9.0 app/javascript/js/custom-stream-actions.js