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-17.21.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.20.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.19.1 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.19.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.18.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.17.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.16.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.15.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.14.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.13.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.12.2 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.12.1 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.12.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.11.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.10.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.9.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.8.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.7.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.6.1 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js
govuk_publishing_components-17.6.0 app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js