Sha256: 98ea325534230c396f1150ed2c25205a5d3c926de92da95d5130d249c237c58b
Contents?: true
Size: 1.72 KB
Versions: 21
Compression:
Stored size: 1.72 KB
Contents
/* eslint-disable no-var */ // used by the header navigation from govuk_template (function () { 'use strict' if (document.querySelectorAll && document.addEventListener) { var els = document.querySelectorAll('.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 = this.getAttribute('href') ? document.getElementById(this.getAttribute('href').substr(1)) : document.getElementById(this.getAttribute('data-search-toggle-for')) var targetClass = target.getAttribute('class') || '' var sourceClass = this.getAttribute('class') || '' var isSearchToggle = sourceClass.match('search-toggle') var showText = this.getAttribute('data-show-text') || 'Show search' var hideText = this.getAttribute('data-hide-text') || 'Hide search' 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|$)/, '')) if (isSearchToggle) { this.innerText = showText } } else { this.setAttribute('class', sourceClass + ' js-visible') if (isSearchToggle) { this.innerText = hideText } } this.setAttribute('aria-expanded', this.getAttribute('aria-expanded') !== 'true') target.setAttribute('aria-hidden', target.getAttribute('aria-hidden') === 'false') }) } } }).call(this)
Version data entries
21 entries across 21 versions & 1 rubygems