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,391 @@
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 InPageNavigation : Content must be defined and set to a DOM selector or Node"]
10
+ },
11
+ {
12
+ setting : "onClicked",
13
+ isRequired : false,
14
+ validate : "type",
15
+ possibleValues : ["function"],
16
+ errorMessage : ["GDK InPageNavigation : onClicked must be a function"]
17
+ },
18
+ {
19
+ setting : "startingPos",
20
+ isRequired : false,
21
+ validate : "type",
22
+ possibleValues : ["number"],
23
+ errorMessage : ["GDK InPageNavigation : startingPos must be set to a number"]
24
+ },
25
+ {
26
+ setting : "autoHide",
27
+ isRequired : false,
28
+ validate : "type",
29
+ possibleValues : ["boolean"],
30
+ errorMessage : ["GDK InPageNavigation : autoHide must be set to be boolean. Default value is False."]
31
+ }
32
+ ];
33
+
34
+ class InPageNavigation{
35
+
36
+ /**
37
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
38
+ * @param {string|Object} content
39
+ * A reference to the html 'in page navigation' node
40
+ *
41
+ * @param {function} [onClicked]
42
+ * Callback function fired once a 'in-page-item' is clicked
43
+ *
44
+ * @param {number} [startingPos=1]
45
+ * The number of the navigation item to display on initialization
46
+ */
47
+
48
+ constructor(options) {
49
+
50
+ this._internalVars = {
51
+ node: null,//used for content item
52
+ navItem: null,
53
+ marker: null
54
+ };
55
+
56
+ //options with defaults set
57
+ this._defaults = {
58
+ startingPos: 1,
59
+ autoHide: false
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
+ setStartPosition.call(this);
73
+ }
74
+ }
75
+
76
+ //Public Methods
77
+
78
+
79
+ /**
80
+ * @param {number} [newIndex]
81
+ * newIndex is the number of the navigation item to go to first on initialization
82
+ */
83
+ goTo(newIndex){
84
+
85
+ let index = newIndex - 1;
86
+
87
+ Array.prototype.map.call(this._internalVars.navItem, (e, rank)=> {
88
+ if(rank===index){
89
+ e.classList.add("in-page-item--selected");
90
+
91
+ let topPosition = e.offsetTop;
92
+ let nodeHeight = e.offsetHeight;
93
+
94
+ // set marker to correct position
95
+ this._internalVars.marker.style.top = topPosition + "px";
96
+ this._internalVars.marker.style.height = nodeHeight + "px";
97
+ } else {
98
+ e.classList.remove("in-page-item--selected");
99
+ }
100
+ });
101
+ }
102
+
103
+ /**
104
+ * destroy()
105
+ * removes the node from the dom and any events attached
106
+ */
107
+ destroy(){
108
+ removeEvents.call(this);
109
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
110
+
111
+ //a little garbage collection
112
+ for (var variableKey in this){
113
+ if (this.hasOwnProperty(variableKey)){
114
+ delete this[variableKey];
115
+ }
116
+ }
117
+ }
118
+
119
+ }
120
+
121
+ // Private Methods
122
+
123
+ /**
124
+ * setLocalVars()
125
+ * set all the local vars to passed in options
126
+ */
127
+ function setLocalVars() {
128
+ //determine the type of content passed in
129
+ if(this._internalVars.contentType === 'string'){
130
+ this._internalVars.node = document.querySelector(this._options.content);
131
+ }else if(this._internalVars.contentType === 'domNode'){
132
+ this._internalVars.node = this._options.content;
133
+ }
134
+
135
+ this._internalVars.node.insertAdjacentHTML('beforeend', `<li class="in-page-marker"></li>`);
136
+
137
+ this._internalVars.navItem = this._internalVars.node.querySelectorAll(".in-page-item");
138
+ this._internalVars.marker = this._internalVars.node.querySelector(".in-page-marker");
139
+
140
+ this._internalVars.navId = this._internalVars.node.id;
141
+
142
+ this._internalVars.backgroundItems = [];
143
+ this._internalVars.backgroundItemsTop = [];
144
+ this._internalVars.backgroundItemsBottom = [];
145
+
146
+ this._internalVars.backgroundItemsDefined = false;
147
+
148
+ this._internalVars.handler = inPageItemClickHandler.bind(this);
149
+ }
150
+
151
+
152
+ /**
153
+ * setEvents()
154
+ * Sets all the events needed for the component
155
+ */
156
+ function setEvents() {
157
+
158
+ let eventName = "click";
159
+
160
+ //set click events
161
+ Array.prototype.forEach.call(this._internalVars.navItem, (el, i)=>{
162
+ el.addEventListener(eventName,this._internalVars.handler);
163
+ });
164
+
165
+ window.addEventListener('scroll', scrollPosition.bind(this));
166
+ window.addEventListener('scroll', checkNode.bind(this));
167
+ }
168
+
169
+
170
+ /**
171
+ * removeEvents()
172
+ * removes all events from the component
173
+ */
174
+ function removeEvents() {
175
+
176
+ let eventName = "click";
177
+
178
+ //remove click events
179
+ Array.prototype.forEach.call(this._internalVars.navItem, (el, i)=>{
180
+ el.removeEventListener(eventName,this._internalVars.handler);
181
+ });
182
+ }
183
+
184
+ /**
185
+ * if In Page Navigation Node exists, run processes
186
+ */
187
+ function checkNode() {
188
+ if(document.getElementById(this._internalVars.navId)) {
189
+ defineBackgroundItems.call(this);
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Create array of all items with a bg or gradient background spanning the full width of the page
195
+ */
196
+ function defineBackgroundItems() {
197
+ if (this._internalVars.backgroundItemsDefined === false) {
198
+ let gradientItems = document.querySelectorAll('.bg-gradient'),
199
+ coloredItems = document.querySelectorAll('.bg-color'),
200
+ crossSellItems = document.querySelectorAll('.cross-sell-image');
201
+
202
+ Array.prototype.forEach.call(gradientItems, (el)=> {
203
+ if (el.clientWidth === document.body.scrollWidth) {
204
+ this._internalVars.backgroundItems.push(el);
205
+ }
206
+ });
207
+
208
+ Array.prototype.forEach.call(coloredItems, (el)=> {
209
+ if (el.clientWidth === document.body.scrollWidth) {
210
+ this._internalVars.backgroundItems.push(el);
211
+ }
212
+ });
213
+
214
+ Array.prototype.forEach.call(crossSellItems, (el)=> {
215
+ if (el.clientWidth === document.body.scrollWidth) {
216
+ this._internalVars.backgroundItems.push(el);
217
+ }
218
+ });
219
+
220
+ this._internalVars.backgroundItemsDefined = true;
221
+ }
222
+ checkBackgroundItems.call(this);
223
+ }
224
+
225
+ function checkBackgroundItems() {
226
+ this._internalVars.backgroundItemsTop = [];
227
+ this._internalVars.backgroundItemsBottom = [];
228
+ Array.prototype.forEach.call(this._internalVars.backgroundItems, (el)=> {
229
+ let top = $(el).offset().top - window.pageYOffset,
230
+ bottom = top + el.clientHeight;
231
+ if(top > 0 && top < window.innerHeight ) {
232
+ addBackgroundItemsToArray.call(this, el);
233
+ } else if (bottom > 0 && bottom < window.innerHeight) {
234
+ addBackgroundItemsToArray.call(this, el);
235
+ }
236
+ });
237
+ changeNavItemColor.call(this);
238
+ }
239
+
240
+ function addBackgroundItemsToArray(el) {
241
+ let crossSellHeight = el.clientHeight / 2;
242
+
243
+ if(el.classList.contains('cross-sell-image')) {
244
+ this._internalVars.backgroundItemsTop.push($(el).offset().top + crossSellHeight);
245
+ this._internalVars.backgroundItemsBottom.push($(el).offset().top + el.clientHeight);
246
+ } else {
247
+ this._internalVars.backgroundItemsTop.push($(el).offset().top);
248
+ this._internalVars.backgroundItemsBottom.push($(el).offset().top + el.clientHeight);
249
+ }
250
+ }
251
+
252
+ function changeNavItemColor() {
253
+ Array.prototype.forEach.call(this._internalVars.navItem, (el)=> {
254
+ let top = $(el).offset().top - window.pageYOffset,
255
+ height = el.clientHeight,
256
+ changePoint = top + (height / 2),
257
+ changeColor = true;
258
+
259
+ Array.prototype.forEach.call(this._internalVars.backgroundItems, (ele, ind)=> {
260
+ if(changeColor === true) {
261
+ if (changePoint + window.pageYOffset > this._internalVars.backgroundItemsTop[ind] && changePoint + window.pageYOffset < this._internalVars.backgroundItemsBottom[ind]) {
262
+ el.classList.add('changeFontColor');
263
+ changeColor = false;
264
+ } else {
265
+ if (el.classList.contains('changeFontColor') ) {
266
+ el.classList.remove('changeFontColor');
267
+ }
268
+ }
269
+ }
270
+ });
271
+ });
272
+
273
+ let component = document.getElementById(this._internalVars.navId),
274
+ navMarker = component.querySelector('.in-page-marker'),
275
+ selected = component.querySelector('.in-page-item--selected');
276
+
277
+ if (selected.classList.contains('changeFontColor')) {
278
+ navMarker.classList.add('changeFontColor');
279
+ } else {
280
+ if (navMarker.classList.contains('changeFontColor')) {
281
+ navMarker.classList.remove('changeFontColor');
282
+ }
283
+ }
284
+ }
285
+
286
+ /**
287
+ * inPageItemClickHandler()
288
+ * Opens tab content for clicked tab and hides the rest
289
+ */
290
+ function inPageItemClickHandler(el){
291
+ el.preventDefault();
292
+ let currentNode = el.currentTarget;
293
+
294
+ // get position and height of currentNode
295
+ let topPosition = currentNode.offsetTop;
296
+ let nodeHeight = currentNode.offsetHeight;
297
+
298
+
299
+ // add selected class
300
+ Array.prototype.map.call(this._internalVars.navItem, (e, rank)=> {
301
+ if(e===currentNode){
302
+ e.classList.add("in-page-item--selected");
303
+ } else {
304
+ e.classList.remove("in-page-item--selected");
305
+ }
306
+ });
307
+
308
+ // set marker to correct position
309
+ this._internalVars.marker.style.top = topPosition + "px";
310
+ this._internalVars.marker.style.height = nodeHeight + "px";
311
+
312
+ let currentNodeSection = currentNode.getElementsByTagName("a");
313
+
314
+ if (currentNodeSection[0].hasAttribute('data-link')) {
315
+ let getDataLink = currentNodeSection[0].getAttribute("data-link");
316
+ let section = document.getElementById(getDataLink);
317
+ if (section) {
318
+ //start will adjusting this number to a negative and go from there. Will adjust position of a.
319
+ let top = -40;
320
+ let sectionTop = section.offsetTop + top;
321
+
322
+ window.scrollTo(0, sectionTop);
323
+ }
324
+
325
+ }
326
+
327
+
328
+ // fire onClicked Callback if there is one
329
+ setTimeout( ()=> {
330
+ if(this._options.onClicked)
331
+ this._options.onClicked(currentNode);
332
+ }, 10);
333
+
334
+ }
335
+
336
+ /**
337
+ * setStartPosition()
338
+ * Set starting link
339
+ */
340
+ function setStartPosition() {
341
+
342
+ let linkIndex = this._options.startingPos - 1;
343
+
344
+ if(this._options.autoHide) {
345
+ if(!this._internalVars.node.classList.contains('hidden')) {
346
+ toggleComponent.call(this);
347
+ }
348
+ }
349
+
350
+ Array.prototype.map.call(this._internalVars.navItem, (e, rank)=> {
351
+ if(rank===linkIndex){
352
+ e.classList.add("in-page-item--selected");
353
+
354
+ let topPosition = e.offsetTop;
355
+ let nodeHeight = e.offsetHeight;
356
+
357
+ this._internalVars.marker.style.top = topPosition + "px";
358
+ this._internalVars.marker.style.height = nodeHeight + "px";
359
+ }
360
+ });
361
+
362
+
363
+ }
364
+
365
+ /**
366
+ * Toggle Component Function
367
+ * Displays and hides the component
368
+ */
369
+ function toggleComponent() {
370
+ if(this._internalVars.node.classList.contains('hidden')){
371
+ this._internalVars.node.classList.remove('hidden');
372
+ }
373
+ else {
374
+ this._internalVars.node.classList.add('hidden');
375
+ }
376
+ }
377
+
378
+ function scrollPosition(){
379
+ var inPageNav = this._internalVars.node;
380
+ if (inPageNav.parentNode.parentNode.getBoundingClientRect().top - 65 < 0) {
381
+ inPageNav.style.position = "fixed";
382
+ inPageNav.style.top = window.innerHeight/2 - inPageNav.offsetHeight + "px";
383
+ } else {
384
+ inPageNav.style.position = "absolute";
385
+ inPageNav.style.top = "";
386
+ }
387
+
388
+ }
389
+
390
+ export default InPageNavigation;
391
+
@@ -0,0 +1,272 @@
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 Loader : Content must be defined and set to a DOM selector or Node"]
10
+ },
11
+ {
12
+ setting : "type",
13
+ isRequired : false,
14
+ validate : "value",
15
+ possibleValues : ["inline","section", "inline--xsmall"],
16
+ errorMessage : ["GDK Loader : Type must be defined and set to inline or section"]
17
+ },
18
+ {
19
+ setting : "autoShow",
20
+ isRequired : false,
21
+ validate : "type",
22
+ possibleValues : ["boolean"],
23
+ errorMessage : ["GDK Loader : autoShow must be a boolean"]
24
+ }
25
+
26
+ ];
27
+
28
+
29
+ const loaderLargeSVG = `
30
+ <svg class="circle-loader" width="62" height="62" version="1.1" xmlns="http://www.w3.org/2000/svg">
31
+ <circle cx="31" cy="31" r="29">
32
+ </svg>
33
+ <span class="geico-icon icon-loader-g" style="width: 60px; height: 60px; line-height: 60px; font-size: 30px;"></span>
34
+ `;
35
+
36
+
37
+
38
+ const loaderSmallSVG = `
39
+ <svg class="circle-loader" width="32" height="32" version="1.1" xmlns="http://www.w3.org/2000/svg">
40
+ <circle cx="16" cy="16" r="15">
41
+ </svg>
42
+ `;
43
+
44
+ const loaderXSmallSVG = `
45
+ <svg class="circle-loader" width="20" height="20" version="1.1" xmlns="http://www.w3.org/2000/svg">
46
+ <circle cx="10" cy="10" r="9">
47
+ </svg>
48
+ `;
49
+
50
+ class Loader{
51
+ /**
52
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
53
+ * @param {string|Object} content
54
+ * A reference to the loader. If the loader type is a section loader this should be a reference to the loader-container. If the loader type is a inline loader this should be a reference to the loader itself.
55
+ *
56
+ * @param {string} type
57
+ * Used to determine the type of loader. Options: "inline" || "section"
58
+ *
59
+ * @param {boolean} [autoShow=false]
60
+ * Use if you want to set loader to auto show when instantiated
61
+ *
62
+ */
63
+ constructor(options) {
64
+
65
+ this._internalVars = {
66
+ node: null,//used for current node
67
+ loaderDom :null,//stores reference to the loader when using a section loader
68
+ tick : 0,
69
+ loaderShouldPlay : false,
70
+ loaderSVG : null,
71
+ loaderG : null
72
+ };
73
+
74
+ //options with defaults set
75
+ this._defaults = {
76
+ autoShow : false
77
+ };
78
+
79
+ // Create options by extending defaults with the passed in arugments
80
+ if (options && typeof options === "object") {
81
+ this._options = baseComponent.extendDefaults(this._defaults, options);
82
+ }
83
+
84
+
85
+ //if the required options are valid set up the environment
86
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
87
+ this._internalVars.contentType = baseComponent.getContentType(this);
88
+ setLocalVars.call(this);
89
+ buildLoader.call(this);
90
+
91
+ if(this._options.autoShow){
92
+ this.show();
93
+ }
94
+ }
95
+
96
+ }
97
+
98
+ //Public Methods
99
+
100
+ /**
101
+ * show()
102
+ * plays and animates loader
103
+ */
104
+ show(){
105
+
106
+ this._internalVars.node.style.display = "block";
107
+ setTimeout( ()=> {
108
+
109
+ if(this._options.type === "section"){
110
+ this._internalVars.node.classList.add("section-loader--show");
111
+ this._internalVars.loaderDom.classList.add("loader--play");
112
+ }else{
113
+ this._internalVars.node.classList.add("inline-loader--show");
114
+ this._internalVars.node.classList.add("loader--play");
115
+ }
116
+
117
+ this._internalVars.loaderShouldPlay = true;
118
+ loaderAnim.call(this);
119
+
120
+ }, 10);
121
+
122
+ }
123
+
124
+ /**
125
+ * hide()
126
+ * hides and stops the loader
127
+ */
128
+ hide(){
129
+
130
+ if(this._options.type === "section"){
131
+ this._internalVars.node.classList.remove("section-loader--show");
132
+ }else{
133
+ this._internalVars.node.classList.remove("inline-loader--show");
134
+ }
135
+
136
+ setTimeout( ()=> {
137
+ this._internalVars.node.style.display = "none";
138
+
139
+ if(this._options.type === "section"){
140
+ this._internalVars.loaderDom.classList.remove("loader--play");
141
+ }else{
142
+ this._internalVars.node.classList.remove("loader--play");
143
+ }
144
+
145
+ this._internalVars.loaderShouldPlay = false;
146
+
147
+ }, 500);
148
+ }
149
+
150
+ /**
151
+ * destroy()
152
+ * removes the node from the dom and any events attached
153
+ */
154
+ destroy(){
155
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
156
+
157
+ //a little garbage collection
158
+ for (var variableKey in this){
159
+ if (this.hasOwnProperty(variableKey)){
160
+ delete this[variableKey];
161
+ }
162
+ }
163
+ }
164
+
165
+ }
166
+
167
+
168
+ /**
169
+ * setLocalVars()
170
+ * set all the local vars to passed in options
171
+ */
172
+ function setLocalVars() {
173
+ //determine the type of content passed in
174
+ if(this._internalVars.contentType === 'string'){
175
+ this._internalVars.node = document.querySelector(this._options.content);
176
+ }else if(this._internalVars.contentType === 'domNode'){
177
+ this._internalVars.node = this._options.content;
178
+ }
179
+
180
+
181
+ //if its a section loader find the loader
182
+ if(this._options.type === "section"){
183
+ this._internalVars.loaderDom = this._internalVars.node.querySelector(".loader");
184
+ this._internalVars.loaderDom.style.width = "60px";
185
+ this._internalVars.loaderDom.style.height = "60px";
186
+ this._internalVars.loaderDom.style.lineHeight = "60px";
187
+ this._internalVars.loaderDom.style.fontSize = "60px";
188
+ }
189
+ }
190
+
191
+
192
+ /**
193
+ * buildLoader()
194
+ * Adds markup and classes this component
195
+ */
196
+ function buildLoader() {
197
+
198
+ if(this._options.type === "section"){
199
+ this._internalVars.loaderDom.classList.add("loader--large");
200
+ this._internalVars.loaderDom.insertAdjacentHTML('afterBegin', loaderLargeSVG);
201
+
202
+ this._internalVars.dashOffsetEnd = 180;
203
+ this._internalVars.dashArrayComplete = 183;
204
+ this._internalVars.dashArrayEnd = 153;
205
+ this._internalVars.tickSpeed = 1;
206
+
207
+ }else if(this._options.type === "inline"){
208
+ this._internalVars.node.classList.add("loader--small");
209
+ this._internalVars.node.insertAdjacentHTML('afterBegin', loaderSmallSVG);
210
+
211
+ this._internalVars.dashOffsetEnd = 92;
212
+ this._internalVars.dashArrayComplete = 95;
213
+ this._internalVars.dashArrayEnd = 153;
214
+ this._internalVars.tickSpeed = 1.5;
215
+
216
+ } else if (this._options.type === "inline--xsmall") {
217
+ this._internalVars.node.classList.add("loader--small");
218
+ this._internalVars.node.insertAdjacentHTML('afterBegin', loaderXSmallSVG);
219
+
220
+ this._internalVars.dashOffsetEnd = 62;
221
+ this._internalVars.dashArrayComplete = 65;
222
+ this._internalVars.dashArrayEnd = 153;
223
+ this._internalVars.tickSpeed = 1.5;
224
+ }
225
+
226
+ this._internalVars.loaderSVG = this._internalVars.node.querySelector(".circle-loader");
227
+
228
+ }
229
+
230
+
231
+ function loaderAnim() {
232
+ this._internalVars.tick += this._internalVars.tickSpeed;
233
+
234
+ if(this._internalVars.tick > 100) {
235
+ this._internalVars.tick = 0;
236
+ }
237
+
238
+ let t = this._internalVars.tick/100;
239
+ let offsetStrokeDashOffset = easeInCubic(t,0,-this._internalVars.dashOffsetEnd,1);
240
+ let offsetStrokeDasharray = easeInCubic(t,0,this._internalVars.dashArrayEnd,1);
241
+
242
+ this._internalVars.loaderSVG.style.strokeDashoffset = offsetStrokeDashOffset;
243
+ this._internalVars.loaderSVG.style.strokeDasharray = `${offsetStrokeDasharray} , ${this._internalVars.dashArrayComplete}`;
244
+
245
+
246
+
247
+ if(this._internalVars.loaderShouldPlay){
248
+ requestAnimationFrame(loaderAnim.bind(this));
249
+ }
250
+
251
+ }
252
+
253
+
254
+ /**
255
+ * easeInQuad()
256
+ * Quadratic easing
257
+ */
258
+ function easeInQuad(t, b, c, d) {
259
+ var ts=(t/=d)*t;
260
+ return b+c*(ts);
261
+ }
262
+ /**
263
+ * easeInCubic()
264
+ * Cubic easing
265
+ */
266
+ function easeInCubic(t, b, c, d) {
267
+ var ts=(t/=d)*t*t;
268
+ return b+c*(ts);
269
+ }
270
+
271
+
272
+ export default Loader;