@4site/engrid-scripts 0.19.1

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.
Files changed (189) hide show
  1. package/.prettierrc.js +226 -0
  2. package/LICENSE +24 -0
  3. package/dist/a11y.d.ts +6 -0
  4. package/dist/a11y.js +46 -0
  5. package/dist/add-name-to-message.d.ts +5 -0
  6. package/dist/add-name-to-message.js +49 -0
  7. package/dist/advocacy.d.ts +7 -0
  8. package/dist/advocacy.js +34 -0
  9. package/dist/amount-label.d.ts +6 -0
  10. package/dist/amount-label.js +29 -0
  11. package/dist/app.d.ts +19 -0
  12. package/dist/app.js +340 -0
  13. package/dist/apple-pay.d.ts +13 -0
  14. package/dist/apple-pay.js +169 -0
  15. package/dist/auto-country-select.d.ts +10 -0
  16. package/dist/auto-country-select.js +63 -0
  17. package/dist/auto-year.d.ts +7 -0
  18. package/dist/auto-year.js +35 -0
  19. package/dist/autocomplete.d.ts +5 -0
  20. package/dist/autocomplete.js +38 -0
  21. package/dist/autosubmit.d.ts +5 -0
  22. package/dist/autosubmit.js +14 -0
  23. package/dist/branding-html.d.ts +14 -0
  24. package/dist/branding-html.js +70 -0
  25. package/dist/capitalize-fields.d.ts +7 -0
  26. package/dist/capitalize-fields.js +22 -0
  27. package/dist/click-to-expand.d.ts +4 -0
  28. package/dist/click-to-expand.js +39 -0
  29. package/dist/cookie.d.ts +53 -0
  30. package/dist/cookie.js +76 -0
  31. package/dist/country-disable.d.ts +4 -0
  32. package/dist/country-disable.js +22 -0
  33. package/dist/country-redirect.d.ts +7 -0
  34. package/dist/country-redirect.js +61 -0
  35. package/dist/custom-currency.d.ts +9 -0
  36. package/dist/custom-currency.js +112 -0
  37. package/dist/data-attributes.d.ts +5 -0
  38. package/dist/data-attributes.js +122 -0
  39. package/dist/data-hide.d.ts +15 -0
  40. package/dist/data-hide.js +66 -0
  41. package/dist/data-layer.d.ts +23 -0
  42. package/dist/data-layer.js +312 -0
  43. package/dist/data-replace.d.ts +26 -0
  44. package/dist/data-replace.js +76 -0
  45. package/dist/debug-hidden-fields.d.ts +4 -0
  46. package/dist/debug-hidden-fields.js +42 -0
  47. package/dist/debug-panel.d.ts +27 -0
  48. package/dist/debug-panel.js +508 -0
  49. package/dist/deprecated.d.ts +5 -0
  50. package/dist/deprecated.js +40 -0
  51. package/dist/digital-wallets.d.ts +8 -0
  52. package/dist/digital-wallets.js +143 -0
  53. package/dist/ecard-to-target.d.ts +11 -0
  54. package/dist/ecard-to-target.js +73 -0
  55. package/dist/ecard.d.ts +8 -0
  56. package/dist/ecard.js +61 -0
  57. package/dist/embedded-ecard.d.ts +18 -0
  58. package/dist/embedded-ecard.js +267 -0
  59. package/dist/en-validators.d.ts +10 -0
  60. package/dist/en-validators.js +89 -0
  61. package/dist/engrid.d.ts +49 -0
  62. package/dist/engrid.js +547 -0
  63. package/dist/event-tickets.d.ts +3 -0
  64. package/dist/event-tickets.js +24 -0
  65. package/dist/events/country.d.ts +12 -0
  66. package/dist/events/country.js +42 -0
  67. package/dist/events/donation-amount.d.ts +16 -0
  68. package/dist/events/donation-amount.js +119 -0
  69. package/dist/events/donation-frequency.d.ts +17 -0
  70. package/dist/events/donation-frequency.js +115 -0
  71. package/dist/events/en-form.d.ts +20 -0
  72. package/dist/events/en-form.js +52 -0
  73. package/dist/events/index.d.ts +6 -0
  74. package/dist/events/index.js +6 -0
  75. package/dist/events/processing-fees.d.ts +20 -0
  76. package/dist/events/processing-fees.js +92 -0
  77. package/dist/events/remember-me-events.d.ts +18 -0
  78. package/dist/events/remember-me-events.js +36 -0
  79. package/dist/exit-intent-lightbox.d.ts +14 -0
  80. package/dist/exit-intent-lightbox.js +145 -0
  81. package/dist/expand-region-name.d.ts +7 -0
  82. package/dist/expand-region-name.js +44 -0
  83. package/dist/fast-form-fill.d.ts +8 -0
  84. package/dist/fast-form-fill.js +75 -0
  85. package/dist/freshaddress.d.ts +18 -0
  86. package/dist/freshaddress.js +204 -0
  87. package/dist/give-by-select.d.ts +9 -0
  88. package/dist/give-by-select.js +82 -0
  89. package/dist/iframe.d.ts +16 -0
  90. package/dist/iframe.js +217 -0
  91. package/dist/index.d.ts +82 -0
  92. package/dist/index.js +84 -0
  93. package/dist/input-has-value-and-focus.d.ts +9 -0
  94. package/dist/input-has-value-and-focus.js +50 -0
  95. package/dist/input-placeholders.d.ts +7 -0
  96. package/dist/input-placeholders.js +82 -0
  97. package/dist/interfaces/ecard-to-target-options.d.ts +9 -0
  98. package/dist/interfaces/ecard-to-target-options.js +8 -0
  99. package/dist/interfaces/embedded-ecard-options.d.ts +8 -0
  100. package/dist/interfaces/embedded-ecard-options.js +7 -0
  101. package/dist/interfaces/exit-intent-options.d.ts +13 -0
  102. package/dist/interfaces/exit-intent-options.js +13 -0
  103. package/dist/interfaces/options.d.ts +147 -0
  104. package/dist/interfaces/options.js +50 -0
  105. package/dist/interfaces/translate-options.d.ts +7 -0
  106. package/dist/interfaces/translate-options.js +42 -0
  107. package/dist/interfaces/upsell-options.d.ts +24 -0
  108. package/dist/interfaces/upsell-options.js +33 -0
  109. package/dist/live-currency.d.ts +15 -0
  110. package/dist/live-currency.js +140 -0
  111. package/dist/live-frequency.d.ts +13 -0
  112. package/dist/live-frequency.js +109 -0
  113. package/dist/live-variables.d.ts +21 -0
  114. package/dist/live-variables.js +147 -0
  115. package/dist/loader.d.ts +10 -0
  116. package/dist/loader.js +175 -0
  117. package/dist/logger.d.ts +16 -0
  118. package/dist/logger.js +84 -0
  119. package/dist/media-attribution.d.ts +4 -0
  120. package/dist/media-attribution.js +66 -0
  121. package/dist/menu.d.ts +0 -0
  122. package/dist/menu.js +1 -0
  123. package/dist/min-max-amount.d.ts +13 -0
  124. package/dist/min-max-amount.js +71 -0
  125. package/dist/mobile-cta.d.ts +9 -0
  126. package/dist/mobile-cta.js +71 -0
  127. package/dist/modal.d.ts +19 -0
  128. package/dist/modal.js +129 -0
  129. package/dist/neverbounce.d.ts +23 -0
  130. package/dist/neverbounce.js +244 -0
  131. package/dist/other-amount.d.ts +6 -0
  132. package/dist/other-amount.js +70 -0
  133. package/dist/page-background.d.ts +7 -0
  134. package/dist/page-background.js +55 -0
  135. package/dist/plaid.d.ts +6 -0
  136. package/dist/plaid.js +49 -0
  137. package/dist/postal-code-validator.d.ts +20 -0
  138. package/dist/postal-code-validator.js +118 -0
  139. package/dist/premium-gift.d.ts +10 -0
  140. package/dist/premium-gift.js +115 -0
  141. package/dist/progress-bar.d.ts +3 -0
  142. package/dist/progress-bar.js +40 -0
  143. package/dist/remember-me.d.ts +61 -0
  144. package/dist/remember-me.js +358 -0
  145. package/dist/required-if-visible.d.ts +8 -0
  146. package/dist/required-if-visible.js +60 -0
  147. package/dist/set-attr.d.ts +4 -0
  148. package/dist/set-attr.js +31 -0
  149. package/dist/set-recurr-freq.d.ts +7 -0
  150. package/dist/set-recurr-freq.js +70 -0
  151. package/dist/show-hide-radio-checkboxes.d.ts +13 -0
  152. package/dist/show-hide-radio-checkboxes.js +161 -0
  153. package/dist/show-if-amount.d.ts +15 -0
  154. package/dist/show-if-amount.js +117 -0
  155. package/dist/show-if-present.d.ts +7 -0
  156. package/dist/show-if-present.js +79 -0
  157. package/dist/skip-link.d.ts +4 -0
  158. package/dist/skip-link.js +36 -0
  159. package/dist/src-defer.d.ts +6 -0
  160. package/dist/src-defer.js +70 -0
  161. package/dist/supporter-hub.d.ts +9 -0
  162. package/dist/supporter-hub.js +75 -0
  163. package/dist/swap-amounts.d.ts +45 -0
  164. package/dist/swap-amounts.js +81 -0
  165. package/dist/thank-you-page-conditional-content.d.ts +8 -0
  166. package/dist/thank-you-page-conditional-content.js +46 -0
  167. package/dist/ticker.d.ts +11 -0
  168. package/dist/ticker.js +66 -0
  169. package/dist/tidycontact.d.ts +46 -0
  170. package/dist/tidycontact.js +1202 -0
  171. package/dist/translate-fields.d.ts +12 -0
  172. package/dist/translate-fields.js +548 -0
  173. package/dist/universal-opt-in.d.ts +7 -0
  174. package/dist/universal-opt-in.js +91 -0
  175. package/dist/upsell-lightbox.d.ts +31 -0
  176. package/dist/upsell-lightbox.js +363 -0
  177. package/dist/url-params-to-body-attrs.d.ts +5 -0
  178. package/dist/url-params-to-body-attrs.js +14 -0
  179. package/dist/url-to-form.d.ts +7 -0
  180. package/dist/url-to-form.js +32 -0
  181. package/dist/us-only-form.d.ts +4 -0
  182. package/dist/us-only-form.js +30 -0
  183. package/dist/version.d.ts +1 -0
  184. package/dist/version.js +1 -0
  185. package/dist/vgs.d.ts +16 -0
  186. package/dist/vgs.js +250 -0
  187. package/dist/welcome-back.d.ts +10 -0
  188. package/dist/welcome-back.js +112 -0
  189. package/package.json +32 -0
