-
Notifications
You must be signed in to change notification settings - Fork 166
Extract Cleave.js-dependant JavaScript from application pack #5435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a5050c2
7b5aee5
5406719
b9ca762
01c97d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,6 @@ | ||
| require('../app/components/index'); | ||
| require('../app/utils/index'); | ||
| require('../app/pw-toggle'); | ||
| require('../app/form-field-format'); | ||
| require('../app/print-personal-key'); | ||
| require('../app/i18n-dropdown'); | ||
| require('../app/accessible-forms'); | ||
| require('../app/ssn-field'); |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||||||
| import Cleave from 'cleave.js'; | ||||||||||||||||||
|
|
||||||||||||||||||
| const SELECTOR_CONFIGS = { | ||||||||||||||||||
| '.personal-key': { | ||||||||||||||||||
| blocks: [4, 4, 4, 4], | ||||||||||||||||||
| delimiter: '-', | ||||||||||||||||||
| }, | ||||||||||||||||||
| '.backup-code': { | ||||||||||||||||||
| blocks: [4, 4, 4], | ||||||||||||||||||
| delimiter: '-', | ||||||||||||||||||
| }, | ||||||||||||||||||
| '.zipcode': { | ||||||||||||||||||
| numericOnly: true, | ||||||||||||||||||
| blocks: [5, 4], | ||||||||||||||||||
| delimiter: '-', | ||||||||||||||||||
| delimiterLazyShow: true, | ||||||||||||||||||
| }, | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| Object.entries(SELECTOR_CONFIGS) | ||||||||||||||||||
| .map(([selector, config]) => [document.querySelector(selector), config]) | ||||||||||||||||||
| .filter(([element]) => element) | ||||||||||||||||||
| .forEach(([element, config]) => new Cleave(element, config)); | ||||||||||||||||||
|
Comment on lines
+20
to
+23
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To confirm: The See: https://github.com/nosir/cleave.js/blob/e3fa6f3/src/Cleave.js#L29-L36 If we ever need to support multiple instances of elements on the page, we could consider constructing each:
Suggested change
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,3 +49,4 @@ | |
| </div> | ||
|
|
||
| <%= render 'idv/doc_auth/back', step: 'verify' %> | ||
| <%= javascript_packs_tag_once('formatted-fields') %> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,3 +30,4 @@ | |
| </button> | ||
| </div> | ||
| <% end %> | ||
| <%= javascript_packs_tag_once('formatted-fields') %> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ | |
| aria: { invalid: false }, | ||
| spellcheck: 'false' } %> | ||
| </div> | ||
| <%= javascript_packs_tag_once('formatted-fields') %> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ | |
| aria: { invalid: false }, | ||
| spellcheck: 'false' } %> | ||
| </div> | ||
| <%= javascript_packs_tag_once('formatted-fields') %> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,3 +8,4 @@ | |
| aria-invalid="false" | ||
| spellcheck="false" | ||
| type="text" /> | ||
| <%= javascript_packs_tag_once('formatted-fields') %> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <%# | ||
| locals: | ||
| * f: from validated_form_for | ||
| %> | ||
|
|
||
| <%# maxlength set and includes '-' delimiters to work around cleave bug %> | ||
| <%= f.input( | ||
| :ssn, | ||
| as: :password, | ||
| label: t('idv.form.ssn_label_html'), | ||
| required: true, | ||
| pattern: '^\d{3}-?\d{2}-?\d{4}$', | ||
| maxlength: 11, | ||
| input_html: { aria: { invalid: false }, class: 'ssn ssn-toggle', value: '' } | ||
| ) %> | ||
| <%= javascript_packs_tag_once('ssn-field') %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note this excludes
.dobfromform-field-format.js, which no longer exists as of #4852.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 5406719, I also removed this from
form-validation.js, along withstate_id_numberwhich was similarly removed as of #3682.