Sha256: 1d56b8e30bc0a81710b4186d08e13260be92c6c82561f633a5d75ba38ed416df

Contents?: true

Size: 1.79 KB

Versions: 30

Compression:

Stored size: 1.79 KB

Contents

// Polyfill for custom events in IE9-11
// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#polyfill
;(function () {
  if (typeof window.CustomEvent === 'function') return false

  function CustomEvent(event, params) {
    params = params || { bubbles: false, cancelable: false, detail: undefined }
    var evt = document.createEvent('CustomEvent')
    evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail)
    return evt
  }

  CustomEvent.prototype = window.Event.prototype

  window.CustomEvent = CustomEvent

  // eslint expects a return here
  return true
})()

export const filterStabilizedEvent = (element, stableId, filterName) => {
  const event = new CustomEvent('filter-stabilized', {
    bubbles: true,
    cancelable: true,
    detail: {
      stableId,
      filterName,
    },
  })
  element.dispatchEvent(event)
}

export const filterUnstableEvent = (blueprint) => {
  const event = new CustomEvent('filter-unstable', {
    bubbles: true,
    cancelable: true,
    detail: {
      blueprint,
    },
  })
  window.dispatchEvent(event)
}

export const filterInvalidEvent = ({blueprint, errors}) => {
  const event = new CustomEvent('filter-invalid', {
    bubbles: true,
    cancelable: true,
    detail: {
      blueprint,
      errors,
    },
  })
  window.dispatchEvent(event)
}

export const filterStoredEvent = (storedFilterId) => {
  const event = new CustomEvent('filter-stored', {
    bubbles: true,
    cancelable: true,
    detail: {
      storedFilterId,
    },
  })
  window.dispatchEvent(event)
}

export const blueprintUpdatedEvent = (element, {blueprint, formId}) => {
  const event = new CustomEvent('blueprint-updated', {
    bubbles: true,
    cancelable: true,
    detail: {
      blueprint,
      formId
    },
  })
  element.dispatchEvent(event)
}

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
refine-rails-2.12.0 app/javascript/refine/helpers/index.js
refine-rails-2.11.12 app/javascript/refine/helpers/index.js
refine-rails-2.11.11 app/javascript/refine/helpers/index.js
refine-rails-2.11.10 app/javascript/refine/helpers/index.js
refine-rails-2.11.9 app/javascript/refine/helpers/index.js
refine-rails-2.11.8 app/javascript/refine/helpers/index.js
refine-rails-2.11.6 app/javascript/refine/helpers/index.js
refine-rails-2.11.5 app/javascript/refine/helpers/index.js
refine-rails-2.11.4 app/javascript/refine/helpers/index.js
refine-rails-2.11.3 app/javascript/refine/helpers/index.js
refine-rails-2.11.2 app/javascript/refine/helpers/index.js
refine-rails-2.11.1 app/javascript/refine/helpers/index.js
refine-rails-2.11.0 app/javascript/refine/helpers/index.js
refine-rails-2.10.1 app/javascript/refine/helpers/index.js
refine-rails-2.10.0 app/javascript/refine/helpers/index.js
refine-rails-2.9.14 app/javascript/refine/helpers/index.js
refine-rails-2.9.13 app/javascript/refine/helpers/index.js
refine-rails-2.9.12 app/javascript/refine/helpers/index.js
refine-rails-2.9.11 app/javascript/refine/helpers/index.js
refine-rails-2.9.10 app/javascript/refine/helpers/index.js