package/.prettierrc.js ADDED
@@ -0,0 +1,226 @@
1
+ module.exports = {
2
+ /**
3
+ * Print Width
4
+ * https://prettier.io/docs/en/options.html#print-width
5
+ *
6
+ * Specify the line length that the printer will wrap on.
7
+ *
8
+ * printWidth: <int>
9
+ * default: 80
10
+ */
11
+ printWidth: 80,
12
+
13
+ /**
14
+ * Tab Width
15
+ * https://prettier.io/docs/en/options.html#tab-width
16
+ *
17
+ * Specify the number of spaces per indentation-level.
18
+ *
19
+ * tabWidth: <int>
20
+ * default: 2
21
+ */
22
+ tabWidth: 2,
23
+
24
+ /**
25
+ * Tabs
26
+ * https://prettier.io/docs/en/options.html#tabs
27
+ *
28
+ * Indent lines with tabs instead of spaces.
29
+ *
30
+ * useTabs: <bool>
31
+ * default: false
32
+ */
33
+ useTabs: false,
34
+
35
+ /**
36
+ * Semicolons
37
+ * https://prettier.io/docs/en/options.html#semicolons
38
+ *
39
+ * Print semicolons at the ends of statements
40
+ *
41
+ * semi: <bool>
42
+ * default: true
43
+ */
44
+ semi: true,
45
+
46
+ /**
47
+ * Quotes
48
+ * https://prettier.io/docs/en/options.html#quotes
49
+ *
50
+ * Use single quotes instead of double quotes.
51
+ *
52
+ * singleQuote: <bool>
53
+ * default: false
54
+ */
55
+ singleQuote: false,
56
+
57
+ /**
58
+ * Quote Props
59
+ * https://prettier.io/docs/en/options.html#quote-props
60
+ *
61
+ * Change when properties in objects are quoted.
62
+ *
63
+ * quoteProps: "<as-needed|consistent|preserve>"
64
+ * default: "as-needed"
65
+ */
66
+ // quoteProps: 'as-needed',
67
+
68
+ /**
69
+ * JSX Quotes
70
+ * https://prettier.io/docs/en/options.html#jsx-quotes
71
+ *
72
+ * Use single quotes instead of double quotes in JSX.
73
+ *
74
+ * jsxSingleQuote: <bool>
75
+ * default: false
76
+ */
77
+ // jsxSingleQuote: false,
78
+
79
+ /**
80
+ * Trailing Commas
81
+ * https://prettier.io/docs/en/options.html#trailing-commas
82
+ *
83
+ * Print trailing commas wherever possible when multi-line. (A single-line array, for example, never gets trailing commas.)
84
+ *
85
+ * trailingComma: "<es5|none|all>"
86
+ * default: 'es5'
87
+ */
88
+ trailingComma: "es5",
89
+
90
+ /**
91
+ * Bracket Spacing
92
+ * https://prettier.io/docs/en/options.html#bracket-spacing
93
+ *
94
+ * Print spaces between brackets in object literals.
95
+ *
96
+ * bracketSpacing: <bool>
97
+ * default: true
98
+ */
99
+ bracketSpacing: true,
100
+
101
+ /**
102
+ * JSX Brackets
103
+ * https://prettier.io/docs/en/options.html#jsx-brackets
104
+ *
105
+ * Put the > of a multi-line JSX element at the end of the last line instead of being alone on the next line (does not apply to self closing elements).
106
+ *
107
+ * jsxBracketSameLine: <bool>
108
+ * default: false
109
+ */
110
+ // jsxBracketSameLine: false,
111
+
112
+ /**
113
+ * Arrow Function Parentheses
114
+ * https://prettier.io/docs/en/options.html#arrow-function-parentheses
115
+ *
116
+ * Include parentheses around a sole arrow function parameter.
117
+ *
118
+ * arrowParens: "<always|avoid>"
119
+ * default: "always"
120
+ */
121
+ arrowParens: "always",
122
+
123
+ /**
124
+ * Range
125
+ * https://prettier.io/docs/en/options.html#range
126
+ *
127
+ * Format only a segment of a file.
128
+ *
129
+ * rangeStart: <int>
130
+ * default: 0
131
+ *
132
+ * rangeEnd: <int>
133
+ * default: Infinity
134
+ */
135
+ // rangeStart: 0,
136
+ // rangeEnd: Infinity,
137
+
138
+ /**
139
+ * Parser
140
+ * https://prettier.io/docs/en/options.html#parser
141
+ *
142
+ * Specify which parser to use.
143
+ *
144
+ * parser: "<string>" | require("./my-parser")
145
+ * no default
146
+ *
147
+ */
148
+ // parser: '',
149
+
150
+ /**
151
+ * File Path
152
+ * https://prettier.io/docs/en/options.html#file-path
153
+ *
154
+ * Specify the file name to use to infer which parser to use.
155
+ *
156
+ * filepath: "<string>"
157
+ * no default
158
+ */
159
+ // filepath: '',
160
+
161
+ /**
162
+ * Require pragma
163
+ * https://prettier.io/docs/en/options.html#require-pragma
164
+ *
165
+ * Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file. This is very useful when gradually transitioning large, unformatted codebases to prettier.
166
+ *
167
+ * requirePragma: <bool>
168
+ * default: false
169
+ */
170
+ // requirePragma: false,
171
+
172
+ /**
173
+ * Insert Pragma
174
+ * https://prettier.io/docs/en/options.html#insert-pragma
175
+ *
176
+ * Prettier can insert a special @format marker at the top of files specifying that the file has been formatted with prettier. This works well when used in tandem with the --require-pragma option. If there is already a docblock at the top of the file then this option will add a newline to it with the @format marker.
177
+ *
178
+ * insertPragma: <bool>
179
+ * default: false
180
+ */
181
+ // insertPragma: false,
182
+
183
+ /**
184
+ * Prose Wrap
185
+ * https://prettier.io/docs/en/options.html#prose-wrap
186
+ *
187
+ * By default, Prettier will wrap markdown text as-is since some services use a linebreak-sensitive renderer, e.g. GitHub comment and BitBucket. In some cases you may want to rely on editor/viewer soft wrapping instead, so this option allows you to opt out with "never".
188
+ *
189
+ * proseWrap: "<always|never|preserve>"
190
+ * default: "preserve"
191
+ */
192
+ // proseWrap: 'preserve',
193
+
194
+ /**
195
+ * HTML Whitespace Sensitivity
196
+ * https://prettier.io/docs/en/options.html#html-whitespace-sensitivity
197
+ *
198
+ * Specify the global whitespace sensitivity for HTML files, see whitespace-sensitive formatting for more info.
199
+ *
200
+ * htmlWhitespaceSensitivity: "<css|strict|ignore>"
201
+ * default: "css"
202
+ */
203
+ // htmlWhitespaceSensitivity: 'css',
204
+
205
+ /**
206
+ * Vue files script and style tags indentation
207
+ * https://prettier.io/docs/en/options.html#vue-files-script-and-style-tags-indentation
208
+ *
209
+ * Whether or not to indent the code inside <script> and <style> tags in Vue files. Some people (like the creator of Vue) don’t indent to save an indentation level, but this might break code folding in your editor.
210
+ *
211
+ * vueIndentScriptAndStyle: <bool>
212
+ * default: false
213
+ */
214
+ // vueIndentScriptAndStyle: false,
215
+
216
+ /**
217
+ * End of Line
218
+ * https://prettier.io/docs/en/options.html#end-of-line
219
+ *
220
+ * For historical reasons, there exist two common flavors of line endings in text files. That is \n (or LF for Line Feed) and \r\n (or CRLF for Carriage Return + Line Feed). The former is common on Linux and macOS, while the latter is prevalent on Windows. Some details explaining why it is so can be found on Wikipedia.
221
+ *
222
+ * endOfLine: "<lf|crlf|cr|auto>"
223
+ * default: "lf"
224
+ */
225
+ // endOfLine: 'lf',
226
+ };
package/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org>
package/dist/a11y.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare class A11y {
2
+ constructor();
3
+ private addGroupRole;
4
+ private addRequired;
5
+ private addLabel;
6
+ }
package/dist/a11y.js ADDED
@@ -0,0 +1,46 @@
1
+ // a11y means accessibility
2
+ // This Component is supposed to be used as a helper for Aria Attributes & Other Accessibility Features
3
+ export class A11y {
4
+ constructor() {
5
+ this.addRequired();
6
+ this.addLabel();
7
+ this.addGroupRole();
8
+ }
9
+ addGroupRole() {
10
+ // Add role="group" to all EN Radio fields
11
+ const radioFields = document.querySelectorAll(".en__field--radio");
12
+ radioFields.forEach((field) => {
13
+ field.setAttribute("role", "group");
14
+ // Add random ID to the label
15
+ const label = field.querySelector("label");
16
+ if (label) {
17
+ label.setAttribute("id", `en__field__label--${Math.random().toString(36).slice(2, 7)}`);
18
+ field.setAttribute("aria-labelledby", label.id);
19
+ }
20
+ });
21
+ }
22
+ addRequired() {
23
+ const mandatoryFields = document.querySelectorAll(".en__mandatory .en__field__input");
24
+ mandatoryFields.forEach((field) => {
25
+ field.setAttribute("aria-required", "true");
26
+ });
27
+ }
28
+ addLabel() {
29
+ const otherAmount = document.querySelector(".en__field__input--otheramount");
30
+ if (otherAmount) {
31
+ otherAmount.setAttribute("aria-label", "Enter your custom donation amount");
32
+ }
33
+ // Split selects usually don't have a label, so let's make the first option the label
34
+ const splitSelects = document.querySelectorAll(".en__field__input--splitselect");
35
+ splitSelects.forEach((select) => {
36
+ var _a, _b, _c, _d;
37
+ const firstOption = select.querySelector("option");
38
+ if (firstOption &&
39
+ firstOption.value === "" &&
40
+ !((_b = (_a = firstOption.textContent) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("select")) &&
41
+ !((_d = (_c = firstOption.textContent) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === null || _d === void 0 ? void 0 : _d.includes("choose"))) {
42
+ select.setAttribute("aria-label", firstOption.textContent || "");
43
+ }
44
+ });
45
+ }
46
+ }
@@ -0,0 +1,5 @@
1
+ export declare class AddNameToMessage {
2
+ constructor();
3
+ shouldRun(): boolean;
4
+ replaceNameShortcode(fName: string, lName: string): void;
5
+ }
@@ -0,0 +1,49 @@
1
+ /*
2
+ Adds first and last name when First Name and Last Name fields lose focus if name shortcodes aren't present
3
+ */
4
+ import { ENGrid } from ".";
5
+ export class AddNameToMessage {
6
+ constructor() {
7
+ if (!this.shouldRun()) {
8
+ // Don't run the script if the page isn't email to target
9
+ return;
10
+ }
11
+ this.replaceNameShortcode("#en__field_supporter_firstName", "#en__field_supporter_lastName");
12
+ }
13
+ shouldRun() {
14
+ return ENGrid.getPageType() === "EMAILTOTARGET";
15
+ }
16
+ replaceNameShortcode(fName, lName) {
17
+ const firstName = document.querySelector(fName);
18
+ const lastName = document.querySelector(lName);
19
+ let message = document.querySelector('[name="contact.message"]');
20
+ let addedFirstName = false;
21
+ let addedLastName = false;
22
+ if (message) {
23
+ if (message.value.includes("{user_data~First Name") ||
24
+ message.value.includes("{user_data~Last Name")) {
25
+ return;
26
+ }
27
+ else {
28
+ if (!message.value.includes("{user_data~First Name") && firstName) {
29
+ firstName.addEventListener("blur", (e) => {
30
+ const target = e.target;
31
+ if (message && !addedFirstName) {
32
+ addedFirstName = true;
33
+ message.value = message.value.concat("\n" + target.value);
34
+ }
35
+ });
36
+ }
37
+ if (!message.value.includes("{user_data~Last Name") && lastName) {
38
+ lastName.addEventListener("blur", (e) => {
39
+ const target = e.target;
40
+ if (message && !addedLastName) {
41
+ addedLastName = true;
42
+ message.value = message.value.concat(" " + target.value);
43
+ }
44
+ });
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,7 @@
1
+ export declare class Advocacy {
2
+ private logger;
3
+ constructor();
4
+ shoudRun(): boolean;
5
+ setClickableLabels(): void;
6
+ toggleCheckbox(contact: HTMLElement): void;
7
+ }
@@ -0,0 +1,34 @@
1
+ // Component to handle advocacy features
2
+ // 1 - Adds EN Polyfill to support "label" clicking on Advocacy Recipient "labels"
3
+ import { ENGrid, EngridLogger } from ".";
4
+ export class Advocacy {
5
+ constructor() {
6
+ this.logger = new EngridLogger("Advocacy", "#232323", "#f7b500", "👨‍⚖️");
7
+ if (!this.shoudRun())
8
+ return;
9
+ this.setClickableLabels();
10
+ }
11
+ shoudRun() {
12
+ return ["ADVOCACY", "EMAILTOTARGET"].includes(ENGrid.getPageType());
13
+ }
14
+ setClickableLabels() {
15
+ const contactItems = document.querySelectorAll(".en__contactDetails__rows");
16
+ if (!contactItems)
17
+ return;
18
+ contactItems.forEach((contact) => {
19
+ contact.addEventListener("click", (e) => {
20
+ this.toggleCheckbox(contact);
21
+ });
22
+ });
23
+ }
24
+ toggleCheckbox(contact) {
25
+ const wrapper = contact.closest(".en__contactDetails");
26
+ if (!wrapper)
27
+ return;
28
+ const checkbox = wrapper.querySelector("input[type='checkbox']");
29
+ if (!checkbox)
30
+ return;
31
+ this.logger.log("toggleCheckbox", checkbox.checked);
32
+ checkbox.checked = !checkbox.checked;
33
+ }
34
+ }
@@ -0,0 +1,6 @@
1
+ export declare class AmountLabel {
2
+ private _frequency;
3
+ constructor();
4
+ shouldRun(): boolean;
5
+ fixAmountLabels(): void;
6
+ }
@@ -0,0 +1,29 @@
1
+ // This script checks if the donations amounts are numbers and if they are, appends the correct currency symbol
2
+ import { DonationFrequency, ENGrid } from ".";
3
+ export class AmountLabel {
4
+ constructor() {
5
+ this._frequency = DonationFrequency.getInstance();
6
+ if (!this.shouldRun()) {
7
+ // If we're not on a Donation Page, get out
8
+ return;
9
+ }
10
+ this._frequency.onFrequencyChange.subscribe((s) => window.setTimeout(this.fixAmountLabels.bind(this), 100));
11
+ // Run the main function on page load so we can analyze the amounts of the current frequency
12
+ window.setTimeout(this.fixAmountLabels.bind(this), 300);
13
+ }
14
+ // Should we run the script?
15
+ shouldRun() {
16
+ return !!(ENGrid.getPageType() === "DONATION" &&
17
+ ENGrid.getOption("AddCurrencySymbol"));
18
+ }
19
+ // Fix Amount Labels
20
+ fixAmountLabels() {
21
+ let amounts = document.querySelectorAll(".en__field--donationAmt label");
22
+ const currencySymbol = ENGrid.getCurrencySymbol() || "";
23
+ amounts.forEach((element) => {
24
+ if (!isNaN(element.innerText)) {
25
+ element.innerText = currencySymbol + element.innerText;
26
+ }
27
+ });
28
+ }
29
+ }
package/dist/app.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { ENGrid, Options } from ".";
2
+ export declare class App extends ENGrid {
3
+ private _form;
4
+ private _fees;
5
+ private _amount;
6
+ private _frequency;
7
+ private _country;
8
+ private _dataLayer;
9
+ private options;
10
+ private logger;
11
+ constructor(options: Options);
12
+ private run;
13
+ private onLoad;
14
+ private onResize;
15
+ private onValidate;
16
+ private onSubmit;
17
+ private onError;
18
+ static log(message: string): void;
19
+ }