Merge pull request #428 from alphagov/better-choose-template

Make choose template page clearer
This commit is contained in:
Chris Hill-Scott
2016-04-12 10:06:40 +01:00
13 changed files with 134 additions and 45 deletions

View File

@@ -0,0 +1,41 @@
(function(Modules) {
"use strict";
Modules.ExpandCollapse = function() {
this.start = function(component) {
this.$component = $(component)
.append(`
<div class='toggle' tabindex='0'>...<span class='visually-hidden'>show full email</span></div>
`)
.addClass('collapsed');
this.$toggle = this.$component.find('.toggle');
this.$toggle
.on(
"click",
".toggle",
this.change
)
.on("keydown", this.filterKeyPresses([32, 13], this.change));
};
this.filterKeyPresses = (keys, callback) => function(event) {
if (keys.indexOf(event.keyCode)) return;
event.preventDefault();
callback();
};
this.change = () => this.toggleCollapsed() && this.$toggle.remove();
this.toggleCollapsed = () => this.$component.toggleClass('collapsed');
};
})(window.GOVUK.Modules);