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,365 @@
1
+ //Module Imports
2
+ import baseComponent from '../../src/baseComponent';
3
+ import UserAgentService from '../../src/services/UserAgentService';
4
+
5
+ var interact = require('interact.js');
6
+
7
+ const validateSettings = [
8
+ {
9
+ setting : "content",
10
+ isRequired : true,
11
+ validate : "type",
12
+ possibleValues : ["string","object"],
13
+ errorMessage : ["GDK Segmented Control : Segmented Control must be defined and set to a DOM selector or Node"]
14
+ },
15
+ {
16
+ setting : "initialActive",
17
+ isRequired : false,
18
+ validate : "type",
19
+ possibleValues : ["number"],
20
+ errorMessage : ["GDK Segmented Control : initialActive must be set to a number"]
21
+ },
22
+ {
23
+ setting : "segmentedControlChange",
24
+ isRequired : false,
25
+ validate : "type",
26
+ possibleValues : ["function"],
27
+ errorMessage : ["GDK Segmented Control : segmentedControlChange must be a defined and set function"]
28
+ }
29
+ ];
30
+
31
+ class SegmentedControl {
32
+ /**
33
+ * Refer to the design kit section of this component for JS examples and setting details.
34
+ * @param {string, Object} content
35
+ * A reference to the segmented control component node
36
+ *
37
+ * @param {number} [initialActive=1]
38
+ * The number of the item to set as the active selection on initialization. Must be greater than 0 and equal to or less than the number of segment options
39
+ *
40
+ * @param {function} [segmentedControlChange]
41
+ * A callback function that is triggered when the Segmented Control selection is changed
42
+ */
43
+ constructor(options) {
44
+
45
+ this._internalVars = {};
46
+
47
+ //options with defaults set
48
+ this._defaults = {
49
+ initialActive: 1
50
+ };
51
+
52
+ // Create options by extending defaults with the passed in arugments
53
+ if (options && typeof options === "object") {
54
+ this._options = baseComponent.extendDefaults(this._defaults, options);
55
+ }
56
+
57
+ //if the required options are valid set up the environment
58
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
59
+ this._internalVars.contentType = baseComponent.getContentType(this);
60
+ setLocalVars.call(this);
61
+ init.call(this);
62
+ setEvents.call(this);
63
+
64
+ Array.prototype.forEach.call(this._internalVars.dropZoneObject, (element)=>{
65
+ element.setAttribute('role', 'switch');
66
+ if(element.classList.contains('active')){
67
+ element.setAttribute('aria-checked', 'true');
68
+ }else{
69
+ element.setAttribute('aria-checked', 'false');
70
+ }
71
+ });
72
+ }
73
+ }
74
+
75
+ //Public Methods
76
+
77
+ /**
78
+ * setInitialActiveOpt(index)
79
+ * @param {number} index
80
+ * sets the initial active segment
81
+ */
82
+
83
+ setInitialActiveOpt(index) {
84
+ setInitialActive.call(this, index);
85
+ }
86
+
87
+ /**
88
+ * activeSegment()
89
+ * returns the current active segment anchor element
90
+ * @returns {Element}
91
+ */
92
+ activeSegment() {
93
+ return this._internalVars.selectedSegment;
94
+ }
95
+
96
+ /**
97
+ * removes the node from the dom and any events attached
98
+ */
99
+ destroy(){
100
+ removeEvents.call(this);
101
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
102
+
103
+ //a little garbage collection
104
+ for (var variableKey in this){
105
+ if (this.hasOwnProperty(variableKey)){
106
+ delete this[variableKey];
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ function setLocalVars() {
113
+ //determine the type of content passed in
114
+ if(this._internalVars.contentType === 'string'){
115
+ this._internalVars.node = document.querySelector(this._options.content);
116
+ }else if(this._internalVars.contentType === 'domNode'){
117
+ this._internalVars.node = this._options.content;
118
+ }
119
+
120
+ this._internalVars.segmentedControlObject = this._internalVars.node;
121
+
122
+ this._internalVars.draggableClass = '.sc-draggable';
123
+ this._internalVars.dropZoneClass = '.dropzone';
124
+ this._internalVars.animateClass = 'animate-drop';
125
+ this._internalVars.dropActiveClass = 'drop-active';
126
+ this._internalVars.dropTargetClass = 'drop-target';
127
+ this._internalVars.activeClass = 'active';
128
+ this._internalVars.activeDragClass = 'active-drag';
129
+
130
+ this._internalVars.dropZoneObject = this._internalVars.segmentedControlObject.querySelectorAll(this._internalVars.dropZoneClass);
131
+ this._internalVars.draggableObject = this._internalVars.segmentedControlObject.querySelector(this._internalVars.draggableClass);
132
+
133
+ this._internalVars.selectedSegment = null;
134
+ }
135
+
136
+ function init() {
137
+ let index = this._options.initialActive;
138
+
139
+ setInitialActive.call(this, index);
140
+
141
+ interact(this._internalVars.draggableObject)
142
+ .draggable({
143
+ inertia: true,
144
+ restrict: {
145
+ restriction: 'parent',
146
+ endOnly: false,
147
+ elementRect: { top: 0, left: 0, bottom: 0, right: 1 }
148
+ },
149
+ autoScroll: false,
150
+ snap: {
151
+ targets : [
152
+ {y: 0, range: Infinity}
153
+ ]
154
+
155
+ },
156
+
157
+ onmove: scDragMoveListener.bind(this)
158
+ });
159
+
160
+ function scDragMoveListener (event) {
161
+ let target = event.target,
162
+ x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx,
163
+ y = (parseFloat(target.getAttribute('data-y')) || 0) + event.dy;
164
+
165
+ target.style.left = x + "px";
166
+
167
+ target.setAttribute('data-x', x);
168
+ target.setAttribute('data-y', 0);
169
+
170
+ target.innerText = '';
171
+ target.style.zIndex = 1;
172
+ target.classList.add(this._internalVars.activeDragClass);
173
+ }
174
+
175
+ Array.prototype.forEach.call(this._internalVars.dropZoneObject, (element) =>{
176
+ interact(element)
177
+ .dropzone({
178
+ accept: this._internalVars.draggableClass,
179
+
180
+ overlap: 0.4,
181
+
182
+ ondropactivate: dropActivate.bind(this),
183
+
184
+ ondragenter: dragEnter.bind(this),
185
+
186
+ ondragleave: dragLeave.bind(this),
187
+
188
+ ondrop: onDrop.bind(this),
189
+
190
+ ondropdeactivate: dropDeactivate.bind(this)
191
+ });
192
+ });
193
+
194
+ function dropActivate(event) {
195
+ event.target.classList.add(this._internalVars.dropActiveClass);
196
+ }
197
+
198
+ function dragEnter(event) {
199
+ let dropzoneElement = event.target;
200
+
201
+ dropzoneElement.classList.add(this._internalVars.dropTargetClass);
202
+ }
203
+
204
+ function dragLeave(event) {
205
+ event.target.classList.remove(this._internalVars.dropTargetClass);
206
+ }
207
+
208
+ function onDrop(event) {
209
+ let xcord = event.target.offsetLeft,
210
+ delay = setTimeout(setNewSelection.bind(this), 350),
211
+ current = event.target.offsetParent.querySelector('.' + this._internalVars.activeClass);
212
+
213
+ current.classList.remove(this._internalVars.activeClass);
214
+ current.setAttribute('aria-checked', 'false');
215
+ event.target.classList.add(this._internalVars.activeClass);
216
+ event.target.setAttribute('aria-checked', 'true');
217
+ event.relatedTarget.classList.add(this._internalVars.animateClass);
218
+ event.relatedTarget.setAttribute('data-x', xcord);
219
+ event.relatedTarget.style.left = xcord + 'px';
220
+
221
+ function setNewSelection() {
222
+ event.relatedTarget.textContent = event.target.textContent;
223
+ event.relatedTarget.style.zIndex = 2;
224
+ event.relatedTarget.classList.remove(this._internalVars.animateClass);
225
+ event.relatedTarget.classList.remove(this._internalVars.activeDragClass);
226
+ this._internalVars.segmentedControlObject.querySelector('.' + this._internalVars.activeClass).focus();
227
+ }
228
+
229
+ this._internalVars.selectedSegment = event.target;
230
+
231
+ if(this._options.segmentedControlChange) {
232
+ this._options.segmentedControlChange(event.target);
233
+ }
234
+ }
235
+
236
+ function dropDeactivate(event) {
237
+ event.target.classList.remove(this._internalVars.dropActiveClass);
238
+ event.target.classList.remove(this._internalVars.dropTargetClass);
239
+ }
240
+ }
241
+
242
+ function setEvents() {
243
+ const eventName = UserAgentService._clickEventName();
244
+
245
+ Array.prototype.forEach.call(this._internalVars.dropZoneObject, (element)=>{
246
+ element.addEventListener(eventName, setActiveSelection.bind(this));
247
+ element.addEventListener('focus', function(){
248
+ if(element.classList.contains('active')){
249
+ element.parentNode.firstElementChild.style.textDecoration = 'underline';
250
+ }else{
251
+ element.parentNode.firstElementChild.style.textDecoration = 'none';
252
+ }
253
+ });
254
+ element.addEventListener('blur', function(){
255
+ element.parentNode.firstElementChild.style.textDecoration = 'none';
256
+ });
257
+ });
258
+
259
+ this._internalVars.draggableObject.addEventListener(eventName, function () {
260
+ this.parentNode.querySelector('.active').focus();
261
+ this.style.textDecoration = 'underline';
262
+ });
263
+
264
+ window.addEventListener('resize', resetActiveSelection.bind(this));
265
+ }
266
+
267
+ /**
268
+ * removeEvents()
269
+ * removes all events from the component
270
+ */
271
+ function removeEvents() {
272
+ const eventName = UserAgentService._clickEventName();
273
+
274
+ Array.prototype.forEach.call(this._internalVars.dropZoneObject, (element)=>{
275
+ element.removeEventListener(eventName, setActiveSelection.bind(this));
276
+ element.removeEventListener('focus', function(){
277
+ if(element.classList.contains('active')){
278
+ element.parentNode.firstElementChild.style.textDecoration = 'underline';
279
+ }else{
280
+ element.parentNode.firstElementChild.style.textDecoration = 'none';
281
+ }
282
+ });
283
+ element.removeEventListener('blur', function(){
284
+ element.parentNode.firstElementChild.style.textDecoration = 'none';
285
+ });
286
+ });
287
+
288
+ this._internalVars.draggableObject.removeEventListener(eventName, function () {
289
+ this.parentNode.querySelector('.active').focus();
290
+ this.style.textDecoration = 'underline';
291
+ });
292
+
293
+ window.removeEventListener('resize', resetActiveSelection.bind(this));
294
+ }
295
+
296
+
297
+ function setInitialActive(activeIndex) {
298
+
299
+ let activeElement = this._internalVars.segmentedControlObject.querySelector('.' + this._internalVars.activeClass);
300
+
301
+ if(activeElement) {
302
+ activeElement.classList.remove(this._internalVars.activeClass);
303
+ activeElement.setAttribute('aria-checked', 'false');
304
+ }
305
+
306
+ if(activeIndex <= this._internalVars.dropZoneObject.length && activeIndex > 0) {
307
+ this._internalVars.dropZoneObject[activeIndex -1].classList.add(this._internalVars.activeClass);
308
+ } else {
309
+ this._internalVars.dropZoneObject[0].classList.add(this._internalVars.activeClass);
310
+ }
311
+
312
+ activeElement = this._internalVars.segmentedControlObject.querySelector('.' + this._internalVars.activeClass);
313
+ let activeElementLeft = activeElement.offsetLeft,
314
+ activeElementContent = activeElement.innerHTML;
315
+
316
+ activeElement.setAttribute('aria-checked', 'true');
317
+ this._internalVars.draggableObject.style.left = activeElementLeft + 'px';
318
+ this._internalVars.draggableObject.innerHTML = activeElementContent;
319
+ this._internalVars.draggableObject.setAttribute('data-x', activeElementLeft);
320
+
321
+ this._internalVars.selectedSegment = activeElement;
322
+ }
323
+
324
+ function setActiveSelection(event) {
325
+ event.preventDefault();
326
+ let left = event.target.offsetLeft,
327
+ delay = setTimeout(setNewSelection.bind(this), 350),
328
+ current = event.target.offsetParent.querySelector('.' + this._internalVars.activeClass);
329
+
330
+ current.classList.remove(this._internalVars.activeClass);
331
+ current.setAttribute('aria-checked', 'false');
332
+ event.target.classList.add(this._internalVars.activeClass);
333
+ event.target.setAttribute('aria-checked', 'true');
334
+ this._internalVars.draggableObject.classList.add(this._internalVars.animateClass);
335
+ this._internalVars.draggableObject.classList.add(this._internalVars.activeDragClass);
336
+ this._internalVars.draggableObject.innerText = '';
337
+ this._internalVars.draggableObject.style.zIndex = 1;
338
+
339
+ this._internalVars.draggableObject.setAttribute('data-x', left);
340
+ this._internalVars.draggableObject.style.left = left + 'px';
341
+
342
+ function setNewSelection() {
343
+ this._internalVars.draggableObject.innerHTML = event.target.innerHTML;
344
+ this._internalVars.draggableObject.style.zIndex = 2;
345
+ this._internalVars.draggableObject.classList.remove(this._internalVars.animateClass);
346
+ this._internalVars.draggableObject.classList.remove(this._internalVars.activeDragClass);
347
+ this._internalVars.draggableObject.style.textDecoration = 'underline';
348
+ }
349
+
350
+ this._internalVars.selectedSegment = event.target;
351
+
352
+ if(this._options.segmentedControlChange) {
353
+ this._options.segmentedControlChange(event.target);
354
+ }
355
+ }
356
+
357
+ function resetActiveSelection() {
358
+ let current = this._internalVars.segmentedControlObject.querySelector('.' + this._internalVars.activeClass),
359
+ left = current.offsetLeft;
360
+
361
+ this._internalVars.draggableObject.setAttribute('data-x', left);
362
+ this._internalVars.draggableObject.style.left = left + 'px';
363
+ }
364
+
365
+ export default SegmentedControl;
@@ -0,0 +1,176 @@
1
+ var Tablesort = require("tablesort");
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 SortableTableDeprecated : Content must be defined and set to a DOM selector or Node"]
12
+ },
13
+ {
14
+ setting : "descending",
15
+ isRequired : false,
16
+ validate : "type",
17
+ possibleValues : ["boolean"],
18
+ errorMessage : ["GDK SortableTableDeprecated : descending must be a boolean"]
19
+ }
20
+ ];
21
+
22
+
23
+ class SortableTable {
24
+ /**
25
+ * Refer to the design kit section of this component for JS examples and setting details.
26
+ * @param {string, Object} content
27
+ * A reference to the sortable table node
28
+ *
29
+ * @param {boolean} [descending=false]
30
+ * The number of the item to set as the active selection on initialization. Must be greater than 0 and equal to or less than the number of segment options
31
+ *
32
+ */
33
+ constructor(options) {
34
+
35
+ this._internalVars = {
36
+ node: null,//used for current node
37
+ sortableTable: null//hold reference to the sortable table
38
+ };
39
+
40
+ //options with defaults set
41
+ this._defaults = {
42
+ descending : false
43
+ };
44
+
45
+ // Create options by extending defaults with the passed in arugments
46
+ if (options && typeof options === "object") {
47
+ this._options = baseComponent.extendDefaults(this._defaults, options);
48
+ }
49
+
50
+
51
+ //if the required options are valid set up the environment
52
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
53
+ this._internalVars.contentType = baseComponent.getContentType(this);
54
+ setLocalVars.call(this);
55
+ init.call(this);
56
+ }
57
+
58
+ }
59
+
60
+ /**
61
+ * update()
62
+ * Updates the sort if you have added content
63
+ */
64
+ update(){
65
+ this._internalVars.sortableTable.refresh();
66
+ }
67
+
68
+
69
+ /**
70
+ * destroy()
71
+ * removes the node from the dom and any events attached
72
+ */
73
+ destroy(){
74
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
75
+
76
+ //a little garbage collection
77
+ for (var variableKey in this){
78
+ if (this.hasOwnProperty(variableKey)){
79
+ delete this[variableKey];
80
+ }
81
+ }
82
+ }
83
+
84
+ }
85
+
86
+ /**
87
+ * init()
88
+ * instantiate the Tablesort
89
+ */
90
+ function init() {
91
+
92
+ let options = {};
93
+
94
+ if(this._options.descending){
95
+ options.descending = true;
96
+ }
97
+
98
+ Tablesort.extend('date', function(item) {
99
+ return (
100
+ item.search(/(Mon|Tue|Wed|Thu|Fri|Sat|Sun)\.?\,?\s*/i) !== -1 ||
101
+ item.search(/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/) !== -1 ||
102
+ item.search(/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)/i) !== -1
103
+ ) && !isNaN(parseDate.call(this,item));
104
+ }, function(a, b) {
105
+ a = a.toLowerCase();
106
+ b = b.toLowerCase();
107
+
108
+ return parseDate.call(this,b) - parseDate.call(this,a);
109
+ });
110
+
111
+
112
+ Tablesort.extend('number', function(item) {
113
+ return item.match(/^-?[£\x24Û¢´€]?\d+\s*([,\.]\d{0,2})/) || // Prefixed currency
114
+ item.match(/^-?\d+\s*([,\.]\d{0,2})?[£\x24Û¢´€]/) || // Suffixed currency
115
+ item.match(/^-?(\d)*-?([,\.]){0,1}-?(\d)+([E,e][\-+][\d]+)?%?$/); // Number
116
+ }, function(a, b) {
117
+ a = cleanNumber.call(this,a);
118
+ b = cleanNumber.call(this,b);
119
+
120
+ return compareNumber.call(this,b,a);
121
+ });
122
+
123
+ this._internalVars.sortableTable = new Tablesort(this._internalVars.node, options);
124
+
125
+ }
126
+
127
+ /**
128
+ * cleanNumber()
129
+ * regex replace for extending Tablsort to sort by numbers (and currency)
130
+ */
131
+ function cleanNumber(i) {
132
+ return i.replace(/[^\-?0-9.]/g, '');
133
+ }
134
+
135
+ /**
136
+ * compareNumber()
137
+ * sort function for numbers
138
+ */
139
+ function compareNumber(a, b) {
140
+ a = parseFloat(a);
141
+ b = parseFloat(b);
142
+
143
+ a = isNaN(a) ? 0 : a;
144
+ b = isNaN(b) ? 0 : b;
145
+
146
+ return a - b;
147
+ }
148
+
149
+ /**
150
+ * parseDate()
151
+ * prepares date for sorting
152
+ */
153
+ function parseDate(date) {
154
+ date = date.replace(/\-/g, '/');
155
+ date = date.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/, '$1/$2/$3'); // format before getTime
156
+
157
+ return new Date(date).getTime();
158
+ }
159
+
160
+
161
+ /**
162
+ * setLocalVars()
163
+ * set all the local vars to passed in options
164
+ */
165
+ function setLocalVars() {
166
+ //determine the type of content passed in
167
+ if(this._internalVars.contentType === 'string'){
168
+ this._internalVars.node = document.querySelector(this._options.content);
169
+ }else if(this._internalVars.contentType === 'domNode'){
170
+ this._internalVars.node = this._options.content;
171
+ }
172
+ }
173
+
174
+
175
+
176
+ export default SortableTable;
File without changes