geico_design_kit 0.0.1-security.1 → 15.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of geico_design_kit might be problematic. Click here for more details.

Files changed (109) hide show
  1. package/.babelrc +5 -0
  2. package/LICENSE +0 -0
  3. package/alt.json +33 -0
  4. package/dist/analytics.js +119 -0
  5. package/dist/appState.js +56 -0
  6. package/dist/baseComponent.js +110 -0
  7. package/dist/components/Accordion.js +312 -0
  8. package/dist/components/AddressAutoComplete.js +220 -0
  9. package/dist/components/Alert.js +145 -0
  10. package/dist/components/BackgroundPattern.js +99 -0
  11. package/dist/components/BackgroundPatternPortfolio.js +242 -0
  12. package/dist/components/ButtonSwitch.js +236 -0
  13. package/dist/components/CardSelections.js +230 -0
  14. package/dist/components/CommonQuestionsSquares.js +169 -0
  15. package/dist/components/Confirmation.js +156 -0
  16. package/dist/components/ConsolidatedSummary.js +489 -0
  17. package/dist/components/CoverageGraph.js +201 -0
  18. package/dist/components/CreditCard.js +591 -0
  19. package/dist/components/CurrencyInput.js +302 -0
  20. package/dist/components/DatePicker.js +468 -0
  21. package/dist/components/DockedMessage.js +146 -0
  22. package/dist/components/DotNavigation.js +200 -0
  23. package/dist/components/EditComponent.js +128 -0
  24. package/dist/components/EditableTable.js +113 -0
  25. package/dist/components/InPageNavigation.js +360 -0
  26. package/dist/components/Loader.js +232 -0
  27. package/dist/components/MakePayment.js +361 -0
  28. package/dist/components/Modal.js +254 -0
  29. package/dist/components/MoreInfoButton.js +227 -0
  30. package/dist/components/MultipleSelectBox.js +217 -0
  31. package/dist/components/NavigationalBox.js +161 -0
  32. package/dist/components/Navigator.js +294 -0
  33. package/dist/components/PasswordMeter.js +201 -0
  34. package/dist/components/PayPlans.js +534 -0
  35. package/dist/components/SegmentedControl.js +327 -0
  36. package/dist/components/SortableTable.js +166 -0
  37. package/dist/components/Tabs.js +1 -0
  38. package/dist/components/TextAreaCountdown.js +219 -0
  39. package/dist/components/Timeline.js +498 -0
  40. package/dist/components/TimelineFilter.js +492 -0
  41. package/dist/components/ToTopArrow.js +153 -0
  42. package/dist/components/Tooltip.js +329 -0
  43. package/dist/components/Upsell.js +168 -0
  44. package/dist/components/VIN.js +271 -0
  45. package/dist/components/ValidateForm.js +938 -0
  46. package/dist/components/ViewMoreLess.js +191 -0
  47. package/dist/components/ZipCode.js +191 -0
  48. package/dist/components/portfolio.js +99 -0
  49. package/dist/geico-design-kit.js +141 -0
  50. package/dist/global/components.js +98 -0
  51. package/dist/global/footer.js +26 -0
  52. package/dist/global/nav.js +1257 -0
  53. package/dist/services/CharacterTypeService.js +106 -0
  54. package/dist/services/UserAgentService.js +73 -0
  55. package/dist/utils.js +79 -0
  56. package/package.json +29 -3
  57. package/src/analytics.js +82 -0
  58. package/src/appState.js +56 -0
  59. package/src/baseComponent.js +156 -0
  60. package/src/components/Accordion.js +336 -0
  61. package/src/components/AddressAutoComplete.js +236 -0
  62. package/src/components/Alert.js +135 -0
  63. package/src/components/BackgroundPattern.js +96 -0
  64. package/src/components/BackgroundPatternPortfolio.js +284 -0
  65. package/src/components/ButtonSwitch.js +241 -0
  66. package/src/components/CardSelections.js +240 -0
  67. package/src/components/CommonQuestionsSquares.js +179 -0
  68. package/src/components/Confirmation.js +160 -0
  69. package/src/components/ConsolidatedSummary.js +505 -0
  70. package/src/components/CoverageGraph.js +203 -0
  71. package/src/components/CreditCard.js +595 -0
  72. package/src/components/CurrencyInput.js +321 -0
  73. package/src/components/DatePicker.js +487 -0
  74. package/src/components/DockedMessage.js +142 -0
  75. package/src/components/DotNavigation.js +206 -0
  76. package/src/components/EditComponent.js +130 -0
  77. package/src/components/EditableTable.js +106 -0
  78. package/src/components/InPageNavigation.js +391 -0
  79. package/src/components/Loader.js +272 -0
  80. package/src/components/MakePayment.js +397 -0
  81. package/src/components/Modal.js +279 -0
  82. package/src/components/MoreInfoButton.js +243 -0
  83. package/src/components/MultipleSelectBox.js +211 -0
  84. package/src/components/NavigationalBox.js +163 -0
  85. package/src/components/Navigator.js +338 -0
  86. package/src/components/PasswordMeter.js +209 -0
  87. package/src/components/PayPlans.js +604 -0
  88. package/src/components/SegmentedControl.js +365 -0
  89. package/src/components/SortableTable.js +176 -0
  90. package/src/components/Tabs.js +0 -0
  91. package/src/components/TextAreaCountdown.js +231 -0
  92. package/src/components/Timeline.js +532 -0
  93. package/src/components/TimelineFilter.js +533 -0
  94. package/src/components/ToTopArrow.js +153 -0
  95. package/src/components/Tooltip.js +344 -0
  96. package/src/components/Upsell.js +196 -0
  97. package/src/components/VIN.js +289 -0
  98. package/src/components/ValidateForm.js +1030 -0
  99. package/src/components/ViewMoreLess.js +193 -0
  100. package/src/components/ZipCode.js +193 -0
  101. package/src/components/portfolio.js +106 -0
  102. package/src/geico-design-kit.js +144 -0
  103. package/src/global/components.js +92 -0
  104. package/src/global/footer.js +25 -0
  105. package/src/global/nav.js +1457 -0
  106. package/src/services/CharacterTypeService.js +107 -0
  107. package/src/services/UserAgentService.js +59 -0
  108. package/src/utils.js +82 -0
  109. package/README.md +0 -5
