hof 22.9.0-beta.v1 → 22.9.0-beta.v3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/hof-defaults.js +1 -0
- package/frontend/template-partials/views/cookies.html +6 -6
- package/frontend/template-partials/views/partials/cookie-banner.html +11 -6
- package/lib/settings.js +1 -0
- package/package.json +1 -1
- package/package/.eslintignore +0 -1
- package/package/CHANGELOG.md +0 -232
- package/package/LICENSE +0 -21
- package/package/README.md +0 -1887
- package/package/bin/hof-build +0 -10
- package/package/bin/hof-transpiler +0 -12
- package/package/build/helpers/importer.js +0 -29
- package/package/build/helpers/local.js +0 -35
- package/package/build/helpers/resolver/import.js +0 -32
- package/package/build/helpers/resolver/nearest-package-root.js +0 -33
- package/package/build/helpers/resolver/package.js +0 -29
- package/package/build/helpers/resolver.js +0 -16
- package/package/build/index.js +0 -49
- package/package/build/lib/env.js +0 -36
- package/package/build/lib/mkdir.js +0 -9
- package/package/build/lib/run.js +0 -17
- package/package/build/lib/spawn.js +0 -18
- package/package/build/tasks/browserify/compress.js +0 -15
- package/package/build/tasks/browserify/index.js +0 -48
- package/package/build/tasks/build/index.js +0 -6
- package/package/build/tasks/images/index.js +0 -27
- package/package/build/tasks/index.js +0 -8
- package/package/build/tasks/sass/index.js +0 -67
- package/package/build/tasks/translate/index.js +0 -20
- package/package/build/tasks/watch/index.js +0 -161
- package/package/components/address-lookup/default-model.js +0 -76
- package/package/components/address-lookup/defaults.js +0 -25
- package/package/components/address-lookup/index.js +0 -251
- package/package/components/address-lookup/templates/address-lookup.html +0 -14
- package/package/components/address-lookup/templates/address.html +0 -22
- package/package/components/address-lookup/templates/postcode.html +0 -9
- package/package/components/clear-session/Readme.md +0 -46
- package/package/components/clear-session/index.js +0 -26
- package/package/components/combine-and-loop-fields/Readme.md +0 -42
- package/package/components/combine-and-loop-fields/index.js +0 -156
- package/package/components/date/fields.js +0 -16
- package/package/components/date/index.js +0 -172
- package/package/components/date/templates/date.html +0 -20
- package/package/components/emailer/assets/images/govuk_logotype_email.png +0 -0
- package/package/components/emailer/assets/images/ho_crest_27px.png +0 -0
- package/package/components/emailer/assets/images/spacer.gif +0 -0
- package/package/components/emailer/email-service.js +0 -51
- package/package/components/emailer/emailer.js +0 -53
- package/package/components/emailer/index.js +0 -74
- package/package/components/emailer/transports/debug.js +0 -74
- package/package/components/emailer/transports/index.js +0 -8
- package/package/components/emailer/transports/ses.js +0 -36
- package/package/components/emailer/transports/smtp.js +0 -26
- package/package/components/emailer/transports/stub.js +0 -5
- package/package/components/emailer/views/layout.html +0 -63
- package/package/components/homeoffice-countries/index.js +0 -22
- package/package/components/index.js +0 -13
- package/package/components/notify/index.js +0 -62
- package/package/components/notify/notify.js +0 -51
- package/package/components/session-timeout-warning/index.js +0 -67
- package/package/components/summary/index.js +0 -237
- package/package/config/builder-defaults.js +0 -45
- package/package/config/component-defaults.js +0 -13
- package/package/config/hof-defaults.js +0 -65
- package/package/config/rate-limits.js +0 -20
- package/package/config/sanitisation-rules.js +0 -32
- package/package/controller/base-controller.js +0 -296
- package/package/controller/behaviour-hooks.js +0 -51
- package/package/controller/behaviour-session.js +0 -64
- package/package/controller/controller.js +0 -258
- package/package/controller/deprecate-error.js +0 -10
- package/package/controller/formatting/formatters.js +0 -70
- package/package/controller/formatting/index.js +0 -32
- package/package/controller/index.js +0 -17
- package/package/controller/validation/email.js +0 -30
- package/package/controller/validation/index.js +0 -101
- package/package/controller/validation/validators.js +0 -181
- package/package/controller/validation-error.js +0 -14
- package/package/frontend/govuk-template/build/config.js +0 -24
- package/package/frontend/govuk-template/build/govuk_template.html +0 -102
- package/package/frontend/govuk-template/build/index.js +0 -23
- package/package/frontend/govuk-template/govuk_template_generated.html +0 -102
- package/package/frontend/govuk-template/index.js +0 -29
- package/package/frontend/index.js +0 -9
- package/package/frontend/template-mixins/mixins/helpers.js +0 -103
- package/package/frontend/template-mixins/mixins/index.js +0 -37
- package/package/frontend/template-mixins/mixins/render.js +0 -12
- package/package/frontend/template-mixins/mixins/template-mixins.js +0 -520
- package/package/frontend/template-mixins/partials/forms/checkbox-group.html +0 -47
- package/package/frontend/template-mixins/partials/forms/checkbox.html +0 -16
- package/package/frontend/template-mixins/partials/forms/input-submit.html +0 -1
- package/package/frontend/template-mixins/partials/forms/input-text-date.html +0 -37
- package/package/frontend/template-mixins/partials/forms/input-text-group.html +0 -45
- package/package/frontend/template-mixins/partials/forms/option-group.html +0 -43
- package/package/frontend/template-mixins/partials/forms/select.html +0 -17
- package/package/frontend/template-mixins/partials/forms/textarea-group.html +0 -37
- package/package/frontend/template-mixins/partials/mixins/panel.html +0 -4
- package/package/frontend/template-partials/index.js +0 -9
- package/package/frontend/template-partials/translations/index.js +0 -26
- package/package/frontend/template-partials/translations/src/cy/base.json +0 -4
- package/package/frontend/template-partials/translations/src/cy/buttons.json +0 -6
- package/package/frontend/template-partials/translations/src/cy/cookies.json +0 -104
- package/package/frontend/template-partials/translations/src/cy/errorlist.json +0 -6
- package/package/frontend/template-partials/translations/src/cy/errors.json +0 -18
- package/package/frontend/template-partials/translations/src/cy/terms.json +0 -28
- package/package/frontend/template-partials/translations/src/en/accessibility.json +0 -43
- package/package/frontend/template-partials/translations/src/en/base.json +0 -5
- package/package/frontend/template-partials/translations/src/en/buttons.json +0 -10
- package/package/frontend/template-partials/translations/src/en/cookies.json +0 -116
- package/package/frontend/template-partials/translations/src/en/errorlist.json +0 -7
- package/package/frontend/template-partials/translations/src/en/errors.json +0 -35
- package/package/frontend/template-partials/translations/src/en/exit.json +0 -5
- package/package/frontend/template-partials/translations/src/en/fields.json +0 -5
- package/package/frontend/template-partials/translations/src/en/journey.json +0 -6
- package/package/frontend/template-partials/translations/src/en/save-and-exit.json +0 -4
- package/package/frontend/template-partials/translations/src/en/terms.json +0 -28
- package/package/frontend/template-partials/views/404.html +0 -9
- package/package/frontend/template-partials/views/accessibility.html +0 -55
- package/package/frontend/template-partials/views/confirm.html +0 -8
- package/package/frontend/template-partials/views/confirmation.html +0 -19
- package/package/frontend/template-partials/views/content/en/what-happens-next.md +0 -0
- package/package/frontend/template-partials/views/cookie-error.html +0 -1
- package/package/frontend/template-partials/views/cookies.html +0 -84
- package/package/frontend/template-partials/views/email/data-row.html +0 -4
- package/package/frontend/template-partials/views/email/formatted.html +0 -12
- package/package/frontend/template-partials/views/email/layout.html +0 -63
- package/package/frontend/template-partials/views/email/raw.html +0 -11
- package/package/frontend/template-partials/views/email/section-row.html +0 -3
- package/package/frontend/template-partials/views/error.html +0 -20
- package/package/frontend/template-partials/views/exit.html +0 -9
- package/package/frontend/template-partials/views/feedback-submitted.html +0 -11
- package/package/frontend/template-partials/views/layout.html +0 -55
- package/package/frontend/template-partials/views/partials/analytics-table.html +0 -25
- package/package/frontend/template-partials/views/partials/back.html +0 -5
- package/package/frontend/template-partials/views/partials/bullet-list.html +0 -7
- package/package/frontend/template-partials/views/partials/confirmation-alert.html +0 -6
- package/package/frontend/template-partials/views/partials/continue.html +0 -5
- package/package/frontend/template-partials/views/partials/cookie-banner.html +0 -29
- package/package/frontend/template-partials/views/partials/cookie-notification.html +0 -4
- package/package/frontend/template-partials/views/partials/cookie-settings-button.html +0 -1
- package/package/frontend/template-partials/views/partials/cookie-settings-radio.html +0 -8
- package/package/frontend/template-partials/views/partials/details-summary.html +0 -8
- package/package/frontend/template-partials/views/partials/external-link.html +0 -1
- package/package/frontend/template-partials/views/partials/form.html +0 -10
- package/package/frontend/template-partials/views/partials/gatag.html +0 -60
- package/package/frontend/template-partials/views/partials/head.html +0 -31
- package/package/frontend/template-partials/views/partials/heading.html +0 -11
- package/package/frontend/template-partials/views/partials/items-table.html +0 -32
- package/package/frontend/template-partials/views/partials/maincontent-left.html +0 -10
- package/package/frontend/template-partials/views/partials/navigation.html +0 -8
- package/package/frontend/template-partials/views/partials/page.html +0 -23
- package/package/frontend/template-partials/views/partials/panel-indent.html +0 -3
- package/package/frontend/template-partials/views/partials/session-cookies-table.html +0 -28
- package/package/frontend/template-partials/views/partials/session-timeout-warning.html +0 -38
- package/package/frontend/template-partials/views/partials/summary-table-row.html +0 -14
- package/package/frontend/template-partials/views/partials/summary-table.html +0 -8
- package/package/frontend/template-partials/views/partials/table.html +0 -18
- package/package/frontend/template-partials/views/partials/validation-list.html +0 -3
- package/package/frontend/template-partials/views/partials/validation-summary.html +0 -25
- package/package/frontend/template-partials/views/partials/warn.html +0 -7
- package/package/frontend/template-partials/views/rate-limit-error.html +0 -10
- package/package/frontend/template-partials/views/save-and-exit.html +0 -17
- package/package/frontend/template-partials/views/service-unavailable.html +0 -13
- package/package/frontend/template-partials/views/session-timeout.html +0 -7
- package/package/frontend/template-partials/views/step.html +0 -14
- package/package/frontend/template-partials/views/terms.html +0 -26
- package/package/frontend/themes/gov-uk/client-js/cookieSettings.js +0 -145
- package/package/frontend/themes/gov-uk/client-js/govuk-cookies.js +0 -121
- package/package/frontend/themes/gov-uk/client-js/index.js +0 -27
- package/package/frontend/themes/gov-uk/client-js/session-timeout-dialog.js +0 -348
- package/package/frontend/themes/gov-uk/client-js/skip-to-main.js +0 -19
- package/package/frontend/themes/gov-uk/index.js +0 -9
- package/package/frontend/themes/gov-uk/styles/_base.scss +0 -17
- package/package/frontend/themes/gov-uk/styles/_check_your_answers.scss +0 -155
- package/package/frontend/themes/gov-uk/styles/_cookie-banner.scss +0 -111
- package/package/frontend/themes/gov-uk/styles/_cookie-settings.scss +0 -33
- package/package/frontend/themes/gov-uk/styles/_govuk_frontend_toolkit.scss +0 -23
- package/package/frontend/themes/gov-uk/styles/_helpers.scss +0 -5
- package/package/frontend/themes/gov-uk/styles/_layout.scss +0 -125
- package/package/frontend/themes/gov-uk/styles/_panel-indent.scss +0 -27
- package/package/frontend/themes/gov-uk/styles/_pdf.scss +0 -42
- package/package/frontend/themes/gov-uk/styles/_session-timeout-dialog.scss +0 -121
- package/package/frontend/themes/gov-uk/styles/_typography.scss +0 -27
- package/package/frontend/themes/gov-uk/styles/_variables.scss +0 -11
- package/package/frontend/themes/gov-uk/styles/govuk.scss +0 -43
- package/package/frontend/themes/gov-uk/styles/mixins.scss +0 -16
- package/package/frontend/themes/gov-uk/styles/modules/_alerts.scss +0 -73
- package/package/frontend/themes/gov-uk/styles/modules/_buttons.scss +0 -5
- package/package/frontend/themes/gov-uk/styles/modules/_character-count.scss +0 -8
- package/package/frontend/themes/gov-uk/styles/modules/_confirm-page.scss +0 -20
- package/package/frontend/themes/gov-uk/styles/modules/_lists.scss +0 -5
- package/package/frontend/themes/gov-uk/styles/modules/_progressive-reveal.scss +0 -17
- package/package/frontend/themes/gov-uk/styles/modules/_validation.scss +0 -51
- package/package/frontend/themes/index.js +0 -5
- package/package/frontend/toolkit/assets/images/passports/new-window-link-blue.png +0 -0
- package/package/frontend/toolkit/assets/images/passports/new-window-link.png +0 -0
- package/package/frontend/toolkit/assets/images/spinner.gif +0 -0
- package/package/frontend/toolkit/assets/javascript/character-count.js +0 -99
- package/package/frontend/toolkit/assets/javascript/form-focus.js +0 -101
- package/package/frontend/toolkit/assets/javascript/helpers.js +0 -177
- package/package/frontend/toolkit/assets/javascript/progressive-reveal.js +0 -72
- package/package/frontend/toolkit/assets/javascript/validation.js +0 -71
- package/package/frontend/toolkit/assets/javascript/vendor/details.polyfill.js +0 -189
- package/package/frontend/toolkit/assets/javascript/vendor/indexof.polyfill.js +0 -39
- package/package/frontend/toolkit/assets/javascript/vendor/safari-cachebuster.js +0 -6
- package/package/frontend/toolkit/assets/stylesheets/_base.scss +0 -17
- package/package/frontend/toolkit/assets/stylesheets/_helpers.scss +0 -5
- package/package/frontend/toolkit/assets/stylesheets/_layout.scss +0 -118
- package/package/frontend/toolkit/assets/stylesheets/_typography.scss +0 -27
- package/package/frontend/toolkit/assets/stylesheets/_variables.scss +0 -11
- package/package/frontend/toolkit/assets/stylesheets/app.scss +0 -30
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_buttons.scss +0 -47
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_details.scss +0 -38
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_elements-typography.scss +0 -175
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_forms.scss +0 -167
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_helpers.scss +0 -39
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_layout.scss +0 -67
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_lists.scss +0 -40
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_panels.scss +0 -29
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_reset.scss +0 -33
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/_tables.scss +0 -33
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-block-labels.scss +0 -63
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-date.scss +0 -39
- package/package/frontend/toolkit/assets/stylesheets/govuk-elements/forms/_form-validation.scss +0 -63
- package/package/frontend/toolkit/assets/stylesheets/mixins.scss +0 -16
- package/package/frontend/toolkit/assets/stylesheets/modules/_alerts.scss +0 -73
- package/package/frontend/toolkit/assets/stylesheets/modules/_buttons.scss +0 -5
- package/package/frontend/toolkit/assets/stylesheets/modules/_confirm-page.scss +0 -20
- package/package/frontend/toolkit/assets/stylesheets/modules/_lists.scss +0 -5
- package/package/frontend/toolkit/assets/stylesheets/modules/_progressive-reveal.scss +0 -17
- package/package/frontend/toolkit/assets/stylesheets/modules/_validation.scss +0 -51
- package/package/frontend/toolkit/index.js +0 -10
- package/package/index.js +0 -351
- package/package/lib/deindex.js +0 -18
- package/package/lib/encryption.js +0 -23
- package/package/lib/ga-tag.js +0 -89
- package/package/lib/health.js +0 -26
- package/package/lib/helpers.js +0 -66
- package/package/lib/logger.js +0 -65
- package/package/lib/markdown.js +0 -46
- package/package/lib/router.js +0 -111
- package/package/lib/serve-static.js +0 -12
- package/package/lib/sessions.js +0 -82
- package/package/lib/settings.js +0 -74
- package/package/lib/which.js +0 -28
- package/package/middleware/cookies.js +0 -43
- package/package/middleware/deep-translate.js +0 -32
- package/package/middleware/errors.js +0 -119
- package/package/middleware/index.js +0 -10
- package/package/middleware/not-found.js +0 -38
- package/package/middleware/rate-limiter.js +0 -98
- package/package/middleware/service-unavailable.js +0 -64
- package/package/model/apis/axios-settings.js +0 -21
- package/package/model/apis/html-to-pdf-converter.js +0 -35
- package/package/model/apis/index.js +0 -5
- package/package/model/index.js +0 -348
- package/package/package.json +0 -147
- package/package/sandbox/README.md +0 -66
- package/package/sandbox/apps/sandbox/behaviours/clear-session.js +0 -8
- package/package/sandbox/apps/sandbox/behaviours/country-select.js +0 -10
- package/package/sandbox/apps/sandbox/behaviours/international-number.js +0 -22
- package/package/sandbox/apps/sandbox/fields.js +0 -128
- package/package/sandbox/apps/sandbox/index.js +0 -99
- package/package/sandbox/apps/sandbox/lib/staticAppealStages.js +0 -189
- package/package/sandbox/apps/sandbox/sections/summary-data-sections.js +0 -43
- package/package/sandbox/apps/sandbox/translations/src/en/errors.json +0 -5
- package/package/sandbox/apps/sandbox/translations/src/en/exit.json +0 -4
- package/package/sandbox/apps/sandbox/translations/src/en/fields.json +0 -101
- package/package/sandbox/apps/sandbox/translations/src/en/journey.json +0 -7
- package/package/sandbox/apps/sandbox/translations/src/en/pages.json +0 -72
- package/package/sandbox/apps/sandbox/translations/src/en/validation.json +0 -54
- package/package/sandbox/apps/sandbox/views/form-guidance-link.html +0 -8
- package/package/sandbox/apps/sandbox/views/save-and-exit.html +0 -19
- package/package/sandbox/assets/images/icons/icon-caret-left.png +0 -0
- package/package/sandbox/assets/images/icons/icon-complete.png +0 -0
- package/package/sandbox/assets/images/icons/icon-cross-remove-sign.png +0 -0
- package/package/sandbox/assets/js/index.js +0 -70
- package/package/sandbox/assets/scss/app.scss +0 -27
- package/package/sandbox/codecept.conf.js +0 -15
- package/package/sandbox/config.js +0 -17
- package/package/sandbox/package.json +0 -26
- package/package/sandbox/server.js +0 -23
- package/package/sandbox/yarn.lock +0 -262
- package/package/transpiler/index.js +0 -2
- package/package/transpiler/lib/aggregate.js +0 -32
- package/package/transpiler/lib/build.js +0 -15
- package/package/transpiler/lib/compile.js +0 -12
- package/package/transpiler/lib/expand-dirs.js +0 -14
- package/package/transpiler/lib/write-files.js +0 -24
- package/package/utilities/autofill/index.js +0 -189
- package/package/utilities/autofill/inputs.js +0 -60
- package/package/utilities/countries.js +0 -12
- package/package/utilities/helpers/index.js +0 -189
- package/package/utilities/index.js +0 -9
- package/package/utilities/reqres/index.js +0 -18
- package/package/utilities/test-data/data/domain.json +0 -7
- package/package/utilities/test-data/data/firstname.json +0 -16
- package/package/utilities/test-data/data/lastname.json +0 -10
- package/package/utilities/test-data/data/postcode.json +0 -12
- package/package/utilities/test-data/data/streetname.json +0 -8
- package/package/utilities/test-data/data/streetsuffix.json +0 -7
- package/package/utilities/test-data/data/town.json +0 -9
- package/package/utilities/test-data/index.js +0 -67
- package/package/wizard/behaviours/complete.js +0 -20
- package/package/wizard/behaviours/index.js +0 -5
- package/package/wizard/index.js +0 -124
- package/package/wizard/middleware/back-links.js +0 -68
- package/package/wizard/middleware/check-complete.js +0 -13
- package/package/wizard/middleware/check-progress.js +0 -139
- package/package/wizard/middleware/check-session.js +0 -17
- package/package/wizard/middleware/csrf.js +0 -47
- package/package/wizard/middleware/session-model.js +0 -11
- package/package/wizard/middleware/session.js +0 -9
- package/package/wizard/model.js +0 -29
- package/package/wizard/util/constants.js +0 -5
- package/package/wizard/util/helpers.js +0 -19
@@ -1,99 +0,0 @@
|
|
1
|
-
/* eslint-disable max-len, no-var, no-use-before-define, no-param-reassign, vars-on-top, radix */
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
var helpers = require('./helpers');
|
5
|
-
|
6
|
-
CharacterCount.prototype.updateCount = function () {
|
7
|
-
var currentLength = this.$textarea.value.length;
|
8
|
-
var characterNoun = ' characters';
|
9
|
-
var remainderSuffix = ' remaining';
|
10
|
-
|
11
|
-
if (this.maxLength - currentLength === 1 || currentLength - this.maxLength === 1) {
|
12
|
-
characterNoun = ' character';
|
13
|
-
}
|
14
|
-
|
15
|
-
if (this.maxLength - currentLength < 0) {
|
16
|
-
remainderSuffix = ' too many';
|
17
|
-
}
|
18
|
-
|
19
|
-
function addCommas(numString) {
|
20
|
-
var rgx = /(\d+)(\d{3})/;
|
21
|
-
while (rgx.test(numString)) {
|
22
|
-
numString = numString.replace(rgx, '$1' + ',' + '$2');
|
23
|
-
}
|
24
|
-
return numString;
|
25
|
-
}
|
26
|
-
|
27
|
-
// format the number with commas separating thousands, so screen readers do not read them as a year
|
28
|
-
var number = addCommas(Math.abs(this.maxLength - currentLength).toString());
|
29
|
-
|
30
|
-
this.$maxlengthHint.innerHTML = 'You have ' + number + characterNoun + remainderSuffix;
|
31
|
-
|
32
|
-
if (currentLength >= this.maxLength + 1) {
|
33
|
-
helpers.removeClass(this.$maxlengthHint, 'govuk-hint');
|
34
|
-
helpers.addClass(this.$maxlengthHint, 'govuk-error-message');
|
35
|
-
helpers.addClass(this.$textarea, 'textarea-error');
|
36
|
-
} else {
|
37
|
-
helpers.addClass(this.$maxlengthHint, 'govuk-hint');
|
38
|
-
helpers.removeClass(this.$maxlengthHint, 'govuk-error-message');
|
39
|
-
helpers.removeClass(this.$textarea, 'textarea-error');
|
40
|
-
}
|
41
|
-
};
|
42
|
-
|
43
|
-
CharacterCount.prototype.checkIfLengthChanged = function () {
|
44
|
-
if (this.$textarea.length !== this.oldLength) {
|
45
|
-
this.updateCount();
|
46
|
-
this.oldLength = this.$textarea.value.length;
|
47
|
-
}
|
48
|
-
};
|
49
|
-
|
50
|
-
CharacterCount.prototype.handleFocus = function () {
|
51
|
-
this.lengthChecker = setInterval(this.checkIfLengthChanged.bind(this), 1000);
|
52
|
-
};
|
53
|
-
|
54
|
-
CharacterCount.prototype.handleBlur = function () {
|
55
|
-
clearInterval(this.lengthChecker);
|
56
|
-
};
|
57
|
-
|
58
|
-
CharacterCount.prototype.init = function () {
|
59
|
-
// Updates hint to js-enabled message
|
60
|
-
this.updateCount();
|
61
|
-
|
62
|
-
// remove maxLength restriction on element
|
63
|
-
this.$textarea.removeAttribute('maxlength');
|
64
|
-
|
65
|
-
// set change event on textarea
|
66
|
-
helpers.addEvent(this.$textarea, 'input', this.updateCount.bind(this));
|
67
|
-
// some assistive technologies do not trigger input events when entering text into fields
|
68
|
-
// add polling functions to check if input length has changed in these circumstances
|
69
|
-
helpers.addEvent(this.$textarea, 'focus', this.handleFocus.bind(this));
|
70
|
-
helpers.addEvent(this.$textarea, 'blur', this.handleBlur.bind(this));
|
71
|
-
};
|
72
|
-
|
73
|
-
function CharacterCount($textarea) {
|
74
|
-
// passes in textarea and attaches to object
|
75
|
-
this.$textarea = $textarea;
|
76
|
-
|
77
|
-
// attaches hint to object
|
78
|
-
this.$maxlengthHint = document.querySelector('[id=' + this.$textarea.id + '-maxlength-hint]');
|
79
|
-
|
80
|
-
// set maxlength to variable
|
81
|
-
this.maxLength = parseInt(this.$textarea.getAttribute('maxlength'));
|
82
|
-
|
83
|
-
// save old length for polling comparison
|
84
|
-
this.oldLength = 0;
|
85
|
-
}
|
86
|
-
|
87
|
-
function characterCountAll() {
|
88
|
-
// find all textareas
|
89
|
-
var $allTextAreas = document.getElementsByTagName('textarea');
|
90
|
-
|
91
|
-
// for each textarea if it has maxlength create new characterCount object
|
92
|
-
for (var i = 0; i < $allTextAreas.length; i++) {
|
93
|
-
if ($allTextAreas[i].hasAttribute('maxlength')) {
|
94
|
-
new CharacterCount($allTextAreas[i]).init();
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
module.exports = characterCountAll;
|
@@ -1,101 +0,0 @@
|
|
1
|
-
/* eslint-disable max-len, no-var, no-param-reassign, vars-on-top */
|
2
|
-
/**
|
3
|
-
* This module adds the yellow focus border to:
|
4
|
-
* * labels with class block-label that are the parent element of radio buttons
|
5
|
-
* * labels with class block-label that are the parent element of check boxes
|
6
|
-
* * details elements
|
7
|
-
*
|
8
|
-
*/
|
9
|
-
|
10
|
-
'use strict';
|
11
|
-
|
12
|
-
var each = require('lodash').forEach;
|
13
|
-
var groupBy = require('lodash').groupBy;
|
14
|
-
|
15
|
-
var NAME = 'form-focus';
|
16
|
-
|
17
|
-
var helpers = require('./helpers');
|
18
|
-
var groups;
|
19
|
-
var blockLabelClass = 'block-label';
|
20
|
-
var focussedClass = 'focused';
|
21
|
-
var selectedClass = 'selected';
|
22
|
-
|
23
|
-
function focussed(e) {
|
24
|
-
helpers.addClass(helpers.target(e).parentNode, focussedClass);
|
25
|
-
}
|
26
|
-
|
27
|
-
function blurred(e) {
|
28
|
-
helpers.removeClass(helpers.target(e).parentNode, focussedClass);
|
29
|
-
}
|
30
|
-
|
31
|
-
function clicked(e, target) {
|
32
|
-
target = target || helpers.target(e);
|
33
|
-
each(groups[target.name], function (input) {
|
34
|
-
if (input.checked) {
|
35
|
-
helpers.addClass(input.parentNode, selectedClass);
|
36
|
-
} else {
|
37
|
-
helpers.removeClass(input.parentNode, selectedClass);
|
38
|
-
}
|
39
|
-
});
|
40
|
-
}
|
41
|
-
|
42
|
-
function bindInputEvents(label) {
|
43
|
-
if (helpers.hasClass(label, blockLabelClass)) {
|
44
|
-
var input = label.getElementsByTagName('input')[0];
|
45
|
-
|
46
|
-
if (input && input.type && input.type.match(/radio|checkbox/)) {
|
47
|
-
helpers.addEvent(input, 'focus', focussed);
|
48
|
-
helpers.addEvent(input, 'blur', blurred);
|
49
|
-
helpers.addEvent(input, 'click', clicked);
|
50
|
-
clicked(null, input);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
54
|
-
|
55
|
-
function bindSummaryEvents(summary) {
|
56
|
-
helpers.addEvent(summary, 'focus', focussed);
|
57
|
-
helpers.addEvent(summary, 'blur', blurred);
|
58
|
-
}
|
59
|
-
|
60
|
-
function setupLabels(labels) {
|
61
|
-
groups = groupBy(document.getElementsByTagName('input'), 'name');
|
62
|
-
for (var i = 0, len = labels.length; i < len; i++) {
|
63
|
-
helpers.once(labels[i], NAME, bindInputEvents);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
function formFocus() {
|
68
|
-
var forms = document.getElementsByTagName('form');
|
69
|
-
var getElementFromSummaryLink = window.location.hash.replace(/^#/, '');
|
70
|
-
var getEditPath = window.location.pathname.split('/').pop();
|
71
|
-
var labels;
|
72
|
-
var summaries;
|
73
|
-
|
74
|
-
var editMode = getElementFromSummaryLink && getEditPath === 'edit';
|
75
|
-
|
76
|
-
if (getElementFromSummaryLink && document.getElementById(getElementFromSummaryLink) && editMode) {
|
77
|
-
document.getElementById(getElementFromSummaryLink).focus();
|
78
|
-
}
|
79
|
-
|
80
|
-
if (getElementFromSummaryLink && document.getElementById(getElementFromSummaryLink + '-group') && editMode) {
|
81
|
-
document.getElementById(getElementFromSummaryLink + '-group').scrollIntoView();
|
82
|
-
}
|
83
|
-
|
84
|
-
if (document.getElementById(getElementFromSummaryLink + '-day') && forms.length === 1 && editMode) {
|
85
|
-
document.getElementById(getElementFromSummaryLink + '-day').focus();
|
86
|
-
}
|
87
|
-
|
88
|
-
if (forms.length > 0) {
|
89
|
-
labels = document.getElementsByTagName('label');
|
90
|
-
if (labels) {
|
91
|
-
setupLabels(labels);
|
92
|
-
}
|
93
|
-
}
|
94
|
-
|
95
|
-
summaries = document.getElementsByTagName('summary');
|
96
|
-
for (var i = 0, len = summaries.length; i < len; i++) {
|
97
|
-
helpers.once(summaries[i], NAME, bindSummaryEvents);
|
98
|
-
}
|
99
|
-
}
|
100
|
-
|
101
|
-
module.exports = formFocus;
|
@@ -1,177 +0,0 @@
|
|
1
|
-
/* eslint-disable max-len, no-var, no-param-reassign, vars-on-top, no-extend-native */
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
var each = require('lodash').forEach;
|
5
|
-
|
6
|
-
var DESKTOP_WIDTH = 769;
|
7
|
-
|
8
|
-
var helpers = {};
|
9
|
-
|
10
|
-
if (!Array.prototype.indexOf) {
|
11
|
-
Array.prototype.indexOf = function (obj, start) {
|
12
|
-
for (var i = (start || 0), j = this.length; i < j; i++) {
|
13
|
-
if (this[i] === obj) { return i; }
|
14
|
-
}
|
15
|
-
return -1;
|
16
|
-
};
|
17
|
-
}
|
18
|
-
|
19
|
-
helpers.documentReady = function (callback) {
|
20
|
-
this.addEvent(document, 'DOMContentLoaded', callback);
|
21
|
-
this.addEvent(window, 'load', callback);
|
22
|
-
};
|
23
|
-
|
24
|
-
helpers.addEvent = function (el, type, callback) {
|
25
|
-
if (el.addEventListener) {
|
26
|
-
el.addEventListener(type, callback, false);
|
27
|
-
} else if (el.attachEvent) {
|
28
|
-
el.attachEvent('on' + type, callback);
|
29
|
-
}
|
30
|
-
};
|
31
|
-
|
32
|
-
helpers.removeEvent = function (el, type, callback) {
|
33
|
-
if (el.removeEventListener) {
|
34
|
-
el.removeEventListener(type, callback, false);
|
35
|
-
} else if (el.detachEvent) {
|
36
|
-
el.detachEvent('on' + type, callback);
|
37
|
-
}
|
38
|
-
};
|
39
|
-
|
40
|
-
helpers.target = function (e) {
|
41
|
-
return e.target || e.srcElement;
|
42
|
-
};
|
43
|
-
|
44
|
-
/**
|
45
|
-
* Cross-browser trigger event method
|
46
|
-
*/
|
47
|
-
helpers.triggerEvent = function (el, type) {
|
48
|
-
var evt;
|
49
|
-
|
50
|
-
if (document.createEvent) {
|
51
|
-
evt = new Event(type);
|
52
|
-
el.dispatchEvent(evt);
|
53
|
-
} else {
|
54
|
-
evt = document.createEventObject();
|
55
|
-
el.fireEvent('on' + type, evt);
|
56
|
-
}
|
57
|
-
};
|
58
|
-
|
59
|
-
helpers.preventDefault = function (e) {
|
60
|
-
e.preventDefault ? e.preventDefault() : event.returnValue = false;
|
61
|
-
};
|
62
|
-
|
63
|
-
/*
|
64
|
-
** Check if an element has a class name
|
65
|
-
***/
|
66
|
-
helpers.hasClass = function (el, className) {
|
67
|
-
if (el.className.split(/\s/).indexOf(className) !== -1) {
|
68
|
-
return true;
|
69
|
-
}
|
70
|
-
return false;
|
71
|
-
};
|
72
|
-
|
73
|
-
helpers.addClass = function (el, className) {
|
74
|
-
var current = el.className;
|
75
|
-
|
76
|
-
if (current === '') {
|
77
|
-
el.className = className;
|
78
|
-
} else {
|
79
|
-
current = current.split(' ');
|
80
|
-
|
81
|
-
if (current.indexOf(className) !== -1) {
|
82
|
-
this.stripClasses(current, className);
|
83
|
-
}
|
84
|
-
|
85
|
-
current.push(className);
|
86
|
-
el.className = current.join(' ');
|
87
|
-
}
|
88
|
-
};
|
89
|
-
|
90
|
-
helpers.addClasses = function (el, classNames) {
|
91
|
-
each(classNames, function (className) {
|
92
|
-
helpers.addClass(el, className);
|
93
|
-
});
|
94
|
-
};
|
95
|
-
|
96
|
-
/*
|
97
|
-
** Strips all class names with name className from array
|
98
|
-
***/
|
99
|
-
helpers.stripClasses = function (arr, className) {
|
100
|
-
for (var i = 0; i < arr.length; i++) {
|
101
|
-
if(arr[i] === className) {
|
102
|
-
arr.splice(i, 1);
|
103
|
-
--i;
|
104
|
-
}
|
105
|
-
}
|
106
|
-
};
|
107
|
-
|
108
|
-
helpers.removeClass = function (el, className) {
|
109
|
-
var current = el.className;
|
110
|
-
|
111
|
-
if (current !== '') {
|
112
|
-
current = current.split(' ');
|
113
|
-
this.stripClasses(current, className);
|
114
|
-
el.className = current.join(' ');
|
115
|
-
}
|
116
|
-
};
|
117
|
-
|
118
|
-
helpers.getElementsByClass = function (parent, tag, className) {
|
119
|
-
if (parent.getElementsByClassName) {
|
120
|
-
return parent.getElementsByClassName(className);
|
121
|
-
}
|
122
|
-
var elems = [];
|
123
|
-
each(parent.getElementsByTagName(tag), function (t) {
|
124
|
-
if (helpers.hasClass(t, className)) {
|
125
|
-
elems.push(t);
|
126
|
-
}
|
127
|
-
});
|
128
|
-
return elems;
|
129
|
-
};
|
130
|
-
|
131
|
-
helpers.once = function (elem, key, callback) {
|
132
|
-
if (!elem) { return; }
|
133
|
-
elem.started = elem.started || {};
|
134
|
-
if (!elem.started[key]) {
|
135
|
-
elem.started[key] = true;
|
136
|
-
callback(elem);
|
137
|
-
}
|
138
|
-
};
|
139
|
-
|
140
|
-
helpers.viewportWidth = function () {
|
141
|
-
return window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
142
|
-
};
|
143
|
-
|
144
|
-
helpers.scrollY = function () {
|
145
|
-
return window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
|
146
|
-
};
|
147
|
-
|
148
|
-
helpers.isDesktop = function () {
|
149
|
-
return helpers.viewportWidth() >= DESKTOP_WIDTH;
|
150
|
-
};
|
151
|
-
|
152
|
-
helpers.isJSWindow = function () {
|
153
|
-
return window.opener !== null;
|
154
|
-
};
|
155
|
-
|
156
|
-
helpers.getStyle = function (elem, prop) {
|
157
|
-
var val = '';
|
158
|
-
if (document.defaultView && document.defaultView.getComputedStyle) {
|
159
|
-
val = document.defaultView.getComputedStyle(elem, '').getPropertyValue(prop);
|
160
|
-
} else if (elem.currentStyle) {
|
161
|
-
prop = prop.replace(/\-(\w)/g, function (match, c) {
|
162
|
-
return c.toUpperCase();
|
163
|
-
});
|
164
|
-
val = elem.currentStyle[prop];
|
165
|
-
}
|
166
|
-
return val;
|
167
|
-
};
|
168
|
-
|
169
|
-
helpers.pagehide = function (func) {
|
170
|
-
if ('onpagehide' in window) {
|
171
|
-
helpers.addEvent(window, 'pagehide', func);
|
172
|
-
} else {
|
173
|
-
helpers.addEvent(window, 'unload', func);
|
174
|
-
}
|
175
|
-
};
|
176
|
-
|
177
|
-
module.exports = helpers;
|
@@ -1,72 +0,0 @@
|
|
1
|
-
/* eslint-disable max-len, no-var, no-param-reassign, vars-on-top */
|
2
|
-
'use strict';
|
3
|
-
|
4
|
-
var each = require('lodash').forEach;
|
5
|
-
var groupBy = require('lodash').groupBy;
|
6
|
-
|
7
|
-
var helpers = require('./helpers');
|
8
|
-
var inputs; var groups;
|
9
|
-
var toggleAttr = 'data-toggle';
|
10
|
-
var checkboxHiddenClass = 'govuk-checkboxes__conditional--hidden';
|
11
|
-
var radioHiddenClass = 'govuk-radios__conditional--hidden';
|
12
|
-
|
13
|
-
function inputClicked(e, target) {
|
14
|
-
target = target || helpers.target(e);
|
15
|
-
var shown;
|
16
|
-
each(groups[target.name], function (input) {
|
17
|
-
var hiddenClass = (input.type.match(/checkbox/)) ? checkboxHiddenClass : radioHiddenClass;
|
18
|
-
var id = input.getAttribute('aria-controls');
|
19
|
-
var toggle = document.getElementById(id);
|
20
|
-
if (toggle) {
|
21
|
-
if (input.checked) {
|
22
|
-
toggle.setAttribute('aria-hidden', 'false');
|
23
|
-
helpers.removeClass(toggle, hiddenClass);
|
24
|
-
shown = toggle.id;
|
25
|
-
var elementToFocus = toggle.querySelectorAll('input,textarea')[0];
|
26
|
-
if ((input === target) && elementToFocus) {
|
27
|
-
elementToFocus.focus();
|
28
|
-
}
|
29
|
-
} else {
|
30
|
-
if (shown !== toggle.id) {
|
31
|
-
toggle.setAttribute('aria-hidden', 'true');
|
32
|
-
helpers.addClass(toggle, hiddenClass);
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
});
|
37
|
-
}
|
38
|
-
|
39
|
-
function setupReveal(input) {
|
40
|
-
var element = input.getAttribute(toggleAttr);
|
41
|
-
// check if the element supplied is part of an {id}-panel
|
42
|
-
// if so then toggle this parent element to also toggle
|
43
|
-
// associated labels and legends
|
44
|
-
var toggleId = document.getElementById(element + '-panel')
|
45
|
-
? element + '-panel'
|
46
|
-
: element;
|
47
|
-
var toggle = document.getElementById(toggleId);
|
48
|
-
|
49
|
-
if (toggle) {
|
50
|
-
input.setAttribute('aria-controls', toggleId);
|
51
|
-
inputClicked(null, input);
|
52
|
-
}
|
53
|
-
helpers.addEvent(input, 'click', inputClicked);
|
54
|
-
}
|
55
|
-
|
56
|
-
function progressiveReveal() {
|
57
|
-
var forms = document.getElementsByTagName('form');
|
58
|
-
var input;
|
59
|
-
|
60
|
-
if (forms.length > 0) {
|
61
|
-
inputs = document.querySelectorAll('input,textarea');
|
62
|
-
groups = groupBy(inputs, 'name');
|
63
|
-
for (var i = 0, num = inputs.length; i < num; i++) {
|
64
|
-
input = inputs[i];
|
65
|
-
if (input.type.match(/radio|checkbox/)) {
|
66
|
-
helpers.once(input, 'progressive-reveal', setupReveal);
|
67
|
-
}
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
module.exports = progressiveReveal;
|
@@ -1,71 +0,0 @@
|
|
1
|
-
/* eslint-disable max-len, no-var, no-shadow, vars-on-top */
|
2
|
-
var each = require('lodash').forEach;
|
3
|
-
|
4
|
-
var helpers = require('./helpers');
|
5
|
-
|
6
|
-
var NAME = 'VALIDATION';
|
7
|
-
|
8
|
-
var summary;
|
9
|
-
|
10
|
-
function clicked(e) {
|
11
|
-
var elem = helpers.target(e);
|
12
|
-
|
13
|
-
var groupId = elem.getAttribute('href').replace(/^#/, '');
|
14
|
-
var group = document.getElementById(groupId + '-group') || document.getElementById(groupId);
|
15
|
-
var inputs;
|
16
|
-
|
17
|
-
if (group) {
|
18
|
-
if (group.getElementsByTagName('input').length) {
|
19
|
-
inputs = group.getElementsByTagName('input');
|
20
|
-
} else if (group.getElementsByTagName('textarea').length) {
|
21
|
-
inputs = group.getElementsByTagName('textarea');
|
22
|
-
} else if (group.getElementsByTagName('select').length) {
|
23
|
-
inputs = group.getElementsByTagName('select');
|
24
|
-
}
|
25
|
-
|
26
|
-
if (inputs) {
|
27
|
-
if (inputs[0].getAttribute('type') === 'hidden') {
|
28
|
-
var getVisibleElements = group.querySelectorAll('input[type=text]');
|
29
|
-
getVisibleElements[0].focus();
|
30
|
-
} else {
|
31
|
-
inputs[0].focus();
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
function pressed(e) {
|
38
|
-
// Allow the spacebar to trigger the same behaviour
|
39
|
-
if(e.keyCode === 32) {
|
40
|
-
clicked(e);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
|
44
|
-
function setup(summary) {
|
45
|
-
summary.focus();
|
46
|
-
|
47
|
-
var errors = summary.getElementsByTagName('a');
|
48
|
-
|
49
|
-
each(errors, function (error) {
|
50
|
-
helpers.addEvent(error, 'click', clicked);
|
51
|
-
helpers.addEvent(error, 'keydown', pressed);
|
52
|
-
});
|
53
|
-
}
|
54
|
-
|
55
|
-
function validation() {
|
56
|
-
var summaries = [];
|
57
|
-
|
58
|
-
if (document.getElementById('content')) {
|
59
|
-
summaries = helpers.getElementsByClass(document.getElementById('content'), 'div', 'validation-summary');
|
60
|
-
}
|
61
|
-
|
62
|
-
if (summaries.length) {
|
63
|
-
summary = summaries[0];
|
64
|
-
|
65
|
-
helpers.once(summary, NAME, function (summary) {
|
66
|
-
setup(summary);
|
67
|
-
});
|
68
|
-
}
|
69
|
-
}
|
70
|
-
|
71
|
-
module.exports = validation;
|