Sha256: 19c76f1d0068d8f21713920f307d8532740ded75820fa57d4de893b9359b05c0

Contents?: true

Size: 1015 Bytes

Versions: 277

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

277 entries across 277 versions & 1 rubygems

Version Path
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
govuk_publishing_components-45.5.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.4.1 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.4.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.3.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.2.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.1.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-45.0.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.11.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.10.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.9.1 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.9.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.8.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.7.1 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.7.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.6.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.5.0 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js
govuk_publishing_components-44.4.2 app/assets/javascripts/govuk_publishing_components/components/contextual-guidance.js