@@ -0,0 +1,289 @@
1
+ import baseComponent from '../../src/baseComponent';
2
+
3
+ const validateSettings = [
4
+ {
5
+ setting : "content",
6
+ isRequired : true,
7
+ validate : "type",
8
+ possibleValues : ["string","object"],
9
+ errorMessage : ["GDK VINCountdown : Content must be defined and set to a DOM selector or Node"]
10
+ },
11
+ {
12
+ setting : "countdownMax",
13
+ isRequired : false,
14
+ validate : "type",
15
+ possibleValues : ["number"],
16
+ errorMessage : ["GDK VINCountdown : countdownMax must be a number"]
17
+ },
18
+ {
19
+ setting : "onCharacterType",
20
+ isRequired : false,
21
+ validate : "type",
22
+ possibleValues : ["function"],
23
+ errorMessage : ["GDK VINCountdown : Content must be defined and set to a function"]
24
+ }
25
+ ];
26
+
27
+ class VINCountdown{
28
+ /**
29
+ * Refer to the design kit section of this component for JS examples and setting details.
30
+ * @param {string, Object} content
31
+ * A reference to the html textarea container node
32
+ *
33
+ * @param {number} [countdownMax=1000]
34
+ * The number of characters allowed in the textarea
35
+ *
36
+ */
37
+ constructor(options) {
38
+
39
+ this._internalVars = {
40
+ node: null,//used for content item
41
+ geicoVINCountdownContainerClass : "vin-countdown-container",
42
+ geicoVINCountdownClass : "vin-area-countdown",
43
+ geicoTextAreaGoodClass : "vin-countdown--good",
44
+ geicoTextAreaCloseClass : "vin-countdown--close",
45
+ geicoTextAreaOverClass : "vin-countdown--over",
46
+ geicoVINCountdownInfoClass : "vin-countdown-info",
47
+ geicoVINCountdownInfoTextClass : "vin-countdown-info-text",
48
+ geicoVINCountdownInfoCounterClass : "vin-countdown-info-counter",
49
+ geicoTextGoodCopy : "Characters Remaining: ",
50
+ geicoTextCloseCopy : "Characters Remaining: ",
51
+ geicoTextOverCopy : "Over by: ",
52
+ closeNum : 10,
53
+ geicoVINCountdownData : null,
54
+ count : null
55
+ };
56
+
57
+ //options with defaults set
58
+ this._defaults = {
59
+ countdownMax: 17
60
+ };
61
+
62
+ // Create options by extending defaults with the passed in arguments
63
+ if (options && typeof options === "object") {
64
+ this._options = baseComponent.extendDefaults(this._defaults, options);
65
+ }
66
+
67
+ //if the required options are valid set up the environment
68
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
69
+ this._internalVars.contentType = baseComponent.getContentType(this);
70
+ setLocalVars.call(this);
71
+ setEvents.call(this);
72
+ }
73
+ }
74
+
75
+ //Public Methods
76
+
77
+ /**
78
+ * destroy()
79
+ * removes the node from the dom and any events attached
80
+ */
81
+ destroy(){
82
+ removeEvents.call(this);
83
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
84
+
85
+ //a little garbage collection
86
+ for (var variableKey in this){
87
+ if (this.hasOwnProperty(variableKey)){
88
+ delete this[variableKey];
89
+ }
90
+ }
91
+ }
92
+
93
+ /**
94
+ * setVINLength(newLength)
95
+ * @param newLength
96
+ * sets the length of the VIN and updates the corresponding countdown number
97
+ */
98
+ setVINLength(newLength) {
99
+ if(typeof newLength === "number") {
100
+ updateVINLength.call(this, newLength);
101
+ }
102
+ }
103
+
104
+ }
105
+
106
+ // Private Methods
107
+ /**
108
+ * setEvents()
109
+ * Sets all the events needed for the component
110
+ */
111
+ function setEvents() {
112
+ this._internalVars.textArea.addEventListener("change", this._internalVars.handler);
113
+ this._internalVars.textArea.addEventListener("keyup", this._internalVars.handler);
114
+ this._internalVars.textArea.addEventListener("keydown", this._internalVars.handler);
115
+ this._internalVars.textArea.addEventListener("blur", this._internalVars.handler);
116
+ this._internalVars.textArea.addEventListener("paste", pasteHandler);
117
+ this._internalVars.textArea.addEventListener("keypress", this._internalVars.checkInputHandler);
118
+ this._internalVars.textArea.addEventListener("input", this._internalVars.replaceCharactersHandler);
119
+ }
120
+
121
+ /**
122
+ * removeEvents()
123
+ * removes all events from the component
124
+ */
125
+ function removeEvents() {
126
+ this._internalVars.textArea.removeEventListener("change", this._internalVars.handler);
127
+ this._internalVars.textArea.removeEventListener("keyup", this._internalVars.handler);
128
+ this._internalVars.textArea.removeEventListener("keydown", this._internalVars.handler);
129
+ this._internalVars.textArea.removeEventListener("blur", this._internalVars.handler);
130
+ this._internalVars.textArea.removeEventListener("paste", pasteHandler);
131
+ this._internalVars.textArea.removeEventListener("keypress", this._internalVars.checkInputHandler);
132
+ this._internalVars.textArea.removeEventListener("input", this._internalVars.replaceCharactersHandler);
133
+ }
134
+
135
+ function checkInputValue(evt) {
136
+ if(this._options.onCharacterType){
137
+ this._options.onCharacterType();
138
+ }
139
+ }
140
+
141
+ function updateVINLength(newLength) {
142
+ this._options.countdownMax = newLength;
143
+ this._internalVars.countdownInfoCounter.innerHTML = newLength - this._internalVars.textArea.value.length;
144
+ this._internalVars.textArea.setAttribute("maxlength", newLength);
145
+ }
146
+
147
+ /**
148
+ * pasteHandler()
149
+ * triggers a keydown event on paste
150
+ */
151
+ function pasteHandler(evt){
152
+ var _this = evt.currentTarget;
153
+ setTimeout(function() {
154
+ let event = document.createEvent('HTMLEvents');
155
+ event.initEvent('keydown', true, false);
156
+ _this.dispatchEvent(event);
157
+ }, 10);
158
+ }
159
+
160
+ /**
161
+ * updateCountdown()
162
+ * updates the countdown text and counter
163
+ */
164
+ function updateCountdown(evt){
165
+ var _this = evt.currentTarget;
166
+ var container = _this.parentNode;
167
+ var text = _this.value;
168
+ var remaining = this._options.countdownMax - text.length;
169
+
170
+ if(remaining < 0){
171
+
172
+ this._internalVars.countdownInfoText.textContent = this._internalVars.geicoTextOverCopy;
173
+ this._internalVars.countdownInfoTextCurrent = this._internalVars.geicoTextOverCopy;
174
+ container.classList.remove(this._internalVars.geicoTextAreaCloseClass);
175
+ container.classList.add(this._internalVars.geicoTextAreaOverClass);
176
+
177
+ }else if(remaining < 10){
178
+
179
+ this._internalVars.countdownInfoText.textContent = this._internalVars.geicoTextCloseCopy;
180
+ this._internalVars.countdownInfoTextCurrent = this._internalVars.geicoTextCloseCopy;
181
+ container.classList.remove(this._internalVars.geicoTextAreaGoodClass);
182
+ container.classList.remove(this._internalVars.geicoTextAreaOverClass);
183
+ container.classList.add(this._internalVars.geicoTextAreaCloseClass);
184
+
185
+ }else if( this._internalVars.countdownInfoTextCurrent === this._internalVars.geicoTextCloseCopy || this._internalVars.countdownInfoTextCurrent === this._internalVars.geicoTextOverCopy ){
186
+
187
+ this._internalVars.countdownInfoText.textContent = this._internalVars.geicoTextGoodCopy;
188
+ this._internalVars.countdownInfoTextCurrent = this._internalVars.geicoTextGoodCopy;
189
+ container.classList.remove(this._internalVars.geicoTextAreaCloseClass);
190
+ container.classList.remove(this._internalVars.geicoTextAreaOverClass);
191
+ container.classList.add(this._internalVars.geicoTextAreaGoodClass);
192
+
193
+ }
194
+
195
+
196
+ updateRemaining.call(this,remaining, text.length, this._options.countdownMax, this._internalVars.countdownInfoCounter);
197
+
198
+ }
199
+
200
+ /**
201
+ * updateRemaining()
202
+ * updates the remaining characters left
203
+ */
204
+ function updateRemaining(remaining, tl, countdown, countdownInfoCounter) {
205
+ var val = remaining;
206
+
207
+ if(remaining === 0)
208
+ val = 0;
209
+ else if(remaining < 0)
210
+ val = tl - countdown;
211
+
212
+ countdownInfoCounter.textContent = val;
213
+ }
214
+
215
+ /**
216
+ * setLocalVars()
217
+ * set all the local vars to passed in options
218
+ */
219
+ function setLocalVars() {
220
+ //determine the type of content passed in
221
+ if(this._internalVars.contentType === 'string'){
222
+ this._internalVars.node = document.querySelector(this._options.content);
223
+ }else if(this._internalVars.contentType === 'domNode'){
224
+ this._internalVars.node = this._options.content;
225
+ }
226
+
227
+ //node to hold status text
228
+ let infoText = document.createElement("SPAN");
229
+ infoText.classList.add(this._internalVars.geicoVINCountdownInfoTextClass);
230
+
231
+ //node to hold count of characters left
232
+ let infoCounter = document.createElement("SPAN");
233
+ infoCounter.classList.add(this._internalVars.geicoVINCountdownInfoCounterClass);
234
+
235
+ //node to hold count of characters left
236
+ let countdownInfo = document.createElement("DIV");
237
+ countdownInfo.classList.add(this._internalVars.geicoVINCountdownInfoClass);
238
+ countdownInfo.setAttribute('aria-live', 'polite');
239
+ countdownInfo.setAttribute('aria-atomic', 'true');
240
+
241
+ //add the text and counter to the container
242
+ countdownInfo.appendChild(infoText);
243
+ countdownInfo.appendChild(infoCounter);
244
+
245
+ //append the container to the node
246
+ this._internalVars.node.appendChild(countdownInfo);
247
+ //set initial class for container
248
+ this._internalVars.node.classList.add(this._internalVars.geicoTextAreaGoodClass);
249
+
250
+ //get access to the textarea, counter and counter info for future reference
251
+ this._internalVars.textArea = this._internalVars.node.querySelector("." + this._internalVars.geicoVINCountdownClass);
252
+ this._internalVars.countdownInfoText = this._internalVars.node.querySelector("." + this._internalVars.geicoVINCountdownInfoTextClass);
253
+ this._internalVars.countdownInfoCounter = this._internalVars.node.querySelector("." + this._internalVars.geicoVINCountdownInfoCounterClass);
254
+ this._internalVars.countdownInfoTextCurrent = this._internalVars.geicoTextGoodCopy;
255
+
256
+
257
+ this._internalVars.countdownInfoCounter.textContent = this._options.countdownMax;
258
+ this._internalVars.countdownInfoText.textContent = this._internalVars.countdownInfoTextCurrent;
259
+
260
+ this._internalVars.handler = updateCountdown.bind(this);
261
+ this._internalVars.replaceCharactersHandler = replaceCharacters.bind(this);
262
+ this._internalVars.checkInputHandler = checkInputValue.bind(this);
263
+
264
+
265
+
266
+ }
267
+
268
+ function replaceCharacters() {
269
+ let entryArray = this._internalVars.textArea.value.split('');
270
+ let convertedArray = [];
271
+
272
+ Array.prototype.forEach.call(entryArray, (el)=> {
273
+ if (el === 'i' || el === 'I') {
274
+ convertedArray.push('1');
275
+ } else if (el === 'o' || el === 'O') {
276
+ convertedArray.push('0');
277
+ } else if (el === 'q' || el === 'Q') {
278
+ convertedArray.push('0');
279
+ } else {
280
+ convertedArray.push(el);
281
+ }
282
+ });
283
+
284
+ let entry = convertedArray.join('');
285
+ this._internalVars.textArea.value = entry;
286
+
287
+ }
288
+
289
+ export default VINCountdown;