geico-design-kit 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of geico-design-kit might be problematic. Click here for more details.
- package/.babelrc +5 -0
- package/LICENSE +0 -0
- package/dist/analytics.js +119 -0
- package/dist/appState.js +56 -0
- package/dist/baseComponent.js +110 -0
- package/dist/components/Accordion.js +312 -0
- package/dist/components/AddressAutoComplete.js +220 -0
- package/dist/components/Alert.js +145 -0
- package/dist/components/BackgroundPattern.js +99 -0
- package/dist/components/BackgroundPatternPortfolio.js +242 -0
- package/dist/components/ButtonSwitch.js +236 -0
- package/dist/components/CardSelections.js +230 -0
- package/dist/components/CommonQuestionsSquares.js +169 -0
- package/dist/components/Confirmation.js +156 -0
- package/dist/components/ConsolidatedSummary.js +489 -0
- package/dist/components/CoverageGraph.js +201 -0
- package/dist/components/CreditCard.js +591 -0
- package/dist/components/CurrencyInput.js +302 -0
- package/dist/components/DatePicker.js +468 -0
- package/dist/components/DockedMessage.js +146 -0
- package/dist/components/DotNavigation.js +200 -0
- package/dist/components/EditComponent.js +128 -0
- package/dist/components/EditableTable.js +113 -0
- package/dist/components/InPageNavigation.js +360 -0
- package/dist/components/Loader.js +232 -0
- package/dist/components/MakePayment.js +361 -0
- package/dist/components/Modal.js +254 -0
- package/dist/components/MoreInfoButton.js +227 -0
- package/dist/components/MultipleSelectBox.js +217 -0
- package/dist/components/NavigationalBox.js +161 -0
- package/dist/components/Navigator.js +294 -0
- package/dist/components/PasswordMeter.js +201 -0
- package/dist/components/PayPlans.js +534 -0
- package/dist/components/SegmentedControl.js +327 -0
- package/dist/components/SortableTable.js +166 -0
- package/dist/components/Tabs.js +1 -0
- package/dist/components/TextAreaCountdown.js +219 -0
- package/dist/components/Timeline.js +498 -0
- package/dist/components/TimelineFilter.js +492 -0
- package/dist/components/ToTopArrow.js +153 -0
- package/dist/components/Tooltip.js +329 -0
- package/dist/components/Upsell.js +168 -0
- package/dist/components/VIN.js +271 -0
- package/dist/components/ValidateForm.js +938 -0
- package/dist/components/ViewMoreLess.js +191 -0
- package/dist/components/ZipCode.js +191 -0
- package/dist/components/portfolio.js +99 -0
- package/dist/geico-design-kit.js +141 -0
- package/dist/global/components.js +98 -0
- package/dist/global/footer.js +26 -0
- package/dist/global/nav.js +1257 -0
- package/dist/services/CharacterTypeService.js +106 -0
- package/dist/services/UserAgentService.js +73 -0
- package/dist/utils.js +79 -0
- package/package.json +32 -0
- package/src/analytics.js +82 -0
- package/src/appState.js +56 -0
- package/src/baseComponent.js +156 -0
- package/src/components/Accordion.js +336 -0
- package/src/components/AddressAutoComplete.js +236 -0
- package/src/components/Alert.js +135 -0
- package/src/components/BackgroundPattern.js +96 -0
- package/src/components/BackgroundPatternPortfolio.js +284 -0
- package/src/components/ButtonSwitch.js +241 -0
- package/src/components/CardSelections.js +240 -0
- package/src/components/CommonQuestionsSquares.js +179 -0
- package/src/components/Confirmation.js +160 -0
- package/src/components/ConsolidatedSummary.js +505 -0
- package/src/components/CoverageGraph.js +203 -0
- package/src/components/CreditCard.js +595 -0
- package/src/components/CurrencyInput.js +321 -0
- package/src/components/DatePicker.js +487 -0
- package/src/components/DockedMessage.js +142 -0
- package/src/components/DotNavigation.js +206 -0
- package/src/components/EditComponent.js +130 -0
- package/src/components/EditableTable.js +106 -0
- package/src/components/InPageNavigation.js +391 -0
- package/src/components/Loader.js +272 -0
- package/src/components/MakePayment.js +397 -0
- package/src/components/Modal.js +279 -0
- package/src/components/MoreInfoButton.js +243 -0
- package/src/components/MultipleSelectBox.js +211 -0
- package/src/components/NavigationalBox.js +163 -0
- package/src/components/Navigator.js +338 -0
- package/src/components/PasswordMeter.js +209 -0
- package/src/components/PayPlans.js +604 -0
- package/src/components/SegmentedControl.js +365 -0
- package/src/components/SortableTable.js +176 -0
- package/src/components/Tabs.js +0 -0
- package/src/components/TextAreaCountdown.js +231 -0
- package/src/components/Timeline.js +532 -0
- package/src/components/TimelineFilter.js +533 -0
- package/src/components/ToTopArrow.js +153 -0
- package/src/components/Tooltip.js +344 -0
- package/src/components/Upsell.js +196 -0
- package/src/components/VIN.js +289 -0
- package/src/components/ValidateForm.js +1030 -0
- package/src/components/ViewMoreLess.js +193 -0
- package/src/components/ZipCode.js +193 -0
- package/src/components/portfolio.js +106 -0
- package/src/geico-design-kit.js +144 -0
- package/src/global/components.js +92 -0
- package/src/global/footer.js +25 -0
- package/src/global/nav.js +1457 -0
- package/src/services/CharacterTypeService.js +107 -0
- package/src/services/UserAgentService.js +59 -0
- package/src/utils.js +82 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _baseComponent = _interopRequireDefault(require("../../src/baseComponent"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
12
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
var validateSettings = [{
|
|
16
|
+
setting: "content",
|
|
17
|
+
isRequired: true,
|
|
18
|
+
validate: "type",
|
|
19
|
+
possibleValues: ["string", "object"],
|
|
20
|
+
errorMessage: ["GDK InPageNavigation : Content must be defined and set to a DOM selector or Node"]
|
|
21
|
+
}, {
|
|
22
|
+
setting: "onClicked",
|
|
23
|
+
isRequired: false,
|
|
24
|
+
validate: "type",
|
|
25
|
+
possibleValues: ["function"],
|
|
26
|
+
errorMessage: ["GDK InPageNavigation : onClicked must be a function"]
|
|
27
|
+
}, {
|
|
28
|
+
setting: "startingPos",
|
|
29
|
+
isRequired: false,
|
|
30
|
+
validate: "type",
|
|
31
|
+
possibleValues: ["number"],
|
|
32
|
+
errorMessage: ["GDK InPageNavigation : startingPos must be set to a number"]
|
|
33
|
+
}, {
|
|
34
|
+
setting: "autoHide",
|
|
35
|
+
isRequired: false,
|
|
36
|
+
validate: "type",
|
|
37
|
+
possibleValues: ["boolean"],
|
|
38
|
+
errorMessage: ["GDK InPageNavigation : autoHide must be set to be boolean. Default value is False."]
|
|
39
|
+
}];
|
|
40
|
+
var InPageNavigation = /*#__PURE__*/function () {
|
|
41
|
+
/**
|
|
42
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
|
43
|
+
* @param {string|Object} content
|
|
44
|
+
* A reference to the html 'in page navigation' node
|
|
45
|
+
*
|
|
46
|
+
* @param {function} [onClicked]
|
|
47
|
+
* Callback function fired once a 'in-page-item' is clicked
|
|
48
|
+
*
|
|
49
|
+
* @param {number} [startingPos=1]
|
|
50
|
+
* The number of the navigation item to display on initialization
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
function InPageNavigation(options) {
|
|
54
|
+
_classCallCheck(this, InPageNavigation);
|
|
55
|
+
this._internalVars = {
|
|
56
|
+
node: null,
|
|
57
|
+
//used for content item
|
|
58
|
+
navItem: null,
|
|
59
|
+
marker: null
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//options with defaults set
|
|
63
|
+
this._defaults = {
|
|
64
|
+
startingPos: 1,
|
|
65
|
+
autoHide: false
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Create options by extending defaults with the passed in arguments
|
|
69
|
+
if (options && _typeof(options) === "object") {
|
|
70
|
+
this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//if the required options are valid set up the environment
|
|
74
|
+
if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
|
|
75
|
+
this._internalVars.contentType = _baseComponent["default"].getContentType(this);
|
|
76
|
+
setLocalVars.call(this);
|
|
77
|
+
setEvents.call(this);
|
|
78
|
+
setStartPosition.call(this);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//Public Methods
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @param {number} [newIndex]
|
|
86
|
+
* newIndex is the number of the navigation item to go to first on initialization
|
|
87
|
+
*/
|
|
88
|
+
return _createClass(InPageNavigation, [{
|
|
89
|
+
key: "goTo",
|
|
90
|
+
value: function goTo(newIndex) {
|
|
91
|
+
var _this = this;
|
|
92
|
+
var index = newIndex - 1;
|
|
93
|
+
Array.prototype.map.call(this._internalVars.navItem, function (e, rank) {
|
|
94
|
+
if (rank === index) {
|
|
95
|
+
e.classList.add("in-page-item--selected");
|
|
96
|
+
var topPosition = e.offsetTop;
|
|
97
|
+
var nodeHeight = e.offsetHeight;
|
|
98
|
+
|
|
99
|
+
// set marker to correct position
|
|
100
|
+
_this._internalVars.marker.style.top = topPosition + "px";
|
|
101
|
+
_this._internalVars.marker.style.height = nodeHeight + "px";
|
|
102
|
+
} else {
|
|
103
|
+
e.classList.remove("in-page-item--selected");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* destroy()
|
|
110
|
+
* removes the node from the dom and any events attached
|
|
111
|
+
*/
|
|
112
|
+
}, {
|
|
113
|
+
key: "destroy",
|
|
114
|
+
value: function destroy() {
|
|
115
|
+
removeEvents.call(this);
|
|
116
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
|
117
|
+
|
|
118
|
+
//a little garbage collection
|
|
119
|
+
for (var variableKey in this) {
|
|
120
|
+
if (this.hasOwnProperty(variableKey)) {
|
|
121
|
+
delete this[variableKey];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}]);
|
|
126
|
+
}(); // Private Methods
|
|
127
|
+
/**
|
|
128
|
+
* setLocalVars()
|
|
129
|
+
* set all the local vars to passed in options
|
|
130
|
+
*/
|
|
131
|
+
function setLocalVars() {
|
|
132
|
+
//determine the type of content passed in
|
|
133
|
+
if (this._internalVars.contentType === 'string') {
|
|
134
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
|
135
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
|
136
|
+
this._internalVars.node = this._options.content;
|
|
137
|
+
}
|
|
138
|
+
this._internalVars.node.insertAdjacentHTML('beforeend', "<li class=\"in-page-marker\"></li>");
|
|
139
|
+
this._internalVars.navItem = this._internalVars.node.querySelectorAll(".in-page-item");
|
|
140
|
+
this._internalVars.marker = this._internalVars.node.querySelector(".in-page-marker");
|
|
141
|
+
this._internalVars.navId = this._internalVars.node.id;
|
|
142
|
+
this._internalVars.backgroundItems = [];
|
|
143
|
+
this._internalVars.backgroundItemsTop = [];
|
|
144
|
+
this._internalVars.backgroundItemsBottom = [];
|
|
145
|
+
this._internalVars.backgroundItemsDefined = false;
|
|
146
|
+
this._internalVars.handler = inPageItemClickHandler.bind(this);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* setEvents()
|
|
151
|
+
* Sets all the events needed for the component
|
|
152
|
+
*/
|
|
153
|
+
function setEvents() {
|
|
154
|
+
var _this2 = this;
|
|
155
|
+
var eventName = "click";
|
|
156
|
+
|
|
157
|
+
//set click events
|
|
158
|
+
Array.prototype.forEach.call(this._internalVars.navItem, function (el, i) {
|
|
159
|
+
el.addEventListener(eventName, _this2._internalVars.handler);
|
|
160
|
+
});
|
|
161
|
+
window.addEventListener('scroll', scrollPosition.bind(this));
|
|
162
|
+
window.addEventListener('scroll', checkNode.bind(this));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* removeEvents()
|
|
167
|
+
* removes all events from the component
|
|
168
|
+
*/
|
|
169
|
+
function removeEvents() {
|
|
170
|
+
var _this3 = this;
|
|
171
|
+
var eventName = "click";
|
|
172
|
+
|
|
173
|
+
//remove click events
|
|
174
|
+
Array.prototype.forEach.call(this._internalVars.navItem, function (el, i) {
|
|
175
|
+
el.removeEventListener(eventName, _this3._internalVars.handler);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* if In Page Navigation Node exists, run processes
|
|
181
|
+
*/
|
|
182
|
+
function checkNode() {
|
|
183
|
+
if (document.getElementById(this._internalVars.navId)) {
|
|
184
|
+
defineBackgroundItems.call(this);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Create array of all items with a bg or gradient background spanning the full width of the page
|
|
190
|
+
*/
|
|
191
|
+
function defineBackgroundItems() {
|
|
192
|
+
var _this4 = this;
|
|
193
|
+
if (this._internalVars.backgroundItemsDefined === false) {
|
|
194
|
+
var gradientItems = document.querySelectorAll('.bg-gradient'),
|
|
195
|
+
coloredItems = document.querySelectorAll('.bg-color'),
|
|
196
|
+
crossSellItems = document.querySelectorAll('.cross-sell-image');
|
|
197
|
+
Array.prototype.forEach.call(gradientItems, function (el) {
|
|
198
|
+
if (el.clientWidth === document.body.scrollWidth) {
|
|
199
|
+
_this4._internalVars.backgroundItems.push(el);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
Array.prototype.forEach.call(coloredItems, function (el) {
|
|
203
|
+
if (el.clientWidth === document.body.scrollWidth) {
|
|
204
|
+
_this4._internalVars.backgroundItems.push(el);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
Array.prototype.forEach.call(crossSellItems, function (el) {
|
|
208
|
+
if (el.clientWidth === document.body.scrollWidth) {
|
|
209
|
+
_this4._internalVars.backgroundItems.push(el);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
this._internalVars.backgroundItemsDefined = true;
|
|
213
|
+
}
|
|
214
|
+
checkBackgroundItems.call(this);
|
|
215
|
+
}
|
|
216
|
+
function checkBackgroundItems() {
|
|
217
|
+
var _this5 = this;
|
|
218
|
+
this._internalVars.backgroundItemsTop = [];
|
|
219
|
+
this._internalVars.backgroundItemsBottom = [];
|
|
220
|
+
Array.prototype.forEach.call(this._internalVars.backgroundItems, function (el) {
|
|
221
|
+
var top = $(el).offset().top - window.pageYOffset,
|
|
222
|
+
bottom = top + el.clientHeight;
|
|
223
|
+
if (top > 0 && top < window.innerHeight) {
|
|
224
|
+
addBackgroundItemsToArray.call(_this5, el);
|
|
225
|
+
} else if (bottom > 0 && bottom < window.innerHeight) {
|
|
226
|
+
addBackgroundItemsToArray.call(_this5, el);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
changeNavItemColor.call(this);
|
|
230
|
+
}
|
|
231
|
+
function addBackgroundItemsToArray(el) {
|
|
232
|
+
var crossSellHeight = el.clientHeight / 2;
|
|
233
|
+
if (el.classList.contains('cross-sell-image')) {
|
|
234
|
+
this._internalVars.backgroundItemsTop.push($(el).offset().top + crossSellHeight);
|
|
235
|
+
this._internalVars.backgroundItemsBottom.push($(el).offset().top + el.clientHeight);
|
|
236
|
+
} else {
|
|
237
|
+
this._internalVars.backgroundItemsTop.push($(el).offset().top);
|
|
238
|
+
this._internalVars.backgroundItemsBottom.push($(el).offset().top + el.clientHeight);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function changeNavItemColor() {
|
|
242
|
+
var _this6 = this;
|
|
243
|
+
Array.prototype.forEach.call(this._internalVars.navItem, function (el) {
|
|
244
|
+
var top = $(el).offset().top - window.pageYOffset,
|
|
245
|
+
height = el.clientHeight,
|
|
246
|
+
changePoint = top + height / 2,
|
|
247
|
+
changeColor = true;
|
|
248
|
+
Array.prototype.forEach.call(_this6._internalVars.backgroundItems, function (ele, ind) {
|
|
249
|
+
if (changeColor === true) {
|
|
250
|
+
if (changePoint + window.pageYOffset > _this6._internalVars.backgroundItemsTop[ind] && changePoint + window.pageYOffset < _this6._internalVars.backgroundItemsBottom[ind]) {
|
|
251
|
+
el.classList.add('changeFontColor');
|
|
252
|
+
changeColor = false;
|
|
253
|
+
} else {
|
|
254
|
+
if (el.classList.contains('changeFontColor')) {
|
|
255
|
+
el.classList.remove('changeFontColor');
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
var component = document.getElementById(this._internalVars.navId),
|
|
262
|
+
navMarker = component.querySelector('.in-page-marker'),
|
|
263
|
+
selected = component.querySelector('.in-page-item--selected');
|
|
264
|
+
if (selected.classList.contains('changeFontColor')) {
|
|
265
|
+
navMarker.classList.add('changeFontColor');
|
|
266
|
+
} else {
|
|
267
|
+
if (navMarker.classList.contains('changeFontColor')) {
|
|
268
|
+
navMarker.classList.remove('changeFontColor');
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* inPageItemClickHandler()
|
|
275
|
+
* Opens tab content for clicked tab and hides the rest
|
|
276
|
+
*/
|
|
277
|
+
function inPageItemClickHandler(el) {
|
|
278
|
+
var _this7 = this;
|
|
279
|
+
el.preventDefault();
|
|
280
|
+
var currentNode = el.currentTarget;
|
|
281
|
+
|
|
282
|
+
// get position and height of currentNode
|
|
283
|
+
var topPosition = currentNode.offsetTop;
|
|
284
|
+
var nodeHeight = currentNode.offsetHeight;
|
|
285
|
+
|
|
286
|
+
// add selected class
|
|
287
|
+
Array.prototype.map.call(this._internalVars.navItem, function (e, rank) {
|
|
288
|
+
if (e === currentNode) {
|
|
289
|
+
e.classList.add("in-page-item--selected");
|
|
290
|
+
} else {
|
|
291
|
+
e.classList.remove("in-page-item--selected");
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
// set marker to correct position
|
|
296
|
+
this._internalVars.marker.style.top = topPosition + "px";
|
|
297
|
+
this._internalVars.marker.style.height = nodeHeight + "px";
|
|
298
|
+
var currentNodeSection = currentNode.getElementsByTagName("a");
|
|
299
|
+
if (currentNodeSection[0].hasAttribute('data-link')) {
|
|
300
|
+
var getDataLink = currentNodeSection[0].getAttribute("data-link");
|
|
301
|
+
var section = document.getElementById(getDataLink);
|
|
302
|
+
if (section) {
|
|
303
|
+
//start will adjusting this number to a negative and go from there. Will adjust position of a.
|
|
304
|
+
var top = -40;
|
|
305
|
+
var sectionTop = section.offsetTop + top;
|
|
306
|
+
window.scrollTo(0, sectionTop);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// fire onClicked Callback if there is one
|
|
311
|
+
setTimeout(function () {
|
|
312
|
+
if (_this7._options.onClicked) _this7._options.onClicked(currentNode);
|
|
313
|
+
}, 10);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* setStartPosition()
|
|
318
|
+
* Set starting link
|
|
319
|
+
*/
|
|
320
|
+
function setStartPosition() {
|
|
321
|
+
var _this8 = this;
|
|
322
|
+
var linkIndex = this._options.startingPos - 1;
|
|
323
|
+
if (this._options.autoHide) {
|
|
324
|
+
if (!this._internalVars.node.classList.contains('hidden')) {
|
|
325
|
+
toggleComponent.call(this);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
Array.prototype.map.call(this._internalVars.navItem, function (e, rank) {
|
|
329
|
+
if (rank === linkIndex) {
|
|
330
|
+
e.classList.add("in-page-item--selected");
|
|
331
|
+
var topPosition = e.offsetTop;
|
|
332
|
+
var nodeHeight = e.offsetHeight;
|
|
333
|
+
_this8._internalVars.marker.style.top = topPosition + "px";
|
|
334
|
+
_this8._internalVars.marker.style.height = nodeHeight + "px";
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Toggle Component Function
|
|
341
|
+
* Displays and hides the component
|
|
342
|
+
*/
|
|
343
|
+
function toggleComponent() {
|
|
344
|
+
if (this._internalVars.node.classList.contains('hidden')) {
|
|
345
|
+
this._internalVars.node.classList.remove('hidden');
|
|
346
|
+
} else {
|
|
347
|
+
this._internalVars.node.classList.add('hidden');
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function scrollPosition() {
|
|
351
|
+
var inPageNav = this._internalVars.node;
|
|
352
|
+
if (inPageNav.parentNode.parentNode.getBoundingClientRect().top - 65 < 0) {
|
|
353
|
+
inPageNav.style.position = "fixed";
|
|
354
|
+
inPageNav.style.top = window.innerHeight / 2 - inPageNav.offsetHeight + "px";
|
|
355
|
+
} else {
|
|
356
|
+
inPageNav.style.position = "absolute";
|
|
357
|
+
inPageNav.style.top = "";
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
var _default = exports["default"] = InPageNavigation;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _baseComponent = _interopRequireDefault(require("../../src/baseComponent"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
9
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
12
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
var validateSettings = [{
|
|
16
|
+
setting: "content",
|
|
17
|
+
isRequired: true,
|
|
18
|
+
validate: "type",
|
|
19
|
+
possibleValues: ["string", "object"],
|
|
20
|
+
errorMessage: ["GDK Loader : Content must be defined and set to a DOM selector or Node"]
|
|
21
|
+
}, {
|
|
22
|
+
setting: "type",
|
|
23
|
+
isRequired: false,
|
|
24
|
+
validate: "value",
|
|
25
|
+
possibleValues: ["inline", "section", "inline--xsmall"],
|
|
26
|
+
errorMessage: ["GDK Loader : Type must be defined and set to inline or section"]
|
|
27
|
+
}, {
|
|
28
|
+
setting: "autoShow",
|
|
29
|
+
isRequired: false,
|
|
30
|
+
validate: "type",
|
|
31
|
+
possibleValues: ["boolean"],
|
|
32
|
+
errorMessage: ["GDK Loader : autoShow must be a boolean"]
|
|
33
|
+
}];
|
|
34
|
+
var loaderLargeSVG = "\n <svg class=\"circle-loader\" width=\"62\" height=\"62\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"31\" cy=\"31\" r=\"29\">\n </svg>\n <span class=\"geico-icon icon-loader-g\" style=\"width: 60px; height: 60px; line-height: 60px; font-size: 30px;\"></span>\n";
|
|
35
|
+
var loaderSmallSVG = "\n <svg class=\"circle-loader\" width=\"32\" height=\"32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"16\" cy=\"16\" r=\"15\">\n </svg>\n";
|
|
36
|
+
var loaderXSmallSVG = "\n <svg class=\"circle-loader\" width=\"20\" height=\"20\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <circle cx=\"10\" cy=\"10\" r=\"9\">\n </svg>\n";
|
|
37
|
+
var Loader = /*#__PURE__*/function () {
|
|
38
|
+
/**
|
|
39
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
|
40
|
+
* @param {string|Object} content
|
|
41
|
+
* A reference to the loader. If the loader type is a section loader this should be a reference to the loader-container. If the loader type is a inline loader this should be a reference to the loader itself.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} type
|
|
44
|
+
* Used to determine the type of loader. Options: "inline" || "section"
|
|
45
|
+
*
|
|
46
|
+
* @param {boolean} [autoShow=false]
|
|
47
|
+
* Use if you want to set loader to auto show when instantiated
|
|
48
|
+
*
|
|
49
|
+
*/
|
|
50
|
+
function Loader(options) {
|
|
51
|
+
_classCallCheck(this, Loader);
|
|
52
|
+
this._internalVars = {
|
|
53
|
+
node: null,
|
|
54
|
+
//used for current node
|
|
55
|
+
loaderDom: null,
|
|
56
|
+
//stores reference to the loader when using a section loader
|
|
57
|
+
tick: 0,
|
|
58
|
+
loaderShouldPlay: false,
|
|
59
|
+
loaderSVG: null,
|
|
60
|
+
loaderG: null
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
//options with defaults set
|
|
64
|
+
this._defaults = {
|
|
65
|
+
autoShow: false
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Create options by extending defaults with the passed in arugments
|
|
69
|
+
if (options && _typeof(options) === "object") {
|
|
70
|
+
this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//if the required options are valid set up the environment
|
|
74
|
+
if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
|
|
75
|
+
this._internalVars.contentType = _baseComponent["default"].getContentType(this);
|
|
76
|
+
setLocalVars.call(this);
|
|
77
|
+
buildLoader.call(this);
|
|
78
|
+
if (this._options.autoShow) {
|
|
79
|
+
this.show();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//Public Methods
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* show()
|
|
88
|
+
* plays and animates loader
|
|
89
|
+
*/
|
|
90
|
+
return _createClass(Loader, [{
|
|
91
|
+
key: "show",
|
|
92
|
+
value: function show() {
|
|
93
|
+
var _this = this;
|
|
94
|
+
this._internalVars.node.style.display = "block";
|
|
95
|
+
setTimeout(function () {
|
|
96
|
+
if (_this._options.type === "section") {
|
|
97
|
+
_this._internalVars.node.classList.add("section-loader--show");
|
|
98
|
+
_this._internalVars.loaderDom.classList.add("loader--play");
|
|
99
|
+
} else {
|
|
100
|
+
_this._internalVars.node.classList.add("inline-loader--show");
|
|
101
|
+
_this._internalVars.node.classList.add("loader--play");
|
|
102
|
+
}
|
|
103
|
+
_this._internalVars.loaderShouldPlay = true;
|
|
104
|
+
loaderAnim.call(_this);
|
|
105
|
+
}, 10);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* hide()
|
|
110
|
+
* hides and stops the loader
|
|
111
|
+
*/
|
|
112
|
+
}, {
|
|
113
|
+
key: "hide",
|
|
114
|
+
value: function hide() {
|
|
115
|
+
var _this2 = this;
|
|
116
|
+
if (this._options.type === "section") {
|
|
117
|
+
this._internalVars.node.classList.remove("section-loader--show");
|
|
118
|
+
} else {
|
|
119
|
+
this._internalVars.node.classList.remove("inline-loader--show");
|
|
120
|
+
}
|
|
121
|
+
setTimeout(function () {
|
|
122
|
+
_this2._internalVars.node.style.display = "none";
|
|
123
|
+
if (_this2._options.type === "section") {
|
|
124
|
+
_this2._internalVars.loaderDom.classList.remove("loader--play");
|
|
125
|
+
} else {
|
|
126
|
+
_this2._internalVars.node.classList.remove("loader--play");
|
|
127
|
+
}
|
|
128
|
+
_this2._internalVars.loaderShouldPlay = false;
|
|
129
|
+
}, 500);
|
|
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
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
|
140
|
+
|
|
141
|
+
//a little garbage collection
|
|
142
|
+
for (var variableKey in this) {
|
|
143
|
+
if (this.hasOwnProperty(variableKey)) {
|
|
144
|
+
delete this[variableKey];
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}]);
|
|
149
|
+
}();
|
|
150
|
+
/**
|
|
151
|
+
* setLocalVars()
|
|
152
|
+
* set all the local vars to passed in options
|
|
153
|
+
*/
|
|
154
|
+
function setLocalVars() {
|
|
155
|
+
//determine the type of content passed in
|
|
156
|
+
if (this._internalVars.contentType === 'string') {
|
|
157
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
|
158
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
|
159
|
+
this._internalVars.node = this._options.content;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//if its a section loader find the loader
|
|
163
|
+
if (this._options.type === "section") {
|
|
164
|
+
this._internalVars.loaderDom = this._internalVars.node.querySelector(".loader");
|
|
165
|
+
this._internalVars.loaderDom.style.width = "60px";
|
|
166
|
+
this._internalVars.loaderDom.style.height = "60px";
|
|
167
|
+
this._internalVars.loaderDom.style.lineHeight = "60px";
|
|
168
|
+
this._internalVars.loaderDom.style.fontSize = "60px";
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* buildLoader()
|
|
174
|
+
* Adds markup and classes this component
|
|
175
|
+
*/
|
|
176
|
+
function buildLoader() {
|
|
177
|
+
if (this._options.type === "section") {
|
|
178
|
+
this._internalVars.loaderDom.classList.add("loader--large");
|
|
179
|
+
this._internalVars.loaderDom.insertAdjacentHTML('afterBegin', loaderLargeSVG);
|
|
180
|
+
this._internalVars.dashOffsetEnd = 180;
|
|
181
|
+
this._internalVars.dashArrayComplete = 183;
|
|
182
|
+
this._internalVars.dashArrayEnd = 153;
|
|
183
|
+
this._internalVars.tickSpeed = 1;
|
|
184
|
+
} else if (this._options.type === "inline") {
|
|
185
|
+
this._internalVars.node.classList.add("loader--small");
|
|
186
|
+
this._internalVars.node.insertAdjacentHTML('afterBegin', loaderSmallSVG);
|
|
187
|
+
this._internalVars.dashOffsetEnd = 92;
|
|
188
|
+
this._internalVars.dashArrayComplete = 95;
|
|
189
|
+
this._internalVars.dashArrayEnd = 153;
|
|
190
|
+
this._internalVars.tickSpeed = 1.5;
|
|
191
|
+
} else if (this._options.type === "inline--xsmall") {
|
|
192
|
+
this._internalVars.node.classList.add("loader--small");
|
|
193
|
+
this._internalVars.node.insertAdjacentHTML('afterBegin', loaderXSmallSVG);
|
|
194
|
+
this._internalVars.dashOffsetEnd = 62;
|
|
195
|
+
this._internalVars.dashArrayComplete = 65;
|
|
196
|
+
this._internalVars.dashArrayEnd = 153;
|
|
197
|
+
this._internalVars.tickSpeed = 1.5;
|
|
198
|
+
}
|
|
199
|
+
this._internalVars.loaderSVG = this._internalVars.node.querySelector(".circle-loader");
|
|
200
|
+
}
|
|
201
|
+
function loaderAnim() {
|
|
202
|
+
this._internalVars.tick += this._internalVars.tickSpeed;
|
|
203
|
+
if (this._internalVars.tick > 100) {
|
|
204
|
+
this._internalVars.tick = 0;
|
|
205
|
+
}
|
|
206
|
+
var t = this._internalVars.tick / 100;
|
|
207
|
+
var offsetStrokeDashOffset = easeInCubic(t, 0, -this._internalVars.dashOffsetEnd, 1);
|
|
208
|
+
var offsetStrokeDasharray = easeInCubic(t, 0, this._internalVars.dashArrayEnd, 1);
|
|
209
|
+
this._internalVars.loaderSVG.style.strokeDashoffset = offsetStrokeDashOffset;
|
|
210
|
+
this._internalVars.loaderSVG.style.strokeDasharray = "".concat(offsetStrokeDasharray, " , ").concat(this._internalVars.dashArrayComplete);
|
|
211
|
+
if (this._internalVars.loaderShouldPlay) {
|
|
212
|
+
requestAnimationFrame(loaderAnim.bind(this));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* easeInQuad()
|
|
218
|
+
* Quadratic easing
|
|
219
|
+
*/
|
|
220
|
+
function easeInQuad(t, b, c, d) {
|
|
221
|
+
var ts = (t /= d) * t;
|
|
222
|
+
return b + c * ts;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* easeInCubic()
|
|
226
|
+
* Cubic easing
|
|
227
|
+
*/
|
|
228
|
+
function easeInCubic(t, b, c, d) {
|
|
229
|
+
var ts = (t /= d) * t * t;
|
|
230
|
+
return b + c * ts;
|
|
231
|
+
}
|
|
232
|
+
var _default = exports["default"] = Loader;
|