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,242 @@
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 Trianglify = require('trianglify');
16
+ var validateSettings = [{
17
+ setting: "content",
18
+ isRequired: true,
19
+ validate: "type",
20
+ possibleValues: ["string", "object"],
21
+ errorMessage: ["GDK BackgroundPatternPortfolioPage : Content must be defined and set to a DOM selector or Node"]
22
+ }];
23
+ var BackgroundPatternPortfolioPage = /*#__PURE__*/function () {
24
+ function BackgroundPatternPortfolioPage(options) {
25
+ _classCallCheck(this, BackgroundPatternPortfolioPage);
26
+ console.log('BackgroundPatternPortfolioPage initialized');
27
+
28
+ //SM=75 MED=125 LG=175
29
+
30
+ this._internalVars = {
31
+ node: null //used for current node
32
+ };
33
+
34
+ //options with defaults set
35
+ this._defaults = {};
36
+
37
+ // Create options by extending defaults with the passed in arugments
38
+ if (options && _typeof(options) === "object") {
39
+ this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
40
+ }
41
+
42
+ //if the required options are valid set up the environment
43
+ if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
44
+ this._internalVars.contentType = _baseComponent["default"].getContentType(this);
45
+ setLocalVars.call(this);
46
+ setEvents.call(this);
47
+ init.call(this);
48
+ }
49
+ }
50
+
51
+ /**
52
+ * destroy()
53
+ * removes the node from the dom and any events attached
54
+ */
55
+ return _createClass(BackgroundPatternPortfolioPage, [{
56
+ key: "destroy",
57
+ value: function destroy() {
58
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
59
+
60
+ //a little garbage collection
61
+ for (var variableKey in this) {
62
+ if (this.hasOwnProperty(variableKey)) {
63
+ delete this[variableKey];
64
+ }
65
+ }
66
+ }
67
+ }]);
68
+ }(); // Private Methods
69
+ /**
70
+ * init()
71
+ * Initializes the Trianglify pattern
72
+ */
73
+ function init() {
74
+ if (this._internalVars.alertVerificationItems.length === 0) {
75
+ alertHeight.call(this);
76
+ } else {
77
+ initialAlertDisplay.call(this);
78
+ }
79
+ }
80
+ function trianglify() {
81
+ console.log(this._internalVars.canvasHeight);
82
+ var pattern = Trianglify({
83
+ variance: "0.7",
84
+ cell_size: 175,
85
+ x_colors: ["#ffffff", "#dcdcdc", "#e6e6e6", "#ffffff", "e8e8e8", "f0f0f0", "#dcdcdc", "#ffffff", "#f5f5f5", "e8e8e8", "#ffffff", "#e6e6e6", "#f5f5f5", "#fafafa", "#ffffff"],
86
+ width: 3000,
87
+ height: this._internalVars.canvasHeight
88
+ });
89
+ this._internalVars.node.appendChild(pattern.canvas());
90
+ var canvas = document.getElementsByTagName('canvas');
91
+ console.log(canvas);
92
+ canvas[0].setAttribute('id', 'portfolioBackground');
93
+ if (canvas[1]) {
94
+ canvas[1].parentElement.removeChild(canvas[1]);
95
+ }
96
+ }
97
+ function setCanvasHeight() {
98
+ if (this._internalVars.alertVerificationItems.length === 0) {
99
+ this._internalVars.canvasHeight = 220;
100
+ }
101
+ if (document.getElementById(this._internalVars.canvasID) === null) {} else {
102
+ document.getElementById(this._internalVars.canvasID).parentNode.removeChild(document.getElementById(this._internalVars.canvasID));
103
+ }
104
+ this._internalVars.backgroundPatternHeightObject.style.height = this._internalVars.canvasHeight + "px";
105
+ trianglify.call(this);
106
+ }
107
+ function initialAlertDisplay() {
108
+ this._internalVars.alertActive = 0;
109
+ this._internalVars.alertItems[this._internalVars.alertActive].classList.add('alert-active');
110
+ if (this._internalVars.alertItems.length > 1) {
111
+ this._internalVars.alertTotalObject.innerHTML = this._internalVars.alertItems.length;
112
+ currentAlertState.call(this);
113
+ } else {
114
+ //hide carousel
115
+ this._internalVars.carouselObject.style.display = 'none';
116
+ }
117
+ alertHeight.call(this);
118
+ chevronState.call(this);
119
+ }
120
+ function chevronState() {
121
+ var currentAlert = this._internalVars.alertActive + 1;
122
+ if (currentAlert === 1) {
123
+ //disable left arrow
124
+ this._internalVars.arrowLeft.setAttribute('disabled', 'disabled');
125
+ this._internalVars.arrowLeft.parentNode.classList.add('disabled');
126
+ if (this._internalVars.alertItems.length === 2) {
127
+ this._internalVars.arrowRight.removeAttribute('disabled');
128
+ this._internalVars.arrowRight.parentNode.classList.remove('disabled');
129
+ }
130
+ } else if (currentAlert === this._internalVars.alertItems.length) {
131
+ //disable right arrow
132
+ if (this._internalVars.alertItems.length === 2) {
133
+ this._internalVars.arrowLeft.removeAttribute('disabled');
134
+ this._internalVars.arrowLeft.parentNode.classList.remove('disabled');
135
+ }
136
+ this._internalVars.arrowRight.setAttribute('disabled', 'disabled');
137
+ this._internalVars.arrowRight.parentNode.classList.add('disabled');
138
+ } else {
139
+ //remove disabled classes/attributes
140
+ this._internalVars.arrowLeft.removeAttribute('disabled');
141
+ this._internalVars.arrowLeft.parentNode.classList.remove('disabled');
142
+ this._internalVars.arrowRight.removeAttribute('disabled');
143
+ this._internalVars.arrowRight.parentNode.classList.remove('disabled');
144
+ }
145
+ }
146
+ function currentAlertState() {
147
+ this._internalVars.alertCurrentObject.innerHTML = this._internalVars.alertActive + 1;
148
+ }
149
+ function alertHeight() {
150
+ this._internalVars.canvasHeight = this._internalVars.backgroundPatternHeightObject.querySelector('.container').clientHeight;
151
+ setCanvasHeight.call(this);
152
+ }
153
+ function setEvents() {
154
+ this._internalVars.arrowRight.addEventListener("click", carouselSelection.bind(this));
155
+ this._internalVars.arrowLeft.addEventListener("click", carouselSelection.bind(this));
156
+ for (var i = 0; i < this._internalVars.closeButtonObject.length; i++) {
157
+ this._internalVars.closeButtonObject[i].addEventListener("click", closeButton.bind(this, this._internalVars.closeButtonObject[i]));
158
+ }
159
+ window.addEventListener('resize', alertHeight.bind(this));
160
+ }
161
+ function closeButton() {
162
+ var nextAlert = null,
163
+ currentAlert = this._internalVars.alertActive + 1;
164
+ if (currentAlert === this._internalVars.alertItems.length) {
165
+ nextAlert = this._internalVars.alertActive - 1;
166
+ } else {
167
+ nextAlert = this._internalVars.alertActive;
168
+ }
169
+ this._internalVars.alertItems[this._internalVars.alertActive].classList.remove('alert-active');
170
+ this._internalVars.alertItems[this._internalVars.alertActive].classList.remove('alert-importance');
171
+ this._internalVars.alertItems = document.querySelectorAll('.' + this._internalVars.alertItemsClass);
172
+ if (this._internalVars.alertItems.length > 0) {
173
+ this._internalVars.alertItems[nextAlert].classList.add('alert-active');
174
+ this._internalVars.alertActive = [].indexOf.call(this._internalVars.alertItems, document.querySelector('.' + this._internalVars.currentAlertClass));
175
+ if (this._internalVars.alertItems.length === 1) {
176
+ this._internalVars.carouselObject.style.display = 'none';
177
+ } else {
178
+ this._internalVars.alertTotalObject.innerHTML = this._internalVars.alertItems.length;
179
+ chevronState.call(this);
180
+ currentAlertState.call(this);
181
+ }
182
+ } else {
183
+ this._internalVars.alertVerificationItems[0].classList.remove('portfolio-alerts');
184
+ }
185
+ alertHeight.call(this);
186
+ }
187
+ function carouselSelection(e) {
188
+ e.preventDefault();
189
+ var nextAlert = null;
190
+ this._internalVars.alertItems[this._internalVars.alertActive].classList.remove('alert-active');
191
+ if (e.target.id === 'arrow-right') {
192
+ nextAlert = this._internalVars.alertActive + 1;
193
+ this._internalVars.alertActive = nextAlert;
194
+ } else {
195
+ nextAlert = this._internalVars.alertActive - 1;
196
+ this._internalVars.alertActive = nextAlert;
197
+ }
198
+ this._internalVars.alertItems[this._internalVars.alertActive].classList.add('alert-active');
199
+ alertHeight.call(this);
200
+ chevronState.call(this);
201
+ currentAlertState.call(this);
202
+ }
203
+
204
+ /**
205
+ * setLocalVars()
206
+ * set local vars to the ones passed in options
207
+ */
208
+ function setLocalVars() {
209
+ if (this._internalVars.contentType === 'string') {
210
+ this._internalVars.node = document.querySelector(this._options.content);
211
+ } else if (this._internalVars.contentType === 'domNode') {
212
+ this._internalVars.node = this._options.content;
213
+ }
214
+ this._internalVars.alertVerificationClass = 'portfolio-alerts';
215
+ this._internalVars.alertVerificationItems = document.getElementsByClassName(this._internalVars.alertVerificationClass);
216
+ this._internalVars.backgroundPatternHeightID = "background-pattern-portfolio-page";
217
+ this._internalVars.backgroundPatternHeightObject = document.getElementById(this._internalVars.backgroundPatternHeightID);
218
+ this._internalVars.canvasHeight = null;
219
+ this._internalVars.alertContainerID = 'portfolio-alert-container';
220
+ this._internalVars.alertContainerObject = document.getElementById(this._internalVars.alertContainerID);
221
+ this._internalVars.alertItemsClass = 'alert-importance';
222
+ this._internalVars.alertItems = document.querySelectorAll('.' + this._internalVars.alertItemsClass);
223
+ this._internalVars.currentAlertClass = 'alert-active';
224
+ this._internalVars.currentAlertObject = document.querySelector('.' + this._internalVars.currentAlertClass);
225
+ this._internalVars.alertActive = null;
226
+ this._internalVars.alertCurrentID = 'alert-current';
227
+ this._internalVars.alertTotalID = 'alert-total';
228
+ this._internalVars.alertCurrentObject = document.getElementById(this._internalVars.alertCurrentID);
229
+ this._internalVars.alertTotalObject = document.getElementById(this._internalVars.alertTotalID);
230
+ this._internalVars.arrowRightID = 'arrow-right';
231
+ this._internalVars.arrowRight = document.getElementById(this._internalVars.arrowRightID);
232
+ this._internalVars.arrowLeftID = 'arrow-left';
233
+ this._internalVars.arrowLeft = document.getElementById(this._internalVars.arrowLeftID);
234
+ this._internalVars.carouselClass = 'carousel';
235
+ this._internalVars.carouselObject = document.querySelector('.' + this._internalVars.carouselClass);
236
+ this._internalVars.closeButtonClass = 'icon-close-20';
237
+ this._internalVars.alertContainerID = 'portfolio-alert-container';
238
+ this._internalVars.alertContainerObject = document.getElementById(this._internalVars.alertContainerID);
239
+ this._internalVars.closeButtonObject = this._internalVars.alertContainerObject.querySelectorAll('.' + this._internalVars.closeButtonClass);
240
+ this._internalVars.canvasID = 'portfolioBackground';
241
+ }
242
+ var _default = exports["default"] = BackgroundPatternPortfolioPage;
@@ -0,0 +1,236 @@
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
+ var _UserAgentService = _interopRequireDefault(require("../../src/services/UserAgentService"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ 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); }
11
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12
+ 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); } }
13
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
+ 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); }
16
+ var validateSettings = [{
17
+ setting: "content",
18
+ isRequired: true,
19
+ validate: "type",
20
+ possibleValues: ["string", "object"],
21
+ errorMessage: ["GDK ButtonSwitch : Content must be defined and set to a DOM selector or Node"]
22
+ }, {
23
+ setting: "initialActiveSide",
24
+ isRequired: false,
25
+ validate: "value",
26
+ possibleValues: ["left", "right"],
27
+ errorMessage: ["GDK ButtonSwitch : initialActiveSide must be set to left or right"]
28
+ }, {
29
+ setting: "leftSideClicked",
30
+ isRequired: false,
31
+ validate: "type",
32
+ possibleValues: ["function"],
33
+ errorMessage: ["GDK ButtonSwitch : leftSideClicked must be a function"]
34
+ }, {
35
+ setting: "rightSideClicked",
36
+ isRequired: false,
37
+ validate: "type",
38
+ possibleValues: ["function"],
39
+ errorMessage: ["GDK ButtonSwitch : rightSideClicked must be a function"]
40
+ }];
41
+ var ButtonSwitch = /*#__PURE__*/function () {
42
+ /**
43
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
44
+ * @param {string|Object} content
45
+ * A reference to the button node to switch
46
+ *
47
+ * @param {string} [initialActiveSide="left"]
48
+ * Used to designate which side of the button is initially active. Options: "left" || "right"
49
+ *
50
+ * @param {function} [leftSideClicked]
51
+ * A callback function that gets fired when the left side of the button is clicked
52
+ *
53
+ * @param {function} [rightSideClicked]
54
+ * A callback function that gets fired when the left side of the button is clicked
55
+ */
56
+
57
+ function ButtonSwitch(options) {
58
+ _classCallCheck(this, ButtonSwitch);
59
+ this._internalVars = {
60
+ node: null,
61
+ //used for content item
62
+ left: null,
63
+ //clickable node on the left side of the button
64
+ right: null,
65
+ //clickable node on the right side of the button
66
+ sideOptions: ["left", "right"],
67
+ side: null
68
+ };
69
+
70
+ //options with defaults set
71
+ this._defaults = {
72
+ initialActiveSide: this._internalVars.sideOptions[0]
73
+ };
74
+
75
+ // Create options by extending defaults with the passed in arugments
76
+ if (options && _typeof(options) === "object") {
77
+ this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
78
+ }
79
+
80
+ //if the required options are valid set up the environment
81
+ if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
82
+ this._internalVars.contentType = _baseComponent["default"].getContentType(this);
83
+ setLocalVars.call(this);
84
+ setEvents.call(this);
85
+ if (!this._internalVars.node.getAttribute('tabindex')) this._internalVars.node.setAttribute('tabindex', '0');
86
+ this._internalVars.node.setAttribute('role', 'checkbox');
87
+ }
88
+ }
89
+
90
+ //Public Methods
91
+ /**
92
+ * currentSide()
93
+ * returns the side the switch button is currently on
94
+ * @returns {string} "left" | "right"
95
+ */
96
+ return _createClass(ButtonSwitch, [{
97
+ key: "currentSide",
98
+ value: function currentSide() {
99
+ return this._internalVars.side;
100
+ }
101
+
102
+ /**
103
+ * slideLeft()
104
+ * invokes a click on the left side of the switch button
105
+ */
106
+ }, {
107
+ key: "slideLeft",
108
+ value: function slideLeft() {
109
+ if (this._internalVars.node.classList.contains("button-switch--slide-right")) {
110
+ this._internalVars.node.classList.remove("button-switch--slide-right");
111
+ switchLeft.call(this);
112
+ } else if (this._internalVars.node.classList.contains("button-switch--start-right") && !this._internalVars.node.classList.contains("button-switch--slide-right") && !this._internalVars.node.classList.contains("button-switch--slide-left")) {
113
+ switchLeft.call(this);
114
+ }
115
+ }
116
+
117
+ /**
118
+ * slideRight()
119
+ * invokes a click on the right side of the switch button
120
+ */
121
+ }, {
122
+ key: "slideRight",
123
+ value: function slideRight() {
124
+ if (this._internalVars.node.classList.contains("button-switch--slide-left")) {
125
+ this._internalVars.node.classList.remove("button-switch--slide-left");
126
+ switchRight.call(this);
127
+ } else if (this._internalVars.node.classList.contains("button-switch--start-left") && !this._internalVars.node.classList.contains("button-switch--slide-right") && !this._internalVars.node.classList.contains("button-switch--slide-left")) {
128
+ switchRight.call(this);
129
+ }
130
+ }
131
+
132
+ /**
133
+ * destroy()
134
+ * removes the node from the dom and any events attached
135
+ */
136
+ }, {
137
+ key: "destroy",
138
+ value: function destroy() {
139
+ removeEvents.call(this);
140
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
141
+
142
+ //a little garbage collection
143
+ for (var variableKey in this) {
144
+ if (this.hasOwnProperty(variableKey)) {
145
+ delete this[variableKey];
146
+ }
147
+ }
148
+ }
149
+ }]);
150
+ }(); // Private Methods
151
+ /**
152
+ * setEvents()
153
+ * Sets all the events needed for the component
154
+ */
155
+ function setEvents() {
156
+ var eventName = _UserAgentService["default"]._clickEventName();
157
+ this._internalVars.node.addEventListener(eventName, this._internalVars.handler);
158
+ this._internalVars.node.addEventListener("keyup", this._internalVars.handler);
159
+ }
160
+
161
+ /**
162
+ * removeEvents()
163
+ * removes all events from the component
164
+ */
165
+ function removeEvents() {
166
+ var eventName = _UserAgentService["default"]._clickEventName();
167
+ this._internalVars.node.removeEventListener(eventName, this._internalVars.handler);
168
+ }
169
+
170
+ /**
171
+ * switchClick()
172
+ * if you click on button it will switch
173
+ */
174
+ function switchClick(e) {
175
+ if (e.type == 'keypress' || e.type == 'keyup' && (e.keyCode || e.which) != 13) {
176
+ return;
177
+ }
178
+ if (this._internalVars.node.classList.contains('disabled')) {
179
+ return;
180
+ }
181
+ if (this._internalVars.node.classList.contains("button-switch--slide-right")) {
182
+ this._internalVars.node.classList.remove("button-switch--slide-right");
183
+ switchLeft.call(this);
184
+ } else if (this._internalVars.node.classList.contains("button-switch--slide-left")) {
185
+ this._internalVars.node.classList.remove("button-switch--slide-left");
186
+ switchRight.call(this);
187
+ }
188
+ if (this._internalVars.node.classList.contains("button-switch--start-left") && !this._internalVars.node.classList.contains("button-switch--slide-right") && !this._internalVars.node.classList.contains("button-switch--slide-left")) {
189
+ switchRight.call(this);
190
+ } else if (this._internalVars.node.classList.contains("button-switch--start-right") && !this._internalVars.node.classList.contains("button-switch--slide-right") && !this._internalVars.node.classList.contains("button-switch--slide-left")) {
191
+ switchLeft.call(this);
192
+ }
193
+ }
194
+ function switchLeft() {
195
+ this._internalVars.node.classList.add("button-switch--slide-left");
196
+ this._internalVars.side = this._internalVars.sideOptions[0];
197
+ this._internalVars.node.setAttribute('aria-checked', 'false');
198
+ if (this._options.leftSideClicked) this._options.leftSideClicked();
199
+ }
200
+ function switchRight() {
201
+ this._internalVars.node.classList.add("button-switch--slide-right");
202
+ this._internalVars.side = this._internalVars.sideOptions[1];
203
+ this._internalVars.node.setAttribute('aria-checked', 'true');
204
+ if (this._options.rightSideClicked) this._options.rightSideClicked();
205
+ }
206
+
207
+ /**
208
+ * setLocalVars()
209
+ * set all the local vars to passed in options
210
+ */
211
+ function setLocalVars() {
212
+ //determine the type of content passed in
213
+ if (this._internalVars.contentType === 'string') {
214
+ this._internalVars.node = document.querySelector(this._options.content);
215
+ } else if (this._internalVars.contentType === 'domNode') {
216
+ this._internalVars.node = this._options.content;
217
+ }
218
+
219
+ //get the child spans to add click events too
220
+ var spans = this._internalVars.node.querySelectorAll("span");
221
+ this._internalVars.left = spans[0];
222
+ this._internalVars.right = spans[1];
223
+
224
+ //init the current side and add the class
225
+ this._internalVars.side = this._options.initialActiveSide.toLowerCase();
226
+ //check for right else use the default left
227
+ if (this._internalVars.side === this._internalVars.sideOptions[1]) {
228
+ this._internalVars.node.classList.add("button-switch--start-right");
229
+ this._internalVars.node.setAttribute('aria-checked', 'true');
230
+ } else {
231
+ this._internalVars.node.classList.add("button-switch--start-left");
232
+ this._internalVars.node.setAttribute('aria-checked', 'false');
233
+ }
234
+ this._internalVars.handler = switchClick.bind(this);
235
+ }
236
+ var _default = exports["default"] = ButtonSwitch;