-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
197 lines (171 loc) · 7.15 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
'use strict';
window.uswdsPresent = true; // Indicate uswds.js has loaded in the DOM.
// The 'polyfills' define key ECMAScript 5 methods that may be missing from older browsers (which?)
// import polyfills from '../../node_modules/@uswds/uswds/packages/uswds-core/src/js/polyfills';
// Adds SVG support for (really) old browsers. If needed add after USWDS initialization svg4everybody();
// import svg4everybody from '../../node_modules/@uswds/uswds/packages/uswds-core/src/js/polyfills/svg4everybody';
import uswds from '../../node_modules/@uswds/uswds/packages/uswds-core/src/js/config.js';
/**
* USWDS packages
*/
// import banner from '@uswds/uswds/js/usa-banner';
// import characterCount from '@uswds/uswds/js/usa-character-count';
// import comboBox from '@uswds/uswds/js/usa-combo-box';
// import datePicker from '@uswds/uswds/js/usa-date-picker';
// import dateRangePicker from '@uswds/uswds/js/usa-date-range-picker';
// import fileInput from '@uswds/uswds/js/usa-file-input';
// import footer from '@uswds/uswds/js/usa-footer';
// import inPageNavigation from '@uswds/uswds/js/usa-in-page-navigation';
// import inputMask from '@uswds/uswds/js/usa-input-mask';
// import languageSelector from '@uswds/uswds/js/usa-language-selector';
// import modal from '@uswds/uswds/js/usa-modal';
// import password from '@uswds/uswds/js/_usa-password';
// import search from '@uswds/uswds/js/usa-search';
// import table from '@uswds/uswds/js/usa-table';
// import timePicker from '@uswds/uswds/js/usa-time-picker';
import accordion from '@uswds/uswds/js/usa-accordion';
import button from '@uswds/uswds/js/usa-button';
import navigation from '@uswds/uswds/js/usa-header';
import skipnav from '@uswds/uswds/js/usa-skipnav';
import tooltip from '@uswds/uswds/js/usa-tooltip';
/**
* Code for America packages
*/
import Copy from '../../packages/cfa-copy/cfa-copy.js';
import Details from '../../packages/cfa-details/cfa-details.js';
import FollowUpQuestion from '../../packages/cfa-follow-up-question/cfa-follow-up-question.js';
import MaskDollars from '../../packages/cfa-mask/cfa-mask-dollars.js';
import MaskTel from '../../packages/cfa-mask/cfa-mask-tel.js';
import MaskSSN from '../../packages/cfa-mask/cfa-mask-ssn.js';
import FileSelector from '../../packages/cfa-file-selector/cfa-file-selector.js';
/**
* Initialize USWDS and Code for America theme utilities and components
*/
accordion.on(document.body);
button.on(document.body);
new Copy({
copied: c => {
let icon = c.element.querySelector(c.selectors.ICON);
let href = icon.getAttribute('href').split('#');
icon.setAttribute('href', `${href[0]}#check_circle`);
},
after: c => {
let icon = c.element.querySelector(c.selectors.ICON);
let href = icon.getAttribute('href').split('#');
icon.setAttribute('href', `${href[0]}#content_copy`);
}
});
new Details();
new FollowUpQuestion();
navigation.on(document.body);
new MaskDollars();
new MaskTel();
new MaskSSN();
skipnav.on(document.body);
tooltip.on(document.body);
/**
* Upload Documents component
*/
(elements => {
for (let i = 0; i < elements.length; i++) {
new FileSelector(elements[i], {
// /**
// * Example of passing already uploaded files to the utility
// *
// * @type {Array}
// */
// mockFiles: [
// {
// @name: {String} file name including extension,
// @size: {Number} file size in bytes,
// @type: {String} file type,
// @id: {String} file ID,
// @dataURL: {String} data encoded URI of the image thumbnail,
// @accepted: {Boolean} defaults to true
// },
// {
// name: 'filename.png',
// size: 192435,
// type: 'image/png',
// id: '0f488973-63e2-4a1d-a509-d1b492f10344',
// dataURL: "data:image/png;base64,...",
// accepted: true
// }
// ],
/**
* Dropzone Options. These will be passed to the Dropzone instantiation.
*
* @url https://github.com/dropzone/dropzone/blob/main/src/options.js
*/
dropzoneOptions: {
/**
* Required. A URL must be set in the Dropzone options configuration
*/
url: 'https://app-46361.on-aptible.com/file-upload',
// /**
// * Example Dropzone init configuration
// */
// init: function() {
// /**
// * Example added file event hook. Called when a file is added to the queue
// *
// * @url https://github.com/dropzone/dropzone/blob/f50d1828ab5df79a76be00d1306cc320e39a27f4/src/options.js#L611
// *
// * @param {Object} file Dropzone file object
// */
// this.on('addedfile', function(file) {
// //... some custom methods can go here
// file.previewElement.querySelector(FileSelector.selectors.documentRemoveLabel).innerText = 'cancel';
// file.previewElement.querySelector(FileSelector.selectors.documentRemove)
// .addEventListener('click', () => {
// //... cancel event for uploading file
// });
// });
// /**
// * Example success event hook. When the complete upload is finished
// * and successful.
// *
// * @url https://github.com/dropzone/dropzone/blob/f50d1828ab5df79a76be00d1306cc320e39a27f4/src/options.js#L752
// *
// * @param {Object} file Dropzone file object
// */
// this.on('success', function(file) {
// //... some custom methods can go here
// file.previewElement.querySelector(FileSelector.selectors.documentRemoveLabel).innerText = 'remove';
// file.previewElement.querySelector(FileSelector.selectors.documentRemove)
// .addEventListener('click', () => {
// //... remove event for uploaded file
// });
// });
// /**
// * Example sending event hook. Called just before the file is sent.
// * Gets the `xhr` object as second parameter, so you can modify it
// * (for example to add a CSRF token) and a `formData` object to add
// * additional information.
// *
// * @url https://github.com/dropzone/dropzone/blob/f50d1828ab5df79a76be00d1306cc320e39a27f4/src/options.js#L746
// *
// * @param {Object} file Dropzone file object
// * @param {Object} xhr The xhr request
// * @param {Object} formData Form data to append additional information to
// */
// this.on('sending', function(file, xhr, formData) {
// let token = document.querySelector('[data-js="csrf"]').value;
// formData.append('_csrf', token);
// //...
// });
// }
}
});
}
})(document.querySelectorAll(FileSelector.selector));
/**
* Add tabindex to pre tags to make them focusable. Site only
*/
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('pre').forEach(pre => {
if (!pre.hasAttribute('tabindex')) {
pre.setAttribute('tabindex', '0');
}
});
});