Sha256: ac2703aeeac13c7393d50c1f78f22c1f420f2587c03459b6939df352bcbfa6ce

Contents?: true

Size: 810 Bytes

Versions: 129

Compression:

Stored size: 810 Bytes

Contents

(function (root) {
  'use strict'
  window.GOVUK = window.GOVUK || {}

  window.GOVUK.triggerEvent = function (element, eventName, parameters) {
    var params = parameters || {}
    var event
    var keyCode = params.keyCode

    if (!Object.prototype.hasOwnProperty.call(params, 'bubbles')) {
      params.bubbles = true
    }

    if (!Object.prototype.hasOwnProperty.call(params, 'cancelable')) {
      params.cancelable = true
    }

    if (typeof window.CustomEvent === 'function') {
      event = new window.CustomEvent(eventName, params)
    } else {
      event = document.createEvent('CustomEvent')
      event.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail)
    }

    if (keyCode) {
      event.keyCode = keyCode
    }

    element.dispatchEvent(event)
  }
}(window))

Version data entries

129 entries across 129 versions & 1 rubygems

Version Path
govuk_publishing_components-34.10.1 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.10.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.9.1 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.9.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.8.1 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.8.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.7.1 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.7.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.6.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.5.1 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.5.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.4.2 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.4.1 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.4.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.3.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.2.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.1.3 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.1.2 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.1.1 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js
govuk_publishing_components-34.1.0 app/assets/javascripts/govuk_publishing_components/lib/trigger-event.js