Sha256: a4619b2113cfbeaf2b1cb76d996088a14c5d3b7fcd60b4f830cc8b34c6214a89

Contents?: true

Size: 1.23 KB

Versions: 49

Compression:

Stored size: 1.23 KB

Contents

// used by the header navigation from govuk_template

(function () {
  'use strict'

  if (document.querySelectorAll && document.addEventListener) {
    var els = document.querySelectorAll('a.js-header-toggle')
    var i
    var _i
    for (i = 0, _i = els.length; i < _i; i++) {
      els[i].addEventListener('click', function (e) {
        e.preventDefault()
        var target = document.getElementById(this.getAttribute('href').substr(1))
        var targetClass = target.getAttribute('class') || ''
        var sourceClass = this.getAttribute('class') || ''

        if (targetClass.indexOf('js-visible') !== -1) {
          target.setAttribute('class', targetClass.replace(/(^|\s)js-visible(\s|$)/, ''))
        } else {
          target.setAttribute('class', targetClass + ' js-visible')
        }
        if (sourceClass.indexOf('js-visible') !== -1) {
          this.setAttribute('class', sourceClass.replace(/(^|\s)js-visible(\s|$)/, ''))
        } else {
          this.setAttribute('class', sourceClass + ' js-visible')
        }
        this.setAttribute('aria-expanded', this.getAttribute('aria-expanded') !== 'true')
        target.setAttribute('aria-hidden', target.getAttribute('aria-hidden') === 'false')
      })
    }
  }
}).call(this)

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
govuk_publishing_components-16.18.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-16.17.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-16.16.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-16.15.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-16.14.1 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-16.14.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-16.13.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-16.12.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-16.11.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js