geico-design-kit 7.0.0

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.

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,206 @@
1
+ import baseComponent from '../../src/baseComponent';
2
+ import UserAgentService from '../../src/services/UserAgentService';
3
+
4
+ const validateSettings = [
5
+ {
6
+ setting : "content",
7
+ isRequired : true,
8
+ validate : "type",
9
+ possibleValues : ["string","object"],
10
+ errorMessage : ["GDK DotNavigation : Content must be defined and set to a DOM selector or Node"]
11
+ },
12
+ {
13
+ setting : "onClicked",
14
+ isRequired : false,
15
+ validate : "type",
16
+ possibleValues : ["function"],
17
+ errorMessage : ["GDK DotNavigation : onClicked must be a function"]
18
+ },
19
+ {
20
+ setting : "startingPos",
21
+ isRequired : false,
22
+ validate : "type",
23
+ possibleValues : ["number"],
24
+ errorMessage : ["GDK DotNavigation : startingPos must be set to a number"]
25
+ }
26
+ ];
27
+
28
+ class DotNavigation{
29
+
30
+ /**
31
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
32
+ * @param {string|Object} content
33
+ * A reference to the html Dot Navigation node
34
+ *
35
+ * @param {function} [onClicked]
36
+ * Callback function fired once a item is clicked
37
+ *
38
+ * @param {number} [startingPos=1]
39
+ * The number of the navigation item to display on initialization
40
+ */
41
+ constructor(options) {
42
+
43
+ console.log("Initialized Dot Navigation");
44
+
45
+ this._internalVars = {
46
+ node: null,//used for content item
47
+ navItem: null,
48
+ svg: `<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="14px" height="14px" viewBox="0 0 16 16"preserveAspectRatio="none"><circle cx="8" cy="8" r="6.215"/></svg>`
49
+ };
50
+
51
+ //options with defaults set
52
+ this._defaults = {
53
+ startingPos: 1
54
+ };
55
+
56
+ // Create options by extending defaults with the passed in arugments
57
+ if (options && typeof options === "object") {
58
+ this._options = baseComponent.extendDefaults(this._defaults, options);
59
+ }
60
+
61
+ //if the required options are valid set up the environment
62
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
63
+ this._internalVars.contentType = baseComponent.getContentType(this);
64
+ setLocalVars.call(this);
65
+ setEvents.call(this);
66
+ setStartPosition.call(this);
67
+ }
68
+ }
69
+
70
+ //Public Methods
71
+
72
+
73
+ /**
74
+ * @param {number} newIndex
75
+ * newIndex is the number of the navigation item to display first on initialization
76
+ */
77
+ goTo(newIndex){
78
+
79
+ let index = newIndex - 1;
80
+
81
+ Array.prototype.map.call(this._internalVars.navItem, (e, rank)=> {
82
+ if(rank===index){
83
+ e.parentNode.classList.add("dot-navigation-active");
84
+ } else {
85
+ e.parentNode.classList.remove("dot-navigation-active");
86
+ }
87
+ });
88
+ }
89
+
90
+ /**
91
+ * destroy()
92
+ * removes the node from the dom and any events attached
93
+ */
94
+ destroy(){
95
+ removeEvents.call(this);
96
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
97
+
98
+ //a little garbage collection
99
+ for (var variableKey in this){
100
+ if (this.hasOwnProperty(variableKey)){
101
+ delete this[variableKey];
102
+ }
103
+ }
104
+ }
105
+
106
+ }
107
+
108
+ // Private Methods
109
+
110
+ /**
111
+ * setLocalVars()
112
+ * set all the local vars to passed in options
113
+ */
114
+ function setLocalVars() {
115
+ //determine the type of content passed in
116
+ if(this._internalVars.contentType === 'string'){
117
+ this._internalVars.node = document.querySelector(this._options.content);
118
+ }else if(this._internalVars.contentType === 'domNode'){
119
+ this._internalVars.node = this._options.content;
120
+ }
121
+
122
+ this._internalVars.navItem = this._internalVars.node.querySelectorAll("li a");
123
+
124
+ //set click events
125
+ Array.prototype.forEach.call(this._internalVars.navItem, (el, i)=>{
126
+ el.insertAdjacentHTML('beforeend', this._internalVars.svg);
127
+ });
128
+
129
+ this._internalVars.handler = dotNavigationClickHandler.bind(this);
130
+ }
131
+
132
+
133
+ /**
134
+ * setEvents()
135
+ * Sets all the events needed for the component
136
+ */
137
+ function setEvents() {
138
+
139
+ const eventName = UserAgentService._clickEventName();
140
+
141
+ //set click events
142
+ Array.prototype.forEach.call(this._internalVars.navItem, (el, i)=>{
143
+ el.addEventListener(eventName,this._internalVars.handler);
144
+ });
145
+ }
146
+
147
+
148
+ /**
149
+ * removeEvents()
150
+ * removes all events from the component
151
+ */
152
+ function removeEvents() {
153
+
154
+ const eventName = UserAgentService._clickEventName();
155
+
156
+ //remove click events
157
+ Array.prototype.forEach.call(this._internalVars.navItem, (el, i)=>{
158
+ el.removeEventListener(eventName,this._internalVars.handler);
159
+ });
160
+ }
161
+
162
+
163
+ /**
164
+ * dotNavigationClickHandler()
165
+ * Gets fired when you click on a navigation item
166
+ */
167
+ function dotNavigationClickHandler(el){
168
+ el.preventDefault();
169
+ let currentNode = el.currentTarget;
170
+ let currentIndex;
171
+ // add selected class
172
+ Array.prototype.map.call(this._internalVars.navItem, (e, rank)=> {
173
+ if(e===currentNode){
174
+ e.parentNode.classList.add("dot-navigation-active");
175
+ currentIndex = rank;
176
+ } else {
177
+ e.parentNode.classList.remove("dot-navigation-active");
178
+ }
179
+ });
180
+
181
+ // fire onClicked Callback if there is one
182
+ setTimeout( ()=> {
183
+ if(this._options.onClicked)
184
+ this._options.onClicked(currentIndex + 1);
185
+ }, 10);
186
+
187
+ }
188
+
189
+ /**
190
+ * setStartPosition()
191
+ * Set starting link
192
+ */
193
+ function setStartPosition() {
194
+
195
+ let linkIndex = this._options.startingPos - 1;
196
+
197
+ Array.prototype.map.call(this._internalVars.navItem, (e, rank)=> {
198
+ if(rank===linkIndex){
199
+ e.parentNode.classList.add("dot-navigation-active");
200
+ }
201
+ });
202
+
203
+ }
204
+
205
+
206
+ export default DotNavigation;
@@ -0,0 +1,130 @@
1
+ import appState from '../../src/appState';
2
+
3
+ import baseComponent from '../../src/baseComponent';
4
+
5
+ const validateSettings = [
6
+ {
7
+ setting : "content",
8
+ isRequired : true,
9
+ validate : "type",
10
+ possibleValues : ["string","object"],
11
+ errorMessage : ["GDK Tabs : Content must be defined and set to a DOM selector or Node"]
12
+ }
13
+ ];
14
+
15
+ class EditComponent {
16
+ /**
17
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
18
+ * @param {string|Object} content
19
+ * A reference to the edit component node
20
+ */
21
+ constructor(options) {
22
+
23
+ this._internalVars = {};
24
+
25
+ //options with defaults set
26
+ this._defaults = {
27
+
28
+ };
29
+
30
+ // Create options by extending defaults with the passed in arugments
31
+ if (options && typeof options === "object") {
32
+ this._options = baseComponent.extendDefaults(this._defaults, options);
33
+ }
34
+
35
+ //if the required options are valid set up the environment
36
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
37
+ this._internalVars.contentType = baseComponent.getContentType(this);
38
+ setLocalVars.call(this);
39
+
40
+ setEvents.call(this);
41
+
42
+ }
43
+ }
44
+
45
+ //Public Methods
46
+
47
+ /**
48
+ * removes the node from the dom and any events attached
49
+ */
50
+ destroy(){
51
+ removeEvents.call(this);
52
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
53
+
54
+ //a little garbage collection
55
+ for (var variableKey in this){
56
+ if (this.hasOwnProperty(variableKey)){
57
+ delete this[variableKey];
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ function setLocalVars() {
64
+ //determine the type of content passed in
65
+ if(this._internalVars.contentType === 'string'){
66
+ this._internalVars.node = document.querySelector(this._options.content);
67
+ }else if(this._internalVars.contentType === 'domNode'){
68
+ this._internalVars.node = this._options.content;
69
+ }
70
+ this._internalVars.editFormPlaceholder = this._internalVars.node.querySelector('.edit-form-placeholder');
71
+ this._internalVars.editForm = this._internalVars.editFormPlaceholder.querySelector('form');
72
+ this._internalVars.editBtn = this._internalVars.node.querySelector('.btn--edit-list');
73
+ this._internalVars.cancelBtn = this._internalVars.editForm.querySelector('.btn-cancel');
74
+ this._internalVars.submitBtn = this._internalVars.editForm.querySelector('.btn-submit');
75
+
76
+ this._internalVars.editHandler = expandEditForm.bind(this);
77
+ this._internalVars.cancelHandler = collapseEditForm.bind(this);
78
+ this._internalVars.submitHandler = handleFormSubmission.bind(this);
79
+ }
80
+
81
+ function init() {
82
+ this._internalVars.editFormPlaceholder.style.maxHeight = 0 + "px";
83
+ }
84
+
85
+ function setEvents() {
86
+ let eventName = 'click';
87
+ this._internalVars.editBtn.addEventListener(eventName, this._internalVars.editHandler);
88
+ // Form Controls
89
+ this._internalVars.cancelBtn.addEventListener(eventName, this._internalVars.cancelHandler);
90
+ this._internalVars.submitBtn.addEventListener(eventName, this._internalVars.submitHandler);
91
+ }
92
+
93
+ function removeEvents(){
94
+ let eventName = 'click';
95
+ this._internalVars.editBtn.addEventListener(eventName, this._internalVars.editHandler);
96
+ // Form Controls
97
+ this._internalVars.cancelBtn.addEventListener(eventName, this._internalVars.cancelHandler);
98
+ this._internalVars.submitBtn.addEventListener(eventName, this._internalVars.submitHandler);
99
+ }
100
+
101
+ function expandEditForm(event) {
102
+
103
+ let editContent = this._internalVars.editFormPlaceholder.querySelector(".edit-content");
104
+ let editPlaceholder = this._internalVars.editFormPlaceholder;
105
+
106
+ $(editPlaceholder).slideDown();
107
+
108
+ let editButton = event.currentTarget;
109
+ if(!editButton.classList.contains('hidden')) {
110
+ editButton.classList.add("hidden");
111
+ }
112
+ }
113
+ function collapseEditForm(event) {
114
+ event.preventDefault();
115
+ let editPlaceholder = this._internalVars.editFormPlaceholder;
116
+ $(editPlaceholder).slideUp();
117
+ let editButton = this._internalVars.editBtn;
118
+ if(editButton.classList.contains('hidden')) {
119
+ editButton.classList.remove("hidden");
120
+ }
121
+ }
122
+ function handleFormSubmission(event) {
123
+ event.preventDefault();
124
+ collapseEditForm.bind(this, event);
125
+ setTimeout(()=>{
126
+ this._internalVars.editForm.submit();
127
+ }, 700);
128
+ }
129
+
130
+ export default EditComponent;
@@ -0,0 +1,106 @@
1
+ import baseComponent from '../../src/baseComponent';
2
+ import UserAgentService from '../../src/services/UserAgentService';
3
+
4
+ const validateSettings = [{
5
+ setting: 'content',
6
+ isRequired: true,
7
+ validate: 'type',
8
+ possibleValues: ['string', 'object'],
9
+ errorMessage: ['GDK EditableTableDeprecated : Content must be defined and set to a DOM selector or Node']
10
+ }];
11
+
12
+ class EditableTable {
13
+ /**
14
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
15
+ * @param {string|Object} content
16
+ * A reference to the editable table with edit buttons and fields node
17
+ */
18
+ constructor(options) {
19
+ this._internalVars = {
20
+ node: null, //used for current node
21
+ editBtn: null
22
+ };
23
+
24
+ //options with defaults set
25
+ this._defaults = {};
26
+
27
+ // Create options by extending defaults with the passed in arugments
28
+ if (options && typeof options === "object") {
29
+ this._options = baseComponent.extendDefaults(this._defaults, options);
30
+ }
31
+
32
+ //if the required options are valid set up the environment
33
+ if (baseComponent.validateSettings(this._options, validateSettings)) {
34
+ this._internalVars.contentType = baseComponent.getContentType(this);
35
+ setLocalVars.call(this);
36
+ setEvents.call(this);
37
+ }
38
+ }
39
+
40
+ //Public Methods
41
+
42
+ /**
43
+ * destroy()
44
+ * removes the node from the dom and any events attached
45
+ */
46
+ destroy(){
47
+ removeEvents.call(this);
48
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
49
+
50
+ //a little garbage collection
51
+ for (var variableKey in this){
52
+ if (this.hasOwnProperty(variableKey)){
53
+ delete this[variableKey];
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ // Private Methods
60
+ function setLocalVars() {
61
+ if(this._internalVars.contentType === 'string') {
62
+ this._internalVars.node = document.querySelector(this._options.content);
63
+ } else if (this._internalVars.contentType === 'domNode') {
64
+ this._internalVars.node = this._options.content;
65
+ }
66
+
67
+ this._internalVars.editBtn = this._internalVars.node.querySelectorAll('.table--editable-non-sortable .btn');
68
+
69
+ this._internalVars.handler = toggleEdit.bind(this);
70
+ }
71
+
72
+ /**
73
+ * setEvents()
74
+ * Sets all the events needed for the component
75
+ */
76
+ function setEvents() {
77
+ const eventName = UserAgentService._clickEventName();
78
+
79
+ for(let i=0;i<this._internalVars.editBtn.length;i++){
80
+ this._internalVars.editBtn[i].addEventListener(eventName, this._internalVars.handler);
81
+ }
82
+ }
83
+
84
+ /**
85
+ * removeEvents()
86
+ * removes all events from the component
87
+ */
88
+ function removeEvents() {
89
+ const eventName = UserAgentService._clickEventName();
90
+
91
+ for(let i=0;i<this._internalVars.editBtn.length;i++){
92
+ this._internalVars.editBtn[i].removeEventListener("click", this._internalVars.handler);
93
+ }
94
+
95
+ }
96
+
97
+ function toggleEdit(e){
98
+ var currentEditBtn = e.target;
99
+ var parentTR = currentEditBtn.parentNode.parentNode;
100
+ var childrenTD = parentTR.querySelectorAll('td');
101
+ for(let i=0;i<childrenTD.length;i++){
102
+ childrenTD[i].classList.toggle("td-edit-fields");
103
+ }
104
+ }
105
+
106
+ export default EditableTable;