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,468 @@
|
|
|
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 _appState = _interopRequireDefault(require("../../src/appState"));
|
|
9
|
+
var utils = _interopRequireWildcard(require("../../src/utils"));
|
|
10
|
+
var _jquery = _interopRequireDefault(require("jquery"));
|
|
11
|
+
var _jqueryDatepicker = _interopRequireDefault(require("jquery-datepicker"));
|
|
12
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
+
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); }
|
|
16
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
17
|
+
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); } }
|
|
18
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
+
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); }
|
|
21
|
+
(0, _jqueryDatepicker["default"])(_jquery["default"]);
|
|
22
|
+
var validateSettings = [{
|
|
23
|
+
setting: "content",
|
|
24
|
+
isRequired: true,
|
|
25
|
+
validate: "type",
|
|
26
|
+
possibleValues: ["string", "object"],
|
|
27
|
+
errorMessage: ["GDK DatePicker : Content must be defined and set to a DOM selector or Node"]
|
|
28
|
+
}, {
|
|
29
|
+
setting: "monthYearDropdowns",
|
|
30
|
+
isRequired: false,
|
|
31
|
+
validate: "type",
|
|
32
|
+
possibleValues: ["boolean"],
|
|
33
|
+
errorMessage: ["GDK DatePicker : monthYearDropdowns must be set to a boolean"]
|
|
34
|
+
}, {
|
|
35
|
+
setting: "dateFormatShort",
|
|
36
|
+
isRequired: false,
|
|
37
|
+
validate: "type",
|
|
38
|
+
possibleValues: ["boolean"],
|
|
39
|
+
errorMessage: ["GDK DatePicker : dateFormatShort must be set to a boolean"]
|
|
40
|
+
}, {
|
|
41
|
+
setting: "minDate",
|
|
42
|
+
isRequired: false,
|
|
43
|
+
validate: "type",
|
|
44
|
+
possibleValues: ["number", "date", "string", "object"],
|
|
45
|
+
errorMessage: ["GDK DatePicker : minDate must be set to a number, date, or string"]
|
|
46
|
+
}, {
|
|
47
|
+
setting: "maxDate",
|
|
48
|
+
isRequired: false,
|
|
49
|
+
validate: "type",
|
|
50
|
+
possibleValues: ["number", "date", "string", "object"],
|
|
51
|
+
errorMessage: ["GDK DatePicker : maxDate must be set to a number, date, or string"]
|
|
52
|
+
}, {
|
|
53
|
+
setting: "showWeekends",
|
|
54
|
+
isRequired: false,
|
|
55
|
+
validate: "type",
|
|
56
|
+
possibleValues: ["boolean"],
|
|
57
|
+
errorMessage: ["GDK DatePicker : showWeekends must be set to a boolean"]
|
|
58
|
+
}, {
|
|
59
|
+
setting: "dateSelected",
|
|
60
|
+
isRequired: false,
|
|
61
|
+
validate: "type",
|
|
62
|
+
possibleValues: ["function"],
|
|
63
|
+
errorMessage: ["GDK DatePicker : dateSelected must be a callback function"]
|
|
64
|
+
}, {
|
|
65
|
+
setting: "disabled",
|
|
66
|
+
isRequired: false,
|
|
67
|
+
validate: "type",
|
|
68
|
+
possibleValues: ["boolean"],
|
|
69
|
+
errorMessage: ["GDK DatePicker : disabled must be a boolean"]
|
|
70
|
+
}];
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* DatePicker Class
|
|
74
|
+
*/
|
|
75
|
+
var DatePicker = /*#__PURE__*/function () {
|
|
76
|
+
/**
|
|
77
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
|
78
|
+
* @param {string|Object} content
|
|
79
|
+
* A reference to the html date node
|
|
80
|
+
*
|
|
81
|
+
* @param {boolean} [monthYearDropdowns=false]
|
|
82
|
+
* Determines whether or not to show select boxes for the month and year
|
|
83
|
+
*
|
|
84
|
+
* @param {boolean} [dateFormatShort=false]
|
|
85
|
+
* Determines whether to use the short format date instead of the default long format
|
|
86
|
+
*
|
|
87
|
+
* @param {function} [dateSelected]
|
|
88
|
+
* Callback gets fired when a user selects a date
|
|
89
|
+
*
|
|
90
|
+
* @param {Date|number|string} [minDate=null]
|
|
91
|
+
* The minimum selectable date. When set to null, there is no minimum.
|
|
92
|
+
*
|
|
93
|
+
* @param {Date|number|string} [maxDate=null]
|
|
94
|
+
* The maximum selectable date. When set to null, there is no maximum.
|
|
95
|
+
*
|
|
96
|
+
* @param {boolean} [hideWeekends=false]
|
|
97
|
+
* Set to true if you would like to disable the weekends in the calender.
|
|
98
|
+
*
|
|
99
|
+
* @param {boolean} [disabled]
|
|
100
|
+
* Set to true if you would like to disable the input and calendar button.
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
function DatePicker(options) {
|
|
104
|
+
_classCallCheck(this, DatePicker);
|
|
105
|
+
this._internalVars = {
|
|
106
|
+
node: null,
|
|
107
|
+
//used for content item
|
|
108
|
+
button: null,
|
|
109
|
+
wrapper: null,
|
|
110
|
+
wrapperElementId: "wrapper",
|
|
111
|
+
marginLeft: 15,
|
|
112
|
+
marginTopBottomLeft: 10,
|
|
113
|
+
marginTopBottomRight: 28,
|
|
114
|
+
breakpoint: 768,
|
|
115
|
+
calendarWidth: 300,
|
|
116
|
+
borderWidth: 4
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
//options with defaults set
|
|
120
|
+
this._defaults = {
|
|
121
|
+
monthYearDropdowns: false,
|
|
122
|
+
dateFormatShort: false,
|
|
123
|
+
minDate: null,
|
|
124
|
+
maxDate: null,
|
|
125
|
+
hideWeekends: false
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Create options by extending defaults with the passed in arugments
|
|
129
|
+
if (options && _typeof(options) === "object") {
|
|
130
|
+
this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
//if the required options are valid set up the environment
|
|
134
|
+
if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
|
|
135
|
+
this._internalVars.contentType = _baseComponent["default"].getContentType(this);
|
|
136
|
+
setLocalVars.call(this);
|
|
137
|
+
setEvents.call(this);
|
|
138
|
+
init.call(this);
|
|
139
|
+
this._internalVars.button.setAttribute('tabindex', '-1');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//Public Methods
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* removes the node from the dom and any events attached
|
|
147
|
+
*/
|
|
148
|
+
return _createClass(DatePicker, [{
|
|
149
|
+
key: "destroy",
|
|
150
|
+
value: function destroy() {
|
|
151
|
+
removeEvents.call(this);
|
|
152
|
+
(0, _jquery["default"])(this._internalVars.node).datepicker("destroy");
|
|
153
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
|
154
|
+
|
|
155
|
+
//a little garbage collection
|
|
156
|
+
for (var variableKey in this) {
|
|
157
|
+
if (this.hasOwnProperty(variableKey)) {
|
|
158
|
+
delete this[variableKey];
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Set Min Date for the DatePicker Instance
|
|
165
|
+
* @param {number|Date|string|object} minDate The starting date for the date picker instance
|
|
166
|
+
*/
|
|
167
|
+
}, {
|
|
168
|
+
key: "setMinDate",
|
|
169
|
+
value: function setMinDate(minDate) {
|
|
170
|
+
this._options.minDate = new Date(minDate);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Set Max Date for the DatePicker Instance
|
|
175
|
+
* @param {number|Date|string|object} maxDate The ending date for the date picker instance
|
|
176
|
+
*/
|
|
177
|
+
}, {
|
|
178
|
+
key: "setMaxDate",
|
|
179
|
+
value: function setMaxDate(maxDate) {
|
|
180
|
+
this._options.maxDate = new Date(maxDate);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Set Min and Max Dates for the DatePicker Instance
|
|
185
|
+
* @param {number|Date|string|object} minDate The starting date for the date picker instance
|
|
186
|
+
* @param {number|Date|string|object} maxDate The ending date for the date picker instance
|
|
187
|
+
*/
|
|
188
|
+
}, {
|
|
189
|
+
key: "setMinMaxDateLimits",
|
|
190
|
+
value: function setMinMaxDateLimits(minDate, maxDate) {
|
|
191
|
+
this._options.minDate = new Date(minDate);
|
|
192
|
+
this._options.maxDate = new Date(maxDate);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Disables a specific date picker
|
|
197
|
+
* @param {String} datePickerId ID of the date picker to be disabled
|
|
198
|
+
*/
|
|
199
|
+
}, {
|
|
200
|
+
key: "disableDatePicker",
|
|
201
|
+
value: function disableDatePicker() {
|
|
202
|
+
var option = 'disable';
|
|
203
|
+
datePickerState.call(this, option);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Enable a specif date picker
|
|
208
|
+
* @param {Object} datePickerId ID of the date picker to be enabled
|
|
209
|
+
*/
|
|
210
|
+
}, {
|
|
211
|
+
key: "enableDatePicker",
|
|
212
|
+
value: function enableDatePicker(datePickerId) {
|
|
213
|
+
var option = 'enable';
|
|
214
|
+
datePickerState.call(this, option);
|
|
215
|
+
}
|
|
216
|
+
}]);
|
|
217
|
+
}();
|
|
218
|
+
/**
|
|
219
|
+
* set all the local vars to passed in options
|
|
220
|
+
*/
|
|
221
|
+
function setLocalVars() {
|
|
222
|
+
var _this = this;
|
|
223
|
+
try {
|
|
224
|
+
//determine the type of content passed in
|
|
225
|
+
if (this._internalVars.contentType === 'string') {
|
|
226
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
|
227
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
|
228
|
+
this._internalVars.node = this._options.content;
|
|
229
|
+
}
|
|
230
|
+
var dpOptions = {
|
|
231
|
+
showOtherMonths: false,
|
|
232
|
+
showOn: "button",
|
|
233
|
+
buttonText: "",
|
|
234
|
+
nextText: "",
|
|
235
|
+
prevText: "",
|
|
236
|
+
dayNamesMin: ["S", "M", "T", "W", "T", "F", "S"],
|
|
237
|
+
changeMonth: false,
|
|
238
|
+
changeYear: false,
|
|
239
|
+
showOptions: {
|
|
240
|
+
direction: "left"
|
|
241
|
+
},
|
|
242
|
+
beforeShow: updateDatepicker.bind(this),
|
|
243
|
+
onClose: closedDatepicker.bind(this),
|
|
244
|
+
onSelect: function onSelect(dateText, inst) {
|
|
245
|
+
var date = (0, _jquery["default"])(this).val();
|
|
246
|
+
_this._internalVars.node.parentNode.classList.remove("form-field--error");
|
|
247
|
+
|
|
248
|
+
// Get all spans and remove ones bearing class "form-message"
|
|
249
|
+
var spans = _this._internalVars.node.parentNode.getElementsByTagName('span');
|
|
250
|
+
for (var e = 0; spans.length > e; e++) {
|
|
251
|
+
if (-1 !== spans[e].className.indexOf("form-message")) {
|
|
252
|
+
spans[e].parentNode.removeChild(spans[e]);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (_this._options.dateSelected) {
|
|
256
|
+
_this._options.dateSelected(date);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
if (this._options.hideWeekends) {
|
|
261
|
+
dpOptions.beforeShowDay = _jquery["default"].datepicker.noWeekends;
|
|
262
|
+
}
|
|
263
|
+
(0, _jquery["default"])(this._internalVars.node).datepicker(dpOptions);
|
|
264
|
+
this._internalVars.button = this._internalVars.node.nextElementSibling;
|
|
265
|
+
this._internalVars.wrapper = document.querySelector("#" + this._internalVars.wrapperElementId);
|
|
266
|
+
this._internalVars.handler = toggleHover.bind(this);
|
|
267
|
+
this._internalVars.handlerOverride = calendarPositionOverride.bind(this);
|
|
268
|
+
var $datapicker = (0, _jquery["default"])(".ui-datepicker");
|
|
269
|
+
if ($datapicker.data("initialized") !== true) {
|
|
270
|
+
$datapicker.data("initialized", true);
|
|
271
|
+
document.addEventListener("animationstart", insertListener, false); // standard + firefox
|
|
272
|
+
document.addEventListener("MSAnimationStart", insertListener, false); // IE
|
|
273
|
+
document.addEventListener("webkitAnimationStart", insertListener, false); // Chrome + Safari
|
|
274
|
+
}
|
|
275
|
+
} catch (ex) {
|
|
276
|
+
console.error("Error : ", ex.message);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Sets all the events needed for the component
|
|
282
|
+
*/
|
|
283
|
+
function setEvents() {
|
|
284
|
+
this._internalVars.button.addEventListener("mouseover", this._internalVars.handler, false);
|
|
285
|
+
this._internalVars.button.addEventListener("mouseout", this._internalVars.handler, false);
|
|
286
|
+
window.addEventListener('resize', handleResize.bind(this));
|
|
287
|
+
|
|
288
|
+
//special case if a datepicker exist in a modal - override third party jquery snippet
|
|
289
|
+
if (utils.isChild('modal', this._internalVars.button)) {
|
|
290
|
+
this._internalVars.button.addEventListener("click", this._internalVars.handlerOverride);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function init() {
|
|
294
|
+
if (this._options.disabled === true) {
|
|
295
|
+
var option = 'disable';
|
|
296
|
+
datePickerState.call(this, option);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* removes all events from the component
|
|
302
|
+
*/
|
|
303
|
+
function removeEvents() {
|
|
304
|
+
this._internalVars.button.removeEventListener("mouseoout", this._internalVars.handler, false);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Checks if the ID passed from the enable or disable public method exists
|
|
309
|
+
* @param {string} option Variable identifying enable or disable
|
|
310
|
+
*/
|
|
311
|
+
function datePickerState(option) {
|
|
312
|
+
var datePickerId = this._internalVars.node.id,
|
|
313
|
+
datePicker = document.getElementById(datePickerId),
|
|
314
|
+
parent = datePicker.parentNode,
|
|
315
|
+
button = parent.querySelector(".ui-datepicker-trigger"),
|
|
316
|
+
hasButton = false;
|
|
317
|
+
if (button) {
|
|
318
|
+
hasButton = true;
|
|
319
|
+
}
|
|
320
|
+
if (option === 'disable') {
|
|
321
|
+
disable.call(this, datePicker, button, hasButton);
|
|
322
|
+
} else if (option === 'enable') {
|
|
323
|
+
enable.call(this, datePicker, button, hasButton);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Disables the specified date picker
|
|
329
|
+
* @param {object} datePicker The date picker HTML element
|
|
330
|
+
* @param {object} button The date picker calendar button HTML element
|
|
331
|
+
* @param {boolean} hasButton Boolean indicating if calendar button exists
|
|
332
|
+
*/
|
|
333
|
+
function disable(datePicker, button, hasButton) {
|
|
334
|
+
datePicker.setAttribute('disabled', 'disabled');
|
|
335
|
+
if (hasButton === true) {
|
|
336
|
+
button.setAttribute('disabled', 'disabled');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Enables the specified date picker
|
|
342
|
+
* @param {object} datePicker The date picker HTML element
|
|
343
|
+
* @param {object} button The date picker calendar button HTML element
|
|
344
|
+
* @param {boolean} hasButton Boolean indicating if calendar button exists
|
|
345
|
+
*/
|
|
346
|
+
function enable(datePicker, button, hasButton) {
|
|
347
|
+
datePicker.removeAttribute('disabled');
|
|
348
|
+
if (hasButton === true) {
|
|
349
|
+
button.removeAttribute('disabled');
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* toggles the active state of the neighboring input field
|
|
355
|
+
*/
|
|
356
|
+
function toggleHover() {
|
|
357
|
+
if (this._internalVars.node.classList.contains("active")) this._internalVars.node.classList.remove("active");else this._internalVars.node.classList.add("active");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* listens for the select box to be inserted and wraps it in a container
|
|
362
|
+
*/
|
|
363
|
+
function insertListener(event) {
|
|
364
|
+
if (event.animationName == "nodeInserted") {
|
|
365
|
+
if (!(0, _jquery["default"])(".ui-datepicker-year").parent().hasClass("select-box")) (0, _jquery["default"])(".ui-datepicker-year").wrap("<div class=\"select-box\"></div>");
|
|
366
|
+
if (!(0, _jquery["default"])(".ui-datepicker-month").parent().hasClass("select-box")) (0, _jquery["default"])(".ui-datepicker-month").wrap("<div class=\"select-box\"></div>");
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* runs when the datepicker window closes
|
|
372
|
+
*/
|
|
373
|
+
function closedDatepicker() {
|
|
374
|
+
//re-assign button variable since datepicker replaces the original node
|
|
375
|
+
this._internalVars.button = this._internalVars.node.nextElementSibling;
|
|
376
|
+
setEvents.call(this);
|
|
377
|
+
this._internalVars.button.setAttribute('tabindex', '-1');
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* runs before displaying the datapicker and updates it based on the current options
|
|
382
|
+
*/
|
|
383
|
+
function updateDatepicker(el, obj) {
|
|
384
|
+
var changeOptions = {};
|
|
385
|
+
changeOptions.minDate = this._options.minDate;
|
|
386
|
+
changeOptions.maxDate = this._options.maxDate;
|
|
387
|
+
if (this._options.monthYearDropdowns) {
|
|
388
|
+
//adds the month and year dropdowns
|
|
389
|
+
changeOptions.changeMonth = true;
|
|
390
|
+
changeOptions.changeYear = true;
|
|
391
|
+
|
|
392
|
+
//hide the month arrows
|
|
393
|
+
(0, _jquery["default"])(".ui-datepicker").addClass("date-picker-hide-arrows");
|
|
394
|
+
} else {
|
|
395
|
+
//removes the month and year dropdowns
|
|
396
|
+
changeOptions.changeMonth = false;
|
|
397
|
+
changeOptions.changeYear = false;
|
|
398
|
+
|
|
399
|
+
//displays the month arrows
|
|
400
|
+
(0, _jquery["default"])(".ui-datepicker").removeClass("date-picker-hide-arrows");
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
//set the date format to full or short
|
|
404
|
+
if (this._options.dateFormatShort) {
|
|
405
|
+
changeOptions.dateFormat = "mm/yy";
|
|
406
|
+
} else {
|
|
407
|
+
changeOptions.dateFormat = "mm/dd/yy";
|
|
408
|
+
}
|
|
409
|
+
(0, _jquery["default"])(el).datepicker("change", changeOptions);
|
|
410
|
+
positionDatePicker.call(this, el);
|
|
411
|
+
_jquery["default"].datepicker._shouldFocusInput = function () {
|
|
412
|
+
return false;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Positions calendar
|
|
418
|
+
* @param {object} el HTML element
|
|
419
|
+
*/
|
|
420
|
+
function positionDatePicker(el) {
|
|
421
|
+
//need to add code to check if position has changed before recalculating
|
|
422
|
+
var winWidth = document.body.clientWidth;
|
|
423
|
+
var winHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
424
|
+
var inputOffset = this._internalVars.node.getBoundingClientRect();
|
|
425
|
+
var containerOffset = this._internalVars.wrapper.getBoundingClientRect();
|
|
426
|
+
var containerOffsetLeft = containerOffset.left;
|
|
427
|
+
var containerWidth = this._internalVars.wrapper.offsetWidth;
|
|
428
|
+
var inputWidth = this._internalVars.node.offsetWidth + this._internalVars.node.nextElementSibling.offsetWidth;
|
|
429
|
+
var isRight = false;
|
|
430
|
+
if (winWidth >= this._internalVars.breakpoint) {
|
|
431
|
+
_jquery["default"].datepicker._pos = _jquery["default"].datepicker._findPos(el);
|
|
432
|
+
//figure out correct horizontal direction
|
|
433
|
+
if (_jquery["default"].datepicker._pos[0] + this._internalVars.calendarWidth + inputWidth < containerWidth) {
|
|
434
|
+
_jquery["default"].datepicker._pos[0] += inputWidth + this._internalVars.marginLeft;
|
|
435
|
+
} else {
|
|
436
|
+
_jquery["default"].datepicker._pos[0] -= this._internalVars.calendarWidth - inputWidth;
|
|
437
|
+
isRight = true;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
//figure out correct vertical direction
|
|
441
|
+
if (inputOffset.top + this._internalVars.calendarWidth < winHeight) {
|
|
442
|
+
if (!isRight) {
|
|
443
|
+
_jquery["default"].datepicker._pos[1] -= this._internalVars.marginTopBottomLeft;
|
|
444
|
+
} else {
|
|
445
|
+
_jquery["default"].datepicker._pos[1] += inputOffset.bottom - inputOffset.top - this._internalVars.borderWidth + this._internalVars.marginTopBottomLeft;
|
|
446
|
+
}
|
|
447
|
+
} else {
|
|
448
|
+
if (!isRight) {
|
|
449
|
+
_jquery["default"].datepicker._pos[1] -= this._internalVars.calendarWidth - this._internalVars.marginTopBottomRight;
|
|
450
|
+
} else {
|
|
451
|
+
_jquery["default"].datepicker._pos[1] -= this._internalVars.calendarWidth + this._internalVars.marginTopBottomRight;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* handles window resize
|
|
459
|
+
*/
|
|
460
|
+
function handleResize() {
|
|
461
|
+
(0, _jquery["default"])(this._internalVars.node).datepicker("hide");
|
|
462
|
+
}
|
|
463
|
+
function calendarPositionOverride() {
|
|
464
|
+
if (_appState["default"].mode == 'desktop') {
|
|
465
|
+
document.querySelector('#ui-datepicker-div').style.top = document.querySelector('.modal .hasDatepicker').offsetTop + 'px';
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
var _default = exports["default"] = DatePicker;
|
|
@@ -0,0 +1,146 @@
|
|
|
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 DockedMessage : Content must be defined and set to a DOM selector or Node"]
|
|
21
|
+
}, {
|
|
22
|
+
setting: "autoHide",
|
|
23
|
+
isRequired: false,
|
|
24
|
+
validate: "type",
|
|
25
|
+
possibleValues: ["boolean"],
|
|
26
|
+
errorMessage: ["GDK DockedMessage : AutoHide must be defined as true or false"]
|
|
27
|
+
}];
|
|
28
|
+
var DockedMessage = /*#__PURE__*/function () {
|
|
29
|
+
/**
|
|
30
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
|
31
|
+
* @param {string|Object} content
|
|
32
|
+
* A reference to the docked real time message node
|
|
33
|
+
*/
|
|
34
|
+
function DockedMessage(options) {
|
|
35
|
+
_classCallCheck(this, DockedMessage);
|
|
36
|
+
this._internalVars = {
|
|
37
|
+
node: null //used for current node
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
//options with defaults set
|
|
41
|
+
this._defaults = {
|
|
42
|
+
autoHide: false
|
|
43
|
+
};
|
|
44
|
+
// Create options by extending defaults with the passed in arugments
|
|
45
|
+
if (options && _typeof(options) === "object") {
|
|
46
|
+
this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
|
|
47
|
+
}
|
|
48
|
+
//if the required options are valid set up the environment
|
|
49
|
+
if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
|
|
50
|
+
this._internalVars.contentType = _baseComponent["default"].getContentType(this);
|
|
51
|
+
setLocalVars.call(this);
|
|
52
|
+
init.call(this);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//Public Methods
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* hides/shows the component
|
|
60
|
+
*/
|
|
61
|
+
return _createClass(DockedMessage, [{
|
|
62
|
+
key: "toggleDockedMessage",
|
|
63
|
+
value: function toggleDockedMessage() {
|
|
64
|
+
toggleComponent.call(this);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* removes the node from the dom and any events attached
|
|
69
|
+
*/
|
|
70
|
+
}, {
|
|
71
|
+
key: "destroy",
|
|
72
|
+
value: function destroy() {
|
|
73
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
|
74
|
+
|
|
75
|
+
//a little garbage collection
|
|
76
|
+
for (var variableKey in this) {
|
|
77
|
+
if (this.hasOwnProperty(variableKey)) {
|
|
78
|
+
delete this[variableKey];
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}]);
|
|
83
|
+
}();
|
|
84
|
+
function init() {
|
|
85
|
+
if (this._options.autoHide) {
|
|
86
|
+
if (this._options.autoHide === true) {
|
|
87
|
+
hideComponent.call(this);
|
|
88
|
+
} else {
|
|
89
|
+
showComponent.call(this);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
showComponent.call(this);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Toggle Component Function
|
|
98
|
+
* Displays and hides the component
|
|
99
|
+
*/
|
|
100
|
+
function toggleComponent() {
|
|
101
|
+
if (this._internalVars.node.classList.contains('hidden')) {
|
|
102
|
+
showComponent.call(this);
|
|
103
|
+
} else {
|
|
104
|
+
hideComponent.call(this);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function showComponent() {
|
|
108
|
+
this._internalVars.node.classList.remove('hidden');
|
|
109
|
+
this._internalVars.main.classList.add("docked-message-on");
|
|
110
|
+
if (this._internalVars.toTopExists === true) {
|
|
111
|
+
this._internalVars.toTop.classList.add("docked-message-on");
|
|
112
|
+
}
|
|
113
|
+
if (!this._internalVars.footer) {
|
|
114
|
+
this._internalVars.footerPush.classList.add('no-footer');
|
|
115
|
+
} else {
|
|
116
|
+
this._internalVars.footer.classList.add("docked-message-on");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function hideComponent() {
|
|
120
|
+
this._internalVars.node.classList.add('hidden');
|
|
121
|
+
this._internalVars.main.classList.remove("docked-message-on");
|
|
122
|
+
if (this._internalVars.toTopExists === true) {
|
|
123
|
+
this._internalVars.toTop.classList.remove("docked-message-on");
|
|
124
|
+
}
|
|
125
|
+
if (!this._internalVars.footer) {
|
|
126
|
+
this._internalVars.footerPush.classList.remove('no-footer');
|
|
127
|
+
} else {
|
|
128
|
+
this._internalVars.footer.classList.remove("docked-message-on");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function setLocalVars() {
|
|
132
|
+
if (this._internalVars.contentType === 'string') {
|
|
133
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
|
134
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
|
135
|
+
this._internalVars.node = this._options.content;
|
|
136
|
+
}
|
|
137
|
+
this._internalVars.toTopExists = false;
|
|
138
|
+
if (document.querySelector(".to-top-arrow") !== null && document.querySelector(".to-top-arrow") !== 'undefined') {
|
|
139
|
+
this._internalVars.toTopExists = true;
|
|
140
|
+
this._internalVars.toTop = document.querySelector(".to-top-arrow");
|
|
141
|
+
}
|
|
142
|
+
this._internalVars.main = document.querySelector('#wrapper');
|
|
143
|
+
this._internalVars.footer = document.querySelector('#primary-footer');
|
|
144
|
+
this._internalVars.footerPush = document.querySelector('.footer-push');
|
|
145
|
+
}
|
|
146
|
+
var _default = exports["default"] = DockedMessage;
|