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