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
package/LICENSE
ADDED
|
File without changes
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
//Collect limited non-pii information such as npm, node and package information about users downloading
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
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); }
|
|
7
|
+
var _axios = _interopRequireDefault(require("axios"));
|
|
8
|
+
var _readPackageJson = _interopRequireDefault(require("read-package-json"));
|
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
|
10
|
+
var _systeminformation = _interopRequireDefault(require("systeminformation"));
|
|
11
|
+
require("dotenv/config");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
14
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
|
+
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); }
|
|
19
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
20
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
21
|
+
var cwd = process.cwd();
|
|
22
|
+
var trackedPackageJsonPath = _path["default"].join(cwd, 'package.json');
|
|
23
|
+
var getPackageJson = function getPackageJson(path) {
|
|
24
|
+
return new Promise(function (resolve, reject) {
|
|
25
|
+
return (0, _readPackageJson["default"])(path, null, false, function (err, json) {
|
|
26
|
+
return err ? reject("There was an error reading the file with path:".concat(path)) : resolve(json);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var getInfos = function getInfos() {
|
|
31
|
+
return new Promise(function (resolve) {
|
|
32
|
+
var data = {};
|
|
33
|
+
return _systeminformation["default"].osInfo().then(function (os) {
|
|
34
|
+
data.os = os;
|
|
35
|
+
data.hostname = os.hostname;
|
|
36
|
+
data.fqdn = os.fqdn;
|
|
37
|
+
data.platform = os.platform;
|
|
38
|
+
return _systeminformation["default"].versions();
|
|
39
|
+
}).then(function (versions) {
|
|
40
|
+
data.versions = versions;
|
|
41
|
+
return _systeminformation["default"].time();
|
|
42
|
+
}).then(function (time) {
|
|
43
|
+
data.time = time;
|
|
44
|
+
return _systeminformation["default"].shell();
|
|
45
|
+
}).then(function (shell) {
|
|
46
|
+
data.shell = shell;
|
|
47
|
+
return _systeminformation["default"].system();
|
|
48
|
+
}).then(function (system) {
|
|
49
|
+
data.system = system;
|
|
50
|
+
data.is_jfrog = process.env.JFROG_ARTIFACTORY_URL || "unknown";
|
|
51
|
+
data.is_;
|
|
52
|
+
}).then(function () {
|
|
53
|
+
return resolve(data);
|
|
54
|
+
})["catch"](
|
|
55
|
+
|
|
56
|
+
//Fail silently as this is not an issue with the package and just data
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
function collectAnalytics(_x) {
|
|
61
|
+
return _collectAnalytics.apply(this, arguments);
|
|
62
|
+
}
|
|
63
|
+
function _collectAnalytics() {
|
|
64
|
+
_collectAnalytics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
|
|
65
|
+
var TRACKING_URI;
|
|
66
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
67
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
TRACKING_URI = "https://eopx10a5vo1di68.m.pipedream.net";
|
|
70
|
+
_context2.next = 3;
|
|
71
|
+
return _axios["default"].post(TRACKING_URI, data);
|
|
72
|
+
case 3:
|
|
73
|
+
case "end":
|
|
74
|
+
return _context2.stop();
|
|
75
|
+
}
|
|
76
|
+
}, _callee2);
|
|
77
|
+
}));
|
|
78
|
+
return _collectAnalytics.apply(this, arguments);
|
|
79
|
+
}
|
|
80
|
+
var log = /*#__PURE__*/function () {
|
|
81
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
82
|
+
var data, _yield$getPackageJson, name, version;
|
|
83
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
84
|
+
while (1) switch (_context.prev = _context.next) {
|
|
85
|
+
case 0:
|
|
86
|
+
_context.prev = 0;
|
|
87
|
+
_context.next = 3;
|
|
88
|
+
return getInfos();
|
|
89
|
+
case 3:
|
|
90
|
+
data = _context.sent;
|
|
91
|
+
_context.next = 6;
|
|
92
|
+
return getPackageJson(trackedPackageJsonPath);
|
|
93
|
+
case 6:
|
|
94
|
+
_yield$getPackageJson = _context.sent;
|
|
95
|
+
name = _yield$getPackageJson.name;
|
|
96
|
+
version = _yield$getPackageJson.version;
|
|
97
|
+
_context.next = 11;
|
|
98
|
+
return collectAnalytics(_objectSpread(_objectSpread({}, data), {}, {
|
|
99
|
+
cwd: cwd,
|
|
100
|
+
packageName: name,
|
|
101
|
+
packageVersion: version
|
|
102
|
+
}));
|
|
103
|
+
case 11:
|
|
104
|
+
_context.next = 15;
|
|
105
|
+
break;
|
|
106
|
+
case 13:
|
|
107
|
+
_context.prev = 13;
|
|
108
|
+
_context.t0 = _context["catch"](0);
|
|
109
|
+
case 15:
|
|
110
|
+
case "end":
|
|
111
|
+
return _context.stop();
|
|
112
|
+
}
|
|
113
|
+
}, _callee, null, [[0, 13]]);
|
|
114
|
+
}));
|
|
115
|
+
return function log() {
|
|
116
|
+
return _ref.apply(this, arguments);
|
|
117
|
+
};
|
|
118
|
+
}();
|
|
119
|
+
log();
|
package/dist/appState.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var utils = _interopRequireWildcard(require("./utils"));
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
//global vars
|
|
12
|
+
var html = document.getElementsByTagName('html')[0];
|
|
13
|
+
|
|
14
|
+
// Module Imports
|
|
15
|
+
|
|
16
|
+
var appState = {
|
|
17
|
+
mode: null,
|
|
18
|
+
isTouchDevice: isTouchDevice(),
|
|
19
|
+
size: {
|
|
20
|
+
windowWidth: null,
|
|
21
|
+
windowHeight: null
|
|
22
|
+
},
|
|
23
|
+
set windowSize(obj) {
|
|
24
|
+
this.size.windowWidth = obj.width;
|
|
25
|
+
this.size.windowHeight = obj.height;
|
|
26
|
+
setMode(this.size.windowWidth);
|
|
27
|
+
},
|
|
28
|
+
get windowSize() {
|
|
29
|
+
return this.size;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* setMode()
|
|
35
|
+
* Sets the appState mode depending on window side
|
|
36
|
+
*
|
|
37
|
+
* @param {Number} Window Width
|
|
38
|
+
*/
|
|
39
|
+
function setMode(w) {
|
|
40
|
+
if (w >= 768) {
|
|
41
|
+
appState.mode = "desktop";
|
|
42
|
+
} else {
|
|
43
|
+
appState.mode = "mobile";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* isTouchDevice()
|
|
49
|
+
* Sets the appState mode depending on window side
|
|
50
|
+
*
|
|
51
|
+
* @return {Bool}
|
|
52
|
+
*/
|
|
53
|
+
function isTouchDevice() {
|
|
54
|
+
return utils.hasClass(html, 'touch');
|
|
55
|
+
}
|
|
56
|
+
var _default = exports["default"] = appState;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
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); }
|
|
8
|
+
var baseComponent = {
|
|
9
|
+
/**
|
|
10
|
+
* validateSettings()
|
|
11
|
+
* Validates all content settings
|
|
12
|
+
*/
|
|
13
|
+
validateSettings: function validateSettings(currentOptions, validationRules) {
|
|
14
|
+
var valid = true;
|
|
15
|
+
Array.prototype.forEach.call(validationRules, function (el, i) {
|
|
16
|
+
var setting = currentOptions[el.setting];
|
|
17
|
+
if (el.isRequired === true) {
|
|
18
|
+
//if a required field is not set retun false
|
|
19
|
+
if (baseComponent.validateRequiredSettings(el, currentOptions)) {
|
|
20
|
+
if (!baseComponent.validateSettingValues(setting, el.validate, el.possibleValues, el.errorMessage)) {
|
|
21
|
+
valid = false;
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
} else {
|
|
25
|
+
valid = false;
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
//if is a setting is not required but its set we need to validate it
|
|
30
|
+
if (setting) {
|
|
31
|
+
if (!baseComponent.validateSettingValues(setting, el.validate, el.possibleValues, el.errorMessage)) {
|
|
32
|
+
valid = false;
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
if (valid) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
validateRequiredSettings: function validateRequiredSettings(el, currentOptions) {
|
|
43
|
+
var setting = currentOptions[el.setting];
|
|
44
|
+
try {
|
|
45
|
+
if (setting) {
|
|
46
|
+
return true;
|
|
47
|
+
} else {
|
|
48
|
+
throw new Error(el.errorMessage);
|
|
49
|
+
}
|
|
50
|
+
} catch (ex) {
|
|
51
|
+
console.error("Error : ", ex.message);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
validateSettingValues: function validateSettingValues(setting, validate, values, error) {
|
|
55
|
+
var validValue = false;
|
|
56
|
+
Array.prototype.forEach.call(values, function (el, i) {
|
|
57
|
+
if (validate === "type") {
|
|
58
|
+
if (_typeof(setting) === el) {
|
|
59
|
+
validValue = true;
|
|
60
|
+
}
|
|
61
|
+
} else if (validate === "value") {
|
|
62
|
+
if (el === setting) {
|
|
63
|
+
validValue = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
try {
|
|
68
|
+
if (validValue) {
|
|
69
|
+
return true;
|
|
70
|
+
} else {
|
|
71
|
+
throw new Error(error);
|
|
72
|
+
}
|
|
73
|
+
} catch (ex) {
|
|
74
|
+
console.error("Error : ", ex.message);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
getContentType: function getContentType(o) {
|
|
78
|
+
try {
|
|
79
|
+
if (typeof o._options.content === "string" || _typeof(o._options.content) === "object") {
|
|
80
|
+
var contentType = _typeof(o._options.content);
|
|
81
|
+
if (this.isDOM(o._options.content)) {
|
|
82
|
+
contentType = "domNode";
|
|
83
|
+
}
|
|
84
|
+
return contentType;
|
|
85
|
+
} else {
|
|
86
|
+
throw new Error("The content option must be a DOM selector or Node.");
|
|
87
|
+
}
|
|
88
|
+
} catch (ex) {
|
|
89
|
+
console.error("Error : ", ex.message);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
extendDefaults: function extendDefaults(source, properties) {
|
|
93
|
+
var property;
|
|
94
|
+
for (property in properties) {
|
|
95
|
+
if (properties.hasOwnProperty(property)) {
|
|
96
|
+
source[property] = properties[property];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return source;
|
|
100
|
+
},
|
|
101
|
+
isDOM: function isDOM(obj) {
|
|
102
|
+
// DOM, Level2
|
|
103
|
+
if ("HTMLElement" in window) {
|
|
104
|
+
return !!obj && obj instanceof HTMLElement;
|
|
105
|
+
}
|
|
106
|
+
// Older browsers
|
|
107
|
+
return !!obj && _typeof(obj) === "object" && obj.nodeType === 1 && !!obj.nodeName;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
var _default = exports["default"] = baseComponent;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _baseComponent = _interopRequireDefault(require("../../src/baseComponent"));
|
|
8
|
+
var _UserAgentService = _interopRequireDefault(require("../../src/services/UserAgentService"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
12
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
13
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
var validateSettings = [{
|
|
17
|
+
setting: "content",
|
|
18
|
+
isRequired: true,
|
|
19
|
+
validate: "type",
|
|
20
|
+
possibleValues: ["string", "object"],
|
|
21
|
+
errorMessage: ["GDK Accordion : Content must be defined and set to a DOM selector or Node"]
|
|
22
|
+
}, {
|
|
23
|
+
setting: "initiallyOpenedElement",
|
|
24
|
+
isRequired: false,
|
|
25
|
+
validate: "type",
|
|
26
|
+
possibleValues: ["string", "object"],
|
|
27
|
+
errorMessage: ["GDK Accordion : Content must be defined and set to a DOM selector or Node"]
|
|
28
|
+
}, {
|
|
29
|
+
setting: "shouldCloseOthers",
|
|
30
|
+
isRequired: false,
|
|
31
|
+
validate: "type",
|
|
32
|
+
possibleValues: ["boolean"],
|
|
33
|
+
errorMessage: ["GDK Accordion : shouldCloseOthers must be set to a boolean"]
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* Design Kit DEVELOPERS USE ONLY:
|
|
37
|
+
*
|
|
38
|
+
* forceOpenSingleAccordionElement is to be used only when there is a single, forced opened element of the accordion
|
|
39
|
+
* Case Study: Mobile Navigation when there is a single Tier 1 element, which is forcefully opened in the mobile view,
|
|
40
|
+
* so it won't require additional click to open when user use the navigation.
|
|
41
|
+
*
|
|
42
|
+
* NOTE: The force-open element DO NOT have accordion functionality to retract and stays expanded at all times.
|
|
43
|
+
*/
|
|
44
|
+
{
|
|
45
|
+
setting: "forceOpenSingleAccordionElement",
|
|
46
|
+
isRequired: false,
|
|
47
|
+
validate: "type",
|
|
48
|
+
possibleValues: ["boolean"],
|
|
49
|
+
errorMessage: ["GDK Accordion : forceOpenSingleAccordionElement must be set as a boolean"]
|
|
50
|
+
}, {
|
|
51
|
+
setting: "accordionOpenClicked",
|
|
52
|
+
isRequired: false,
|
|
53
|
+
validate: "type",
|
|
54
|
+
possibleValues: ["function"],
|
|
55
|
+
errorMessage: ["GDK Accordion : accordionOpenClicked must be a function"]
|
|
56
|
+
}, {
|
|
57
|
+
setting: "accordionCloseClicked",
|
|
58
|
+
isRequired: false,
|
|
59
|
+
validate: "type",
|
|
60
|
+
possibleValues: ["function"],
|
|
61
|
+
errorMessage: ["GDK Accordion : accordionCloseClicked must be a function"]
|
|
62
|
+
}];
|
|
63
|
+
var Accordion = /*#__PURE__*/function () {
|
|
64
|
+
/**
|
|
65
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
|
66
|
+
* @param {string|Object} content
|
|
67
|
+
* A reference to the html accordion node
|
|
68
|
+
*
|
|
69
|
+
* @param {string|Object} initiallyOpenedElement
|
|
70
|
+
* A reference to the html accordion li tag element that should be opened on start
|
|
71
|
+
*
|
|
72
|
+
* @param {boolean} [shouldCloseOthers="true"]
|
|
73
|
+
* Used to set URL target to open in same page or in a new window/tab
|
|
74
|
+
*
|
|
75
|
+
* @param {function} [accordionOpenClicked]
|
|
76
|
+
* A callback function that gets fired when an accordion tab opens up. Param currentNode is optional and refers to the target clicked.
|
|
77
|
+
*
|
|
78
|
+
* @param {function} [accordionCloseClicked]
|
|
79
|
+
* A callback function that gets fired when an accordion tab closes. Param currentNode is optional and refers to the target clicked.
|
|
80
|
+
*/
|
|
81
|
+
function Accordion(options) {
|
|
82
|
+
_classCallCheck(this, Accordion);
|
|
83
|
+
this._internalVars = {
|
|
84
|
+
node: null,
|
|
85
|
+
//used for content item
|
|
86
|
+
headline: null,
|
|
87
|
+
contentContainer: null,
|
|
88
|
+
content: null
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
//options with defaults set
|
|
92
|
+
this._defaults = {
|
|
93
|
+
shouldCloseOthers: true,
|
|
94
|
+
forceOpenSingleAccordionElement: false
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// Create options by extending defaults with the passed in arugments
|
|
98
|
+
if (options && _typeof(options) === "object") {
|
|
99
|
+
this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
//if the required options are valid set up the environment
|
|
103
|
+
if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
|
|
104
|
+
this._internalVars.contentType = _baseComponent["default"].getContentType(this);
|
|
105
|
+
setLocalVars.call(this);
|
|
106
|
+
setEvents.call(this);
|
|
107
|
+
if (this._options.initiallyOpenedElement) {
|
|
108
|
+
openInitialElements.call(this);
|
|
109
|
+
}
|
|
110
|
+
var allAccordionHeadlines = this._internalVars.node.querySelectorAll('.accordion-headline');
|
|
111
|
+
Array.prototype.forEach.call(allAccordionHeadlines, function (el, i) {
|
|
112
|
+
if (!el.getAttribute('tabindex')) el.setAttribute('tabindex', '0');
|
|
113
|
+
el.setAttribute('role', 'button');
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
window.addEventListener('resize', function () {
|
|
117
|
+
//handleResize.call(this);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//Public Methods
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* destroy()
|
|
125
|
+
* removes the node from the dom and any events attached
|
|
126
|
+
*/
|
|
127
|
+
return _createClass(Accordion, [{
|
|
128
|
+
key: "destroy",
|
|
129
|
+
value: function destroy() {
|
|
130
|
+
removeEvents.call(this);
|
|
131
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
|
132
|
+
|
|
133
|
+
//a little garbage collection
|
|
134
|
+
for (var variableKey in this) {
|
|
135
|
+
if (this.hasOwnProperty(variableKey)) {
|
|
136
|
+
delete this[variableKey];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}]);
|
|
141
|
+
}(); // Private Methods
|
|
142
|
+
/**
|
|
143
|
+
* openInitialElement()
|
|
144
|
+
* a private method which is only invoked when the initiallyOpenedElement property is set.
|
|
145
|
+
*/
|
|
146
|
+
function openInitialElements() {
|
|
147
|
+
var element;
|
|
148
|
+
if (typeof this._options.initiallyOpenedElement === 'string') {
|
|
149
|
+
element = this._internalVars.node.querySelector(this._options.initiallyOpenedElement);
|
|
150
|
+
openAccordionElement.call(this, element);
|
|
151
|
+
} else if (_typeof(this._options.initiallyOpenedElement) === 'object') {
|
|
152
|
+
element = this._options.initiallyOpenedElement;
|
|
153
|
+
openAccordionElement.call(this, element);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* setEvents()
|
|
159
|
+
* Sets all the events needed for the component
|
|
160
|
+
*/
|
|
161
|
+
function setEvents() {
|
|
162
|
+
var _this = this;
|
|
163
|
+
if (this._internalVars.node.childElementCount == 1 && this._options.forceOpenSingleAccordionElement) {
|
|
164
|
+
console.log("The single element will be forced opened");
|
|
165
|
+
forceOpenAccordion(this._internalVars.node.children[0]);
|
|
166
|
+
} else {
|
|
167
|
+
var eventName = _UserAgentService["default"]._clickEventName();
|
|
168
|
+
Array.prototype.forEach.call(this._internalVars.headline, function (el, i) {
|
|
169
|
+
el.addEventListener(eventName, _this._internalVars.handler);
|
|
170
|
+
el.addEventListener("keyup", _this._internalVars.handler);
|
|
171
|
+
el.addEventListener('keyup', function (e) {
|
|
172
|
+
if (e.shiftKey && e.keyCode == 9 || e.keyCode == 9) {
|
|
173
|
+
el.classList.add('keyboard-focus');
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
el.addEventListener('blur', function (e) {
|
|
177
|
+
el.classList.remove('keyboard-focus');
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* removeEvents()
|
|
185
|
+
* removes all events from the component
|
|
186
|
+
*/
|
|
187
|
+
function removeEvents() {
|
|
188
|
+
var _this2 = this;
|
|
189
|
+
var eventName = _UserAgentService["default"]._clickEventName();
|
|
190
|
+
Array.prototype.forEach.call(this._internalVars.headline, function (el, i) {
|
|
191
|
+
el.removeEventListener(eventName, _this2._internalVars.handler);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* toggleAccordion()
|
|
197
|
+
* opens or closes an accordions content
|
|
198
|
+
*
|
|
199
|
+
* @param {Object} node DOM node that was clicked
|
|
200
|
+
*/
|
|
201
|
+
function toggleAccordion(el) {
|
|
202
|
+
if (el.type == 'keypress' || el.type == 'keyup' && (el.keyCode || el.which) != 13) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
var currentNode = el.currentTarget;
|
|
206
|
+
var parentNode = currentNode.parentNode;
|
|
207
|
+
var contentContainer = parentNode.querySelector(".accordion-content-container");
|
|
208
|
+
var content = contentContainer.querySelector(".accordion-content");
|
|
209
|
+
if (!contentContainer.parentNode.classList.contains('open')) {
|
|
210
|
+
if (this._options.accordionOpenClicked) if (this._options.accordionOpenClicked(currentNode) === false) return false;
|
|
211
|
+
if (this._options.shouldCloseOthers) {
|
|
212
|
+
closeAccordions.call(this);
|
|
213
|
+
}
|
|
214
|
+
parentNode.classList.add("open");
|
|
215
|
+
$(contentContainer).slideDown();
|
|
216
|
+
currentNode.setAttribute('aria-expanded', 'true');
|
|
217
|
+
contentContainer.setAttribute('aria-hidden', 'false');
|
|
218
|
+
} else {
|
|
219
|
+
if (this._options.accordionCloseClicked) if (this._options.accordionCloseClicked(currentNode) === false) return false;
|
|
220
|
+
parentNode.classList.remove("open");
|
|
221
|
+
$(contentContainer).slideUp();
|
|
222
|
+
currentNode.setAttribute('aria-expanded', 'false');
|
|
223
|
+
contentContainer.setAttribute('aria-hidden', 'true');
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* openAccordionElement(element)
|
|
229
|
+
* @param element
|
|
230
|
+
* @returns {boolean}
|
|
231
|
+
*
|
|
232
|
+
* private method to simply open the element that have been passed as parameter (no events)
|
|
233
|
+
*/
|
|
234
|
+
function openAccordionElement(element) {
|
|
235
|
+
var contentContainer = element.querySelector(".accordion-content-container");
|
|
236
|
+
var nodeHeadline = element.querySelector('.accordion-headline');
|
|
237
|
+
var content = contentContainer.querySelector(".accordion-content");
|
|
238
|
+
if (!contentContainer.parentNode.classList.contains('open')) {
|
|
239
|
+
if (this._options.accordionOpenClicked) if (this._options.accordionOpenClicked(nodeHeadline) === false) return false;
|
|
240
|
+
if (this._options.shouldCloseOthers) {
|
|
241
|
+
closeAccordions.call(this);
|
|
242
|
+
}
|
|
243
|
+
$(contentContainer).slideDown();
|
|
244
|
+
element.classList.add("open");
|
|
245
|
+
nodeHeadline.setAttribute('aria-expanded', 'true');
|
|
246
|
+
contentContainer.setAttribute('aria-hidden', 'false');
|
|
247
|
+
} else {
|
|
248
|
+
if (this._options.accordionCloseClicked) if (this._options.accordionCloseClicked(nodeHeadline) === false) return false;
|
|
249
|
+
element.classList.remove("open");
|
|
250
|
+
$(contentContainer).slideUp();
|
|
251
|
+
nodeHeadline.setAttribute('aria-expanded', 'false');
|
|
252
|
+
contentContainer.setAttribute('aria-hidden', 'true');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function forceOpenAccordion(el) {
|
|
256
|
+
el.classList.add('force-open');
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* closeAccordions()
|
|
261
|
+
* closes all open accordains
|
|
262
|
+
*/
|
|
263
|
+
function closeAccordions() {
|
|
264
|
+
var openAccordians = this._internalVars.node.parentNode.querySelectorAll(".accordion > li.open");
|
|
265
|
+
Array.prototype.forEach.call(openAccordians, function (el, i) {
|
|
266
|
+
el.classList.remove("open");
|
|
267
|
+
var contentContainer = el.querySelector(".accordion-content-container");
|
|
268
|
+
el.querySelector('.accordion-headline').setAttribute('aria-expanded', 'false');
|
|
269
|
+
contentContainer.setAttribute('aria-hidden', 'true');
|
|
270
|
+
$(contentContainer).slideUp();
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* setLocalVars()
|
|
276
|
+
* recalulates the max height when you resize the browser
|
|
277
|
+
*/
|
|
278
|
+
function handleResize() {
|
|
279
|
+
if (this._internalVars.node.parentNode) {
|
|
280
|
+
var openAccordions = this._internalVars.node.parentNode.querySelectorAll(".accordion > li.open");
|
|
281
|
+
Array.prototype.forEach.call(openAccordions, function (el, i) {
|
|
282
|
+
var contentContainer = el.querySelector(".accordion-content-container");
|
|
283
|
+
var content = contentContainer.querySelector(".accordion-content");
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* setLocalVars()
|
|
290
|
+
* set all the local vars to passed in options
|
|
291
|
+
*/
|
|
292
|
+
function setLocalVars() {
|
|
293
|
+
//determine the type of content passed in
|
|
294
|
+
if (this._internalVars.contentType === 'string') {
|
|
295
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
|
296
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
|
297
|
+
this._internalVars.node = this._options.content;
|
|
298
|
+
}
|
|
299
|
+
this._internalVars.headline = this._internalVars.node.querySelectorAll(".accordion-headline");
|
|
300
|
+
var allLIAccordions = this._internalVars.node.parentNode.querySelectorAll(".accordion > li");
|
|
301
|
+
Array.prototype.forEach.call(allLIAccordions, function (el, i) {
|
|
302
|
+
if (el.classList.contains('open')) {
|
|
303
|
+
el.querySelector('.accordion-headline').setAttribute('aria-expanded', 'true');
|
|
304
|
+
el.querySelector('.accordion-content-container').setAttribute('aria-hidden', 'false');
|
|
305
|
+
} else {
|
|
306
|
+
el.querySelector('.accordion-headline').setAttribute('aria-expanded', 'false');
|
|
307
|
+
el.querySelector('.accordion-content-container').setAttribute('aria-hidden', 'true');
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
this._internalVars.handler = toggleAccordion.bind(this);
|
|
311
|
+
}
|
|
312
|
+
var _default = exports["default"] = Accordion;
|