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,344 @@
1
+ import baseComponent from '../../src/baseComponent';
2
+ import UserAgentService from '../../src/services/UserAgentService';
3
+
4
+ const validateSettings = [
5
+ {
6
+ setting : "content",
7
+ isRequired : true,
8
+ validate : "type",
9
+ possibleValues : ["string","object"],
10
+ errorMessage : ["GDK Tooltip : Content must be defined and set to a DOM selector or Node"]
11
+ },
12
+ {
13
+ setting : "toolTipText",
14
+ isRequired : false,
15
+ validate : "type",
16
+ possibleValues : ["string"],
17
+ errorMessage : ["GDK Tooltip : toolTipText must be set to a string"]
18
+ },
19
+ {
20
+ setting: "toolTipOpen",
21
+ isRequired: false,
22
+ validate: "type",
23
+ possibleValues: ["function"],
24
+ errorMessage: ["GDK Tooltip : toolTipOpen must be defined and set function"]
25
+ },
26
+ {
27
+ setting: "toolTipClose",
28
+ isRequired: false,
29
+ validate: "type",
30
+ possibleValues: ["function"],
31
+ errorMessage: ["GDK Tooltip : toolTipClose must be defined and set function"]
32
+ }
33
+ ];
34
+
35
+ class Tooltip{
36
+ /**
37
+ * Refer to the design kit section of this component for JS examples and setting details.
38
+ * @param {string, Object} content
39
+ * A reference to the html Tooltip trigger's node
40
+ *
41
+ * @param {string} [toolTipText]
42
+ * Callback function fired once a 'filter-submit' is clicked
43
+ *
44
+ * @param {function} [toolTipOpen]
45
+ * A callback function triggered when a tooltip is displayed
46
+ *
47
+ * @param {function} [toolTipClose]
48
+ * A callback function triggered when a tooltip is closed manually
49
+ *
50
+ */
51
+ constructor(options) {
52
+
53
+ this._internalVars = {
54
+ node: null,//used for content item
55
+ toolTip : null,
56
+
57
+ triggerOffset : null,
58
+ timeout : null,
59
+ delay : 300, // delay 0.3 seconds
60
+ breakpoint : 768,
61
+ margin : 12,
62
+ wrapperElementId : "wrapper",
63
+ toolTiplElementClass : "tooltip",
64
+ toolTipTriggerElementClass : "tooltip-trigger",
65
+ toolTipCloseElementClass : "icon-close-20",
66
+ toolTipActiveClass : "tooltip--active",
67
+ wrapper : null,
68
+ closeBtn : null
69
+ };
70
+
71
+ //options with defaults set
72
+ this._defaults = {
73
+ toolTipText: null
74
+ };
75
+
76
+ // Create options by extending defaults with the passed in arugments
77
+ if (options && typeof options === "object") {
78
+ this._options = baseComponent.extendDefaults(this._defaults, options);
79
+ }
80
+
81
+ //if the required options are valid set up the environment
82
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
83
+ this._internalVars.contentType = baseComponent.getContentType(this);
84
+ setLocalVars.call(this);
85
+ setEvents.call(this);
86
+ }
87
+ }
88
+
89
+ //Public Methods
90
+
91
+ /**
92
+ * destroy()
93
+ * removes the node from the dom and any events attached
94
+ */
95
+ destroy(){
96
+ removeEvents.call(this);
97
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
98
+ this._internalVars.toolTip.parentNode.removeChild(this._internalVars.toolTip);
99
+ //a little garbage collection
100
+ for (let variableKey in this){
101
+ if (this.hasOwnProperty(variableKey)){
102
+ delete this[variableKey];
103
+ }
104
+ }
105
+ }
106
+
107
+ }
108
+
109
+ // Private Methods
110
+ /**
111
+ * setLocalVars()
112
+ * set all the local vars to passed in options
113
+ */
114
+ function setLocalVars() {
115
+ //determine the type of content passed in
116
+ if(this._internalVars.contentType === 'string'){
117
+ this._internalVars.node = document.querySelector(this._options.content);
118
+ }else if(this._internalVars.contentType === 'domNode'){
119
+ this._internalVars.node = this._options.content;
120
+ }
121
+
122
+ if(this._options.toolTipText === null) {
123
+ this._internalVars.toolTip = document.querySelector("#" + this._internalVars.node.getAttribute('data-tooltip-view'));
124
+ this._internalVars.node.parentNode.insertBefore(this._internalVars.toolTip, this._internalVars.node.nextSibling);
125
+ }else{
126
+ buildNewTooltip.call(this);
127
+ }
128
+
129
+ this._internalVars.wrapper = document.querySelector("#" + this._internalVars.wrapperElementId);
130
+ this._internalVars.closeBtn = this._internalVars.toolTip.querySelector("." + this._internalVars.toolTipCloseElementClass);
131
+ this._internalVars.toolTipClass = 'tooltip';
132
+ }
133
+
134
+ /**
135
+ * setEvents()
136
+ * Sets all the events needed for the component
137
+ */
138
+ function setEvents() {
139
+ const eventName = UserAgentService._clickEventName();
140
+ if ("ontouchstart" in document.documentElement)
141
+ {
142
+ this._internalVars.node.addEventListener(eventName, showToolTip.bind(this));
143
+ this._internalVars.node.addEventListener("mouseover", showToolTip.bind(this));
144
+ this._internalVars.closeBtn.addEventListener(eventName, closeBtnClickHandler.bind(this));
145
+ } else {
146
+ this._internalVars.node.addEventListener("mouseenter", showToolTip.bind(this));
147
+ this._internalVars.node.addEventListener(eventName, function(e){e.preventDefault();});
148
+ this._internalVars.node.addEventListener("focus", showToolTip.bind(this));
149
+ this._internalVars.node.addEventListener("keydown", shiftTab.bind(this));
150
+ this._internalVars.closeBtn.addEventListener(eventName, closeBtnClickHandler.bind(this));
151
+ this._internalVars.closeBtn.addEventListener("blur", closeBtnClickHandler.bind(this));
152
+ }
153
+ }
154
+
155
+ function shiftTab(e){
156
+ if(e.keyCode == '9' && e.shiftKey){
157
+ hideToolTip.call(this);
158
+ }
159
+ }
160
+
161
+ /**
162
+ * removeEvents()
163
+ * removes all events from the component
164
+ */
165
+ function removeEvents() {
166
+ const eventName = UserAgentService._clickEventName();
167
+ if ("ontouchstart" in document.documentElement)
168
+ {
169
+ this._internalVars.node.removeEventListener(eventName, showToolTip.bind(this));
170
+ this._internalVars.node.removeEventListener("mouseover", showToolTip.bind(this));
171
+ this._internalVars.closeBtn.removeEventListener(eventName, closeBtnClickHandler.bind(this));
172
+ } else {
173
+ this._internalVars.node.removeEventListener("mouseenter", showToolTip.bind(this));
174
+ this._internalVars.closeBtn.removeEventListener(eventName, closeBtnClickHandler.bind(this));
175
+ this._internalVars.node.removeEventListener(eventName, function(e){e.preventDefault();});
176
+ this._internalVars.node.removeEventListener("focus", showToolTip.bind(this));
177
+ this._internalVars.node.removeEventListener("keydown", shiftTab.bind(this));
178
+ this._internalVars.closeBtn.removeEventListener("blur", closeBtnClickHandler.bind(this));
179
+ }
180
+ }
181
+
182
+ /**
183
+ * closeBtnClickHandler()
184
+ * catches click on close button
185
+ */
186
+ function closeBtnClickHandler(e){
187
+ console.log("closeBtnClickHandler");
188
+ e.preventDefault();
189
+ hideToolTip.call(this);
190
+
191
+ if(this._options.toolTipClose) {
192
+ let tooltip = e.currentTarget.parentNode;
193
+ this._options.toolTipClose(tooltip);
194
+ }
195
+ }
196
+
197
+ /**
198
+ * buildNewTooltip()
199
+ * use to dynamically create the tooltip
200
+ */
201
+ function buildNewTooltip() {
202
+ let toolTipId = this._internalVars.node.getAttribute('data-tooltip-view');
203
+
204
+ let dynamicToolTip = document.createElement('div');
205
+ dynamicToolTip.setAttribute('id', toolTipId);
206
+ dynamicToolTip.classList.add("tooltip");
207
+ dynamicToolTip.innerHTML= '<div tabindex="0">' + this._options.toolTipText + '</div><button class="icon-close-20" aria-label="Close tooltip"></button>';
208
+
209
+ this._internalVars.node.parentNode.insertBefore(dynamicToolTip, this._internalVars.node.nextSibling);
210
+ this._internalVars.toolTip = document.querySelector("#" + toolTipId);
211
+ }
212
+
213
+ /**
214
+ * showToolTip()
215
+ * show tooltip on hover
216
+ */
217
+ function showToolTip(e){
218
+ e.preventDefault();
219
+
220
+ // prep tooltip
221
+
222
+ let toolTipId = this._internalVars.node.getAttribute('data-tooltip-view');
223
+ let toolTip = document.querySelector("#"+toolTipId);
224
+ this._internalVars.node.parentNode.insertBefore(toolTip, this._internalVars.node.nextSibling);
225
+ this._internalVars.toolTip = toolTip;
226
+
227
+ try {
228
+ hideToolTip.call(this);
229
+ } catch(err) {
230
+ // clear existing tt
231
+ }
232
+
233
+ clearTimeout(this._internalVars.timeout);
234
+ let self = e.currentTarget;
235
+
236
+ self.classList.add(this._internalVars.toolTipActiveClass);
237
+
238
+ this._internalVars.activationArea = self;
239
+
240
+ self.addEventListener("mouseleave", settimeout.bind(this));
241
+
242
+ this._internalVars.toolTip.addEventListener("mouseleave", settimeout.bind(this));
243
+
244
+ this._internalVars.toolTip.addEventListener("mouseover", cleartimeout.bind(this));
245
+
246
+ this._internalVars.triggerOffset = self.getBoundingClientRect();
247
+
248
+ setTimeout(()=>{
249
+ if(self.classList.contains("tooltip--active")) {
250
+ this._internalVars.toolTip.style.display = "block";
251
+ //position the tooltip after setting to block
252
+ positionToolTip.call(this);
253
+ //set opacity and let css transition fade it in
254
+ this._internalVars.toolTip.style.opacity = 1;
255
+ }
256
+ },this._internalVars.delay);
257
+
258
+ if(this._options.toolTipOpen) {
259
+ let triggerElement = e.currentTarget.parentNode,
260
+ tooltip = triggerElement.querySelector('.' + this._internalVars.toolTipClass);
261
+ this._options.toolTipOpen(tooltip);
262
+ }
263
+ }
264
+
265
+ /**
266
+ * cleartimeout()
267
+ * clears set timeout
268
+ */
269
+ function cleartimeout(e){
270
+ clearTimeout(this._internalVars.timeout);
271
+ }
272
+
273
+ /**
274
+ * settimeout()
275
+ * sets a timeout to hide the tooltip
276
+ */
277
+ function settimeout(e){
278
+ if(document.activeElement != e.currentTarget){
279
+ clearTimeout(this._internalVars.timeout);
280
+ this._internalVars.node.classList.remove(this._internalVars.toolTipActiveClass);
281
+ this._internalVars.timeout = setTimeout(hideToolTip.bind(this), 200);
282
+ // this._internalVars.timeout = hideToolTip.call(this);
283
+ }
284
+ }
285
+
286
+ /**
287
+ * hideToolTip()
288
+ * hides the tooltip
289
+ */
290
+ function hideToolTip(){
291
+ this._internalVars.toolTip.style.opacity = 0;
292
+
293
+ setTimeout(()=>{
294
+ this._internalVars.toolTip.style.display = "none";
295
+ },this._internalVars.delay);
296
+
297
+ }
298
+
299
+ /**
300
+ * positionToolTip()
301
+ * sets the position for the tooltip depending on trigger position
302
+ */
303
+ function positionToolTip(){
304
+ this._internalVars.toolTip.classList.remove("arrow-right");
305
+ this._internalVars.toolTip.classList.remove("arrow-bottom");
306
+
307
+ let winWidth = document.body.clientWidth;
308
+ let winHeight = window.innerHeight || document.documentElement.clientHeight;
309
+ let containerOffset = this._internalVars.wrapper.getBoundingClientRect();
310
+ let containerOffsetLeft = containerOffset.left;
311
+ let containerWidth = this._internalVars.wrapper.offsetWidth;
312
+ let tooltipWidth = this._internalVars.toolTip.offsetWidth;
313
+ let tooltipHeight = this._internalVars.toolTip.offsetHeight;
314
+ let xpos = null;
315
+ let ypos = null;
316
+
317
+ if( winWidth < this._internalVars.breakpoint){
318
+ ypos = 25;
319
+ if( this._internalVars.triggerOffset.left - containerOffsetLeft + tooltipWidth< containerWidth) {
320
+ xpos = 0;
321
+ }else{
322
+ xpos = -(this._internalVars.triggerOffset.left - containerOffsetLeft + tooltipWidth - containerWidth + 10);
323
+ }
324
+
325
+ }else{
326
+ xpos = 40;
327
+ ypos = -15;
328
+ if( this._internalVars.triggerOffset.left - containerOffsetLeft + tooltipWidth + 50 < containerWidth){
329
+ xpos = 40;
330
+ ypos = -15;
331
+ }else{
332
+ xpos = -(tooltipWidth + 5);
333
+ this._internalVars.toolTip.classList.add("arrow-right");
334
+ }
335
+ }
336
+
337
+ this._internalVars.toolTip.style.left = xpos + "px";
338
+ this._internalVars.toolTip.style.top = ypos + "px";
339
+
340
+ }
341
+
342
+
343
+
344
+ export default Tooltip;
@@ -0,0 +1,196 @@
1
+ import * as utils from '../../src/utils';
2
+ import baseComponent from '../../src/baseComponent';
3
+
4
+ const validateSettings = [
5
+ {
6
+ setting: "content",
7
+ isRequired: true,
8
+ validate: "type",
9
+ possibleValues: ["string", "object"],
10
+ errorMessage: ["GDK UpsellCarousel : Content must be defined and set to a DOM selector or Node"]
11
+ }
12
+ ];
13
+
14
+ class UpsellCarousel {
15
+ constructor(options) {
16
+
17
+ console.log('UpsellCarousel initialized');
18
+
19
+ this._internalVars = {
20
+ node: null
21
+ };
22
+
23
+ //options with defaults set
24
+ this._defaults = {
25
+
26
+ };
27
+
28
+ // Create options by extending defaults with the passed in arguments
29
+ if (options && typeof options === "object") {
30
+ this._options = baseComponent.extendDefaults(this._defaults, options);
31
+ }
32
+
33
+
34
+ //if the required options are valid set up the environment
35
+ if( baseComponent.validateSettings(this._options, validateSettings) ){
36
+ this._internalVars.contentType = baseComponent.getContentType(this);
37
+ setLocalVars.call(this);
38
+ setEvents.call(this);
39
+ if(this._internalVars.node) {
40
+ carouselDefaults.call(this);
41
+ }
42
+ }
43
+ }
44
+ }
45
+
46
+ // Private Methods
47
+ /**
48
+ * setEvents()
49
+ * Sets all the events needed for the component
50
+ */
51
+ function setEvents() {
52
+ window.addEventListener("load", carouselDefaults.bind(this));
53
+ window.addEventListener("resize", carouselDefaults.bind(this));
54
+
55
+ for(let i=0;i<this._internalVars.carouselChevronBtn.length;i++){
56
+ this._internalVars.carouselChevronBtn[i].addEventListener("click", carouselClick.bind(this, this._internalVars.carouselChevronBtn[i]));
57
+ }
58
+ }
59
+
60
+
61
+ /**
62
+ * removeEvents()
63
+ * removes all events from the component
64
+ */
65
+ function removeEvents() {
66
+ window.removeEventListener("load", carouselDefaults.bind(this));
67
+ window.removeEventListener("resize", carouselDefaults.bind(this));
68
+
69
+ for(let i=0;i<this._internalVars.carouselChevronBtn.length;i++){
70
+ this._internalVars.carouselChevronBtn[i].removeEventListener("click", carouselClick.bind(this, this._internalVars.carouselChevronBtn[i]));
71
+ }
72
+ }
73
+
74
+
75
+ /**
76
+ * toggleView()
77
+ * instantiate View More/Less
78
+ */
79
+ function carouselDefaults() {
80
+ if(window.innerWidth > this._internalVars.carouselIconDisplay) {
81
+ this._internalVars.carouselIconNumber = 4;
82
+ }
83
+ else if(window.innerWidth > this._internalVars.carouselIconSmallDisplay) {
84
+ this._internalVars.carouselIconNumber = 2;
85
+ }
86
+ else {
87
+ this._internalVars.carouselIconNumber = 1;
88
+ }
89
+
90
+ this._internalVars.carouselIconWidth = this._internalVars.carouselObject.querySelector(this._internalVars.carouselIconClass).clientWidth;
91
+
92
+ this._internalVars.carouselObject.style.width = (this._internalVars.carouselIconNumber + 2) * this._internalVars.carouselIconWidth + 'px';
93
+ this._internalVars.carouselItemsLeft = this._internalVars.carouselUpsellNumber - this._internalVars.carouselIconNumber;
94
+ this._internalVars.carouselLeftVal = 0;
95
+ this._internalVars.carouselObject.querySelector(this._internalVars.carouselIconWrapperClass).style.left = 0 + 'px';
96
+
97
+ var wrapperWidth = this._internalVars.carouselIconWidth * this._internalVars.carouselIconNumber,
98
+ containerWidth = this._internalVars.carouselIconWidth * this._internalVars.carouselUpsellNumber;
99
+
100
+ document.querySelector(this._internalVars.carouselWrapperClass).style.width = wrapperWidth + 'px';
101
+ document.querySelector(this._internalVars.carouselIconWrapperClass).style.width = containerWidth + 'px';
102
+
103
+ chevronState.call(this);
104
+ }
105
+
106
+ function carouselClick(e) {
107
+
108
+ if(!e.classList.contains("disabled")) {
109
+
110
+ let itemsLeftWidth = document.querySelector(this._internalVars.carouselIconWrapperClass).style.getPropertyValue("left"),
111
+ itemsLeftWidthValue = itemsLeftWidth.slice(0, -2),
112
+ itemsLeftWidthVal = Number(itemsLeftWidthValue.replace(/^-/, "")),
113
+ itemsRightWidth = (this._internalVars.carouselIconWidth * this._internalVars.carouselUpsellNumber) - itemsLeftWidthVal - (this._internalVars.carouselIconWidth * this._internalVars.carouselIconNumber);
114
+
115
+ var operand = null;
116
+ var totalScrollValue = null;
117
+ var movementValue = null;
118
+
119
+ if(e.querySelector("span").classList.contains("icon-chevron-right")){
120
+ operand = "-";
121
+ totalScrollValue = itemsRightWidth;
122
+ }
123
+ else {
124
+ operand = "+";
125
+ totalScrollValue = itemsLeftWidthVal;
126
+ }
127
+
128
+ if(this._internalVars.carouselIconWidth * this._internalVars.carouselIconNumber > totalScrollValue){
129
+ movementValue = totalScrollValue;
130
+ }
131
+ else {
132
+ movementValue = this._internalVars.carouselIconWidth * this._internalVars.carouselIconNumber;
133
+ }
134
+
135
+ if(operand === "+") {
136
+ this._internalVars.carouselObject.querySelector(this._internalVars.carouselIconWrapperClass).style.left = Number(itemsLeftWidthValue) + movementValue + 'px';
137
+ } else {
138
+ this._internalVars.carouselObject.querySelector(this._internalVars.carouselIconWrapperClass).style.left = Number(itemsLeftWidthValue) - movementValue + 'px';
139
+ }
140
+
141
+ chevronState.call(this);
142
+ }
143
+
144
+ }
145
+
146
+
147
+ function chevronState() {
148
+ let itemsLeftWidth = document.querySelector(this._internalVars.carouselIconWrapperClass).style.getPropertyValue("left"),
149
+ itemsLeftWidthValue = itemsLeftWidth.slice(0, -2),
150
+ itemsLeftWidthVal = Number(itemsLeftWidthValue.replace(/^-/, "")),
151
+ itemsRightWidth = (this._internalVars.carouselIconWidth * this._internalVars.carouselUpsellNumber) - itemsLeftWidthVal - (this._internalVars.carouselIconWidth * this._internalVars.carouselIconNumber);
152
+
153
+ if(itemsLeftWidthVal === 0) {
154
+ this._internalVars.carouselChevronBtn[0].classList.add("disabled");
155
+ this._internalVars.carouselChevronBtn[0].children[0].setAttribute("disabled","disabled");
156
+ }
157
+ else {
158
+ this._internalVars.carouselChevronBtn[0].classList.remove("disabled");
159
+ this._internalVars.carouselChevronBtn[0].children[0].removeAttribute("disabled");
160
+ }
161
+
162
+ if(itemsRightWidth === 0){
163
+ this._internalVars.carouselChevronBtn[1].classList.add("disabled");
164
+ this._internalVars.carouselChevronBtn[1].children[0].setAttribute("disabled","disabled");
165
+ }
166
+ else {
167
+ this._internalVars.carouselChevronBtn[1].classList.remove("disabled");
168
+ this._internalVars.carouselChevronBtn[1].children[0].removeAttribute("disabled");
169
+ }
170
+ }
171
+
172
+ /**
173
+ * setLocalVars()
174
+ * set local vars to the ones passed in options
175
+ */
176
+ function setLocalVars() {
177
+ if(this._internalVars.contentType === 'string') {
178
+ this._internalVars.node = document.querySelector(this._options.content);
179
+ } else if (this._internalVars.contentType === 'domNode') {
180
+ this._internalVars.node = this._options.content;
181
+ }
182
+
183
+ this._internalVars.carouselIconDisplay = 645;
184
+ this._internalVars.carouselIconSmallDisplay = 440;
185
+ this._internalVars.carouselIconNumber = 0;
186
+ this._internalVars.carouselIconClass = '.carousel-upsell-product';
187
+ this._internalVars.carouselWrapperClass = '.icon-carousel';
188
+ this._internalVars.carouselIconWrapperClass = '.icon-carousel-display';
189
+ this._internalVars.carouselIconChevronClass = '.carousel-upsell-chevron';
190
+ this._internalVars.carouselObject = this._internalVars.node;
191
+ this._internalVars.carouselUpsellNumber = this._internalVars.carouselObject.querySelectorAll(this._internalVars.carouselIconClass).length;
192
+ this._internalVars.carouselChevronBtn = this._internalVars.carouselObject.querySelectorAll(this._internalVars.carouselIconChevronClass);
193
+
194
+ }
195
+
196
+ export default UpsellCarousel;