Skip to content

Commit

Permalink
PP-5783 - Move to new GOV.UK Frontend double click protection
Browse files Browse the repository at this point in the history
GOV.UK Frontend has a double click on buttons protector built in so
favouring that.

Plus moved inclusion of the GOV.UK Frontend scripts into our compiled
JS rather than including as extra HTTP request.

Details of how it works here - alphagov/govuk-frontend#1018
  • Loading branch information
jonheslop committed Oct 28, 2019
1 parent 7c9faf1 commit d956e23
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 26 deletions.
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ module.exports = function (grunt) {
dist: {
src: ['public/javascripts/application.js',
'node_modules/promise-polyfill/dist/polyfill.min.js',
'node_modules/govuk-frontend/govuk/all.js',
'app/assets/javascripts/modules/*.js'],
dest: 'public/javascripts/application.js'
}
Expand Down
21 changes: 0 additions & 21 deletions app/assets/javascripts/modules/stop-double-submission.js

This file was deleted.

1 change: 1 addition & 0 deletions app/views/charge.njk
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@
{{
govukButton({
text: __p("commonButtons.continueButton"),
preventDoubleClick: true,
attributes: {
id: "submit-card-details"
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/confirm.njk
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@
{{
govukButton({
html: confirmButtonHTML,
preventDoubleClick: true,
attributes: {
id: 'confirm',
'data-module': 'stop-double-submit'
id: 'confirm'
}
})
}}
Expand Down
2 changes: 1 addition & 1 deletion app/views/includes/scripts.njk
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
var mainWrap = document.getElementsByTagName('main')[0]
document.addEventListener('DOMContentLoaded', function() {
GOVUK.stopDoubleSubmit.init();
window.GOVUKFrontend.initAll();
if (mainWrap.classList.contains('charge-new')) {
showCardType().init();
window.payScripts.inputConfirm.init();
Expand Down
2 changes: 0 additions & 2 deletions app/views/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@

{% block bodyEnd %}
{# Run JavaScript at end of the <body>, to avoid blocking the initial render. #}
<script src="/all.js"></script>
<script>window.GOVUKFrontend.initAll()</script>
{% include "includes/scripts.njk" %}
{% endblock %}

Expand Down

0 comments on commit d956e23

Please sign in to comment.