diff --git a/app.json b/app.json index 8e4bc930f6..a69722b136 100644 --- a/app.json +++ b/app.json @@ -1,5 +1,5 @@ { - "name": "govuk-frontend", + "name": "navody-digital", "scripts": { }, "env": { diff --git a/app/__tests__/app.test.js b/app/__tests__/app.test.js index b91e2256c7..27f8a6be6c 100644 --- a/app/__tests__/app.test.js +++ b/app/__tests__/app.test.js @@ -15,9 +15,7 @@ const expectedPages = [ '/examples/form-elements', '/examples/grid', '/examples/links', - '/examples/typography', - '/examples/template-default', - '/examples/template-custom' + '/examples/typography' ] // Returns a wrapper for `request` which applies these options by default @@ -59,160 +57,160 @@ describe(`http://localhost:${PORT}`, () => { let componentsList = $('li a[href^="/components/"]').get() // Since we have an 'all' component link that renders the default example of all // components, there will always be one more expected link. - let expectedComponentLinks = lib.allComponents.length + 1 + let expectedComponentLinks = lib.allComponents.length expect(componentsList.length).toEqual(expectedComponentLinks) done(err) }) }) }) - describe('/examples/template-custom', () => { - const templatePath = '/examples/template-custom' - - it.each([ - 'headIcons', - 'bodyStart', - 'main', - 'content', - 'bodyEnd' - ])('should have a %s block set', (block, done) => { - requestPath(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - expect($.html()).toContain(``) - done(err) - }) - }) - - it('should have additional `htmlClasses`', done => { - requestPath(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $html = $('html') - - expect($html.attr('class')).toBe('govuk-template app-html-class') - done(err) - }) - }) - - it('should have assets overriden', done => { - requestPath(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $linkAsset = $('link[href^="/images/"]') - expect($linkAsset.length).toBe(6) - done(err) - }) - }) - - it('should have theme-color overriden', done => { - requestPath(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $linkMaskIcon = $('link[rel="mask-icon"]') - const $metaThemeColor = $('meta[name="theme-color"]') - - expect($linkMaskIcon.attr('color')).toBe('blue') - expect($metaThemeColor.attr('content')).toBe('blue') - done(err) - }) - }) - - it('should have additional `bodyClasses`', done => { - requestPath(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $body = $('body') - - expect($body.attr('class')).toBe('govuk-template__body app-body-class') - done(err) - }) - }) - - it('should have `pageTitle` overriden', done => { - requestPath(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $title = $('title') - - expect($title.html()).toBe('GOV.UK - Le meilleur endroit pour trouver des services gouvernementaux et de l'information') - done(err) - }) - }) - - it('should have an application stylesheet', done => { - requestPath(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $appStylesheet = $('link[href="/public/app.css"]') - expect($appStylesheet.length).toBe(1) - done(err) - }) - }) - - it('should have a custom Skip link component', done => { - requestPath(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $skipLink = $('.govuk-skip-link') - expect($skipLink.html()).toBe('Passer au contenu principal') - done(err) - }) - }) - - it('should have a custom Header component', done => { - requestPath(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $header = $('.govuk-header') - const $serviceName = $header.find('.govuk-header__link--service-name') - expect($serviceName.html()).toContain('Nom du service') - done(err) - }) - }) - - it('should have a Phase banner component', done => { - requestPath.get(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $phaseBanner = $('.govuk-phase-banner') - const $text = $phaseBanner.find('.govuk-phase-banner__text') - expect($text.html()).toContain('C'est un nouveau service - vos commentaires nous aideront à l'améliorer.') - done(err) - }) - }) - - it('should have a custom Footer component', done => { - requestPath.get(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $footer = $('.govuk-footer') - const $footerLink = $footer.find('.govuk-footer__link') - expect($footerLink.html()).toContain('Aidez-moi') - done(err) - }) - }) - - it('should have `content` within the main section of the page', done => { - requestPath.get(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $main = $('main') - - expect($main.html()).toContain('') - done(err) - }) - }) - - it('should have `beforeContent` outside the main section of the page', done => { - requestPath.get(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $container = $('.govuk-width-container') - const $phaseBanner = $container.find('> .govuk-phase-banner') - const $backLink = $container.find('> .govuk-back-link') - - expect($phaseBanner.length).toBe(1) - expect($backLink.length).toBe(1) - done(err) - }) - }) - - it('should have set `mainClasses`', done => { - requestPath.get(templatePath, (err, res) => { - let $ = cheerio.load(res.body) - const $main = $('main') - - expect($main.attr('class')).toBe('govuk-main-wrapper app-main-class') - done(err) - }) - }) - }) + // describe('/examples/template-custom', () => { + // const templatePath = '/examples/template-custom' + // + // it.each([ + // 'headIcons', + // 'bodyStart', + // 'main', + // 'content', + // 'bodyEnd' + // ])('should have a %s block set', (block, done) => { + // requestPath(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // expect($.html()).toContain(``) + // done(err) + // }) + // }) + // + // it('should have additional `htmlClasses`', done => { + // requestPath(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $html = $('html') + // + // expect($html.attr('class')).toBe('govuk-template app-html-class') + // done(err) + // }) + // }) + // + // it('should have assets overriden', done => { + // requestPath(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $linkAsset = $('link[href^="/images/"]') + // expect($linkAsset.length).toBe(6) + // done(err) + // }) + // }) + // + // it('should have theme-color overriden', done => { + // requestPath(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $linkMaskIcon = $('link[rel="mask-icon"]') + // const $metaThemeColor = $('meta[name="theme-color"]') + // + // expect($linkMaskIcon.attr('color')).toBe('blue') + // expect($metaThemeColor.attr('content')).toBe('blue') + // done(err) + // }) + // }) + // + // it('should have additional `bodyClasses`', done => { + // requestPath(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $body = $('body') + // + // expect($body.attr('class')).toBe('govuk-template__body app-body-class') + // done(err) + // }) + // }) + // + // it('should have `pageTitle` overriden', done => { + // requestPath(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $title = $('title') + // + // expect($title.html()).toBe('GOV.UK - Le meilleur endroit pour trouver des services gouvernementaux et de l'information') + // done(err) + // }) + // }) + // + // it('should have an application stylesheet', done => { + // requestPath(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $appStylesheet = $('link[href="/public/app.css"]') + // expect($appStylesheet.length).toBe(1) + // done(err) + // }) + // }) + // + // it('should have a custom Skip link component', done => { + // requestPath(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $skipLink = $('.govuk-skip-link') + // expect($skipLink.html()).toBe('Passer au contenu principal') + // done(err) + // }) + // }) + // + // it('should have a custom Header component', done => { + // requestPath(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $header = $('.govuk-header') + // const $serviceName = $header.find('.govuk-header__link--service-name') + // expect($serviceName.html()).toContain('Nom du service') + // done(err) + // }) + // }) + // + // it('should have a Phase banner component', done => { + // requestPath.get(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $phaseBanner = $('.govuk-phase-banner') + // const $text = $phaseBanner.find('.govuk-phase-banner__text') + // expect($text.html()).toContain('C'est un nouveau service - vos commentaires nous aideront à l'améliorer.') + // done(err) + // }) + // }) + // + // it('should have a custom Footer component', done => { + // requestPath.get(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $footer = $('.govuk-footer') + // const $footerLink = $footer.find('.govuk-footer__link') + // expect($footerLink.html()).toContain('Aidez-moi') + // done(err) + // }) + // }) + // + // it('should have `content` within the main section of the page', done => { + // requestPath.get(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $main = $('main') + // + // expect($main.html()).toContain('') + // done(err) + // }) + // }) + // + // it('should have `beforeContent` outside the main section of the page', done => { + // requestPath.get(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $container = $('.govuk-width-container') + // const $phaseBanner = $container.find('> .govuk-phase-banner') + // const $backLink = $container.find('> .govuk-back-link') + // + // expect($phaseBanner.length).toBe(1) + // expect($backLink.length).toBe(1) + // done(err) + // }) + // }) + // + // it('should have set `mainClasses`', done => { + // requestPath.get(templatePath, (err, res) => { + // let $ = cheerio.load(res.body) + // const $main = $('main') + // + // expect($main.attr('class')).toBe('govuk-main-wrapper app-main-class') + // done(err) + // }) + // }) + // }) }) diff --git a/dist/VERSION.txt b/dist/VERSION.txt index 73462a5a13..6e8bf73aa5 100644 --- a/dist/VERSION.txt +++ b/dist/VERSION.txt @@ -1 +1 @@ -2.5.1 +0.1.0 diff --git a/dist/govuk-frontend-2.5.1.min.js b/dist/govuk-frontend-2.5.1.min.js deleted file mode 100644 index 308d6fd361..0000000000 --- a/dist/govuk-frontend-2.5.1.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("navodyDigitalFrontend",["exports"],e):e(t.navodyDigitalFrontend={})}(this,function(t){"use strict";function e(t,e){if(window.NodeList.prototype.forEach)return t.forEach(e);for(var n=0;n=l)for(;l>>0,"object"==typeof e[o]?e[o].baseVal=r.join(" "):e[o]=r.join(" "),u())},i.remove=function(){d.apply(i,t=arguments);for(var t,n={},l=0,c=[];l>>0,"object"==typeof e[o]?e[o].baseVal=r.join(" "):e[o]=r.join(" "),u()},i.toggle=function(e,n){return d.apply(i,[e]),t!==n?n?(i.add(e),!0):(i.remove(e),!1):s[e]?(i.remove(e),!1):(i.add(e),!0)},i}}()),"classList"in(o=document.createElement("span"))&&(o.classList.toggle("x",!1),o.classList.contains("x")&&(o.classList.constructor.prototype.toggle=function(e){var n=arguments[1];if(n===t){var o=!this.contains(e);return this[o?"add":"remove"](e),o}return this[(n=!!n)?"add":"remove"](e),n})),function(){var t=document.createElement("span");if("classList"in t&&(t.classList.add("a","b"),!t.classList.contains("b"))){var e=t.classList.constructor.prototype.add;t.classList.constructor.prototype.add=function(){for(var t=arguments,n=arguments.length,o=0;osections',this.$openAllButton.setAttribute("class",this.openAllClass),this.$openAllButton.setAttribute("aria-expanded","false"),this.$openAllButton.setAttribute("type","button");var t=document.createElement("div");t.setAttribute("class",this.controlsClass),t.appendChild(this.$openAllButton),this.$module.insertBefore(t,this.$module.firstChild),this.$openAllButton.addEventListener("click",this.onOpenOrCloseAllToggle.bind(this))},n.prototype.initSectionHeaders=function(){e(this.$sections,function(t,e){var n=t.querySelector("."+this.sectionHeaderClass);this.initHeaderAttributes(n,e),this.setExpanded(this.isExpanded(t),t),n.addEventListener("click",this.onSectionToggle.bind(this,t)),this.setInitialState(t)}.bind(this))},n.prototype.initHeaderAttributes=function(t,e){var n=this,o=t.querySelector("."+this.sectionButtonClass),i=t.querySelector("."+this.sectionHeadingClass),r=t.querySelector("."+this.sectionSummaryClass),s=document.createElement("button");s.setAttribute("type","button"),s.setAttribute("id",this.moduleId+"-heading-"+(e+1)),s.setAttribute("aria-controls",this.moduleId+"-content-"+(e+1));for(var a=0;a'),this.describedBy=t.getAttribute("aria-describedby"),this.describedByInfo=this.describedBy+" "+e+"-info",t.setAttribute("aria-describedby",this.describedByInfo),n=document.getElementById(e+"-info")):t.insertAdjacentElement("afterend",n),n},a.prototype.bindChangeEvents=function(){var t=this.$textarea;t.addEventListener("keyup",this.checkIfValueChanged.bind(this)),t.addEventListener("focus",this.handleFocus.bind(this)),t.addEventListener("blur",this.handleBlur.bind(this))},a.prototype.checkIfValueChanged=function(){(this.$textarea.oldValue||(this.$textarea.oldValue=""),this.$textarea.value!==this.$textarea.oldValue)&&(this.$textarea.oldValue=this.$textarea.value,this.updateCountMessage.bind(this)())},a.prototype.updateCountMessage=function(){var t=this.$textarea,e=this.options,n=this.countMessage,o=this.count(t.value),i=this.maxLength,r=i-o;i*(e.threshold?e.threshold:0)/100>o?n.classList.add("govuk-character-count__message--disabled"):n.classList.remove("govuk-character-count__message--disabled"),r<0?(t.classList.add("govuk-textarea--error"),n.classList.remove("govuk-hint"),n.classList.add("govuk-error-message")):(t.classList.remove("govuk-textarea--error"),n.classList.remove("govuk-error-message"),n.classList.add("govuk-hint"));var s,a,l="character";e.maxwords&&(l="word"),l+=-1===r||1===r?"":"s",s=r<0?"too many":"remaining",a=Math.abs(r),n.innerHTML="You have "+a+" "+l+" "+s},a.prototype.handleFocus=function(){this.valueChecker=setInterval(this.checkIfValueChanged.bind(this),1e3)},a.prototype.handleBlur=function(){clearInterval(this.valueChecker)},l.prototype.init=function(){var t=this.$module;e(this.$inputs,function(e){var n=e.getAttribute("data-aria-controls");n&&t.querySelector("#"+n)&&(e.setAttribute("aria-controls",n),e.removeAttribute("data-aria-controls"),this.setAttributes(e))}.bind(this)),t.addEventListener("click",this.handleClick.bind(this))},l.prototype.setAttributes=function(t){var e=t.checked;t.setAttribute("aria-expanded",e),document.querySelector("#"+t.getAttribute("aria-controls")).classList.toggle("govuk-checkboxes__conditional--hidden",!e)},l.prototype.handleClick=function(t){var e=t.target,n="checkbox"===e.getAttribute("type"),o=e.getAttribute("aria-controls");n&&o&&this.setAttributes(e)},function(t){"document"in this&&"matches"in document.documentElement||(Element.prototype.matches=Element.prototype.webkitMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.mozMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),n=0;e[n]&&e[n]!==this;)++n;return!!e[n]})}.call("object"==typeof window&&window||"object"==typeof self&&self||"object"==typeof global&&global||{}),function(t){"document"in this&&"closest"in document.documentElement||(Element.prototype.closest=function(t){for(var e=this;e;){if(e.matches(t))return e;e="SVGElement"in window&&e instanceof SVGElement?e.parentNode:e.parentElement}return null})}.call("object"==typeof window&&window||"object"==typeof self&&self||"object"==typeof global&&global||{}),c.prototype.init=function(){var t=this.$module;t&&(window.addEventListener("load",function(){t.focus()}),t.addEventListener("click",this.handleClick.bind(this)))},c.prototype.handleClick=function(t){var e=t.target;this.focusTarget(e)&&t.preventDefault()},c.prototype.focusTarget=function(t){if("A"!==t.tagName||!1===t.href)return!1;var e=this.getFragmentFromUrl(t.href),n=document.getElementById(e);if(!n)return!1;var o=this.getAssociatedLegendOrLabel(n);return!!o&&(window.history.pushState?window.history.pushState(null,null,"#"+e):window.location.hash=e,o.scrollIntoView(),n.focus({preventScroll:!0}),!0)},c.prototype.getFragmentFromUrl=function(t){return-1!==t.indexOf("#")&&t.split("#").pop()},c.prototype.getAssociatedLegendOrLabel=function(t){var e=t.closest("fieldset");if(e){var n=e.getElementsByTagName("legend");if(n.length)return n[0]}return document.querySelector("label[for='"+t.getAttribute("id")+"']")||t.closest("label")},u.prototype.init=function(){var t=this.$module;if(t){var e=t.querySelector(".js-header-toggle");e&&e.addEventListener("click",this.handleClick.bind(this))}},u.prototype.toggleClass=function(t,e){t.className.indexOf(e)>0?t.className=t.className.replace(" "+e,""):t.className+=" "+e},u.prototype.handleClick=function(t){var e=this.$module,n=t.target||t.srcElement,o=e.querySelector("#"+n.getAttribute("aria-controls"));n&&o&&(this.toggleClass(o,"govuk-header__navigation--open"),this.toggleClass(n,"govuk-header__menu-button--open"),n.setAttribute("aria-expanded","true"!==n.getAttribute("aria-expanded")),o.setAttribute("aria-hidden","false"===o.getAttribute("aria-hidden")))},d.prototype.init=function(){var t=this.$module;e(this.$inputs,function(e){var n=e.getAttribute("data-aria-controls");n&&t.querySelector("#"+n)&&(e.setAttribute("aria-controls",n),e.removeAttribute("data-aria-controls"),this.setAttributes(e))}.bind(this)),t.addEventListener("click",this.handleClick.bind(this))},d.prototype.setAttributes=function(t){var e=t.checked;t.setAttribute("aria-expanded",e),document.querySelector("#"+t.getAttribute("aria-controls")).classList.toggle("govuk-radios__conditional--hidden",!e)},d.prototype.handleClick=function(t){e(this.$inputs,function(t){var e="radio"===t.getAttribute("type"),n=t.getAttribute("aria-controls");e&&n&&this.setAttributes(t)}.bind(this))},p.prototype.init=function(){"function"==typeof window.matchMedia?this.setupResponsiveChecks():this.setup()},p.prototype.setupResponsiveChecks=function(){this.mql=window.matchMedia("(min-width: 40.0625em)"),this.mql.addListener(this.checkMode.bind(this)),this.checkMode()},p.prototype.checkMode=function(){this.mql.matches?this.setup():this.teardown()},p.prototype.setup=function(){var t=this.$module,n=this.$tabs,o=t.querySelector(".govuk-tabs__list"),i=t.querySelectorAll(".govuk-tabs__list-item");if(n&&o&&i){o.setAttribute("role","tablist"),e(i,function(t){t.setAttribute("role","presentation")}),e(n,function(t){this.setAttributes(t),t.boundTabClick=this.onTabClick.bind(this),t.boundTabKeydown=this.onTabKeydown.bind(this),t.addEventListener("click",t.boundTabClick,!0),t.addEventListener("keydown",t.boundTabKeydown,!0),this.hideTab(t)}.bind(this));var r=this.getTab(window.location.hash)||this.$tabs[0];this.showTab(r),t.boundOnHashChange=this.onHashChange.bind(this),window.addEventListener("hashchange",t.boundOnHashChange,!0)}},p.prototype.teardown=function(){var t=this.$module,n=this.$tabs,o=t.querySelector(".govuk-tabs__list"),i=t.querySelectorAll(".govuk-tabs__list-item");n&&o&&i&&(o.removeAttribute("role"),e(i,function(t){t.removeAttribute("role","presentation")}),e(n,function(t){t.removeEventListener("click",t.boundTabClick,!0),t.removeEventListener("keydown",t.boundTabKeydown,!0),this.unsetAttributes(t)}.bind(this)),window.removeEventListener("hashchange",t.boundOnHashChange,!0))},p.prototype.onHashChange=function(t){var e=window.location.hash,n=this.getTab(e);if(n)if(this.changingHash)this.changingHash=!1;else{var o=this.getCurrentTab();this.hideTab(o),this.showTab(n),n.focus()}},p.prototype.hideTab=function(t){this.unhighlightTab(t),this.hidePanel(t)},p.prototype.showTab=function(t){this.highlightTab(t),this.showPanel(t)},p.prototype.getTab=function(t){return this.$module.querySelector('.govuk-tabs__tab[href="'+t+'"]')},p.prototype.setAttributes=function(t){var e=this.getHref(t).slice(1);t.setAttribute("id","tab_"+e),t.setAttribute("role","tab"),t.setAttribute("aria-controls",e),t.setAttribute("tabindex","-1");var n=this.getPanel(t);n.setAttribute("role","tabpanel"),n.setAttribute("aria-labelledby",t.id),n.classList.add(this.jsHiddenClass)},p.prototype.unsetAttributes=function(t){t.removeAttribute("id"),t.removeAttribute("role"),t.removeAttribute("aria-controls"),t.removeAttribute("tabindex");var e=this.getPanel(t);e.removeAttribute("role"),e.removeAttribute("aria-labelledby"),e.classList.remove(this.jsHiddenClass)},p.prototype.onTabClick=function(t){t.preventDefault();var e=t.target,n=this.getCurrentTab();this.hideTab(n),this.showTab(e),this.createHistoryEntry(e)},p.prototype.createHistoryEntry=function(t){var e=this.getPanel(t),n=e.id;e.id="",this.changingHash=!0,window.location.hash=this.getHref(t).slice(1),e.id=n},p.prototype.onTabKeydown=function(t){switch(t.keyCode){case this.keys.left:case this.keys.up:this.activatePreviousTab(),t.preventDefault();break;case this.keys.right:case this.keys.down:this.activateNextTab(),t.preventDefault()}},p.prototype.activateNextTab=function(){var t=this.getCurrentTab(),e=t.parentNode.nextElementSibling;if(e)var n=e.firstElementChild;n&&(this.hideTab(t),this.showTab(n),n.focus(),this.createHistoryEntry(n))},p.prototype.activatePreviousTab=function(){var t=this.getCurrentTab(),e=t.parentNode.previousElementSibling;if(e)var n=e.firstElementChild;n&&(this.hideTab(t),this.showTab(n),n.focus(),this.createHistoryEntry(n))},p.prototype.getPanel=function(t){return this.$module.querySelector(this.getHref(t))},p.prototype.showPanel=function(t){this.getPanel(t).classList.remove(this.jsHiddenClass)},p.prototype.hidePanel=function(t){this.getPanel(t).classList.add(this.jsHiddenClass)},p.prototype.unhighlightTab=function(t){t.setAttribute("aria-selected","false"),t.classList.remove("govuk-tabs__tab--selected"),t.setAttribute("tabindex","-1")},p.prototype.highlightTab=function(t){t.setAttribute("aria-selected","true"),t.classList.add("govuk-tabs__tab--selected"),t.setAttribute("tabindex","0")},p.prototype.getCurrentTab=function(){return this.$module.querySelector(".govuk-tabs__tab--selected")},p.prototype.getHref=function(t){var e=t.getAttribute("href");return e.slice(e.indexOf("#"),e.length)};for(var f="undefined"!=typeof window&&"undefined"!=typeof document,h=["Edge","Trident","Firefox"],m=0,b=0;b=0){m=1;break}var g=f&&window.Promise?function(t){var e=!1;return function(){e||(e=!0,window.Promise.resolve().then(function(){e=!1,t()}))}}:function(t){var e=!1;return function(){e||(e=!0,setTimeout(function(){e=!1,t()},m))}};function v(t){return t&&"[object Function]"==={}.toString.call(t)}function y(t,e){if(1!==t.nodeType)return[];var n=t.ownerDocument.defaultView.getComputedStyle(t,null);return e?n[e]:n}function w(t){return"HTML"===t.nodeName?t:t.parentNode||t.host}function E(t){if(!t)return document.body;switch(t.nodeName){case"HTML":case"BODY":return t.ownerDocument.body;case"#document":return t.body}var e=y(t),n=e.overflow,o=e.overflowX,i=e.overflowY;return/(auto|scroll|overlay)/.test(n+i+o)?t:E(w(t))}var L=f&&!(!window.MSInputMethodContext||!document.documentMode),A=f&&/MSIE 10/.test(navigator.userAgent);function x(t){return 11===t?L:10===t?A:L||A}function k(t){if(!t)return document.documentElement;for(var e=x(10)?document.body:null,n=t.offsetParent||null;n===e&&t.nextElementSibling;)n=(t=t.nextElementSibling).offsetParent;var o=n&&n.nodeName;return o&&"BODY"!==o&&"HTML"!==o?-1!==["TH","TD","TABLE"].indexOf(n.nodeName)&&"static"===y(n,"position")?k(n):n:t?t.ownerDocument.documentElement:document.documentElement}function C(t){return null!==t.parentNode?C(t.parentNode):t}function S(t,e){if(!(t&&t.nodeType&&e&&e.nodeType))return document.documentElement;var n=t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING,o=n?t:e,i=n?e:t,r=document.createRange();r.setStart(o,0),r.setEnd(i,0);var s,a,l=r.commonAncestorContainer;if(t!==l&&e!==l||o.contains(i))return"BODY"===(a=(s=l).nodeName)||"HTML"!==a&&k(s.firstElementChild)!==s?k(l):l;var c=C(t);return c.host?S(c.host,e):S(t,C(e).host)}function T(t){var e="top"===(arguments.length>1&&arguments[1]!==undefined?arguments[1]:"top")?"scrollTop":"scrollLeft",n=t.nodeName;if("BODY"===n||"HTML"===n){var o=t.ownerDocument.documentElement;return(t.ownerDocument.scrollingElement||o)[e]}return t[e]}function O(t,e){var n="x"===e?"Left":"Top",o="Left"===n?"Right":"Bottom";return parseFloat(t["border"+n+"Width"],10)+parseFloat(t["border"+o+"Width"],10)}function _(t,e,n,o){return Math.max(e["offset"+t],e["scroll"+t],n["client"+t],n["offset"+t],n["scroll"+t],x(10)?parseInt(n["offset"+t])+parseInt(o["margin"+("Height"===t?"Top":"Left")])+parseInt(o["margin"+("Height"===t?"Bottom":"Right")]):0)}function $(t){var e=t.body,n=t.documentElement,o=x(10)&&getComputedStyle(n);return{height:_("Height",e,n,o),width:_("Width",e,n,o)}}var j=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},M=function(){function t(t,e){for(var n=0;n2&&arguments[2]!==undefined&&arguments[2],o=x(10),i="HTML"===e.nodeName,r=B(t),s=B(e),a=E(t),l=y(e),c=parseFloat(l.borderTopWidth,10),u=parseFloat(l.borderLeftWidth,10);n&&i&&(s.top=Math.max(s.top,0),s.left=Math.max(s.left,0));var d=H({top:r.top-s.top-c,left:r.left-s.left-u,width:r.width,height:r.height});if(d.marginTop=0,d.marginLeft=0,!o&&i){var p=parseFloat(l.marginTop,10),f=parseFloat(l.marginLeft,10);d.top-=c-p,d.bottom-=c-p,d.left-=u-f,d.right-=u-f,d.marginTop=p,d.marginLeft=f}return(o&&!n?e.contains(a):e===a&&"BODY"!==a.nodeName)&&(d=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined&&arguments[2],o=T(e,"top"),i=T(e,"left"),r=n?-1:1;return t.top+=o*r,t.bottom+=o*r,t.left+=i*r,t.right+=i*r,t}(d,e)),d}function I(t){if(!t||!t.parentElement||x())return document.documentElement;for(var e=t.parentElement;e&&"none"===y(e,"transform");)e=e.parentElement;return e||document.documentElement}function P(t,e,n,o){var i=arguments.length>4&&arguments[4]!==undefined&&arguments[4],r={top:0,left:0},s=i?I(t):S(t,e);if("viewport"===o)r=function(t){var e=arguments.length>1&&arguments[1]!==undefined&&arguments[1],n=t.ownerDocument.documentElement,o=F(t,n),i=Math.max(n.clientWidth,window.innerWidth||0),r=Math.max(n.clientHeight,window.innerHeight||0),s=e?0:T(n),a=e?0:T(n,"left");return H({top:s-o.top+o.marginTop,left:a-o.left+o.marginLeft,width:i,height:r})}(s,i);else{var a=void 0;"scrollParent"===o?"BODY"===(a=E(w(e))).nodeName&&(a=t.ownerDocument.documentElement):a="window"===o?t.ownerDocument.documentElement:o;var l=F(a,s,i);if("HTML"!==a.nodeName||function f(t){var e=t.nodeName;return"BODY"!==e&&"HTML"!==e&&("fixed"===y(t,"position")||f(w(t)))}(s))r=l;else{var c=$(t.ownerDocument),u=c.height,d=c.width;r.top+=l.top-l.marginTop,r.bottom=u+l.top,r.left+=l.left-l.marginLeft,r.right=d+l.left}}var p="number"==typeof(n=n||0);return r.left+=p?n:n.left||0,r.top+=p?n:n.top||0,r.right-=p?n:n.right||0,r.bottom-=p?n:n.bottom||0,r}function q(t,e,n,o,i){var r=arguments.length>5&&arguments[5]!==undefined?arguments[5]:0;if(-1===t.indexOf("auto"))return t;var s=P(n,o,r,i),a={top:{width:s.width,height:e.top-s.top},right:{width:s.right-e.right,height:s.height},bottom:{width:s.width,height:s.bottom-e.bottom},left:{width:e.left-s.left,height:s.height}},l=Object.keys(a).map(function(t){return D({key:t},a[t],{area:(e=a[t],e.width*e.height)});var e}).sort(function(t,e){return e.area-t.area}),c=l.filter(function(t){var e=t.width,o=t.height;return e>=n.clientWidth&&o>=n.clientHeight}),u=c.length>0?c[0].key:l[0].key,d=t.split("-")[1];return u+(d?"-"+d:"")}function W(t,e,n){var o=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return F(n,o?I(e):S(e,n),o)}function V(t){var e=t.ownerDocument.defaultView.getComputedStyle(t),n=parseFloat(e.marginTop||0)+parseFloat(e.marginBottom||0),o=parseFloat(e.marginLeft||0)+parseFloat(e.marginRight||0);return{width:t.offsetWidth+o,height:t.offsetHeight+n}}function R(t){var e={left:"right",right:"left",bottom:"top",top:"bottom"};return t.replace(/left|right|bottom|top/g,function(t){return e[t]})}function G(t,e,n){n=n.split("-")[0];var o=V(t),i={width:o.width,height:o.height},r=-1!==["right","left"].indexOf(n),s=r?"top":"left",a=r?"left":"top",l=r?"height":"width",c=r?"width":"height";return i[s]=e[s]+e[l]/2-o[l]/2,i[a]=n===a?e[a]-o[c]:e[R(a)],i}function U(t,e){return Array.prototype.find?t.find(e):t.filter(e)[0]}function Y(t,e,n){return(n===undefined?t:t.slice(0,function(t,e,n){if(Array.prototype.findIndex)return t.findIndex(function(t){return t[e]===n});var o=U(t,function(t){return t[e]===n});return t.indexOf(o)}(t,"name",n))).forEach(function(t){t["function"]&&console.warn("`modifier.function` is deprecated, use `modifier.fn`!");var n=t["function"]||t.fn;t.enabled&&v(n)&&(e.offsets.popper=H(e.offsets.popper),e.offsets.reference=H(e.offsets.reference),e=n(e,t))}),e}function K(t,e){return t.some(function(t){var n=t.name;return t.enabled&&n===e})}function z(t){for(var e=[!1,"ms","Webkit","Moz","O"],n=t.charAt(0).toUpperCase()+t.slice(1),o=0;o1&&arguments[1]!==undefined&&arguments[1],n=it.indexOf(t),o=it.slice(n+1).concat(it.slice(0,n));return e?o.reverse():o}var st={FLIP:"flip",CLOCKWISE:"clockwise",COUNTERCLOCKWISE:"counterclockwise"};function at(t,e,n,o){var i=[0,0],r=-1!==["right","left"].indexOf(o),s=t.split(/(\+|\-)/).map(function(t){return t.trim()}),a=s.indexOf(U(s,function(t){return-1!==t.search(/,|\s/)}));s[a]&&-1===s[a].indexOf(",")&&console.warn("Offsets separated by white space(s) are deprecated, use a comma (,) instead.");var l=/\s*,\s*|\s+/,c=-1!==a?[s.slice(0,a).concat([s[a].split(l)[0]]),[s[a].split(l)[1]].concat(s.slice(a+1))]:[s];return(c=c.map(function(t,o){var i=(1===o?!r:r)?"height":"width",s=!1;return t.reduce(function(t,e){return""===t[t.length-1]&&-1!==["+","-"].indexOf(e)?(t[t.length-1]=e,s=!0,t):s?(t[t.length-1]+=e,s=!1,t):t.concat(e)},[]).map(function(t){return function(t,e,n,o){var i=t.match(/((?:\-|\+)?\d*\.?\d*)(.*)/),r=+i[1],s=i[2];if(!r)return t;if(0===s.indexOf("%")){var a=void 0;switch(s){case"%p":a=n;break;case"%":case"%r":default:a=o}return H(a)[e]/100*r}if("vh"===s||"vw"===s)return("vh"===s?Math.max(document.documentElement.clientHeight,window.innerHeight||0):Math.max(document.documentElement.clientWidth,window.innerWidth||0))/100*r;return r}(t,i,e,n)})})).forEach(function(t,e){t.forEach(function(n,o){Z(n)&&(i[e]+=n*("-"===t[o-1]?-1:1))})}),i}var lt={placement:"bottom",positionFixed:!1,eventsEnabled:!0,removeOnDestroy:!1,onCreate:function(){},onUpdate:function(){},modifiers:{shift:{order:100,enabled:!0,fn:function(t){var e=t.placement,n=e.split("-")[0],o=e.split("-")[1];if(o){var i=t.offsets,r=i.reference,s=i.popper,a=-1!==["bottom","top"].indexOf(n),l=a?"left":"top",c=a?"width":"height",u={start:N({},l,r[l]),end:N({},l,r[l]+r[c]-s[c])};t.offsets.popper=D({},s,u[o])}return t}},offset:{order:200,enabled:!0,fn:function(t,e){var n=e.offset,o=t.placement,i=t.offsets,r=i.popper,s=i.reference,a=o.split("-")[0],l=void 0;return l=Z(+n)?[+n,0]:at(n,r,s,a),"left"===a?(r.top+=l[0],r.left-=l[1]):"right"===a?(r.top+=l[0],r.left+=l[1]):"top"===a?(r.left+=l[0],r.top-=l[1]):"bottom"===a&&(r.left+=l[0],r.top+=l[1]),t.popper=r,t},offset:0},preventOverflow:{order:300,enabled:!0,fn:function(t,e){var n=e.boundariesElement||k(t.instance.popper);t.instance.reference===n&&(n=k(n));var o=z("transform"),i=t.instance.popper.style,r=i.top,s=i.left,a=i[o];i.top="",i.left="",i[o]="";var l=P(t.instance.popper,t.instance.reference,e.padding,n,t.positionFixed);i.top=r,i.left=s,i[o]=a,e.boundaries=l;var c=e.priority,u=t.offsets.popper,d={primary:function(t){var n=u[t];return u[t]l[t]&&!e.escapeWithReference&&(o=Math.min(u[n],l[t]-("right"===t?u.width:u.height))),N({},n,o)}};return c.forEach(function(t){var e=-1!==["left","top"].indexOf(t)?"primary":"secondary";u=D({},u,d[e](t))}),t.offsets.popper=u,t},priority:["left","right","top","bottom"],padding:5,boundariesElement:"scrollParent"},keepTogether:{order:400,enabled:!0,fn:function(t){var e=t.offsets,n=e.popper,o=e.reference,i=t.placement.split("-")[0],r=Math.floor,s=-1!==["top","bottom"].indexOf(i),a=s?"right":"bottom",l=s?"left":"top",c=s?"width":"height";return n[a]r(o[a])&&(t.offsets.popper[l]=r(o[a])),t}},arrow:{order:500,enabled:!0,fn:function(t,e){var n;if(!nt(t.instance.modifiers,"arrow","keepTogether"))return t;var o=e.element;if("string"==typeof o){if(!(o=t.instance.popper.querySelector(o)))return t}else if(!t.instance.popper.contains(o))return console.warn("WARNING: `arrow.element` must be child of its popper element!"),t;var i=t.placement.split("-")[0],r=t.offsets,s=r.popper,a=r.reference,l=-1!==["left","right"].indexOf(i),c=l?"height":"width",u=l?"Top":"Left",d=u.toLowerCase(),p=l?"left":"top",f=l?"bottom":"right",h=V(o)[c];a[f]-hs[f]&&(t.offsets.popper[d]+=a[d]+h-s[f]),t.offsets.popper=H(t.offsets.popper);var m=a[d]+a[c]/2-h/2,b=y(t.instance.popper),g=parseFloat(b["margin"+u],10),v=parseFloat(b["border"+u+"Width"],10),w=m-t.offsets.popper[d]-g-v;return w=Math.max(Math.min(s[c]-h,w),0),t.arrowElement=o,t.offsets.arrow=(N(n={},d,Math.round(w)),N(n,p,""),n),t},element:"[x-arrow]"},flip:{order:600,enabled:!0,fn:function(t,e){if(K(t.instance.modifiers,"inner"))return t;if(t.flipped&&t.placement===t.originalPlacement)return t;var n=P(t.instance.popper,t.instance.reference,e.padding,e.boundariesElement,t.positionFixed),o=t.placement.split("-")[0],i=R(o),r=t.placement.split("-")[1]||"",s=[];switch(e.behavior){case st.FLIP:s=[o,i];break;case st.CLOCKWISE:s=rt(o);break;case st.COUNTERCLOCKWISE:s=rt(o,!0);break;default:s=e.behavior}return s.forEach(function(a,l){if(o!==a||s.length===l+1)return t;o=t.placement.split("-")[0],i=R(o);var c,u=t.offsets.popper,d=t.offsets.reference,p=Math.floor,f="left"===o&&p(u.right)>p(d.left)||"right"===o&&p(u.left)p(d.top)||"bottom"===o&&p(u.top)p(n.right),b=p(u.top)p(n.bottom),v="left"===o&&h||"right"===o&&m||"top"===o&&b||"bottom"===o&&g,y=-1!==["top","bottom"].indexOf(o),w=!!e.flipVariations&&(y&&"start"===r&&h||y&&"end"===r&&m||!y&&"start"===r&&b||!y&&"end"===r&&g);(f||v||w)&&(t.flipped=!0,(f||v)&&(o=s[l+1]),w&&(r="end"===(c=r)?"start":"start"===c?"end":c),t.placement=o+(r?"-"+r:""),t.offsets.popper=D({},t.offsets.popper,G(t.instance.popper,t.offsets.reference,t.placement)),t=Y(t.instance.modifiers,t,"flip"))}),t},behavior:"flip",padding:5,boundariesElement:"viewport"},inner:{order:700,enabled:!1,fn:function(t){var e=t.placement,n=e.split("-")[0],o=t.offsets,i=o.popper,r=o.reference,s=-1!==["left","right"].indexOf(n),a=-1===["top","left"].indexOf(n);return i[s?"left":"top"]=r[n]-(a?i[s?"width":"height"]:0),t.placement=R(e),t.offsets.popper=H(i),t}},hide:{order:800,enabled:!0,fn:function(t){if(!nt(t.instance.modifiers,"hide","preventOverflow"))return t;var e=t.offsets.reference,n=U(t.instance.modifiers,function(t){return"preventOverflow"===t.name}).boundaries;if(e.bottomn.right||e.top>n.bottom||e.right2&&arguments[2]!==undefined?arguments[2]:{};j(this,t),this.scheduleUpdate=function(){return requestAnimationFrame(o.update)},this.update=g(this.update.bind(this)),this.options=D({},t.Defaults,i),this.state={isDestroyed:!1,isCreated:!1,scrollParents:[]},this.reference=e&&e.jquery?e[0]:e,this.popper=n&&n.jquery?n[0]:n,this.options.modifiers={},Object.keys(D({},t.Defaults.modifiers,i.modifiers)).forEach(function(e){o.options.modifiers[e]=D({},t.Defaults.modifiers[e]||{},i.modifiers?i.modifiers[e]:{})}),this.modifiers=Object.keys(this.options.modifiers).map(function(t){return D({name:t},o.options.modifiers[t])}).sort(function(t,e){return t.order-e.order}),this.modifiers.forEach(function(t){t.enabled&&v(t.onLoad)&&t.onLoad(o.reference,o.popper,o.options,t,o.state)}),this.update();var r=this.options.eventsEnabled;r&&this.enableEventListeners(),this.state.eventsEnabled=r}return M(t,[{key:"update",value:function(){return function(){if(!this.state.isDestroyed){var t={instance:this,styles:{},arrowStyles:{},attributes:{},flipped:!1,offsets:{}};t.offsets.reference=W(this.state,this.popper,this.reference,this.options.positionFixed),t.placement=q(this.options.placement,t.offsets.reference,this.popper,this.reference,this.options.modifiers.flip.boundariesElement,this.options.modifiers.flip.padding),t.originalPlacement=t.placement,t.positionFixed=this.options.positionFixed,t.offsets.popper=G(this.popper,t.offsets.reference,t.placement),t.offsets.popper.position=this.options.positionFixed?"fixed":"absolute",t=Y(this.modifiers,t),this.state.isCreated?this.options.onUpdate(t):(this.state.isCreated=!0,this.options.onCreate(t))}}.call(this)}},{key:"destroy",value:function(){return function(){return this.state.isDestroyed=!0,K(this.modifiers,"applyStyle")&&(this.popper.removeAttribute("x-placement"),this.popper.style.position="",this.popper.style.top="",this.popper.style.left="",this.popper.style.right="",this.popper.style.bottom="",this.popper.style.willChange="",this.popper.style[z("transform")]=""),this.disableEventListeners(),this.options.removeOnDestroy&&this.popper.parentNode.removeChild(this.popper),this}.call(this)}},{key:"enableEventListeners",value:function(){return function(){this.state.eventsEnabled||(this.state=J(this.reference,this.options,this.state,this.scheduleUpdate))}.call(this)}},{key:"disableEventListeners",value:function(){return Q.call(this)}}]),t}();function ut(t){this.$module=t,this.$toggleButton=null,this.$dropdown=null,this.popper=null,this.blurEnabled=!0}function dt(t){this.$module=t}function pt(t){console.log(t),this.$module=t,this.$appear=null,this.$disappear=null}ct.Utils=("undefined"!=typeof window?window:global).PopperUtils,ct.placements=ot,ct.Defaults=lt,ut.prototype.init=function(){var t=this.$module;t&&(this.$toggleButton=t.querySelector(".js-dropdown-toggle"),this.$toggleButton&&(t.querySelectorAll(".sdn-header__dropdown a").forEach(function(t){t.addEventListener("click",function(){this.$dropdown.style.display="none",this.blurEnabled=!0}.bind(this))}.bind(this)),this.$dropdown=t.querySelector("#"+this.$toggleButton.getAttribute("aria-controls")),document.getElementsByTagName("body")[0].appendChild(this.$dropdown),this.popper=new ct(this.$toggleButton,this.$dropdown,{placement:"bottom-end"}),this.$toggleButton.addEventListener("click",this.handleClick.bind(this)),this.$toggleButton.addEventListener("blur",this.handleBlur.bind(this)),this.$dropdown.addEventListener("mouseenter",this.handleMouseenter.bind(this)),this.$dropdown.addEventListener("mouseleave",this.handleMouseleave.bind(this))))},ut.prototype.toggleClass=function(t,e){t.className.indexOf(e)>0?t.className=t.className.replace(" "+e,""):t.className+=" "+e},ut.prototype.handleClick=function(t){t.preventDefault(),this.$dropdown.style.display="block",this.popper.update()},ut.prototype.handleBlur=function(t){this.blurEnabled&&(this.$dropdown.style.display="none")},ut.prototype.handleMouseenter=function(t){this.blurEnabled=!1},ut.prototype.handleMouseleave=function(t){this.blurEnabled=!0},dt.prototype.init=function(){var t,e,n,o,i,r=this.$module;!r||r.className.indexOf("snd-timeline--readonly")>-1||(t="body",e="click",n=".js-sdn-timeline__bullet",o=this.handleClick.bind(this),(i=document.querySelector(t)).addEventListener(e,function(t){for(var e=i.querySelectorAll(n),r=t.target,s=0,a=e.length;s=l)for(;l>>0,"object"==typeof e[o]?e[o].baseVal=r.join(" "):e[o]=r.join(" "),u())},i.remove=function(){d.apply(i,t=arguments);for(var t,n={},l=0,c=[];l>>0,"object"==typeof e[o]?e[o].baseVal=r.join(" "):e[o]=r.join(" "),u()},i.toggle=function(e,n){return d.apply(i,[e]),t!==n?n?(i.add(e),!0):(i.remove(e),!1):s[e]?(i.remove(e),!1):(i.add(e),!0)},i}}()),"classList"in(o=document.createElement("span"))&&(o.classList.toggle("x",!1),o.classList.contains("x")&&(o.classList.constructor.prototype.toggle=function(e){var n=arguments[1];if(n===t){var o=!this.contains(e);return this[o?"add":"remove"](e),o}return this[(n=!!n)?"add":"remove"](e),n})),function(){var t=document.createElement("span");if("classList"in t&&(t.classList.add("a","b"),!t.classList.contains("b"))){var e=t.classList.constructor.prototype.add;t.classList.constructor.prototype.add=function(){for(var t=arguments,n=arguments.length,o=0;osections',this.$openAllButton.setAttribute("class",this.openAllClass),this.$openAllButton.setAttribute("aria-expanded","false"),this.$openAllButton.setAttribute("type","button");var t=document.createElement("div");t.setAttribute("class",this.controlsClass),t.appendChild(this.$openAllButton),this.$module.insertBefore(t,this.$module.firstChild),this.$openAllButton.addEventListener("click",this.onOpenOrCloseAllToggle.bind(this))},o.prototype.initSectionHeaders=function(){e(this.$sections,function(t,e){var n=t.querySelector("."+this.sectionHeaderClass);this.initHeaderAttributes(n,e),this.setExpanded(this.isExpanded(t),t),n.addEventListener("click",this.onSectionToggle.bind(this,t)),this.setInitialState(t)}.bind(this))},o.prototype.initHeaderAttributes=function(t,e){var n=this,o=t.querySelector("."+this.sectionButtonClass),i=t.querySelector("."+this.sectionHeadingClass),r=t.querySelector("."+this.sectionSummaryClass),s=document.createElement("button");s.setAttribute("type","button"),s.setAttribute("id",this.moduleId+"-heading-"+(e+1)),s.setAttribute("aria-controls",this.moduleId+"-content-"+(e+1));for(var a=0;a'),this.describedBy=t.getAttribute("aria-describedby"),this.describedByInfo=this.describedBy+" "+e+"-info",t.setAttribute("aria-describedby",this.describedByInfo),n=document.getElementById(e+"-info")):t.insertAdjacentElement("afterend",n),n},l.prototype.bindChangeEvents=function(){var t=this.$textarea;t.addEventListener("keyup",this.checkIfValueChanged.bind(this)),t.addEventListener("focus",this.handleFocus.bind(this)),t.addEventListener("blur",this.handleBlur.bind(this))},l.prototype.checkIfValueChanged=function(){(this.$textarea.oldValue||(this.$textarea.oldValue=""),this.$textarea.value!==this.$textarea.oldValue)&&(this.$textarea.oldValue=this.$textarea.value,this.updateCountMessage.bind(this)())},l.prototype.updateCountMessage=function(){var t=this.$textarea,e=this.options,n=this.countMessage,o=this.count(t.value),i=this.maxLength,r=i-o;i*(e.threshold?e.threshold:0)/100>o?n.classList.add("govuk-character-count__message--disabled"):n.classList.remove("govuk-character-count__message--disabled"),r<0?(t.classList.add("govuk-textarea--error"),n.classList.remove("govuk-hint"),n.classList.add("govuk-error-message")):(t.classList.remove("govuk-textarea--error"),n.classList.remove("govuk-error-message"),n.classList.add("govuk-hint"));var s,a,l="character";e.maxwords&&(l="word"),l+=-1===r||1===r?"":"s",s=r<0?"too many":"remaining",a=Math.abs(r),n.innerHTML="You have "+a+" "+l+" "+s},l.prototype.handleFocus=function(){this.valueChecker=setInterval(this.checkIfValueChanged.bind(this),1e3)},l.prototype.handleBlur=function(){clearInterval(this.valueChecker)},c.prototype.init=function(){var t=this.$module;e(this.$inputs,function(e){var n=e.getAttribute("data-aria-controls");n&&t.querySelector("#"+n)&&(e.setAttribute("aria-controls",n),e.removeAttribute("data-aria-controls"),this.setAttributes(e))}.bind(this)),t.addEventListener("click",this.handleClick.bind(this))},c.prototype.setAttributes=function(t){var e=t.checked;t.setAttribute("aria-expanded",e),document.querySelector("#"+t.getAttribute("aria-controls")).classList.toggle("govuk-checkboxes__conditional--hidden",!e)},c.prototype.handleClick=function(t){var e=t.target,n="checkbox"===e.getAttribute("type"),o=e.getAttribute("aria-controls");n&&o&&this.setAttributes(e)},function(t){"document"in this&&"matches"in document.documentElement||(Element.prototype.matches=Element.prototype.webkitMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.mozMatchesSelector||function(t){for(var e=(this.document||this.ownerDocument).querySelectorAll(t),n=0;e[n]&&e[n]!==this;)++n;return!!e[n]})}.call("object"==typeof window&&window||"object"==typeof self&&self||"object"==typeof global&&global||{}),function(t){"document"in this&&"closest"in document.documentElement||(Element.prototype.closest=function(t){for(var e=this;e;){if(e.matches(t))return e;e="SVGElement"in window&&e instanceof SVGElement?e.parentNode:e.parentElement}return null})}.call("object"==typeof window&&window||"object"==typeof self&&self||"object"==typeof global&&global||{}),u.prototype.init=function(){var t=this.$module;t&&(window.addEventListener("load",function(){t.focus()}),t.addEventListener("click",this.handleClick.bind(this)))},u.prototype.handleClick=function(t){var e=t.target;this.focusTarget(e)&&t.preventDefault()},u.prototype.focusTarget=function(t){if("A"!==t.tagName||!1===t.href)return!1;var e=this.getFragmentFromUrl(t.href),n=document.getElementById(e);if(!n)return!1;var o=this.getAssociatedLegendOrLabel(n);return!!o&&(window.history.pushState?window.history.pushState(null,null,"#"+e):window.location.hash=e,o.scrollIntoView(),n.focus({preventScroll:!0}),!0)},u.prototype.getFragmentFromUrl=function(t){return-1!==t.indexOf("#")&&t.split("#").pop()},u.prototype.getAssociatedLegendOrLabel=function(t){var e=t.closest("fieldset");if(e){var n=e.getElementsByTagName("legend");if(n.length)return n[0]}return document.querySelector("label[for='"+t.getAttribute("id")+"']")||t.closest("label")},d.prototype.init=function(){var t=this.$module;if(t){var e=t.querySelector(".js-header-toggle");e&&e.addEventListener("click",this.handleClick.bind(this))}},d.prototype.toggleClass=function(t,e){t.className.indexOf(e)>0?t.className=t.className.replace(" "+e,""):t.className+=" "+e},d.prototype.handleClick=function(t){var e=this.$module,n=t.target||t.srcElement,o=e.querySelector("#"+n.getAttribute("aria-controls"));n&&o&&(this.toggleClass(o,"govuk-header__navigation--open"),this.toggleClass(n,"govuk-header__menu-button--open"),n.setAttribute("aria-expanded","true"!==n.getAttribute("aria-expanded")),o.setAttribute("aria-hidden","false"===o.getAttribute("aria-hidden")))},p.prototype.init=function(){var t=this.$module;e(this.$inputs,function(e){var n=e.getAttribute("data-aria-controls");n&&t.querySelector("#"+n)&&(e.setAttribute("aria-controls",n),e.removeAttribute("data-aria-controls"),this.setAttributes(e))}.bind(this)),t.addEventListener("click",this.handleClick.bind(this))},p.prototype.setAttributes=function(t){var e=t.checked;t.setAttribute("aria-expanded",e),document.querySelector("#"+t.getAttribute("aria-controls")).classList.toggle("govuk-radios__conditional--hidden",!e)},p.prototype.handleClick=function(t){e(this.$inputs,function(t){var e="radio"===t.getAttribute("type"),n=t.getAttribute("aria-controls");e&&n&&this.setAttributes(t)}.bind(this))},f.prototype.init=function(){"function"==typeof window.matchMedia?this.setupResponsiveChecks():this.setup()},f.prototype.setupResponsiveChecks=function(){this.mql=window.matchMedia("(min-width: 40.0625em)"),this.mql.addListener(this.checkMode.bind(this)),this.checkMode()},f.prototype.checkMode=function(){this.mql.matches?this.setup():this.teardown()},f.prototype.setup=function(){var t=this.$module,n=this.$tabs,o=t.querySelector(".govuk-tabs__list"),i=t.querySelectorAll(".govuk-tabs__list-item");if(n&&o&&i){o.setAttribute("role","tablist"),e(i,function(t){t.setAttribute("role","presentation")}),e(n,function(t){this.setAttributes(t),t.boundTabClick=this.onTabClick.bind(this),t.boundTabKeydown=this.onTabKeydown.bind(this),t.addEventListener("click",t.boundTabClick,!0),t.addEventListener("keydown",t.boundTabKeydown,!0),this.hideTab(t)}.bind(this));var r=this.getTab(window.location.hash)||this.$tabs[0];this.showTab(r),t.boundOnHashChange=this.onHashChange.bind(this),window.addEventListener("hashchange",t.boundOnHashChange,!0)}},f.prototype.teardown=function(){var t=this.$module,n=this.$tabs,o=t.querySelector(".govuk-tabs__list"),i=t.querySelectorAll(".govuk-tabs__list-item");n&&o&&i&&(o.removeAttribute("role"),e(i,function(t){t.removeAttribute("role","presentation")}),e(n,function(t){t.removeEventListener("click",t.boundTabClick,!0),t.removeEventListener("keydown",t.boundTabKeydown,!0),this.unsetAttributes(t)}.bind(this)),window.removeEventListener("hashchange",t.boundOnHashChange,!0))},f.prototype.onHashChange=function(t){var e=window.location.hash,n=this.getTab(e);if(n)if(this.changingHash)this.changingHash=!1;else{var o=this.getCurrentTab();this.hideTab(o),this.showTab(n),n.focus()}},f.prototype.hideTab=function(t){this.unhighlightTab(t),this.hidePanel(t)},f.prototype.showTab=function(t){this.highlightTab(t),this.showPanel(t)},f.prototype.getTab=function(t){return this.$module.querySelector('.govuk-tabs__tab[href="'+t+'"]')},f.prototype.setAttributes=function(t){var e=this.getHref(t).slice(1);t.setAttribute("id","tab_"+e),t.setAttribute("role","tab"),t.setAttribute("aria-controls",e),t.setAttribute("tabindex","-1");var n=this.getPanel(t);n.setAttribute("role","tabpanel"),n.setAttribute("aria-labelledby",t.id),n.classList.add(this.jsHiddenClass)},f.prototype.unsetAttributes=function(t){t.removeAttribute("id"),t.removeAttribute("role"),t.removeAttribute("aria-controls"),t.removeAttribute("tabindex");var e=this.getPanel(t);e.removeAttribute("role"),e.removeAttribute("aria-labelledby"),e.classList.remove(this.jsHiddenClass)},f.prototype.onTabClick=function(t){t.preventDefault();var e=t.target,n=this.getCurrentTab();this.hideTab(n),this.showTab(e),this.createHistoryEntry(e)},f.prototype.createHistoryEntry=function(t){var e=this.getPanel(t),n=e.id;e.id="",this.changingHash=!0,window.location.hash=this.getHref(t).slice(1),e.id=n},f.prototype.onTabKeydown=function(t){switch(t.keyCode){case this.keys.left:case this.keys.up:this.activatePreviousTab(),t.preventDefault();break;case this.keys.right:case this.keys.down:this.activateNextTab(),t.preventDefault()}},f.prototype.activateNextTab=function(){var t=this.getCurrentTab(),e=t.parentNode.nextElementSibling;if(e)var n=e.firstElementChild;n&&(this.hideTab(t),this.showTab(n),n.focus(),this.createHistoryEntry(n))},f.prototype.activatePreviousTab=function(){var t=this.getCurrentTab(),e=t.parentNode.previousElementSibling;if(e)var n=e.firstElementChild;n&&(this.hideTab(t),this.showTab(n),n.focus(),this.createHistoryEntry(n))},f.prototype.getPanel=function(t){return this.$module.querySelector(this.getHref(t))},f.prototype.showPanel=function(t){this.getPanel(t).classList.remove(this.jsHiddenClass)},f.prototype.hidePanel=function(t){this.getPanel(t).classList.add(this.jsHiddenClass)},f.prototype.unhighlightTab=function(t){t.setAttribute("aria-selected","false"),t.classList.remove("govuk-tabs__tab--selected"),t.setAttribute("tabindex","-1")},f.prototype.highlightTab=function(t){t.setAttribute("aria-selected","true"),t.classList.add("govuk-tabs__tab--selected"),t.setAttribute("tabindex","0")},f.prototype.getCurrentTab=function(){return this.$module.querySelector(".govuk-tabs__tab--selected")},f.prototype.getHref=function(t){var e=t.getAttribute("href");return e.slice(e.indexOf("#"),e.length)};for(var h="undefined"!=typeof window&&"undefined"!=typeof document,m=["Edge","Trident","Firefox"],b=0,g=0;g=0){b=1;break}var v=h&&window.Promise?function(t){var e=!1;return function(){e||(e=!0,window.Promise.resolve().then(function(){e=!1,t()}))}}:function(t){var e=!1;return function(){e||(e=!0,setTimeout(function(){e=!1,t()},b))}};function y(t){return t&&"[object Function]"==={}.toString.call(t)}function w(t,e){if(1!==t.nodeType)return[];var n=t.ownerDocument.defaultView.getComputedStyle(t,null);return e?n[e]:n}function E(t){return"HTML"===t.nodeName?t:t.parentNode||t.host}function L(t){if(!t)return document.body;switch(t.nodeName){case"HTML":case"BODY":return t.ownerDocument.body;case"#document":return t.body}var e=w(t),n=e.overflow,o=e.overflowX,i=e.overflowY;return/(auto|scroll|overlay)/.test(n+i+o)?t:L(E(t))}var A=h&&!(!window.MSInputMethodContext||!document.documentMode),x=h&&/MSIE 10/.test(navigator.userAgent);function k(t){return 11===t?A:10===t?x:A||x}function C(t){if(!t)return document.documentElement;for(var e=k(10)?document.body:null,n=t.offsetParent||null;n===e&&t.nextElementSibling;)n=(t=t.nextElementSibling).offsetParent;var o=n&&n.nodeName;return o&&"BODY"!==o&&"HTML"!==o?-1!==["TH","TD","TABLE"].indexOf(n.nodeName)&&"static"===w(n,"position")?C(n):n:t?t.ownerDocument.documentElement:document.documentElement}function S(t){return null!==t.parentNode?S(t.parentNode):t}function T(t,e){if(!(t&&t.nodeType&&e&&e.nodeType))return document.documentElement;var n=t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING,o=n?t:e,i=n?e:t,r=document.createRange();r.setStart(o,0),r.setEnd(i,0);var s,a,l=r.commonAncestorContainer;if(t!==l&&e!==l||o.contains(i))return"BODY"===(a=(s=l).nodeName)||"HTML"!==a&&C(s.firstElementChild)!==s?C(l):l;var c=S(t);return c.host?T(c.host,e):T(t,S(e).host)}function _(t){var e="top"===(arguments.length>1&&arguments[1]!==undefined?arguments[1]:"top")?"scrollTop":"scrollLeft",n=t.nodeName;if("BODY"===n||"HTML"===n){var o=t.ownerDocument.documentElement;return(t.ownerDocument.scrollingElement||o)[e]}return t[e]}function O(t,e){var n="x"===e?"Left":"Top",o="Left"===n?"Right":"Bottom";return parseFloat(t["border"+n+"Width"],10)+parseFloat(t["border"+o+"Width"],10)}function $(t,e,n,o){return Math.max(e["offset"+t],e["scroll"+t],n["client"+t],n["offset"+t],n["scroll"+t],k(10)?parseInt(n["offset"+t])+parseInt(o["margin"+("Height"===t?"Top":"Left")])+parseInt(o["margin"+("Height"===t?"Bottom":"Right")]):0)}function j(t){var e=t.body,n=t.documentElement,o=k(10)&&getComputedStyle(n);return{height:$("Height",e,n,o),width:$("Width",e,n,o)}}var M=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},N=function(){function t(t,e){for(var n=0;n2&&arguments[2]!==undefined&&arguments[2],o=k(10),i="HTML"===e.nodeName,r=F(t),s=F(e),a=L(t),l=w(e),c=parseFloat(l.borderTopWidth,10),u=parseFloat(l.borderLeftWidth,10);n&&i&&(s.top=Math.max(s.top,0),s.left=Math.max(s.left,0));var d=B({top:r.top-s.top-c,left:r.left-s.left-u,width:r.width,height:r.height});if(d.marginTop=0,d.marginLeft=0,!o&&i){var p=parseFloat(l.marginTop,10),f=parseFloat(l.marginLeft,10);d.top-=c-p,d.bottom-=c-p,d.left-=u-f,d.right-=u-f,d.marginTop=p,d.marginLeft=f}return(o&&!n?e.contains(a):e===a&&"BODY"!==a.nodeName)&&(d=function(t,e){var n=arguments.length>2&&arguments[2]!==undefined&&arguments[2],o=_(e,"top"),i=_(e,"left"),r=n?-1:1;return t.top+=o*r,t.bottom+=o*r,t.left+=i*r,t.right+=i*r,t}(d,e)),d}function q(t){if(!t||!t.parentElement||k())return document.documentElement;for(var e=t.parentElement;e&&"none"===w(e,"transform");)e=e.parentElement;return e||document.documentElement}function P(t,e,n,o){var i=arguments.length>4&&arguments[4]!==undefined&&arguments[4],r={top:0,left:0},s=i?q(t):T(t,e);if("viewport"===o)r=function(t){var e=arguments.length>1&&arguments[1]!==undefined&&arguments[1],n=t.ownerDocument.documentElement,o=I(t,n),i=Math.max(n.clientWidth,window.innerWidth||0),r=Math.max(n.clientHeight,window.innerHeight||0),s=e?0:_(n),a=e?0:_(n,"left");return B({top:s-o.top+o.marginTop,left:a-o.left+o.marginLeft,width:i,height:r})}(s,i);else{var a=void 0;"scrollParent"===o?"BODY"===(a=L(E(e))).nodeName&&(a=t.ownerDocument.documentElement):a="window"===o?t.ownerDocument.documentElement:o;var l=I(a,s,i);if("HTML"!==a.nodeName||function f(t){var e=t.nodeName;return"BODY"!==e&&"HTML"!==e&&("fixed"===w(t,"position")||f(E(t)))}(s))r=l;else{var c=j(t.ownerDocument),u=c.height,d=c.width;r.top+=l.top-l.marginTop,r.bottom=u+l.top,r.left+=l.left-l.marginLeft,r.right=d+l.left}}var p="number"==typeof(n=n||0);return r.left+=p?n:n.left||0,r.top+=p?n:n.top||0,r.right-=p?n:n.right||0,r.bottom-=p?n:n.bottom||0,r}function W(t,e,n,o,i){var r=arguments.length>5&&arguments[5]!==undefined?arguments[5]:0;if(-1===t.indexOf("auto"))return t;var s=P(n,o,r,i),a={top:{width:s.width,height:e.top-s.top},right:{width:s.right-e.right,height:s.height},bottom:{width:s.width,height:s.bottom-e.bottom},left:{width:e.left-s.left,height:s.height}},l=Object.keys(a).map(function(t){return D({key:t},a[t],{area:(e=a[t],e.width*e.height)});var e}).sort(function(t,e){return e.area-t.area}),c=l.filter(function(t){var e=t.width,o=t.height;return e>=n.clientWidth&&o>=n.clientHeight}),u=c.length>0?c[0].key:l[0].key,d=t.split("-")[1];return u+(d?"-"+d:"")}function V(t,e,n){var o=arguments.length>3&&arguments[3]!==undefined?arguments[3]:null;return I(n,o?q(e):T(e,n),o)}function R(t){var e=t.ownerDocument.defaultView.getComputedStyle(t),n=parseFloat(e.marginTop||0)+parseFloat(e.marginBottom||0),o=parseFloat(e.marginLeft||0)+parseFloat(e.marginRight||0);return{width:t.offsetWidth+o,height:t.offsetHeight+n}}function G(t){var e={left:"right",right:"left",bottom:"top",top:"bottom"};return t.replace(/left|right|bottom|top/g,function(t){return e[t]})}function U(t,e,n){n=n.split("-")[0];var o=R(t),i={width:o.width,height:o.height},r=-1!==["right","left"].indexOf(n),s=r?"top":"left",a=r?"left":"top",l=r?"height":"width",c=r?"width":"height";return i[s]=e[s]+e[l]/2-o[l]/2,i[a]=n===a?e[a]-o[c]:e[G(a)],i}function Y(t,e){return Array.prototype.find?t.find(e):t.filter(e)[0]}function K(t,e,n){return(n===undefined?t:t.slice(0,function(t,e,n){if(Array.prototype.findIndex)return t.findIndex(function(t){return t[e]===n});var o=Y(t,function(t){return t[e]===n});return t.indexOf(o)}(t,"name",n))).forEach(function(t){t["function"]&&console.warn("`modifier.function` is deprecated, use `modifier.fn`!");var n=t["function"]||t.fn;t.enabled&&y(n)&&(e.offsets.popper=B(e.offsets.popper),e.offsets.reference=B(e.offsets.reference),e=n(e,t))}),e}function z(t,e){return t.some(function(t){var n=t.name;return t.enabled&&n===e})}function X(t){for(var e=[!1,"ms","Webkit","Moz","O"],n=t.charAt(0).toUpperCase()+t.slice(1),o=0;o1&&arguments[1]!==undefined&&arguments[1],n=rt.indexOf(t),o=rt.slice(n+1).concat(rt.slice(0,n));return e?o.reverse():o}var at={FLIP:"flip",CLOCKWISE:"clockwise",COUNTERCLOCKWISE:"counterclockwise"};function lt(t,e,n,o){var i=[0,0],r=-1!==["right","left"].indexOf(o),s=t.split(/(\+|\-)/).map(function(t){return t.trim()}),a=s.indexOf(Y(s,function(t){return-1!==t.search(/,|\s/)}));s[a]&&-1===s[a].indexOf(",")&&console.warn("Offsets separated by white space(s) are deprecated, use a comma (,) instead.");var l=/\s*,\s*|\s+/,c=-1!==a?[s.slice(0,a).concat([s[a].split(l)[0]]),[s[a].split(l)[1]].concat(s.slice(a+1))]:[s];return(c=c.map(function(t,o){var i=(1===o?!r:r)?"height":"width",s=!1;return t.reduce(function(t,e){return""===t[t.length-1]&&-1!==["+","-"].indexOf(e)?(t[t.length-1]=e,s=!0,t):s?(t[t.length-1]+=e,s=!1,t):t.concat(e)},[]).map(function(t){return function(t,e,n,o){var i=t.match(/((?:\-|\+)?\d*\.?\d*)(.*)/),r=+i[1],s=i[2];if(!r)return t;if(0===s.indexOf("%")){var a=void 0;switch(s){case"%p":a=n;break;case"%":case"%r":default:a=o}return B(a)[e]/100*r}if("vh"===s||"vw"===s)return("vh"===s?Math.max(document.documentElement.clientHeight,window.innerHeight||0):Math.max(document.documentElement.clientWidth,window.innerWidth||0))/100*r;return r}(t,i,e,n)})})).forEach(function(t,e){t.forEach(function(n,o){tt(n)&&(i[e]+=n*("-"===t[o-1]?-1:1))})}),i}var ct={placement:"bottom",positionFixed:!1,eventsEnabled:!0,removeOnDestroy:!1,onCreate:function(){},onUpdate:function(){},modifiers:{shift:{order:100,enabled:!0,fn:function(t){var e=t.placement,n=e.split("-")[0],o=e.split("-")[1];if(o){var i=t.offsets,r=i.reference,s=i.popper,a=-1!==["bottom","top"].indexOf(n),l=a?"left":"top",c=a?"width":"height",u={start:H({},l,r[l]),end:H({},l,r[l]+r[c]-s[c])};t.offsets.popper=D({},s,u[o])}return t}},offset:{order:200,enabled:!0,fn:function(t,e){var n=e.offset,o=t.placement,i=t.offsets,r=i.popper,s=i.reference,a=o.split("-")[0],l=void 0;return l=tt(+n)?[+n,0]:lt(n,r,s,a),"left"===a?(r.top+=l[0],r.left-=l[1]):"right"===a?(r.top+=l[0],r.left+=l[1]):"top"===a?(r.left+=l[0],r.top-=l[1]):"bottom"===a&&(r.left+=l[0],r.top+=l[1]),t.popper=r,t},offset:0},preventOverflow:{order:300,enabled:!0,fn:function(t,e){var n=e.boundariesElement||C(t.instance.popper);t.instance.reference===n&&(n=C(n));var o=X("transform"),i=t.instance.popper.style,r=i.top,s=i.left,a=i[o];i.top="",i.left="",i[o]="";var l=P(t.instance.popper,t.instance.reference,e.padding,n,t.positionFixed);i.top=r,i.left=s,i[o]=a,e.boundaries=l;var c=e.priority,u=t.offsets.popper,d={primary:function(t){var n=u[t];return u[t]l[t]&&!e.escapeWithReference&&(o=Math.min(u[n],l[t]-("right"===t?u.width:u.height))),H({},n,o)}};return c.forEach(function(t){var e=-1!==["left","top"].indexOf(t)?"primary":"secondary";u=D({},u,d[e](t))}),t.offsets.popper=u,t},priority:["left","right","top","bottom"],padding:5,boundariesElement:"scrollParent"},keepTogether:{order:400,enabled:!0,fn:function(t){var e=t.offsets,n=e.popper,o=e.reference,i=t.placement.split("-")[0],r=Math.floor,s=-1!==["top","bottom"].indexOf(i),a=s?"right":"bottom",l=s?"left":"top",c=s?"width":"height";return n[a]r(o[a])&&(t.offsets.popper[l]=r(o[a])),t}},arrow:{order:500,enabled:!0,fn:function(t,e){var n;if(!ot(t.instance.modifiers,"arrow","keepTogether"))return t;var o=e.element;if("string"==typeof o){if(!(o=t.instance.popper.querySelector(o)))return t}else if(!t.instance.popper.contains(o))return console.warn("WARNING: `arrow.element` must be child of its popper element!"),t;var i=t.placement.split("-")[0],r=t.offsets,s=r.popper,a=r.reference,l=-1!==["left","right"].indexOf(i),c=l?"height":"width",u=l?"Top":"Left",d=u.toLowerCase(),p=l?"left":"top",f=l?"bottom":"right",h=R(o)[c];a[f]-hs[f]&&(t.offsets.popper[d]+=a[d]+h-s[f]),t.offsets.popper=B(t.offsets.popper);var m=a[d]+a[c]/2-h/2,b=w(t.instance.popper),g=parseFloat(b["margin"+u],10),v=parseFloat(b["border"+u+"Width"],10),y=m-t.offsets.popper[d]-g-v;return y=Math.max(Math.min(s[c]-h,y),0),t.arrowElement=o,t.offsets.arrow=(H(n={},d,Math.round(y)),H(n,p,""),n),t},element:"[x-arrow]"},flip:{order:600,enabled:!0,fn:function(t,e){if(z(t.instance.modifiers,"inner"))return t;if(t.flipped&&t.placement===t.originalPlacement)return t;var n=P(t.instance.popper,t.instance.reference,e.padding,e.boundariesElement,t.positionFixed),o=t.placement.split("-")[0],i=G(o),r=t.placement.split("-")[1]||"",s=[];switch(e.behavior){case at.FLIP:s=[o,i];break;case at.CLOCKWISE:s=st(o);break;case at.COUNTERCLOCKWISE:s=st(o,!0);break;default:s=e.behavior}return s.forEach(function(a,l){if(o!==a||s.length===l+1)return t;o=t.placement.split("-")[0],i=G(o);var c,u=t.offsets.popper,d=t.offsets.reference,p=Math.floor,f="left"===o&&p(u.right)>p(d.left)||"right"===o&&p(u.left)p(d.top)||"bottom"===o&&p(u.top)p(n.right),b=p(u.top)p(n.bottom),v="left"===o&&h||"right"===o&&m||"top"===o&&b||"bottom"===o&&g,y=-1!==["top","bottom"].indexOf(o),w=!!e.flipVariations&&(y&&"start"===r&&h||y&&"end"===r&&m||!y&&"start"===r&&b||!y&&"end"===r&&g);(f||v||w)&&(t.flipped=!0,(f||v)&&(o=s[l+1]),w&&(r="end"===(c=r)?"start":"start"===c?"end":c),t.placement=o+(r?"-"+r:""),t.offsets.popper=D({},t.offsets.popper,U(t.instance.popper,t.offsets.reference,t.placement)),t=K(t.instance.modifiers,t,"flip"))}),t},behavior:"flip",padding:5,boundariesElement:"viewport"},inner:{order:700,enabled:!1,fn:function(t){var e=t.placement,n=e.split("-")[0],o=t.offsets,i=o.popper,r=o.reference,s=-1!==["left","right"].indexOf(n),a=-1===["top","left"].indexOf(n);return i[s?"left":"top"]=r[n]-(a?i[s?"width":"height"]:0),t.placement=G(e),t.offsets.popper=B(i),t}},hide:{order:800,enabled:!0,fn:function(t){if(!ot(t.instance.modifiers,"hide","preventOverflow"))return t;var e=t.offsets.reference,n=Y(t.instance.modifiers,function(t){return"preventOverflow"===t.name}).boundaries;if(e.bottomn.right||e.top>n.bottom||e.right2&&arguments[2]!==undefined?arguments[2]:{};M(this,t),this.scheduleUpdate=function(){return requestAnimationFrame(o.update)},this.update=v(this.update.bind(this)),this.options=D({},t.Defaults,i),this.state={isDestroyed:!1,isCreated:!1,scrollParents:[]},this.reference=e&&e.jquery?e[0]:e,this.popper=n&&n.jquery?n[0]:n,this.options.modifiers={},Object.keys(D({},t.Defaults.modifiers,i.modifiers)).forEach(function(e){o.options.modifiers[e]=D({},t.Defaults.modifiers[e]||{},i.modifiers?i.modifiers[e]:{})}),this.modifiers=Object.keys(this.options.modifiers).map(function(t){return D({name:t},o.options.modifiers[t])}).sort(function(t,e){return t.order-e.order}),this.modifiers.forEach(function(t){t.enabled&&y(t.onLoad)&&t.onLoad(o.reference,o.popper,o.options,t,o.state)}),this.update();var r=this.options.eventsEnabled;r&&this.enableEventListeners(),this.state.eventsEnabled=r}return N(t,[{key:"update",value:function(){return function(){if(!this.state.isDestroyed){var t={instance:this,styles:{},arrowStyles:{},attributes:{},flipped:!1,offsets:{}};t.offsets.reference=V(this.state,this.popper,this.reference,this.options.positionFixed),t.placement=W(this.options.placement,t.offsets.reference,this.popper,this.reference,this.options.modifiers.flip.boundariesElement,this.options.modifiers.flip.padding),t.originalPlacement=t.placement,t.positionFixed=this.options.positionFixed,t.offsets.popper=U(this.popper,t.offsets.reference,t.placement),t.offsets.popper.position=this.options.positionFixed?"fixed":"absolute",t=K(this.modifiers,t),this.state.isCreated?this.options.onUpdate(t):(this.state.isCreated=!0,this.options.onCreate(t))}}.call(this)}},{key:"destroy",value:function(){return function(){return this.state.isDestroyed=!0,z(this.modifiers,"applyStyle")&&(this.popper.removeAttribute("x-placement"),this.popper.style.position="",this.popper.style.top="",this.popper.style.left="",this.popper.style.right="",this.popper.style.bottom="",this.popper.style.willChange="",this.popper.style[X("transform")]=""),this.disableEventListeners(),this.options.removeOnDestroy&&this.popper.parentNode.removeChild(this.popper),this}.call(this)}},{key:"enableEventListeners",value:function(){return function(){this.state.eventsEnabled||(this.state=Q(this.reference,this.options,this.state,this.scheduleUpdate))}.call(this)}},{key:"disableEventListeners",value:function(){return Z.call(this)}}]),t}();function dt(t){this.$module=t,this.$toggleButton=null,this.$dropdown=null,this.popper=null,this.blurEnabled=!0}function pt(t){this.$module=t}function ft(t){console.log(t),this.$module=t,this.$appear=null,this.$disappear=null}ut.Utils=("undefined"!=typeof window?window:global).PopperUtils,ut.placements=it,ut.Defaults=ct,dt.prototype.init=function(){var t=this.$module;t&&(this.$toggleButton=t.querySelector(".js-dropdown-toggle"),this.$toggleButton&&(t.querySelectorAll(".sdn-header__dropdown a").forEach(function(t){t.addEventListener("click",function(){this.$dropdown.style.display="none",this.blurEnabled=!0}.bind(this))}.bind(this)),this.$dropdown=t.querySelector("#"+this.$toggleButton.getAttribute("aria-controls")),document.getElementsByTagName("body")[0].appendChild(this.$dropdown),this.popper=new ut(this.$toggleButton,this.$dropdown,{placement:"bottom-end"}),this.$toggleButton.addEventListener("click",this.handleClick.bind(this)),this.$toggleButton.addEventListener("blur",this.handleBlur.bind(this)),this.$dropdown.addEventListener("mouseenter",this.handleMouseenter.bind(this)),this.$dropdown.addEventListener("mouseleave",this.handleMouseleave.bind(this))))},dt.prototype.toggleClass=function(t,e){t.className.indexOf(e)>0?t.className=t.className.replace(" "+e,""):t.className+=" "+e},dt.prototype.handleClick=function(t){t.preventDefault(),this.$dropdown.style.display="block",this.popper.update()},dt.prototype.handleBlur=function(t){this.blurEnabled&&(this.$dropdown.style.display="none")},dt.prototype.handleMouseenter=function(t){this.blurEnabled=!1},dt.prototype.handleMouseleave=function(t){this.blurEnabled=!0},pt.prototype.init=function(){var t=this.$module;!t||t.className.indexOf("snd-timeline--readonly")>-1||(document.addEventListener("click",this.handleBlur.bind(this)),n("body","click",".js-sdn-timeline__bullet",this.handleClick.bind(this)),n("body","click",".sdn-timeline-dropdown__option",this.closeMenu))},pt.prototype.handleClick=function(t){t.preventDefault();var e=t.target;this.closeMenu(),e.parentNode.classList.add("sdn-timeline__step--dropdown-active"),e.getAttribute("data-blur-initialized")||(e.setAttribute("data-blur-initialized",!0),e.setAttribute("tabindex","0"),e.focus())},pt.prototype.handleBlur=function(t){var e=!0;e=(e=(e=e&&!t.target.classList.contains("sdn-timeline-dropdown__option"))&&!t.target.classList.contains("sdn-timeline-dropdown__bullet"))&&!t.target.classList.contains("sdn-timeline-dropdown__additional-info"),t.target.classList.contains("js-sdn-timeline__bullet")&&(e=!t.target.parentNode.classList.contains("sdn-timeline__step--dropdown-active")),e&&this.closeMenu()},pt.prototype.closeMenu=function(){e(document.querySelectorAll(".sdn-timeline__step--dropdown-active"),function(t){t.classList.remove("sdn-timeline__step--dropdown-active")})},ft.prototype.init=function(){var t=this.$module;if(t){t.addEventListener("click",this.handleClick.bind(this));var e=t.dataset.appear,n=t.dataset.disappear;this.$appear=document.getElementById(e),this.$disappear=document.getElementById(n)}},ft.prototype.handleClick=function(t){t.preventDefault(),this.$appear&&this.$appear.classList.remove("sdn-appear-link-hide"),this.$disappear&&this.$disappear.classList.add("sdn-appear-link-hide"),console.log(this.$appear,this.$disappear)},t.initAll=function(){new r(document).init(),e(document.querySelectorAll('[data-module="accordion"]'),function(t){new o(t).init()}),e(document.querySelectorAll("details"),function(t){new a(t).init()}),e(document.querySelectorAll('[data-module="character-count"]'),function(t){new l(t).init()}),e(document.querySelectorAll('[data-module="checkboxes"]'),function(t){new c(t).init()}),new u(document.querySelector('[data-module="error-summary"]')).init(),new d(document.querySelector('[data-module="header"]')).init(),e(document.querySelectorAll('[data-module="radios"]'),function(t){new p(t).init()}),e(document.querySelectorAll('[data-module="tabs"]'),function(t){new f(t).init()}),new dt(document.querySelector('[data-module="sdn-header"]')).init(),new pt(document.querySelector('[data-module="sdn-timeline"]')).init(),e(document.querySelectorAll('[data-module="sdn-appear-link"]'),function(t){new ft(t).init()})},t.Accordion=o,t.Button=r,t.Details=a,t.CharacterCount=l,t.Checkboxes=c,t.ErrorSummary=u,t.Header=d,t.Radios=p,t.Tabs=f,t.SdnHeader=dt,t.SdnTimeline=pt}); diff --git a/dist/govuk-frontend-ie8-2.5.1.min.css b/dist/navody-digital-ie8-0.1.0.min.css similarity index 100% rename from dist/govuk-frontend-ie8-2.5.1.min.css rename to dist/navody-digital-ie8-0.1.0.min.css diff --git a/lib/file-helper.js b/lib/file-helper.js index c350fd125f..6c16f29ee5 100644 --- a/lib/file-helper.js +++ b/lib/file-helper.js @@ -17,7 +17,9 @@ const sdnChildDirectories = dir => { // Generate component list from source directory, excluding anything that's not // a directory (for example, .DS_Store files) -exports.allComponents = childDirectories(configPaths.components) +exports.allComponents = childDirectories(configPaths.components).filter(function (directory) { + return directory !== '_sdn' && directory !== '_custom' +}) exports.allSdnComponents = sdnChildDirectories(configPaths.sdn_components) // Read the contents of a file from a given path diff --git a/package.json b/package.json index 2d381ef7d1..68daeb1a4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "govuk-frontend-repository", + "name": "navody-digital-repository", "description": "Used only for the development of GOV.UK Frontend, see `package/package.json` for the published `package.json`", "engines": { "node": "8.9.4" diff --git a/package/all.js b/package/all.js index 1d6718742d..7d7bcb9dc0 100644 --- a/package/all.js +++ b/package/all.js @@ -4952,7 +4952,9 @@ SdnTimeline.prototype.init = function () { return } + document.addEventListener('click', this.handleBlur.bind(this)); on('body', 'click', '.js-sdn-timeline__bullet', this.handleClick.bind(this)); + on('body', 'click', '.sdn-timeline-dropdown__option', this.closeMenu); }; SdnTimeline.prototype.handleClick = function (event) { @@ -4960,58 +4962,72 @@ SdnTimeline.prototype.handleClick = function (event) { var element = event.target; - element.parentNode.classList.toggle('sdn-timeline__step--dropdown-active'); + this.closeMenu(); + element.parentNode.classList.add('sdn-timeline__step--dropdown-active'); if (!element.getAttribute('data-blur-initialized')) { element.setAttribute('data-blur-initialized', true); element.setAttribute('tabindex', '0'); - element.addEventListener('focusout', this.handleBlur); + // element.addEventListener('focusout', this.handleBlur) element.focus(); } }; SdnTimeline.prototype.handleBlur = function (event) { - event.preventDefault(); + var closeMenu = true; + closeMenu = closeMenu && !event.target.classList.contains('sdn-timeline-dropdown__option'); + closeMenu = closeMenu && !event.target.classList.contains('sdn-timeline-dropdown__bullet'); + closeMenu = closeMenu && !event.target.classList.contains('sdn-timeline-dropdown__additional-info'); + + if (event.target.classList.contains('js-sdn-timeline__bullet')) { + closeMenu = !event.target.parentNode.classList.contains('sdn-timeline__step--dropdown-active'); + } - setTimeout(function () { - this.parentNode.classList.remove('sdn-timeline__step--dropdown-active'); - }.bind(this), 100); + if (closeMenu) { + this.closeMenu(); + } }; -function SndAppearLink($module) { +SdnTimeline.prototype.closeMenu = function () { + var items = document.querySelectorAll('.sdn-timeline__step--dropdown-active'); + nodeListForEach(items, function (item) { + item.classList.remove('sdn-timeline__step--dropdown-active'); + }); +}; + +function SndAppearLink ($module) { console.log($module); this.$module = $module; this.$appear = null; this.$disappear = null; } -SndAppearLink.prototype.init = function() { +SndAppearLink.prototype.init = function () { // Check for module var $module = this.$module; if (!$module) { - return; + return } - $module.addEventListener("click", this.handleClick.bind(this)); - var appearId = $module.dataset["appear"]; - var disappearId = $module.dataset["disappear"]; + $module.addEventListener('click', this.handleClick.bind(this)); + var appearId = $module.dataset['appear']; + var disappearId = $module.dataset['disappear']; this.$appear = document.getElementById(appearId); this.$disappear = document.getElementById(disappearId); }; -SndAppearLink.prototype.handleClick = function(event) { +SndAppearLink.prototype.handleClick = function (event) { event.preventDefault(); if (this.$appear) { - this.$appear.classList.remove("sdn-appear-link-hide"); + this.$appear.classList.remove('sdn-appear-link-hide'); } if (this.$disappear) { - this.$disappear.classList.add("sdn-appear-link-hide"); + this.$disappear.classList.add('sdn-appear-link-hide'); } console.log(this.$appear, this.$disappear); - }; function initAll () { diff --git a/package/components/_custom/timeline/timeline.js b/package/components/_custom/timeline/timeline.js index b34f136b35..93fe9fc1cc 100644 --- a/package/components/_custom/timeline/timeline.js +++ b/package/components/_custom/timeline/timeline.js @@ -664,6 +664,14 @@ if (detect) return * This seems to fail in IE8, requires more investigation. * See: https://github.com/imagitama/nodelist-foreach-polyfill */ +function nodeListForEach (nodes, callback) { + if (window.NodeList.prototype.forEach) { + return nodes.forEach(callback) + } + for (var i = 0; i < nodes.length; i++) { + callback.call(window, nodes[i], i, nodes); + } +} function on (elSelector, eventName, selector, fn) { var element = document.querySelector(elSelector); @@ -698,7 +706,9 @@ SdnTimeline.prototype.init = function () { return } + document.addEventListener('click', this.handleBlur.bind(this)); on('body', 'click', '.js-sdn-timeline__bullet', this.handleClick.bind(this)); + on('body', 'click', '.sdn-timeline-dropdown__option', this.closeMenu); }; SdnTimeline.prototype.handleClick = function (event) { @@ -706,22 +716,37 @@ SdnTimeline.prototype.handleClick = function (event) { var element = event.target; - element.parentNode.classList.toggle('sdn-timeline__step--dropdown-active'); + this.closeMenu(); + element.parentNode.classList.add('sdn-timeline__step--dropdown-active'); if (!element.getAttribute('data-blur-initialized')) { element.setAttribute('data-blur-initialized', true); element.setAttribute('tabindex', '0'); - element.addEventListener('focusout', this.handleBlur); + // element.addEventListener('focusout', this.handleBlur) element.focus(); } }; SdnTimeline.prototype.handleBlur = function (event) { - event.preventDefault(); + var closeMenu = true; + closeMenu = closeMenu && !event.target.classList.contains('sdn-timeline-dropdown__option'); + closeMenu = closeMenu && !event.target.classList.contains('sdn-timeline-dropdown__bullet'); + closeMenu = closeMenu && !event.target.classList.contains('sdn-timeline-dropdown__additional-info'); + + if (event.target.classList.contains('js-sdn-timeline__bullet')) { + closeMenu = !event.target.parentNode.classList.contains('sdn-timeline__step--dropdown-active'); + } - setTimeout(function () { - this.parentNode.classList.remove('sdn-timeline__step--dropdown-active'); - }.bind(this), 100); + if (closeMenu) { + this.closeMenu(); + } +}; + +SdnTimeline.prototype.closeMenu = function () { + var items = document.querySelectorAll('.sdn-timeline__step--dropdown-active'); + nodeListForEach(items, function (item) { + item.classList.remove('sdn-timeline__step--dropdown-active'); + }); }; return SdnTimeline; diff --git a/package/package.json b/package/package.json index 459178424c..7749df97db 100644 --- a/package/package.json +++ b/package/package.json @@ -1,7 +1,7 @@ { - "name": "govuk-frontend", + "name": "mavody-digital-frontend", "description": "GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.", - "version": "2.5.1", + "version": "0.1.0", "main": "all.js", "sass": "all.scss", "engines": { @@ -20,6 +20,7 @@ }, "homepage": "https://github.com/alphagov/govuk-frontend#readme", "keywords": [ + "slovensko.digital", "govuk", "frontend", "design system", diff --git a/package/utilities/appear-link/appear-link.js b/package/utilities/appear-link/appear-link.js index fb2367024d..0a5be5f61f 100644 --- a/package/utilities/appear-link/appear-link.js +++ b/package/utilities/appear-link/appear-link.js @@ -4,40 +4,39 @@ (global.navodyDigitalFrontend = factory()); }(this, (function () { 'use strict'; -function SndAppearLink($module) { +function SndAppearLink ($module) { console.log($module); this.$module = $module; this.$appear = null; this.$disappear = null; } -SndAppearLink.prototype.init = function() { +SndAppearLink.prototype.init = function () { // Check for module var $module = this.$module; if (!$module) { - return; + return } - $module.addEventListener("click", this.handleClick.bind(this)); - var appearId = $module.dataset["appear"]; - var disappearId = $module.dataset["disappear"]; + $module.addEventListener('click', this.handleClick.bind(this)); + var appearId = $module.dataset['appear']; + var disappearId = $module.dataset['disappear']; this.$appear = document.getElementById(appearId); this.$disappear = document.getElementById(disappearId); }; -SndAppearLink.prototype.handleClick = function(event) { +SndAppearLink.prototype.handleClick = function (event) { event.preventDefault(); if (this.$appear) { - this.$appear.classList.remove("sdn-appear-link-hide"); + this.$appear.classList.remove('sdn-appear-link-hide'); } if (this.$disappear) { - this.$disappear.classList.add("sdn-appear-link-hide"); + this.$disappear.classList.add('sdn-appear-link-hide'); } console.log(this.$appear, this.$disappear); - }; return SndAppearLink; diff --git a/src/all.test.js b/src/all.test.js index 691fd92924..78f76774bd 100644 --- a/src/all.test.js +++ b/src/all.test.js @@ -40,26 +40,26 @@ afterAll(async (done) => { describe('GOV.UK Frontend', () => { describe('javascript', async () => { - it('can be accessed via `GOVUKFrontend`', async () => { + it('can be accessed via `navodyDigitalFrontend`', async () => { await page.goto(baseUrl + '/', { waitUntil: 'load' }) - const GOVUKFrontendGlobal = await page.evaluate(() => window.GOVUKFrontend) + const navodyDigitalFrontendGlobal = await page.evaluate(() => window.navodyDigitalFrontend) - expect(typeof GOVUKFrontendGlobal).toBe('object') + expect(typeof navodyDigitalFrontendGlobal).toBe('object') }) it('exports `initAll` function', async () => { await page.goto(baseUrl + '/', { waitUntil: 'load' }) - const typeofInitAll = await page.evaluate(() => typeof window.GOVUKFrontend.initAll) + const typeofInitAll = await page.evaluate(() => typeof window.navodyDigitalFrontend.initAll) expect(typeofInitAll).toEqual('function') }) it('exports Components', async () => { await page.goto(baseUrl + '/', { waitUntil: 'load' }) - const GOVUKFrontendGlobal = await page.evaluate(() => window.GOVUKFrontend) + const navodyDigitalFrontendGlobal = await page.evaluate(() => window.navodyDigitalFrontend) - var components = Object.keys(GOVUKFrontendGlobal).filter(method => method !== 'initAll') + var components = Object.keys(navodyDigitalFrontendGlobal).filter(method => method !== 'initAll') // Ensure GOV.UK Frontend exports the expected components expect(components).toEqual([ @@ -71,45 +71,50 @@ describe('GOV.UK Frontend', () => { 'ErrorSummary', 'Header', 'Radios', - 'Tabs' + 'Tabs', + 'SdnHeader', + 'SdnTimeline' ]) }) it('exported Components can be initialised', async () => { await page.goto(baseUrl + '/', { waitUntil: 'load' }) - const GOVUKFrontendGlobal = await page.evaluate(() => window.GOVUKFrontend) + const navodyDigitalFrontendGlobal = await page.evaluate(() => window.navodyDigitalFrontend) - var components = Object.keys(GOVUKFrontendGlobal).filter(method => method !== 'initAll') + var components = Object.keys(navodyDigitalFrontendGlobal).filter(method => method !== 'initAll') // Check that all the components on the GOV.UK Frontend global can be initialised components.forEach(component => { page.evaluate(component => { - const Component = window.GOVUKFrontend[component] + const Component = window.navodyDigitalFrontend[component] const $module = document.documentElement new Component($module).init() }, component) }) }) }) - describe('global styles', async () => { - it('are disabled by default', async () => { - const sass = ` - @import "all"; - ` - const results = await sassRender({ data: sass, ...sassConfig }) - expect(results.css.toString()).not.toContain(', a {') - expect(results.css.toString()).not.toContain(', p {') - }) - it('are enabled if $global-styles variable is set to true', async () => { - const sass = ` - $govuk-global-styles: true; - @import "all"; - ` - const results = await sassRender({ data: sass, ...sassConfig }) - expect(results.css.toString()).toContain(', a {') - expect(results.css.toString()).toContain(', p {') - }) - }) + + // navody.digital uses global styles in the default build + // + // describe('global styles', async () => { + // it('are disabled by default', async () => { + // const sass = ` + // @import "all"; + // ` + // const results = await sassRender({ data: sass, ...sassConfig }) + // expect(results.css.toString()).not.toContain(', a {') + // expect(results.css.toString()).not.toContain(', p {') + // }) + // it('are enabled if $global-styles variable is set to true', async () => { + // const sass = ` + // $govuk-global-styles: true; + // @import "all"; + // ` + // const results = await sassRender({ data: sass, ...sassConfig }) + // expect(results.css.toString()).toContain(', a {') + // expect(results.css.toString()).toContain(', p {') + // }) + // }) // Sass functions will be automatically evaluated at compile time and the // return value from the function will be used in the compiled CSS. diff --git a/src/components/_custom/footer/template.test.js b/src/components/_custom/footer/template.test.js deleted file mode 100644 index 129bedf89f..0000000000 --- a/src/components/_custom/footer/template.test.js +++ /dev/null @@ -1,212 +0,0 @@ -/* eslint-env jest */ - -const axe = require('../../../lib/axe-helper') - -const { render, getExamples } = require('../../../lib/jest-helpers') - -const examples = getExamples('sdn-footer') - -describe('sdn-footer', () => { - it('default example passes accessibility tests', async () => { - const $ = render('footer', examples.default) - - const results = await axe($.html()) - expect(results).toHaveNoViolations() - }) - - it('entire component must have a role of `contentinfo`', () => { - const $ = render('footer', {}) - - const $component = $('.govuk-footer') - expect($component.attr('role')).toEqual('contentinfo') - }) - - it('renders attributes correctly', () => { - const $ = render('footer', { - attributes: { - 'data-test-attribute': 'value', - 'data-test-attribute-2': 'value-2' - } - }) - - const $component = $('.govuk-footer') - expect($component.attr('data-test-attribute')).toEqual('value') - expect($component.attr('data-test-attribute-2')).toEqual('value-2') - }) - - it('renders classes', () => { - const $ = render('footer', { - classes: 'app-footer--custom-modifier' - }) - - const $component = $('.govuk-footer') - expect($component.hasClass('app-footer--custom-modifier')).toBeTruthy() - }) - - it('renders custom container classes', () => { - const $ = render('footer', { - containerClasses: 'app-width-container' - }) - - const $component = $('.govuk-footer') - const $container = $component.find('.govuk-width-container') - - expect($container.hasClass('app-width-container')).toBeTruthy() - }) - - describe('meta', () => { - it('passes accessibility tests', async () => { - const $ = render('footer', examples['with meta']) - - const results = await axe($.html()) - expect(results).toHaveNoViolations() - }) - - it('renders heading', () => { - const $ = render('footer', examples['with meta']) - - const $component = $('.govuk-footer') - const $heading = $component.find('h2.govuk-visually-hidden') - expect($heading.text()).toEqual('Support links') - }) - - it('renders links', () => { - const $ = render('footer', examples['with meta']) - - const $component = $('.govuk-footer') - const $list = $component.find('ul.govuk-footer__inline-list') - const $items = $list.find('li.govuk-footer__inline-list-item') - const $firstItem = $items.find('a.govuk-footer__link:first-child') - expect($items.length).toEqual(3) - expect($firstItem.attr('href')).toEqual('#1') - expect($firstItem.text()).toContain('Item 1') - }) - - it('renders custom meta text', () => { - const $ = render('footer', { - meta: { - text: 'GOV.UK Prototype Kit v7.0.1' - } - }) - - const $component = $('.govuk-footer') - const $custom = $component.find('.govuk-footer__meta-custom') - expect($custom.text()).toContain('GOV.UK Prototype Kit v7.0.1') - }) - - it('renders custom meta html', () => { - const $ = render('footer', { - meta: { - html: 'GOV.UK Prototype Kit v7.0.1' - } - }) - - const $component = $('.govuk-footer') - const $custom = $component.find('.govuk-footer__meta-custom') - expect($custom.text()).toContain('GOV.UK Prototype Kit v7.0.1') - }) - - it('renders attributes on meta links', () => { - const $ = render('footer', { - meta: { - items: [ - { - href: '#1', - text: 'meta item 1', - attributes: { - 'data-attribute': 'my-attribute', - 'data-attribute-2': 'my-attribute-2' - } - } - ] - } - }) - - const $metaLink = $('.govuk-footer__meta .govuk-footer__link') - expect($metaLink.attr('data-attribute')).toEqual('my-attribute') - expect($metaLink.attr('data-attribute-2')).toEqual('my-attribute-2') - }) - }) - - describe('navigation', () => { - it('passes accessibility tests', async () => { - const $ = render('footer', examples['with navigation']) - - const results = await axe($.html()) - expect(results).toHaveNoViolations() - }) - - it('renders headings', () => { - const $ = render('footer', examples['with navigation']) - - const $component = $('.govuk-footer') - const $firstSection = $component.find('.govuk-footer__section:first-child') - const $lastSection = $component.find('.govuk-footer__section:last-child') - const $firstHeading = $firstSection.find('h2.govuk-footer__heading') - const $lastHeading = $lastSection.find('h2.govuk-footer__heading') - expect($firstHeading.text()).toEqual('Two column list') - expect($lastHeading.text()).toEqual('Single column list') - }) - - it('renders lists of links', () => { - const $ = render('footer', examples['with navigation']) - - const $component = $('.govuk-footer') - const $list = $component.find('ul.govuk-footer__list') - const $items = $list.find('li.govuk-footer__list-item') - const $firstItem = $items.find('a.govuk-footer__link:first-child') - expect($items.length).toEqual(9) - expect($firstItem.attr('href')).toEqual('#1') - expect($firstItem.text()).toContain('Navigation item 1') - }) - - it('renders attributes on links', () => { - const $ = render('footer', { - navigation: [ - { - items: [ - { - href: '#1', - text: 'Navigation item 1', - attributes: { - 'data-attribute': 'my-attribute', - 'data-attribute-2': 'my-attribute-2' - } - } - ] - } - ] - }) - - const $navigationLink = $('.govuk-footer__list .govuk-footer__link') - expect($navigationLink.attr('data-attribute')).toEqual('my-attribute') - expect($navigationLink.attr('data-attribute-2')).toEqual('my-attribute-2') - }) - - it('renders lists in columns', () => { - const $ = render('footer', examples['with navigation']) - - const $component = $('.govuk-footer') - const $list = $component.find('ul.govuk-footer__list') - expect($list.hasClass('govuk-footer__list--columns-2')).toBeTruthy() - }) - }) - - describe('section break', () => { - it('renders when there is a navigation', () => { - const $ = render('footer', examples['with navigation']) - - const $component = $('.govuk-footer') - const $sectionBreak = $component.find('hr.govuk-footer__section-break') - expect($sectionBreak.length).toBeTruthy() - }) - - it('renders nothing when there is only meta', () => { - const $ = render('footer', examples['with meta']) - - const $component = $('.govuk-footer') - const $sectionBreak = $component.find('hr.govuk-footer__section-break') - expect($sectionBreak.length).toBeFalsy() - }) - }) -}) diff --git a/src/components/_custom/header/template.test.js b/src/components/_custom/header/template.test.js deleted file mode 100644 index 7cf694dec2..0000000000 --- a/src/components/_custom/header/template.test.js +++ /dev/null @@ -1,135 +0,0 @@ -/* eslint-env jest */ - -const axe = require('../../../../lib/axe-helper') - -const { render, getExamples } = require('../../../../lib/jest-helpers') - -const examples = getExamples('header') - -describe('header', () => { - it('passes accessibility tests', async () => { - const $ = render('header', examples.default) - - const results = await axe($.html()) - expect(results).toHaveNoViolations() - }) - - it('has a role of `banner`', () => { - const $ = render('header', {}) - - const $component = $('.govuk-header') - expect($component.attr('role')).toEqual('banner') - }) - - it('renders attributes correctly', () => { - const $ = render('header', { - attributes: { - 'data-test-attribute': 'value', - 'data-test-attribute-2': 'value-2' - } - }) - - const $component = $('.govuk-header') - expect($component.attr('data-test-attribute')).toEqual('value') - expect($component.attr('data-test-attribute-2')).toEqual('value-2') - }) - - it('renders classes', () => { - const $ = render('header', { - classes: 'app-header--custom-modifier' - }) - - const $component = $('.govuk-header') - expect($component.hasClass('app-header--custom-modifier')).toBeTruthy() - }) - - it('renders custom container classes', () => { - const $ = render('header', { - containerClasses: 'app-width-container' - }) - - const $component = $('.govuk-header') - const $container = $component.find('.govuk-header__container') - - expect($container.hasClass('app-width-container')).toBeTruthy() - }) - - it('renders home page URL', () => { - const $ = render('header', { - homepageUrl: '/' - }) - - const $component = $('.govuk-header') - const $homepageLink = $component.find('.govuk-header__link--homepage') - expect($homepageLink.attr('href')).toEqual('/') - }) - - describe('with product name', () => { - it('renders product name', () => { - const $ = render('header', examples['full width']) - - const $component = $('.govuk-header') - const $productName = $component.find('.govuk-header__product-name') - expect($productName.text().trim()).toEqual('Product Name') - }) - }) - - describe('with service name', () => { - it('renders service name', () => { - const $ = render('header', examples['with service name']) - - const $component = $('.govuk-header') - const $serviceName = $component.find('.govuk-header__link--service-name') - expect($serviceName.text().trim()).toEqual('Service Name') - }) - }) - - describe('with navigation', () => { - it('passes accessibility tests', async () => { - const $ = render('header', examples['with navigation']) - - const results = await axe($.html()) - expect(results).toHaveNoViolations() - }) - - it('renders navigation', () => { - const $ = render('header', examples['with navigation']) - - const $component = $('.govuk-header') - const $list = $component.find('ul.govuk-header__navigation') - const $items = $list.find('li.govuk-header__navigation-item') - const $firstItem = $items.find('a.govuk-header__link:first-child') - expect($items.length).toEqual(4) - expect($firstItem.attr('href')).toEqual('#1') - expect($firstItem.text()).toContain('Navigation item 1') - }) - - it('renders navigation item anchor with attributes', () => { - const $ = render('header', { - navigation: [ - { - 'text': 'Item', - 'href': '/link', - 'attributes': { - 'data-attribute': 'my-attribute', - 'data-attribute-2': 'my-attribute-2' - } - } - ] - }) - - const $navigationLink = $('.govuk-header__navigation-item a') - expect($navigationLink.attr('data-attribute')).toEqual('my-attribute') - expect($navigationLink.attr('data-attribute-2')).toEqual('my-attribute-2') - }) - describe('menu button', () => { - it('has an explicit type="button" so it does not act as a submit button', () => { - const $ = render('header', examples['with navigation']) - - const $button = $('.govuk-header__menu-button') - - expect($button.attr('type')).toEqual('button') - }) - }) - }) -}) diff --git a/src/components/_custom/searchbar/template.test.js b/src/components/_custom/searchbar/template.test.js deleted file mode 100644 index a9be19b697..0000000000 --- a/src/components/_custom/searchbar/template.test.js +++ /dev/null @@ -1,93 +0,0 @@ -/* eslint-env jest */ - -const axe = require('../../../lib/axe-helper') - -const { render, getExamples, htmlWithClassName } = require('../../../lib/jest-helpers') - -const examples = getExamples('phase-banner') - -describe('Phase banner', () => { - describe('by default', () => { - it('passes accessibility tests', async () => { - const $ = render('phase-banner', examples.default) - - const results = await axe($.html()) - expect(results).toHaveNoViolations() - }) - - it('allows additional classes to be added to the component', () => { - const $ = render('phase-banner', { - classes: 'extra-class one-more-class' - }) - - const $component = $('.govuk-phase-banner') - expect($component.hasClass('extra-class one-more-class')).toBeTruthy() - }) - - it('renders banner text', () => { - const $ = render('phase-banner', { - text: 'This is a new service – your feedback will help us to improve it.' - }) - const phaseBannerText = $('.govuk-phase-banner__text').text().trim() - - expect(phaseBannerText).toEqual('This is a new service – your feedback will help us to improve it.') - }) - - it('allows body text to be passed whilst escaping HTML entities', () => { - const $ = render('phase-banner', { - text: 'This is a new service - your feedback will help us to improve it.' - }) - - const phaseBannerText = $('.govuk-phase-banner__text').html().trim() - expect(phaseBannerText).toEqual('This is a new service - your <a href="#" class="govuk-link">feedback</a> will help us to improve it.') - }) - - it('allows body HTML to be passed un-escaped', () => { - const $ = render('phase-banner', examples.default) - - const phaseBannerText = $('.govuk-phase-banner__text').html().trim() - expect(phaseBannerText).toEqual('This is a new service - your feedback will help us to improve it.') - }) - - it('allows additional attributes to be added to the component', () => { - const $ = render('phase-banner', { - attributes: { - 'first-attribute': 'true', - 'second-attribute': 'false' - } - }) - - const $component = $('.govuk-phase-banner') - expect($component.attr('first-attribute')).toEqual('true') - expect($component.attr('second-attribute')).toEqual('false') - }) - }) - describe('with dependant components', () => { - it('renders the tag component text', () => { - const $ = render('phase-banner', examples.default) - - expect(htmlWithClassName($, '.govuk-phase-banner__content__tag')).toMatchSnapshot() - }) - - it('renders the tag component html', () => { - const $ = render('phase-banner', { - 'tag': { - 'html': 'alpha' - } - }) - - expect(htmlWithClassName($, '.govuk-phase-banner__content__tag')).toMatchSnapshot() - }) - - it('renders the tag component classes', () => { - const $ = render('phase-banner', { - 'tag': { - 'text': 'alpha', - 'classes': 'govuk-tag--inactive' - } - }) - - expect(htmlWithClassName($, '.govuk-phase-banner__content__tag')).toMatchSnapshot() - }) - }) -}) diff --git a/src/components/_custom/timeline/timeline.js b/src/components/_custom/timeline/timeline.js index 34d2db8c06..4f0fe68bd4 100644 --- a/src/components/_custom/timeline/timeline.js +++ b/src/components/_custom/timeline/timeline.js @@ -1,6 +1,6 @@ import '../../../vendor/polyfills/Function/prototype/bind' import '../../../vendor/polyfills/Event' -import { on } from '../../../common' +import { nodeListForEach, on } from '../../../common' function SdnTimeline ($module) { this.$module = $module @@ -13,7 +13,9 @@ SdnTimeline.prototype.init = function () { return } + document.addEventListener('click', this.handleBlur.bind(this)) on('body', 'click', '.js-sdn-timeline__bullet', this.handleClick.bind(this)) + on('body', 'click', '.sdn-timeline-dropdown__option', this.closeMenu) } SdnTimeline.prototype.handleClick = function (event) { @@ -21,22 +23,37 @@ SdnTimeline.prototype.handleClick = function (event) { var element = event.target - element.parentNode.classList.toggle('sdn-timeline__step--dropdown-active') + this.closeMenu() + element.parentNode.classList.add('sdn-timeline__step--dropdown-active') if (!element.getAttribute('data-blur-initialized')) { element.setAttribute('data-blur-initialized', true) element.setAttribute('tabindex', '0') - element.addEventListener('focusout', this.handleBlur) + // element.addEventListener('focusout', this.handleBlur) element.focus() } } SdnTimeline.prototype.handleBlur = function (event) { - event.preventDefault() + var closeMenu = true + closeMenu = closeMenu && !event.target.classList.contains('sdn-timeline-dropdown__option') + closeMenu = closeMenu && !event.target.classList.contains('sdn-timeline-dropdown__bullet') + closeMenu = closeMenu && !event.target.classList.contains('sdn-timeline-dropdown__additional-info') + + if (event.target.classList.contains('js-sdn-timeline__bullet')) { + closeMenu = !event.target.parentNode.classList.contains('sdn-timeline__step--dropdown-active') + } + + if (closeMenu) { + this.closeMenu() + } +} - setTimeout(function () { - this.parentNode.classList.remove('sdn-timeline__step--dropdown-active') - }.bind(this), 100) +SdnTimeline.prototype.closeMenu = function () { + var items = document.querySelectorAll('.sdn-timeline__step--dropdown-active') + nodeListForEach(items, function (item) { + item.classList.remove('sdn-timeline__step--dropdown-active') + }) } export default SdnTimeline diff --git a/src/components/_custom/todo-list/template.test.js b/src/components/_custom/todo-list/template.test.js deleted file mode 100644 index c7d8efac1b..0000000000 --- a/src/components/_custom/todo-list/template.test.js +++ /dev/null @@ -1,104 +0,0 @@ -/* eslint-env jest */ - -const axe = require('../../../lib/axe-helper') - -const { render, getExamples } = require('../../../lib/jest-helpers') - -const examples = getExamples('label') - -describe('Label', () => { - describe('by default', () => { - it('passes accessibility tests', async () => { - const $ = render('label', examples.default) - - const results = await axe($.html()) - expect(results).toHaveNoViolations() - }) - - it('renders a label element', () => { - const $ = render('label', examples.default) - - const $component = $('.govuk-label') - expect($component.get(0).tagName).toEqual('label') - }) - - it('does not output anything if no html or text is provided', () => { - const $ = render('label', {}) - - const $component = $('.govuk-label') - - expect($component.length).toEqual(0) - }) - - it('allows additional classes to be added to the component', () => { - const $ = render('label', { - text: 'National Insurance number', - classes: 'extra-class one-more-class' - }) - - const $component = $('.govuk-label') - expect($component.hasClass('extra-class one-more-class')).toBeTruthy() - }) - - it('renders label text', () => { - const $ = render('label', { - text: 'National Insurance number' - }) - const labelText = $('.govuk-label').text().trim() - - expect(labelText).toEqual('National Insurance number') - }) - - it('allows label text to be passed whilst escaping HTML entities', () => { - const $ = render('label', { - text: 'National Insurance number, NINO' - }) - - const labelText = $('.govuk-label').html().trim() - expect(labelText).toEqual('National Insurance number, <em>NINO</em>') - }) - - it('allows label HTML to be passed un-escaped', () => { - const $ = render('label', { - html: 'National Insurance number NINO' - }) - - const labelText = $('.govuk-label').html().trim() - expect(labelText).toEqual('National Insurance number NINO') - }) - - it('renders for attribute if specified', () => { - const $ = render('label', { - text: 'National Insurance number', - for: '#dummy-input' - }) - - const labelForAttr = $('.govuk-label').attr('for') - expect(labelForAttr).toEqual('#dummy-input') - }) - - it('can be nested inside an H1 using isPageHeading', () => { - const $ = render('label', { - text: 'National Insurance number', - isPageHeading: true - }) - - const $selector = $('h1 > .govuk-label') - expect($selector.length).toBeTruthy() - }) - - it('allows additional attributes to be added to the component', () => { - const $ = render('label', { - text: 'National Insurance number', - attributes: { - 'first-attribute': 'true', - 'second-attribute': 'false' - } - }) - - const $component = $('.govuk-label') - expect($component.attr('first-attribute')).toEqual('true') - expect($component.attr('second-attribute')).toEqual('false') - }) - }) -}) diff --git a/src/utilities/appear-link/appear-link.js b/src/utilities/appear-link/appear-link.js index e8e932fb43..aaabe680fc 100644 --- a/src/utilities/appear-link/appear-link.js +++ b/src/utilities/appear-link/appear-link.js @@ -1,37 +1,36 @@ -function SndAppearLink($module) { - console.log($module); - this.$module = $module; - this.$appear = null; - this.$disappear = null; +function SndAppearLink ($module) { + console.log($module) + this.$module = $module + this.$appear = null + this.$disappear = null } -SndAppearLink.prototype.init = function() { +SndAppearLink.prototype.init = function () { // Check for module - var $module = this.$module; + var $module = this.$module if (!$module) { - return; + return } - $module.addEventListener("click", this.handleClick.bind(this)); - var appearId = $module.dataset["appear"]; - var disappearId = $module.dataset["disappear"]; + $module.addEventListener('click', this.handleClick.bind(this)) + var appearId = $module.dataset['appear'] + var disappearId = $module.dataset['disappear'] - this.$appear = document.getElementById(appearId); - this.$disappear = document.getElementById(disappearId); -}; + this.$appear = document.getElementById(appearId) + this.$disappear = document.getElementById(disappearId) +} -SndAppearLink.prototype.handleClick = function(event) { - event.preventDefault(); +SndAppearLink.prototype.handleClick = function (event) { + event.preventDefault() if (this.$appear) { - this.$appear.classList.remove("sdn-appear-link-hide"); + this.$appear.classList.remove('sdn-appear-link-hide') } if (this.$disappear) { - this.$disappear.classList.add("sdn-appear-link-hide"); + this.$disappear.classList.add('sdn-appear-link-hide') } console.log(this.$appear, this.$disappear) +} -}; - -export default SndAppearLink; +export default SndAppearLink diff --git a/tasks/gulp/__tests__/after-build-dist.test.js b/tasks/gulp/__tests__/after-build-dist.test.js index db6634273f..1a36ffc855 100644 --- a/tasks/gulp/__tests__/after-build-dist.test.js +++ b/tasks/gulp/__tests__/after-build-dist.test.js @@ -54,24 +54,24 @@ describe('dist/', () => { }) }) - describe(`govuk-frontend-${version}.min.css`, () => { - const stylesheet = lib.readFileContents(path.join(configPaths.dist, `govuk-frontend-${version}.min.css`)) + describe(`navody-digital-${version}.min.css`, () => { + const stylesheet = lib.readFileContents(path.join(configPaths.dist, `navody-digital-${version}.min.css`)) it('should not contain current media query displayed on body element', () => { expect(stylesheet).not.toMatch(/body:before{content:/) }) }) - describe(`govuk-frontend-ie8-${version}.min.css`, () => { - const stylesheet = lib.readFileContents(path.join(configPaths.dist, `govuk-frontend-ie8-${version}.min.css`)) + describe(`navody-digital-ie8-${version}.min.css`, () => { + const stylesheet = lib.readFileContents(path.join(configPaths.dist, `navody-digital-ie8-${version}.min.css`)) it('should not contain current media query displayed on body element', () => { expect(stylesheet).not.toMatch(/body:before{content:/) }) }) - describe(`govuk-frontend-${version}.min.js`, () => { - const javascript = lib.readFileContents(path.join(configPaths.dist, `govuk-frontend-${version}.min.js`)) + describe(`navody-digital-${version}.min.js`, () => { + const javascript = lib.readFileContents(path.join(configPaths.dist, `navody-digital-${version}.min.js`)) it('should have the correct version name', () => { expect(javascript).toBeTruthy() diff --git a/tasks/gulp/asset-version.js b/tasks/gulp/asset-version.js index bf52fe0b78..bd99381c48 100644 --- a/tasks/gulp/asset-version.js +++ b/tasks/gulp/asset-version.js @@ -20,14 +20,14 @@ gulp.task('update-assets-version', () => { let pkg = require('../../' + configPaths.package + 'package.json') fs.writeFileSync(taskArguments.destination + '/VERSION.txt', pkg.version + '\r\n') return gulp.src([ - taskArguments.destination + '/govuk-frontend.min.css', - taskArguments.destination + '/govuk-frontend-ie8.min.css', - taskArguments.destination + '/govuk-frontend.min.js' + taskArguments.destination + '/navody-digital.min.css', + taskArguments.destination + '/navody-digital-ie8.min.css', + taskArguments.destination + '/navody-digital.min.js' ]) .pipe(vinylPaths(del)) .pipe(gulpif(isDist, rename(obj => { - obj.basename = obj.basename.replace(/(govuk.*)(?=\.min)/g, '$1-' + pkg.version) + obj.basename = obj.basename.replace(/(navody.*)(?=\.min)/g, '$1-' + pkg.version) return obj }) )) diff --git a/tasks/gulp/compile-assets.js b/tasks/gulp/compile-assets.js index 34f971e1ce..91ec116dc7 100644 --- a/tasks/gulp/compile-assets.js +++ b/tasks/gulp/compile-assets.js @@ -14,7 +14,6 @@ const uglify = require('gulp-uglify') const eol = require('gulp-eol') const rename = require('gulp-rename') const cssnano = require('cssnano') -const postcsspseudoclasses = require('postcss-pseudo-classes') // Compile CSS and JS task -------------- // -------------------------------------- @@ -51,7 +50,7 @@ gulp.task('scss:compile', () => { ]))) .pipe(gulpif(isDist, rename({ - basename: 'govuk-frontend', + basename: 'navody-digital', extname: '.min.css' }) )) @@ -85,7 +84,7 @@ gulp.task('scss:compile', () => { ]))) .pipe(gulpif(isDist, rename({ - basename: 'govuk-frontend-ie8', + basename: 'navody-digital-ie8', extname: '.min.css' }) )) @@ -116,7 +115,7 @@ gulp.task('js:compile', () => { }))) .pipe(gulpif(isDist, rename({ - basename: 'govuk-frontend', + basename: 'navody-digital', extname: '.min.js' }) ))