Sha256: 6daa58f280e437d316205d53b4639690d38fcd94f2c6b04eb96f519d218c7bf4

Contents?: true

Size: 622 Bytes

Versions: 3

Compression:

Stored size: 622 Bytes

Contents

window.GOVUK = window.GOVUK || {}
window.GOVUK.Modules = window.GOVUK.Modules || {};

(function (global, GOVUK) {
  'use strict'

  GOVUK.Modules.CopyToClipboard = function () {
    this.start = function (element) {
      var input = element[0].querySelector('.gem-c-input')
      var copyButton = element[0].querySelector('.gem-c-button')

      input.addEventListener('click', function() {
        input.select()
      })

      copyButton.addEventListener('click', function (event) {
        event.preventDefault()
        input.select()
        document.execCommand('copy')
      })
    }
  }
})(window, window.GOVUK)

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
govuk_publishing_components-12.13.0 app/assets/javascripts/govuk_publishing_components/components/copy-to-clipboard.js
govuk_publishing_components-12.12.1 app/assets/javascripts/govuk_publishing_components/components/copy-to-clipboard.js
govuk_publishing_components-12.12.0 app/assets/javascripts/govuk_publishing_components/components/copy-to-clipboard.js