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