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,492 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _appState = _interopRequireDefault(require("../../src/appState"));
8
+ var utils = _interopRequireWildcard(require("../../src/utils"));
9
+ var _baseComponent = _interopRequireDefault(require("../../src/baseComponent"));
10
+ var _UserAgentService = _interopRequireDefault(require("../../src/services/UserAgentService"));
11
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
14
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
16
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
17
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ var validateSettings = [{
21
+ setting: "content",
22
+ isRequired: true,
23
+ validate: "type",
24
+ possibleValues: ["string", "object"],
25
+ errorMessage: ["GDK TimelineFilter : Content must be defined and set to a DOM selector or Node"]
26
+ }, {
27
+ setting: "onFilterSubmit",
28
+ isRequired: false,
29
+ validate: "type",
30
+ possibleValues: ["function"],
31
+ errorMessage: ["GDK TimelineFilter : onFilterSubmit must be a function"]
32
+ }, {
33
+ setting: "onClearFilter",
34
+ isRequired: false,
35
+ validate: "type",
36
+ possibleValues: ["function"],
37
+ errorMessage: ["GDK TimelineFilter : onClearFilter must be a function"]
38
+ }, {
39
+ setting: "setInitialFilters",
40
+ isRequired: false,
41
+ validate: "type",
42
+ possibleValues: ["object"],
43
+ errorMessage: ["GDK TimelineFilter : setInitialFilters must be an object"]
44
+ }];
45
+ var TimelineFilter = /*#__PURE__*/function () {
46
+ /**
47
+ * Refer to the design kit section of this component for JS examples and setting details.
48
+ * @param {string, Object} content
49
+ * A reference to the html timeline filter node
50
+ *
51
+ * @param {function} [onFilterSubmit]
52
+ * Callback function fired once a 'filter-submit' is clicked
53
+ *
54
+ * @param {function} [onClearFilter]
55
+ * Callback function fired once 'Clear Filters' is clicked
56
+ *
57
+ * @param {object} [setDefaultFilters]
58
+ * Accepts an array of objects containing checkbox IDs and an indicator to select or deselect them, selects or deselects them, and updates the count bubble
59
+ *
60
+ */
61
+ function TimelineFilter(options) {
62
+ _classCallCheck(this, TimelineFilter);
63
+ this._internalVars = {
64
+ node: null,
65
+ //used for content item
66
+ dropdownTrigger: null,
67
+ checkbox: null,
68
+ dropdown: null,
69
+ mobileOpen: null,
70
+ //mobileClose: null,
71
+ mobileBar: null,
72
+ mobileText: null,
73
+ clear: null,
74
+ search: null,
75
+ submit: null,
76
+ dropdownContainer: null
77
+ };
78
+
79
+ //options with defaults set
80
+ this._defaults = {};
81
+
82
+ // Create options by extending defaults with the passed in arugments
83
+ if (options && _typeof(options) === "object") {
84
+ this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
85
+ }
86
+
87
+ //if the required options are valid set up the environment
88
+ if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
89
+ this._internalVars.contentType = _baseComponent["default"].getContentType(this);
90
+ setLocalVars.call(this);
91
+ setEvents.call(this);
92
+ if (_appState["default"].mode == "desktop") Array.prototype.forEach.call(this._internalVars.dropdownTrigger, function (el, i) {
93
+ el.setAttribute('aria-expanded', 'false');
94
+ });
95
+ if (this._options.setInitialFilters) {
96
+ this.setDefaultFilters.call(this, this._options.setInitialFilters);
97
+ }
98
+ }
99
+ }
100
+
101
+ //Public Methods
102
+
103
+ /**
104
+ * setDefaultFilters(obj)
105
+ * @param {object} [obj]
106
+ * Accepts an array of objects containing checkbox IDs and an indicator to select or deselect them, selects or deselects them, and updates the count bubble
107
+ */
108
+ return _createClass(TimelineFilter, [{
109
+ key: "setDefaultFilters",
110
+ value: function setDefaultFilters(obj) {
111
+ var _this = this;
112
+ Array.prototype.forEach.call(obj, function (el) {
113
+ if (el.id && el.action) {
114
+ var checkbox = document.querySelector('#' + el.id);
115
+ if (checkbox) {
116
+ if (el.action === 'select') {
117
+ checkbox.checked = true;
118
+ updateAllNotificationBubbles.call(_this, checkbox);
119
+ } else if (el.action === 'deselect') {
120
+ checkbox.checked = false;
121
+ updateAllNotificationBubbles.call(_this, checkbox);
122
+ }
123
+ }
124
+ }
125
+ });
126
+ }
127
+
128
+ /**
129
+ * destroy()
130
+ * removes the node from the dom and any events attached
131
+ */
132
+ }, {
133
+ key: "destroy",
134
+ value: function destroy() {
135
+ removeEvents.call(this);
136
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
137
+
138
+ //a little garbage collection
139
+ for (var variableKey in this) {
140
+ if (this.hasOwnProperty(variableKey)) {
141
+ delete this[variableKey];
142
+ }
143
+ }
144
+ }
145
+ }]);
146
+ }(); // Private Methods
147
+ /**
148
+ * setLocalVars()
149
+ * set all the local vars to passed in options
150
+ */
151
+ function setLocalVars() {
152
+ //determine the type of content passed in
153
+ if (this._internalVars.contentType === 'string') {
154
+ this._internalVars.node = document.querySelector(this._options.content);
155
+ } else if (this._internalVars.contentType === 'domNode') {
156
+ this._internalVars.node = this._options.content;
157
+ }
158
+ this._internalVars.dropdownTrigger = this._internalVars.node.querySelectorAll(".filter-dropdown-trigger");
159
+ this._internalVars.checkbox = this._internalVars.node.querySelectorAll(".filter-checkbox");
160
+ this._internalVars.dropdown = this._internalVars.node.querySelectorAll(".filter-dropdown");
161
+ this._internalVars.clear = this._internalVars.node.querySelector(".filter-clear");
162
+ this._internalVars.search = this._internalVars.node.querySelector(".filter-search");
163
+ this._internalVars.submit = this._internalVars.node.querySelector(".filter-submit");
164
+ this._internalVars.dropdownContainer = this._internalVars.node.querySelectorAll(".filter-container");
165
+ this._internalVars.mobileOpen = this._internalVars.node.querySelector(".filter-mobile-open");
166
+ //this._internalVars.mobileClose = this._internalVars.node.querySelector(".filter-mobile-close");
167
+ this._internalVars.mobileBar = this._internalVars.node.querySelector(".filter-mobile-bar");
168
+ this._internalVars.mobileText = this._internalVars.node.querySelector(".filter-mobile-bar-text");
169
+ this._internalVars.outsideHandler = outsideFieldClickHandler.bind(this);
170
+ this._internalVars.dropdownHandler = dropdownClickHandler.bind(this);
171
+ this._internalVars.checkTouchHandler = checkForTouch.bind(this);
172
+ this._internalVars.checkboxHandler = checkboxChangeHandler.bind(this);
173
+ this._internalVars.clearFilterHandler = clearFilter.bind(this);
174
+ this._internalVars.submitFilterHandler = submitFilter.bind(this);
175
+ this._internalVars.openDrawerHandler = openDrawer.bind(this);
176
+ this._internalVars.searchFocusHandler = searchFocus.bind(this);
177
+ }
178
+
179
+ /**
180
+ * setEvents()
181
+ * Sets all the events needed for the component
182
+ */
183
+ function setEvents() {
184
+ var _this2 = this;
185
+ var eventName = _UserAgentService["default"]._clickEventName();
186
+
187
+ //set click events
188
+ Array.prototype.forEach.call(this._internalVars.dropdownTrigger, function (el, i) {
189
+ el.addEventListener(eventName, _this2._internalVars.dropdownHandler);
190
+ el.addEventListener("pointerdown", _this2._internalVars.checkTouchHandler);
191
+ });
192
+ Array.prototype.forEach.call(this._internalVars.dropdownContainer, function (el, i) {
193
+ el.addEventListener("mouseleave", _this2._internalVars.outsideHandler);
194
+ });
195
+ Array.prototype.forEach.call(this._internalVars.checkbox, function (el, i) {
196
+ el.addEventListener('change', _this2._internalVars.checkboxHandler);
197
+ });
198
+ this._internalVars.clear.addEventListener(eventName, this._internalVars.clearFilterHandler);
199
+ if (this._internalVars.search) {
200
+ this._internalVars.search.addEventListener('focus', this._internalVars.searchFocusHandler);
201
+ }
202
+ this._internalVars.submit.addEventListener(eventName, this._internalVars.submitFilterHandler);
203
+
204
+ // mobile
205
+ this._internalVars.mobileOpen.addEventListener(eventName, this._internalVars.openDrawerHandler);
206
+ //this._internalVars.mobileClose.addEventListener(eventName, closeDrawer.bind(this) );
207
+ }
208
+
209
+ /**
210
+ * removeEvents()
211
+ * removes all events from the component
212
+ */
213
+ function removeEvents() {
214
+ var _this3 = this;
215
+ var eventName = _UserAgentService["default"]._clickEventName();
216
+
217
+ //remove click events
218
+ Array.prototype.forEach.call(this._internalVars.dropdownTrigger, function (el, i) {
219
+ el.removeEventListener(eventName, _this3._internalVars.dropdownHandler);
220
+ el.removeEventListener("pointerdown", _this3._internalVars.checkTouchHandler);
221
+ });
222
+ Array.prototype.forEach.call(this._internalVars.dropdownContainer, function (el, i) {
223
+ el.removeEventListener("mouseleave", _this3._internalVars.outsideHandler);
224
+ });
225
+ Array.prototype.forEach.call(this._internalVars.checkbox, function (el, i) {
226
+ el.removeEventListener('change', _this3._internalVars.checkboxHandler);
227
+ });
228
+ this._internalVars.clear.removeEventListener(eventName, this._internalVars.clearFilterHandler);
229
+ if (this._internalVars.search) {
230
+ this._internalVars.search.removeEventListener('focus', this._internalVars.searchFocusHandler);
231
+ }
232
+ this._internalVars.submit.removeEventListener(eventName, this._internalVars.submitFilterHandler);
233
+
234
+ // mobile
235
+ this._internalVars.mobileOpen.removeEventListener(eventName, this._internalVars.openDrawerHandler);
236
+ //this._internalVars.mobileClose.removeEventListener(eventName, closeDrawer.bind(this) );
237
+ }
238
+ function checkForTouch(el) {
239
+ var _this4 = this;
240
+ if (el.pointerType == 'touch') {
241
+ Array.prototype.forEach.call(this._internalVars.dropdownContainer, function (el, i) {
242
+ el.removeEventListener("mouseleave", _this4._internalVars.outsideHandler);
243
+ });
244
+ } else {
245
+ Array.prototype.forEach.call(this._internalVars.dropdownContainer, function (el, i) {
246
+ el.addEventListener("mouseleave", _this4._internalVars.outsideHandler);
247
+ });
248
+ }
249
+ }
250
+
251
+ /**
252
+ * openDrawer()
253
+ * opens the mobile filter drawer
254
+ */
255
+ function openDrawer(el) {
256
+ if (utils.hasClass(this._internalVars.node, "-drawer-open")) {
257
+ closeDrawer.call(this);
258
+ } else {
259
+ this._internalVars.node.classList.add("-drawer-open");
260
+ }
261
+ }
262
+
263
+ /**
264
+ * closeDrawer()
265
+ * closes the mobile filter drawer
266
+ */
267
+ function closeDrawer(el) {
268
+ this._internalVars.node.classList.remove("-drawer-open");
269
+ }
270
+
271
+ /**
272
+ * submitFilter()
273
+ * submits Filter form
274
+ */
275
+ function submitFilter(el) {
276
+ var _this5 = this;
277
+ var data = serializeForm(this._internalVars.node);
278
+
279
+ // if mobile, close the drawer and update the filter text
280
+ if (_appState["default"].mode === "mobile") {
281
+ var fields = Object.keys(data).length;
282
+ if (data.keywords !== '' || fields > 1) {
283
+ this._internalVars.mobileText.innerHTML = 'Showing filtered activities & policies';
284
+ } else {
285
+ this._internalVars.mobileText.innerHTML = 'Showing all activities & policies';
286
+ }
287
+ this._internalVars.node.classList.remove("-drawer-open");
288
+ }
289
+
290
+ // fire onFilterSubmit Callback if there is one
291
+ setTimeout(function () {
292
+ if (_this5._options.onFilterSubmit) _this5._options.onFilterSubmit(data);
293
+ }, 10);
294
+ return false;
295
+ }
296
+
297
+ /**
298
+ * serializeForm()
299
+ * serialize form into object
300
+ */
301
+ function serializeForm(form) {
302
+ if (!form || form.nodeName !== "FORM") {
303
+ return;
304
+ }
305
+ var i,
306
+ j,
307
+ obj = {};
308
+ for (i = form.elements.length - 1; i >= 0; i = i - 1) {
309
+ if (form.elements[i].name === "") {
310
+ continue;
311
+ }
312
+ switch (form.elements[i].nodeName) {
313
+ case 'INPUT':
314
+ switch (form.elements[i].type) {
315
+ case 'text':
316
+ case 'hidden':
317
+ case 'password':
318
+ case 'button':
319
+ case 'reset':
320
+ case 'submit':
321
+ obj[form.elements[i].name] = encodeURIComponent(form.elements[i].value);
322
+ break;
323
+ case 'checkbox':
324
+ case 'radio':
325
+ if (form.elements[i].checked) {
326
+ obj[form.elements[i].name] = encodeURIComponent(form.elements[i].value);
327
+ }
328
+ break;
329
+ case 'file':
330
+ break;
331
+ }
332
+ break;
333
+ case 'TEXTAREA':
334
+ obj[form.elements[i].name] = encodeURIComponent(form.elements[i].value);
335
+ break;
336
+ case 'SELECT':
337
+ switch (form.elements[i].type) {
338
+ case 'select-one':
339
+ obj[form.elements[i].name] = encodeURIComponent(form.elements[i].value);
340
+ break;
341
+ case 'select-multiple':
342
+ for (j = form.elements[i].options.length - 1; j >= 0; j = j - 1) {
343
+ if (form.elements[i].options[j].selected) {
344
+ obj[form.elements[i].name] = encodeURIComponent(form.elements[i].options[j].value);
345
+ }
346
+ }
347
+ break;
348
+ }
349
+ break;
350
+ case 'BUTTON':
351
+ switch (form.elements[i].type) {
352
+ case 'reset':
353
+ case 'submit':
354
+ case 'button':
355
+ obj[form.elements[i].name] = encodeURIComponent(form.elements[i].value);
356
+ break;
357
+ }
358
+ break;
359
+ }
360
+ }
361
+ return obj;
362
+ }
363
+
364
+ /**
365
+ * clearFilter()
366
+ * clears the timeline filters and unchecks all checkboxes
367
+ */
368
+ function clearFilter(e) {
369
+ var _this6 = this;
370
+ e.preventDefault();
371
+ // unchecks all checkboxes
372
+ Array.prototype.forEach.call(this._internalVars.checkbox, function (el, i) {
373
+ el.checked = false;
374
+ });
375
+
376
+ // update notification bubble to 0
377
+ Array.prototype.forEach.call(this._internalVars.dropdownTrigger, function (el, i) {
378
+ updateNotificationBubble(el, 0);
379
+ });
380
+
381
+ // clears search field
382
+ if (this._internalVars.search) {
383
+ this._internalVars.search.value = '';
384
+ }
385
+
386
+ // fire onClearFilter Callback if there is one
387
+ setTimeout(function () {
388
+ if (_this6._options.onClearFilter) _this6._options.onClearFilter();
389
+ }, 10);
390
+ }
391
+
392
+ /**
393
+ * checkboxChangeHandler()
394
+ * updates the notification of how many checkboxes are selected per dropdown
395
+ */
396
+ function checkboxChangeHandler(el) {
397
+ var currentNode = el.currentTarget;
398
+ var dropdownParent = findAncestor(currentNode, 'filter-dropdown');
399
+ var dropdownTrigger = dropdownParent.parentElement;
400
+ var total = dropdownParent.querySelectorAll('input[type="checkbox"]:checked').length;
401
+ updateNotificationBubble(dropdownTrigger, total);
402
+ }
403
+
404
+ /**
405
+ * findAncestor()
406
+ * Finds nearest ancestor with specified class
407
+ */
408
+ function findAncestor(el, cls) {
409
+ while ((el = el.parentElement) && !el.classList.contains(cls));
410
+ return el;
411
+ }
412
+
413
+ /**
414
+ * updateNotificationBubble()
415
+ * updates the notification of how many checkboxes are selected per dropdown
416
+ */
417
+ function updateNotificationBubble(el, value) {
418
+ var bubble = el.getElementsByClassName('dropdown-notify')[0];
419
+ bubble.innerHTML = value;
420
+ if (value > 0) {
421
+ bubble.classList.add("-visible");
422
+ } else {
423
+ bubble.classList.remove("-visible");
424
+ }
425
+ }
426
+ function updateAllNotificationBubbles(el) {
427
+ var dropdownParent = findAncestor(el, 'filter-dropdown');
428
+ var dropdownTrigger = dropdownParent.parentElement;
429
+ var total = dropdownParent.querySelectorAll('input[type="checkbox"]:checked').length;
430
+ updateNotificationBubble(dropdownTrigger, total);
431
+ }
432
+
433
+ /**
434
+ * dropdownClickHandler()
435
+ * Opens tab content for clicked tab and hides the rest
436
+ */
437
+ function dropdownClickHandler(el) {
438
+ var currentNode = el.currentTarget;
439
+ currentNode.focus();
440
+ // add -active class
441
+ Array.prototype.map.call(this._internalVars.dropdownTrigger, function (e, rank) {
442
+ if (e === currentNode && e === document.activeElement) {
443
+ // if already has active class, remove it
444
+ if (utils.hasClass(e, 'filter-dropdown-trigger--active')) {
445
+ e.classList.remove("filter-dropdown-trigger--active");
446
+ if (_appState["default"].mode == 'desktop') e.setAttribute('aria-expanded', 'false');
447
+ } else {
448
+ e.classList.add("filter-dropdown-trigger--active");
449
+ if (_appState["default"].mode == 'desktop') {
450
+ e.setAttribute('aria-expanded', 'true');
451
+ }
452
+ }
453
+ } else {
454
+ e.classList.remove("filter-dropdown-trigger--active");
455
+ if (_appState["default"].mode == 'desktop') e.setAttribute('aria-expanded', 'false');
456
+ }
457
+ });
458
+ }
459
+
460
+ /**
461
+ * dropdownClickHandler()
462
+ * Opens tab content for clicked tab and hides the rest
463
+ */
464
+ function outsideFieldClickHandler(el) {
465
+ var currentNode = el.currentTarget;
466
+ // add -active class
467
+ Array.prototype.map.call(this._internalVars.dropdownTrigger, function (e, rank) {
468
+ if (e === currentNode) {
469
+ // if already has active class, remove it
470
+ if (utils.hasClass(e, 'filter-dropdown-trigger--active')) {
471
+ e.classList.remove("filter-dropdown-trigger--active");
472
+ if (_appState["default"].mode == 'desktop') e.setAttribute('aria-expanded', 'false');
473
+ }
474
+ } else {
475
+ e.classList.remove("filter-dropdown-trigger--active");
476
+ if (_appState["default"].mode == 'desktop') e.setAttribute('aria-expanded', 'false');
477
+ }
478
+ });
479
+ }
480
+
481
+ /**
482
+ * searchFocus()
483
+ * Closes all dropdowns on search focus
484
+ */
485
+ function searchFocus(el) {
486
+ // add -active class
487
+ Array.prototype.map.call(this._internalVars.dropdownTrigger, function (e, rank) {
488
+ e.classList.remove("filter-dropdown-trigger--active");
489
+ if (_appState["default"].mode == 'desktop') e.setAttribute('aria-expanded', 'false');
490
+ });
491
+ }
492
+ var _default = exports["default"] = TimelineFilter;
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _baseComponent = _interopRequireDefault(require("../../src/baseComponent"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
11
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
12
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
15
+ var validateSettings = [{
16
+ setting: "content",
17
+ isRequired: true,
18
+ validate: "type",
19
+ possibleValues: ["string", "object"],
20
+ errorMessage: ["GDK ToTopArrow : Content must be defined and set to a DOM selector or Node"]
21
+ }, {
22
+ setting: "toTopArrowClicked",
23
+ isRequired: false,
24
+ validate: "type",
25
+ possibleValues: ["function"],
26
+ errorMessage: ["GDK ToTopArrow : toTopArrowClicked must be defined and set function"]
27
+ }];
28
+ var ToTopArrow = /*#__PURE__*/function () {
29
+ /**
30
+ * Refer to the design kit section of this component for JS examples and setting details.
31
+ * @param {string, Object} content
32
+ * A reference to the component node to toggle
33
+ *
34
+ * @param {function} [toTopArrowClicked]
35
+ * A callback function that gets fired when the To Top arrow is clicked
36
+ *
37
+ */
38
+ function ToTopArrow(options) {
39
+ _classCallCheck(this, ToTopArrow);
40
+ console.log('ToTopArrow has been initialized');
41
+ this._internalVars = {
42
+ node: null //used for current node
43
+ };
44
+
45
+ //options with defaults set
46
+ this._defaults = {
47
+ "getDuration": function getDuration() {
48
+ return pageYOffset <= 2000 ? 300 : 1200;
49
+ }
50
+ };
51
+
52
+ // Create options by extending defaults with the passed in arguments
53
+ if (options && _typeof(options) === "object") {
54
+ this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
55
+ }
56
+
57
+ //if the required options are valid set up the environment
58
+ if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
59
+ this._internalVars.contentType = _baseComponent["default"].getContentType(this);
60
+ setLocalVars.call(this);
61
+ setEvents.call(this);
62
+ }
63
+ }
64
+
65
+ //Public Methods
66
+
67
+ /**
68
+ * removes the node from the dom and any events attached
69
+ */
70
+ return _createClass(ToTopArrow, [{
71
+ key: "destroy",
72
+ value: function destroy() {
73
+ removeEvents.call(this);
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
+ }(); // Private Methods
85
+ /**
86
+ * setEvents()
87
+ * Sets all the events needed for the component
88
+ */
89
+ function setEvents() {
90
+ this._internalVars.button.addEventListener("click", this._internalVars.handler);
91
+ window.addEventListener("scroll", toggleScrollBtnView.bind(this));
92
+ }
93
+
94
+ /**
95
+ * removeEvents()
96
+ * removes all events from the component
97
+ */
98
+ function removeEvents() {
99
+ this._internalVars.button.removeEventListener("click", this._internalVars.handler);
100
+ }
101
+
102
+ /**
103
+ * toggleScrollBtnView()
104
+ * @param e
105
+ */
106
+ function toggleScrollBtnView(e) {
107
+ if ((window.scrollY || screen.scrollY) > 200 && !this._internalVars.isDisplayed || (window.pageYOffset || screen.pageYOffset) > 200 && !this._internalVars.isDisplayed) {
108
+ this._internalVars.button.classList.add('displayed');
109
+ this._internalVars.isDisplayed = true;
110
+ } else if (window.scrollY <= 100 && this._internalVars.isDisplayed || window.pageYOffset <= 100 && this._internalVars.isDisplayed) {
111
+ this._internalVars.button.classList.remove('displayed');
112
+ this._internalVars.isDisplayed = false;
113
+ }
114
+ }
115
+
116
+ /**
117
+ * toggleView()
118
+ * instantiate To Top Arrow
119
+ */
120
+
121
+ function toggleScroll(e) {
122
+ //TODO: set correct Duration speed!
123
+ var duration = this._defaults.getDuration();
124
+ e.preventDefault();
125
+ var scrollStep = -window.scrollY / (duration / 15) || -window.pageYOffset / (duration / 15),
126
+ scrollInterval = setInterval(function () {
127
+ if (window.scrollY !== 0 && window.scrollY !== undefined || window.pageYOffset !== 0 && window.pageYOffset !== undefined) {
128
+ window.scrollBy(0, scrollStep);
129
+ } else clearInterval(scrollInterval);
130
+ }, 15);
131
+ if (this._options.toTopArrowClicked) {
132
+ this._options.toTopArrowClicked();
133
+ }
134
+ }
135
+
136
+ /**
137
+ * setLocalVars()
138
+ * set local vars to the ones passed in options
139
+ */
140
+ function setLocalVars() {
141
+ if (this._internalVars.contentType === 'string') {
142
+ this._internalVars.node = document.querySelector(this._options.content);
143
+ } else if (this._internalVars.contentType === 'domNode') {
144
+ this._internalVars.node = this._options.content;
145
+ }
146
+
147
+ //add icon dom
148
+ this._internalVars.node.insertAdjacentHTML('beforeend', "<div class=\"icon-to-top-arrow\"></div>");
149
+ this._internalVars.button = this._internalVars.node;
150
+ this._internalVars.isDisplayed = false;
151
+ this._internalVars.handler = toggleScroll.bind(this);
152
+ }
153
+ var _default = exports["default"] = ToTopArrow;