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,243 @@
1
+ import * as utils from '../../src/utils';
2
+ import baseComponent from '../../src/baseComponent';
3
+ import UserAgentService from '../../src/services/UserAgentService';
4
+
5
+ const validateSettings = [
6
+ {
7
+ setting: "content",
8
+ isRequired: true,
9
+ validate: "type",
10
+ possibleValues: ["string", "object"],
11
+ errorMessage: ["GDK MoreInfoButton : Content must be defined and set to a DOM selector or Node"]
12
+ }
13
+ ];
14
+
15
+ class MoreInfoButton {
16
+ /**
17
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
18
+ * @param {string|Object} content
19
+ * A reference to the html More Info Button node
20
+ */
21
+ constructor(options) {
22
+
23
+ console.log('MoreInfoButton initialized');
24
+
25
+ this._internalVars = {
26
+ node: null, //used for current node
27
+ button : null,
28
+ ul : null,
29
+ wrapperElementId : "wrapper",
30
+ wrapper : null
31
+ };
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.extendDefaults(this._defaults, options);
39
+ }
40
+
41
+
42
+ //if the required options are valid set up the environment
43
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
44
+ this._internalVars.contentType = baseComponent.getContentType(this);
45
+ setLocalVars.call(this);
46
+ setEvents.call(this);
47
+
48
+ this._internalVars.button.setAttribute('aria-expanded', 'false');
49
+ this._internalVars.button.setAttribute('role', 'button');
50
+ }
51
+ }
52
+
53
+
54
+ /**
55
+ * destroy()
56
+ * removes the node from the dom and any events attached
57
+ */
58
+ destroy(){
59
+ removeEvents.call(this);
60
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
61
+
62
+ //a little garbage collection
63
+ for (var variableKey in this){
64
+ if (this.hasOwnProperty(variableKey)){
65
+ delete this[variableKey];
66
+ }
67
+ }
68
+ }
69
+
70
+ }
71
+
72
+ // Private Methods
73
+ /**
74
+ * setEvents()
75
+ * Sets all the events needed for the component
76
+ */
77
+ function setEvents() {
78
+ const eventName = UserAgentService._clickEventName();
79
+
80
+ this._internalVars.node.addEventListener('mouseleave', this._internalVars.menuHandler);
81
+ this._internalVars.button.addEventListener("pointerdown", this._internalVars.checkTouchHandler);
82
+ this._internalVars.button.addEventListener(eventName, this._internalVars.toggleHandler);
83
+ this._internalVars.button.addEventListener("keydown", this._internalVars.keyHandler);
84
+ }
85
+
86
+
87
+ /**
88
+ * removeEvents()
89
+ * removes all events from the component
90
+ */
91
+ function removeEvents() {
92
+ const eventName = UserAgentService._clickEventName();
93
+
94
+ this._internalVars.node.removeEventListener('mouseleave', this._internalVars.menuHandler);
95
+ this._internalVars.button.removeEventListener("pointerdown", this._internalVars.checkTouchHandler);
96
+ this._internalVars.button.removeEventListener(eventName, this._internalVars.toggleHandler);
97
+ this._internalVars.button.removeEventListener("keydown", this._internalVars.keyHandler);
98
+ }
99
+
100
+ function closeMenu(){
101
+ this._internalVars.ul.classList.remove("options-in");
102
+ this._internalVars.ul.classList.add("options-out");
103
+ this._internalVars.button.setAttribute('aria-expanded', 'false');
104
+ setTimeout( ()=> {
105
+ this._internalVars.ul.style.display = "none";
106
+ }, 300);
107
+
108
+ }
109
+
110
+ function checkForTouch(el){
111
+ console.log(el.pointerType);
112
+ if(el.pointerType=='touch'){
113
+ this._internalVars.node.removeEventListener('mouseleave', this._internalVars.menuHandler);
114
+ }else{
115
+ this._internalVars.node.addEventListener('mouseleave', this._internalVars.menuHandler);
116
+ }
117
+ }
118
+
119
+ /**
120
+ * toggleOptions()
121
+ * toggles the options view
122
+ */
123
+ function toggleOptions() {
124
+
125
+ if(utils.hasClass(this._internalVars.ul, "options-in")){
126
+ this._internalVars.ul.classList.remove("options-in");
127
+ this._internalVars.ul.classList.add("options-out");
128
+ this._internalVars.button.setAttribute('aria-expanded', 'false');
129
+ setTimeout( ()=> {
130
+ this._internalVars.ul.style.display = "none";
131
+ }, 300);
132
+ }else{
133
+ this._internalVars.ul.style.display = "block";
134
+ this._internalVars.ul.classList.remove("options-out");
135
+ this._internalVars.ul.classList.add("options-in");
136
+ this._internalVars.button.setAttribute('aria-expanded', 'true');
137
+
138
+ checkUlPosistion.call(this);
139
+ }
140
+
141
+
142
+ }
143
+
144
+ function keyOptions(e) {
145
+ if((e.type == 'keydown' || e.type == 'keypress') && ((e.keyCode || e.which) != 13))
146
+ {
147
+ return;
148
+ }else{
149
+ if(utils.hasClass(this._internalVars.ul, "options-out")){
150
+ this._internalVars.ul.style.display = "block";
151
+ this._internalVars.ul.classList.remove("options-out");
152
+ this._internalVars.ul.classList.add("options-in");
153
+ this._internalVars.button.setAttribute('aria-expanded', 'true');
154
+ let allA = this._internalVars.ul.querySelectorAll('a');
155
+ allA[0].focus();
156
+
157
+ checkUlPosistion.call(this);
158
+ }
159
+ }
160
+
161
+ }
162
+
163
+ /**
164
+ * toggleOptions()
165
+ * detect if there is enough space to see the whole menu when opened
166
+ * if not we need to scroll the body so there is enough space
167
+ */
168
+ function checkUlPosistion() {
169
+
170
+ if((this._internalVars.ul.getBoundingClientRect().top + this._internalVars.ul.offsetHeight) > window.innerHeight){
171
+
172
+ let windowHeight = window.innerHeight;
173
+ let moreInfoHeight = (this._internalVars.ul.getBoundingClientRect().top + this._internalVars.ul.offsetHeight);
174
+ let neededSpace = moreInfoHeight - windowHeight;
175
+
176
+ let currentScrollOffset = window.scrollY || window.pageYOffset;
177
+ let newScrollOffset = Math.round(currentScrollOffset + neededSpace);
178
+
179
+ scrollTo(newScrollOffset, 200);
180
+ }
181
+ }
182
+
183
+
184
+ /**
185
+ * scrollTo()
186
+ * Scrolls to a specific point
187
+ * @param to
188
+ * @param duration
189
+ */
190
+ function scrollTo(to, duration) {
191
+ var start = document.documentElement.scrollTop || document.body.scrollTop,
192
+ change = to - start,
193
+ currentTime = 0,
194
+ increment = 20;
195
+
196
+ var animateScroll = function(){
197
+ currentTime += increment;
198
+ var val = easeInOutQuad(currentTime, start, change, duration);
199
+ document.documentElement.scrollTop = val;
200
+ document.body.scrollTop = val;
201
+
202
+ if(currentTime < duration) {
203
+ setTimeout(animateScroll, increment);
204
+ }
205
+ };
206
+ animateScroll();
207
+ }
208
+
209
+ /**
210
+ * easeInQuad()
211
+ * Quadratic easing
212
+ */
213
+ function easeInOutQuad(t, b, c, d) {
214
+ t /= d/2;
215
+ if (t < 1) return c/2*t*t + b;
216
+ t--;
217
+ return -c/2 * (t*(t-2) - 1) + b;
218
+ }
219
+
220
+
221
+
222
+ /**
223
+ * setLocalVars()
224
+ * set local vars to the ones passed in options
225
+ */
226
+ function setLocalVars() {
227
+ if(this._internalVars.contentType === 'string') {
228
+ this._internalVars.node = document.querySelector(this._options.content);
229
+ } else if (this._internalVars.contentType === 'domNode') {
230
+ this._internalVars.node = this._options.content;
231
+ }
232
+
233
+ this._internalVars.button = this._internalVars.node.querySelector(".more-info-button");
234
+ this._internalVars.ul = this._internalVars.node.querySelector("ul");
235
+ this._internalVars.wrapper = document.querySelector("#" + this._internalVars.wrapperElementId);
236
+
237
+ this._internalVars.menuHandler = closeMenu.bind(this);
238
+ this._internalVars.toggleHandler = toggleOptions.bind(this);
239
+ this._internalVars.keyHandler = keyOptions.bind(this);
240
+ this._internalVars.checkTouchHandler = checkForTouch.bind(this);
241
+ }
242
+
243
+ export default MoreInfoButton;
@@ -0,0 +1,211 @@
1
+ import baseComponent from '../../src/baseComponent';
2
+
3
+ const validateSettings = [
4
+ {
5
+ setting: "content",
6
+ isRequired: true,
7
+ validate: "type",
8
+ possibleValues: ["string", "object"],
9
+ errorMessage: ["GDK MultipleSelectBox : Content must be defined and set to a DOM selector or Node"]
10
+ },
11
+ {
12
+ setting: "config",
13
+ isRequired: false,
14
+ validate: "type",
15
+ possibleValues: ["object"],
16
+ errorMessage: ["GDK MultipleSelectBox : config may be defined and set as an object"]
17
+ },
18
+ {
19
+ setting: "initialOptions",
20
+ isRequired: false,
21
+ validate: "type",
22
+ possibleValues: ["object", "string"],
23
+ errorMessage: ["GDK MultipleSelectBox : initialOptions may be defined and set as an array"]
24
+ },
25
+ {
26
+ setting: "multiSelectChange",
27
+ isRequired: false,
28
+ validate: "type",
29
+ possibleValues: ["function"],
30
+ errorMessage: ["GDK MultipleSelectBox : multiSelectChange may be defined and set as a function"]
31
+ }
32
+
33
+ ];
34
+
35
+ /**
36
+ * MultipleSelectBox class
37
+ */
38
+ class MultipleSelectBox {
39
+
40
+ /**
41
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
42
+ * @param {string|Object} content
43
+ * A reference to the multiple select box node
44
+ *
45
+ * @param {Object} [initialOptions]
46
+ * An array containing strings corresponding to 'value' attributes or numbers referencing the index of the select options
47
+ *
48
+ * @param {function} [multiSelectChange]
49
+ * A callback function that is triggered when an option is added or removed from the Multi-Select Box
50
+ */
51
+ constructor(options) {
52
+
53
+ this._internalVars = {
54
+ node: null,//used for current node
55
+ closeBtn: null
56
+ };
57
+
58
+ //options with defaults set
59
+ this._defaults = {
60
+ autoShow: false,
61
+ overlayShouldCloseModal: true,
62
+ hideCloseButton: false,
63
+ config: {
64
+ '.chosen-select': {},
65
+ '.chosen-select-deselect': {allow_single_deselect: true},
66
+ '.chosen-select-no-single': {disable_search_threshold: 10},
67
+ '.chosen-select-no-results': {no_results_text: 'Oops, nothing found!'},
68
+ '.chosen-select-width': {width: "auto"}
69
+ }
70
+ };
71
+
72
+ // Create options by extending defaults with the passed in arugments
73
+ if (options && typeof options === "object") {
74
+ this._options = baseComponent.extendDefaults(this._defaults, options);
75
+ }
76
+
77
+ //if the required options are valid set up the environment
78
+ if (baseComponent.validateSettings(this._options, validateSettings)) {
79
+ this._internalVars.contentType = baseComponent.getContentType(this);
80
+ setLocalVars.call(this);
81
+ init.call(this);
82
+ setEvents.call(this);
83
+ }
84
+
85
+ }
86
+
87
+ //Public Methods
88
+
89
+ /**
90
+ * sets the initial selected options
91
+ * @param {Object} array Array containing the index or option text of the items to be pre-selected
92
+ */
93
+ setInitialSelectionOptions(array) {
94
+ setInitialSelections.call(this, array);
95
+ }
96
+
97
+ /**
98
+ * Returns the current selected options
99
+ * @returns {Array} containing the selected options
100
+ */
101
+ activeSelections() {
102
+ return this._internalVars.selectedItems;
103
+ }
104
+
105
+ /**
106
+ * removes the node from the dom and any events attached
107
+ */
108
+ destroy(){
109
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
110
+
111
+ //a little garbage collection
112
+ for (var variableKey in this){
113
+ if (this.hasOwnProperty(variableKey)){
114
+ delete this[variableKey];
115
+ }
116
+ }
117
+ }
118
+
119
+ }
120
+
121
+ function init() {
122
+ if (this._options.initialOptions) {
123
+ let array = this._options.initialOptions;
124
+
125
+ setInitialSelections.call(this, array);
126
+ }
127
+
128
+ for (let selector in this._options.config) {
129
+ $(selector).chosen(this._options.config[selector]);
130
+ }
131
+ }
132
+
133
+ function setEvents() {
134
+ $('#'+this._internalVars.node.id).chosen().on('change', updateValues.bind(this));
135
+ }
136
+
137
+
138
+ /**
139
+ * Sets the initial values pragmatically
140
+ * @param {array} array Array containing numbers or strings referencing options to be set by default
141
+ */
142
+ function setInitialSelections(array) {
143
+
144
+ let initialValues = [];
145
+
146
+ Array.prototype.forEach.call(array, (item)=>{
147
+ if (typeof item === "string") {
148
+ Array.prototype.forEach.call(this._internalVars.node.options, (ele)=>{
149
+ if (item === ele.value) {
150
+ initialValues.push(item);
151
+ }
152
+ });
153
+ } else if (typeof item === "number") {
154
+ if (item >= 0 && item <= this._internalVars.node.options.length) {
155
+ if (item - Math.floor(item) === 0) {
156
+ let value = this._internalVars.node.options[item].value;
157
+ initialValues.push(value);
158
+ }
159
+ }
160
+ }
161
+ });
162
+
163
+ $('#'+this._internalVars.node.id).val(initialValues).trigger('chosen:updated');
164
+
165
+ updateValues.call(this);
166
+ }
167
+
168
+ /**
169
+ * creates an array of the chosen values
170
+ */
171
+ function updateValues() {
172
+
173
+ let selectBox = $('#'+this._internalVars.node.id),
174
+ empty;
175
+
176
+ this._internalVars.selectedItems = [];
177
+
178
+ if (selectBox.val() !== null) {
179
+ Array.prototype.forEach.call(selectBox.val(), (element)=>{
180
+ Array.prototype.forEach.call(this._internalVars.node.options, (el)=>{
181
+ if (element === el.value) {
182
+ this._internalVars.selectedItems.push(el);
183
+ }
184
+ });
185
+ });
186
+ empty = false;
187
+ } else {
188
+ empty = true;
189
+ }
190
+
191
+ if(this._options.multiSelectChange) {
192
+ this._options.multiSelectChange(this._internalVars.selectedItems, empty);
193
+ }
194
+ }
195
+
196
+ /**
197
+ * setLocalVars()
198
+ * set all the local vars to passed in options
199
+ */
200
+ function setLocalVars() {
201
+ //determine the type of content passed in
202
+ if (this._internalVars.contentType === 'string') {
203
+ this._internalVars.node = document.querySelector(this._options.content);
204
+ } else if (this._internalVars.contentType === 'domNode') {
205
+ this._internalVars.node = this._options.content;
206
+ }
207
+
208
+ this._internalVars.nodeParent = this._internalVars.node.parentNode;
209
+ }
210
+
211
+ export default MultipleSelectBox;
@@ -0,0 +1,163 @@
1
+ import appState from '../../src/appState';
2
+
3
+ import baseComponent from '../../src/baseComponent';
4
+ import UserAgentService from '../../src/services/UserAgentService';
5
+
6
+ const validateSettings = [
7
+ {
8
+ setting : "content",
9
+ isRequired : true,
10
+ validate : "type",
11
+ possibleValues : ["string","object"],
12
+ errorMessage : ["GDK NavigationalBox : Content must be defined and set to a DOM selector or Node"]
13
+ },
14
+ {
15
+ setting : "urlSetting",
16
+ isRequired : true,
17
+ validate : "type",
18
+ possibleValues : ["string"],
19
+ errorMessage : ["GDK NavigationalBox : urlSetting must be defined and set to a URL string"]
20
+ },
21
+ {
22
+ setting : "targetSetting",
23
+ isRequired : false,
24
+ validate : "value",
25
+ possibleValues : ["_self","_blank"],
26
+ errorMessage : ["GDK NavigationalBox : targetSetting must be defined and set to '_self' or '_blank'"]
27
+ }
28
+ ];
29
+
30
+ class NavigationalBox{
31
+
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 navigational box
36
+ *
37
+ * @param {string} urlSetting
38
+ * Used to set the initial URL for the navigational box
39
+ *
40
+ * @param {string} [targetSetting="_self"]
41
+ * Used to set URL target to open in same page or in a new window/tab
42
+ */
43
+ constructor(options) {
44
+
45
+ this._internalVars = {
46
+ node: null//used for content item
47
+ };
48
+
49
+ //options with defaults set
50
+ this._defaults = {
51
+ targetSetting : "_self"
52
+ };
53
+
54
+ // Create options by extending defaults with the passed in arugments
55
+ if (options && typeof options === "object") {
56
+ this._options = baseComponent.extendDefaults(this._defaults, options);
57
+ }
58
+
59
+ //if the required options are valid set up the environment
60
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
61
+ this._internalVars.contentType = baseComponent.getContentType(this);
62
+ setLocalVars.call(this);
63
+ setEvents.call(this);
64
+ if(!this._internalVars.node.getAttribute('tabindex'))
65
+ this._internalVars.node.setAttribute('tabindex', '0');
66
+
67
+ this._internalVars.node.setAttribute('role', 'link');
68
+ }
69
+ }
70
+
71
+ //Public Methods
72
+ /**
73
+ * @param {string} [url]
74
+ * url is new URL string to set to component
75
+ */
76
+ setURL(url){
77
+ this._options.urlSetting = url;
78
+ }
79
+
80
+ /**
81
+ * @param {string} [target="_self"]
82
+ * target is new target string to set to component with '_self' or '_blank'
83
+ */
84
+ setTarget(target){
85
+ this._options.targetSetting = target;
86
+ }
87
+
88
+ /**
89
+ * destroy()
90
+ * removes the node from the dom and any events attached
91
+ */
92
+ destroy(){
93
+ removeEvents.call(this);
94
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
95
+
96
+ //a little garbage collection
97
+ for (var variableKey in this){
98
+ if (this.hasOwnProperty(variableKey)){
99
+ delete this[variableKey];
100
+ }
101
+ }
102
+ }
103
+
104
+ }
105
+
106
+ // Private Methods
107
+ /**
108
+ * setEvents()
109
+ * Sets all the events needed for the component
110
+ */
111
+ function setEvents() {
112
+ const eventName = UserAgentService._clickEventName();
113
+
114
+ if(appState.mode == 'mobile' && appState.isTouchDevice === true && screen.width <= 480){
115
+ this._internalVars.node.addEventListener("click", this._internalVars.handler);
116
+ }else{
117
+ this._internalVars.node.addEventListener(eventName, this._internalVars.handler);
118
+ this._internalVars.node.addEventListener("keyup", this._internalVars.handler);
119
+ }
120
+
121
+
122
+ }
123
+
124
+
125
+ /**
126
+ * removeEvents()
127
+ * removes all events from the component
128
+ */
129
+ function removeEvents() {
130
+ const eventName = UserAgentService._clickEventName();
131
+
132
+ this._internalVars.node.removeEventListener(eventName, this._internalVars.handler);
133
+ this._internalVars.node.removeEventListener("keyup", this._internalVars.handler);
134
+ }
135
+
136
+ /**
137
+ * setLocalVars()
138
+ * set all the local vars to passed in options
139
+ */
140
+ function setLocalVars() {
141
+ //determine the type of content passed in
142
+ if(this._internalVars.contentType === 'string'){
143
+ this._internalVars.node = document.querySelector(this._options.content);
144
+ }else if(this._internalVars.contentType === 'domNode'){
145
+ this._internalVars.node = this._options.content;
146
+ }
147
+
148
+ this._internalVars.handler = redirectionToURL.bind(this);
149
+ }
150
+
151
+ function redirectionToURL(el){
152
+ if(el.type == 'keypress' || el.type == 'keyup' && ((el.keyCode || el.which) != 13)){
153
+ return;
154
+ }
155
+ if(appState.mode == 'desktop'){
156
+ window.open(this._options.urlSetting, this._options.targetSetting);
157
+ }else if(appState.mode == 'mobile'){
158
+ window.open(this._options.urlSetting, '_self');
159
+ }
160
+ }
161
+
162
+
163
+ export default NavigationalBox;