Sha256: 19c76f1d0068d8f21713920f307d8532740ded75820fa57d4de893b9359b05c0

Contents?: true

Size: 1015 Bytes

Versions: 294

Compression:

Stored size: 1015 Bytes

Contents

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

(function (Modules) {
  function ContextualGuidance ($module) {
    this.$module = $module
    this.$guidance = this.$module.querySelector('.gem-c-contextual-guidance__wrapper')
    this.$inputId = this.$guidance.getAttribute('for')
    this.$input = this.$module.querySelector('#' + this.$inputId)
  }

  ContextualGuidance.prototype.init = function () {
    if (!this.$input) return
    this.$input.addEventListener('focus', this.handleFocus.bind(this))
  }

  ContextualGuidance.prototype.handleFocus = function (event) {
    this.hideAllGuidance()
    this.$guidance.style.display = 'block'
  }

  ContextualGuidance.prototype.hideAllGuidance = function () {
    var $guidances = document.querySelectorAll('.gem-c-contextual-guidance__wrapper')

    for (var i = 0; i < $guidances.length; i++) {
      $guidances[i].style.display = 'none'
    }
  }

  Modules.ContextualGuidance = ContextualGuidance
})(window.GOVUK.Modules)

Version data entries

294 entries across 294 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-51.0.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-50.0.1 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-50.0.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-49.1.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-49.0.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-48.0.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-47.0.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-46.4.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-46.3.1 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-46.3.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-46.2.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-46.1.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-46.0.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.10.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.9.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.8.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.7.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.6.1 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.6.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js