1089 lines
No EOL
48 KiB
JavaScript
Vendored
1089 lines
No EOL
48 KiB
JavaScript
Vendored
(function webpackUniversalModuleDefinition(root, factory) {
|
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
module.exports = factory();
|
|
else if(typeof define === 'function' && define.amd)
|
|
define([], factory);
|
|
else if(typeof exports === 'object')
|
|
exports["CookieNotice"] = factory();
|
|
else
|
|
root["CookieNotice"] = factory();
|
|
})(this, function() {
|
|
return /******/ (function() { // webpackBootstrap
|
|
/******/ "use strict";
|
|
/******/ var __webpack_modules__ = ({
|
|
|
|
/***/ "./src/ts/classes/CookieNotice.ts":
|
|
/*!****************************************!*\
|
|
!*** ./src/ts/classes/CookieNotice.ts ***!
|
|
\****************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ "default": function() { return /* binding */ CookieNotice; }
|
|
/* harmony export */ });
|
|
/* harmony import */ var _cookie_defaults__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../cookie-defaults */ "./src/ts/cookie-defaults.ts");
|
|
/* harmony import */ var _cookie_references__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../cookie-references */ "./src/ts/cookie-references.ts");
|
|
/* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./../enums */ "./src/ts/enums.ts");
|
|
/* harmony import */ var _DocumentCookie__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DocumentCookie */ "./src/ts/classes/DocumentCookie.ts");
|
|
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); }
|
|
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; }
|
|
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; }
|
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
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); }
|
|
|
|
|
|
|
|
|
|
var CookieNotice = /*#__PURE__*/function () {
|
|
// * -- END DOM ELEMENTS
|
|
|
|
/**
|
|
* @param config Holding all cookie configs
|
|
*/
|
|
function CookieNotice(config) {
|
|
var _this = this;
|
|
_classCallCheck(this, CookieNotice);
|
|
/** The CN cookie status */
|
|
_defineProperty(this, "cookieName", _cookie_defaults__WEBPACK_IMPORTED_MODULE_0__["default"].cookieName);
|
|
/** Cookie life time */
|
|
_defineProperty(this, "cookieTimeLife", _cookie_defaults__WEBPACK_IMPORTED_MODULE_0__["default"].cookieTimeLife);
|
|
/** The index on which store the expiration date */
|
|
_defineProperty(this, "cookieExpirationName", _cookie_defaults__WEBPACK_IMPORTED_MODULE_0__["default"].cookieExpirationName);
|
|
/** Cookie policies for each functionality */
|
|
_defineProperty(this, "cookiePolicies", _cookie_defaults__WEBPACK_IMPORTED_MODULE_0__["default"].cookiePolicies);
|
|
/** Prevent user from closing modal */
|
|
_defineProperty(this, "restrictCloseModal", _cookie_defaults__WEBPACK_IMPORTED_MODULE_0__["default"].restrictCloseModal);
|
|
/** Cookie expiration date as specified in the cookie itself */
|
|
_defineProperty(this, "cookieExpirationDate", new Date());
|
|
// * -- DOM ELEMENTS
|
|
_defineProperty(this, "domElList", {});
|
|
this.config = config;
|
|
// * Merge cookie config with references
|
|
_toConsumableArray(Object.keys(this.config)).forEach(function (cookieName) {
|
|
var _cookieReferences$get;
|
|
_this.config[cookieName].cookies = _toConsumableArray(new Set([].concat(_toConsumableArray(_this.config[cookieName].cookies), _toConsumableArray((_cookieReferences$get = _cookie_references__WEBPACK_IMPORTED_MODULE_1__["default"].get(cookieName)) !== null && _cookieReferences$get !== void 0 ? _cookieReferences$get : []))));
|
|
});
|
|
|
|
// * Setup cookie expiration date
|
|
this.cookieExpirationDate = this.getCnCookieInfo().date;
|
|
this.initDomElements();
|
|
this.setupEvents();
|
|
|
|
// * Setup CN Cookie
|
|
if (this.configHasChanged() || this.configHasExpired()) {
|
|
// * Setup Browser Cookie if none.
|
|
this.resetCnCookie();
|
|
this.openCookieModalToBannerPage();
|
|
}
|
|
this.updateRestrictCloseModal();
|
|
|
|
// * Cookie should have been created from here.
|
|
this.getCnCookieInfo().values.forEach(function (cookieStatus, cookieName) {
|
|
if (cookieStatus === _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait) {
|
|
_this.openCookieModalToBannerPage();
|
|
return;
|
|
}
|
|
_this.setCnCookieStatus(cookieName, cookieStatus);
|
|
_this.setCookieSwitchButton(cookieName, cookieStatus);
|
|
});
|
|
}
|
|
|
|
// * --- PUBLIC ---
|
|
|
|
/** Accept a all cookies */
|
|
return _createClass(CookieNotice, [{
|
|
key: "acceptAllCookies",
|
|
value: function acceptAllCookies() {
|
|
var _this2 = this;
|
|
_toConsumableArray(this.getCnCookieInfo().values.keys()).forEach(function (cookieName) {
|
|
return _this2.acceptCookie(cookieName);
|
|
});
|
|
}
|
|
|
|
/** Accept a specific cookie */
|
|
}, {
|
|
key: "acceptCookie",
|
|
value: function acceptCookie(cookieName) {
|
|
this.setCnCookieStatus(cookieName, _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.true);
|
|
this.setCookieSwitchButton(cookieName, _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.true);
|
|
this.refreshCnCookieExpirationDate();
|
|
}
|
|
|
|
/** Deny a all cookies */
|
|
}, {
|
|
key: "denyAllCookies",
|
|
value: function denyAllCookies() {
|
|
var _this3 = this;
|
|
_toConsumableArray(this.getCnCookieInfo().values.keys()).forEach(function (cookieName) {
|
|
return _this3.denyCookie(cookieName);
|
|
});
|
|
}
|
|
|
|
/** Deny a specific cookie */
|
|
}, {
|
|
key: "denyCookie",
|
|
value: function denyCookie(cookieName) {
|
|
this.setCnCookieStatus(cookieName, _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.false);
|
|
this.setCookieSwitchButton(cookieName, _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.false);
|
|
this.refreshCnCookieExpirationDate();
|
|
}
|
|
|
|
/** Deny all waiting cookies */
|
|
}, {
|
|
key: "denyAllWaitingCookies",
|
|
value: function denyAllWaitingCookies() {
|
|
var _this4 = this;
|
|
this.getCnCookieInfo().values.forEach(function (cookieStatus, cookieName) {
|
|
if (cookieStatus === _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait) {
|
|
_this4.persistCnCookie(cookieName, _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.false);
|
|
return;
|
|
}
|
|
});
|
|
this.updateRestrictCloseModal();
|
|
}
|
|
|
|
/**
|
|
* Get a specific cookie config
|
|
* @throws {Error} If the cookie `cookieName` is not found in config.
|
|
*/
|
|
}, {
|
|
key: "getCookieConfig",
|
|
value: function getCookieConfig(cookieName) {
|
|
var _Object$entries$find;
|
|
var cookieOptions = (_Object$entries$find = Object.entries(this.config).find(function (entry) {
|
|
return entry[0] === cookieName;
|
|
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[1];
|
|
if (cookieOptions === undefined) {
|
|
throw new Error("Cookie options ".concat(cookieName, " not found in list"));
|
|
}
|
|
return cookieOptions;
|
|
}
|
|
|
|
// * --- PRIVATE ---
|
|
|
|
// * - Utilities
|
|
|
|
/** Check if the config has expired */
|
|
}, {
|
|
key: "configHasExpired",
|
|
value: function configHasExpired() {
|
|
return this.cookieExpirationDate.getTime() < new Date().getTime();
|
|
}
|
|
|
|
/** Check if the actual cookie config matches the CN config */
|
|
}, {
|
|
key: "configHasChanged",
|
|
value: function configHasChanged() {
|
|
var cookies = this.getCnCookieInfo().values;
|
|
return cookies.size !== Object.keys(this.config).length || _toConsumableArray(cookies.keys()).join(".") !== Object.keys(this.config).join(".");
|
|
}
|
|
|
|
/**
|
|
* Invert cookie status
|
|
*
|
|
* @param cookieStatus
|
|
* @returns Inverted cookie status, `wait` will give `false`.
|
|
* @throw {Error} If the cookie status is not handled.
|
|
*/
|
|
}, {
|
|
key: "invertCookieStatus",
|
|
value: function invertCookieStatus(cookieStatus) {
|
|
switch (cookieStatus) {
|
|
case _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.true:
|
|
case _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait:
|
|
return _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.false;
|
|
case _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.false:
|
|
return _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.true;
|
|
default:
|
|
throw new Error("Un handled cookie status ".concat(cookieStatus));
|
|
}
|
|
}
|
|
|
|
/** Get a new expiration date */
|
|
}, {
|
|
key: "getNewExpirationDate",
|
|
value: function getNewExpirationDate() {
|
|
var expDate = new Date();
|
|
return new Date(expDate.setMonth(expDate.getMonth() + this.cookieTimeLife));
|
|
}
|
|
|
|
// * - CN Browser Cookie Manipulation
|
|
}, {
|
|
key: "getCnCookieInfo",
|
|
value: function getCnCookieInfo() {
|
|
var _cookies$get;
|
|
var cookies = this.getCnCookieValues();
|
|
var expirationDate = (_cookies$get = cookies.get(this.cookieExpirationName)) !== null && _cookies$get !== void 0 ? _cookies$get : this.getNewExpirationDate();
|
|
cookies.delete(this.cookieExpirationName);
|
|
return {
|
|
name: this.cookieName,
|
|
values: cookies,
|
|
date: expirationDate,
|
|
cookiePolicies: this.cookiePolicies
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get a cookie status
|
|
*
|
|
* @param cookieName
|
|
* @throws {Error} If the cookie value could not be found.
|
|
*/
|
|
}, {
|
|
key: "getCnCookieStatus",
|
|
value: function getCnCookieStatus(cookieName) {
|
|
var statusList = this.getCnCookieInfo().values;
|
|
var cookieStatus = statusList.get(cookieName);
|
|
if (cookieStatus === undefined) {
|
|
throw new Error("Cookie options ".concat(cookieName, " not found in list"));
|
|
}
|
|
return cookieStatus;
|
|
}
|
|
|
|
/** Trigger cookie status actions and persist status */
|
|
}, {
|
|
key: "setCnCookieStatus",
|
|
value: function setCnCookieStatus(cookieName, status) {
|
|
var cookieConfig = this.getCookieConfig(cookieName);
|
|
this.persistCnCookie(cookieName, status);
|
|
if (status === _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.true) {
|
|
cookieConfig.script();
|
|
return;
|
|
}
|
|
if (status === _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.false) {
|
|
if (cookieConfig.fallback) {
|
|
cookieConfig.fallback();
|
|
}
|
|
return;
|
|
}
|
|
this.persistCnCookie(cookieName, _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait);
|
|
}
|
|
|
|
/** Save cookie content on web browser */
|
|
}, {
|
|
key: "persistCnCookieList",
|
|
value: function persistCnCookieList(statusMap) {
|
|
var _this5 = this;
|
|
var content = Array.from(statusMap.entries()).map(function (_ref) {
|
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
cookieName = _ref2[0],
|
|
cookieStatus = _ref2[1];
|
|
if (cookieStatus === _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.false) {
|
|
// * Need to remove all associated cookies
|
|
_this5.getCookieConfig(cookieName).cookies.forEach(function (cookieToRemove) {
|
|
_toConsumableArray(_DocumentCookie__WEBPACK_IMPORTED_MODULE_3__.DocumentCookie.getAllStartingWith(cookieToRemove.replace(/\*+$/, "")).keys()).forEach(function (cookieName) {
|
|
return _DocumentCookie__WEBPACK_IMPORTED_MODULE_3__.DocumentCookie.markForDeletion(cookieName);
|
|
});
|
|
});
|
|
}
|
|
return "".concat(cookieName, "=").concat(cookieStatus);
|
|
});
|
|
|
|
// * Append expiration date
|
|
content.push("".concat(this.cookieExpirationName, "=").concat(this.cookieExpirationDate.getTime()));
|
|
_DocumentCookie__WEBPACK_IMPORTED_MODULE_3__.DocumentCookie.set(this.cookieName, content.join(","), this.cookieExpirationDate, this.cookiePolicies);
|
|
}
|
|
|
|
/** Bump CN expiration date */
|
|
}, {
|
|
key: "refreshCnCookieExpirationDate",
|
|
value: function refreshCnCookieExpirationDate() {
|
|
var content = Array.from(this.getCnCookieInfo().values.entries()).map(function (_ref3) {
|
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
cookieName = _ref4[0],
|
|
cookieStatus = _ref4[1];
|
|
return "".concat(cookieName, "=").concat(cookieStatus);
|
|
});
|
|
|
|
// * Update expiration date
|
|
this.cookieExpirationDate = this.getNewExpirationDate();
|
|
|
|
// * Append expiration date
|
|
content.push("".concat(this.cookieExpirationName, "=").concat(this.cookieExpirationDate.getTime()));
|
|
_DocumentCookie__WEBPACK_IMPORTED_MODULE_3__.DocumentCookie.set(this.cookieName, content.join(","), this.cookieExpirationDate, this.cookiePolicies);
|
|
}
|
|
|
|
/** Read CN cookie values */
|
|
}, {
|
|
key: "getCnCookieValues",
|
|
value: function getCnCookieValues() {
|
|
var _DocumentCookie$get,
|
|
_this6 = this;
|
|
var cookies = ((_DocumentCookie$get = _DocumentCookie__WEBPACK_IMPORTED_MODULE_3__.DocumentCookie.get(this.cookieName)) !== null && _DocumentCookie$get !== void 0 ? _DocumentCookie$get : "").split(",").filter(function (e) {
|
|
return e;
|
|
}).map(function (cookieKeyValue) {
|
|
return cookieKeyValue.split(/=|(?:\x2D>)/);
|
|
}),
|
|
out = new Map();
|
|
cookies.forEach(function (keyValue) {
|
|
var key = keyValue[0],
|
|
value = keyValue[1];
|
|
// * Exp Date
|
|
if (key === _this6.cookieExpirationName) {
|
|
var expDate = _this6.getNewExpirationDate();
|
|
try {
|
|
var epochExpiration = Number.parseInt(value);
|
|
if (!isNaN(epochExpiration)) {
|
|
expDate = new Date(epochExpiration);
|
|
}
|
|
} finally {
|
|
out.set(keyValue[0], expDate);
|
|
}
|
|
return;
|
|
}
|
|
// * CookieStatus values
|
|
out.set(keyValue[0], keyValue[1]);
|
|
});
|
|
return out;
|
|
}
|
|
|
|
/** Reset Cookie status list */
|
|
}, {
|
|
key: "resetCnCookie",
|
|
value: function resetCnCookie() {
|
|
var newCookieList = new Map();
|
|
Object.entries(this.config).forEach(function (_ref5) {
|
|
var _ref6 = _slicedToArray(_ref5, 1),
|
|
cookieName = _ref6[0];
|
|
return newCookieList.set(cookieName, _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait);
|
|
});
|
|
this.persistCnCookieList(newCookieList);
|
|
}
|
|
|
|
/** Change the status of a cookie */
|
|
}, {
|
|
key: "persistCnCookie",
|
|
value: function persistCnCookie(cookieName, status) {
|
|
var statusMap = this.getCnCookieInfo().values;
|
|
// * Force refresh
|
|
_DocumentCookie__WEBPACK_IMPORTED_MODULE_3__.DocumentCookie.markForDeletion(this.cookieName);
|
|
statusMap.set(cookieName, status);
|
|
this.persistCnCookieList(statusMap);
|
|
this.updateRestrictCloseModal();
|
|
}
|
|
|
|
// * --- LISTENERS ---
|
|
|
|
/**
|
|
* Add event on a specific element
|
|
*
|
|
* @param element
|
|
* @param evnt
|
|
* @param funct
|
|
* @returns
|
|
*/
|
|
}, {
|
|
key: "addEvent",
|
|
value: function addEvent(element, evnt, funct) {
|
|
element.addEventListener(evnt, funct.bind(this), false);
|
|
}
|
|
|
|
/**
|
|
* Add event on a specific element and prevent default
|
|
*
|
|
* @param element
|
|
* @param evnt
|
|
* @param funct
|
|
*/
|
|
}, {
|
|
key: "addEventPrevent",
|
|
value: function addEventPrevent(element, evnt, funct) {
|
|
var _this7 = this;
|
|
element.addEventListener(evnt, function (e) {
|
|
e.preventDefault();
|
|
funct.call(_this7, e);
|
|
}, false);
|
|
}
|
|
|
|
/**
|
|
* Add event on a specific element
|
|
*
|
|
* @param element A HTMLElement on which the should should be bound.
|
|
* @param funct A closure for the event hanling.
|
|
*/
|
|
}, {
|
|
key: "addEventKbdValidate",
|
|
value: function addEventKbdValidate(element, funct) {
|
|
var _this8 = this;
|
|
this.addEvent(element, "keydown", function (e) {
|
|
var kbdEvt = e;
|
|
if (kbdEvt.key == " " || kbdEvt.code == "Space" || kbdEvt.keyCode == 32 || kbdEvt.key == "Enter" || kbdEvt.code == "Enter" || kbdEvt.keyCode == 13) {
|
|
funct.call(_this8, kbdEvt);
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
}
|
|
|
|
// * --- COOKIE MODAL ---
|
|
}, {
|
|
key: "setCookieSwitchButton",
|
|
value: function setCookieSwitchButton(cookieName, status) {
|
|
var cnSwitch = document.getElementById("".concat(cookieName, "-switch"));
|
|
var cnSwitchInput = cnSwitch === null || cnSwitch === void 0 ? void 0 : cnSwitch.querySelector("input");
|
|
if (!cnSwitch || !cnSwitchInput) {
|
|
return;
|
|
}
|
|
cnSwitchInput.indeterminate = status === _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait;
|
|
cnSwitchInput.checked = status === _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.true;
|
|
cnSwitch.ariaChecked = status === _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait ? _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.false : status;
|
|
}
|
|
|
|
/** Update restrict for closing cookie modal */
|
|
}, {
|
|
key: "updateRestrictCloseModal",
|
|
value: function updateRestrictCloseModal() {
|
|
var cookieCloseModalBtn = this.getDomEl("cookieCloseModalBtn"),
|
|
modalBg = this.getDomEl("modalBg");
|
|
this.restrictCloseModal = Array.from(this.getCnCookieInfo().values.values()).includes(_enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait) ? true : false;
|
|
this.restrictCloseModal ? cookieCloseModalBtn.classList.add("d-none") : cookieCloseModalBtn.classList.remove("d-none");
|
|
this.restrictCloseModal ? modalBg.classList.add("cn-modal-bg-active") : modalBg.classList.remove("cn-modal-bg-active");
|
|
}
|
|
|
|
/** Show or hide Cookie modal */
|
|
}, {
|
|
key: "toggleCookieModal",
|
|
value: function toggleCookieModal() {
|
|
if (!document.body.classList.contains("cn-open")) {
|
|
this.openCookieModalToBannerPage();
|
|
return;
|
|
}
|
|
this.closeCookieModal();
|
|
}
|
|
|
|
/** Open the cookies modal to the banner page */
|
|
}, {
|
|
key: "openCookieModalToBannerPage",
|
|
value: function openCookieModalToBannerPage() {
|
|
this.openCookieModalToCookiePage();
|
|
this.toggleCookieModalPages();
|
|
}
|
|
|
|
/** Open the cookies modal to the cookies page */
|
|
}, {
|
|
key: "openCookieModalToCookiePage",
|
|
value: function openCookieModalToCookiePage() {
|
|
document.body.classList.add("cn-open");
|
|
this.resetCookieModal();
|
|
this.getDomEl("bannerContent").classList.add("d-none");
|
|
this.getDomEl("modalContainer").classList.remove("d-none");
|
|
this.getDomEl("bannerContainer").classList.add("cn-modal-page");
|
|
|
|
// Scroll to the top of the cookies list
|
|
this.getDomEl("modalContainer").scrollTop = 0;
|
|
this.setupCookieModalList();
|
|
this.setTabIndex();
|
|
}
|
|
|
|
/** Hide the cookies modal */
|
|
}, {
|
|
key: "closeCookieModal",
|
|
value: function closeCookieModal() {
|
|
this.updateRestrictCloseModal();
|
|
if (!this.restrictCloseModal) {
|
|
document.body.classList.remove("cn-open");
|
|
if (!this.isOnBannerPage()) {
|
|
// * Make toggle page to banner on closing
|
|
this.getDomEl("bannerContent").classList.toggle("d-none");
|
|
this.getDomEl("modalContainer").classList.toggle("d-none");
|
|
this.getDomEl("bannerContainer").classList.remove("cn-modal-page");
|
|
}
|
|
this.unsetTabIndex();
|
|
this.setupCookieModalList();
|
|
} else {
|
|
throw new Error("You need to accept or refuse all cookies");
|
|
}
|
|
}
|
|
|
|
/** Setup tab indexes on visible elements */
|
|
}, {
|
|
key: "setTabIndex",
|
|
value: function setTabIndex() {
|
|
var _this9 = this;
|
|
// * Prevent focus html tag
|
|
document.documentElement.setAttribute("tabindex", "-1");
|
|
setTimeout(function () {
|
|
var focusableSelector = "a[href], button, [role=\"button\"], input, embed, object, iframe, textarea, select, details, [tabindex]:not([tabindex=\"-1\"])";
|
|
var cookieContainer = _this9.getDomEl("cookieContainer");
|
|
// * Only focusable elements
|
|
_toConsumableArray(document.body.querySelectorAll(focusableSelector)).filter(function (el) {
|
|
return !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden") && !cookieContainer.contains(el);
|
|
}).forEach(function (el) {
|
|
el.setAttribute("tabindex", "-1");
|
|
el.classList.add("cn-disabled");
|
|
});
|
|
_toConsumableArray(cookieContainer.querySelectorAll(focusableSelector)).filter(function (el) {
|
|
return !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden") &&
|
|
// * Only visible elements
|
|
!!(el.offsetWidth || el.offsetHeight || el.getClientRects().length) && !cookieContainer.contains(el);
|
|
}).forEach(function (el) {
|
|
el.setAttribute("tabindex", "0");
|
|
el.classList.remove("cn-disabled");
|
|
});
|
|
_this9.getDomEl("cookieShowModalBtn").setAttribute("tabindex", "-1");
|
|
}, 500);
|
|
}
|
|
|
|
/** Undo setup tab indexes on visible elements */
|
|
}, {
|
|
key: "unsetTabIndex",
|
|
value: function unsetTabIndex() {
|
|
var _this10 = this;
|
|
document.documentElement.setAttribute("tabindex", "0");
|
|
setTimeout(function () {
|
|
document.body.querySelectorAll(".cn-disabled").forEach(function (el) {
|
|
el.setAttribute("tabindex", "0");
|
|
el.classList.remove("cn-disabled");
|
|
});
|
|
_this10.getDomEl("cookieShowModalBtn").setAttribute("tabindex", "0");
|
|
}, 500);
|
|
}
|
|
|
|
/** Reset the modal view state */
|
|
}, {
|
|
key: "resetCookieModal",
|
|
value: function resetCookieModal() {
|
|
var customizeBtn = this.getDomEl("customizeBtn");
|
|
this.getDomEl("bannerContent").classList.remove("d-none");
|
|
this.getDomEl("modalContainer").classList.add("d-none");
|
|
this.getDomEl("bannerContainer").classList.remove("cn-modal-page");
|
|
if (!customizeBtn.dataset.openModal) {
|
|
throw new Error("Cannot find attribut data-open-modal");
|
|
}
|
|
customizeBtn.innerHTML = customizeBtn.dataset.openModal;
|
|
}
|
|
|
|
/** Set the cookies list in the modal */
|
|
}, {
|
|
key: "setupCookieModalList",
|
|
value: function setupCookieModalList() {
|
|
var _this11 = this;
|
|
this.getDomEl("cookiesUnorderedList").innerHTML = "";
|
|
Object.entries(this.config).forEach(function (_ref7) {
|
|
var _ref8 = _slicedToArray(_ref7, 2),
|
|
cookieName = _ref8[0],
|
|
cookieConfig = _ref8[1];
|
|
_this11.initDomCookieSwitch(cookieName, cookieConfig);
|
|
if (!_DocumentCookie__WEBPACK_IMPORTED_MODULE_3__.DocumentCookie.has(_this11.cookieName)) {
|
|
// * Ldcweb cookie is not set.
|
|
return;
|
|
}
|
|
var cookieStatus = _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait;
|
|
try {
|
|
cookieStatus = _this11.getCnCookieStatus(cookieName);
|
|
} finally {
|
|
// * Setup list status state
|
|
_this11.setCookieSwitchButton(cookieName, cookieStatus);
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "switchToModalPageOrClose",
|
|
value: function switchToModalPageOrClose() {
|
|
// * Modification du comportement du bouton, même si ca n'a pas de sens.
|
|
// https://lab.s-web.fr/ldc-web/projets/ldc-web-cookie-notice/-/issues/9`
|
|
|
|
if (this.isOnBannerPage()) {
|
|
this.toggleCookieModalPages();
|
|
return;
|
|
}
|
|
// * Pas de permutation en arrière
|
|
this.closeCookieModal();
|
|
}
|
|
|
|
/** Toggle Cookie modal pages */
|
|
}, {
|
|
key: "toggleCookieModalPages",
|
|
value: function toggleCookieModalPages() {
|
|
this.getDomEl("bannerContent").classList.toggle("d-none");
|
|
this.getDomEl("modalContainer").classList.toggle("d-none");
|
|
this.getDomEl("bannerContainer").classList.toggle("cn-modal-page");
|
|
if (!this.isOnBannerPage()) {
|
|
this.getDomEl("bannerContainer").classList.add("cn-modal-page");
|
|
this.denyAllWaitingCookies();
|
|
}
|
|
this.setTabIndex();
|
|
this.setupCookieModalList();
|
|
this.toggleCustomizeBtn();
|
|
}
|
|
|
|
/** Toggle customize btn */
|
|
}, {
|
|
key: "toggleCustomizeBtn",
|
|
value: function toggleCustomizeBtn() {
|
|
var customizeBtn = this.getDomEl("customizeBtn"),
|
|
customizeBtnBannerDataset = this.getDomEl("customizeBtn").dataset;
|
|
this.getDomEl("modalContainer").scrollTop = 0;
|
|
if (this.getDomEl("bannerContent").classList.contains("d-none")) {
|
|
customizeBtn.innerHTML = customizeBtnBannerDataset.openModal;
|
|
customizeBtn.title = customizeBtnBannerDataset.openModal;
|
|
} else {
|
|
customizeBtn.innerHTML = customizeBtnBannerDataset.closeModal;
|
|
customizeBtn.title = customizeBtnBannerDataset.closeModal;
|
|
}
|
|
}
|
|
|
|
/** Get the actual page: banner or modal (with cookie choices) */
|
|
}, {
|
|
key: "isOnBannerPage",
|
|
value: function isOnBannerPage() {
|
|
return this.getDomEl("modalContainer").classList.contains("d-none");
|
|
}
|
|
|
|
/** Setup Events */
|
|
}, {
|
|
key: "setupEvents",
|
|
value: function setupEvents() {
|
|
var _this12 = this;
|
|
this.addEventPrevent(this.getDomEl("modalBg"), "click", this.closeCookieModal);
|
|
this.addEventPrevent(this.getDomEl("cookieCloseModalBtn"), "click", this.closeCookieModal);
|
|
this.addEventPrevent(this.getDomEl("acceptAllBtn"), "click", function () {
|
|
_this12.acceptAllCookies();
|
|
_this12.closeCookieModal();
|
|
});
|
|
this.addEventPrevent(this.getDomEl("denyAllBtn"), "click", function () {
|
|
_this12.denyAllCookies();
|
|
_this12.closeCookieModal();
|
|
});
|
|
this.addEventPrevent(this.getDomEl("customizeBtn"), "click", this.switchToModalPageOrClose);
|
|
this.addEventPrevent(this.getDomEl("cookieShowModalBtn"), "click", this.toggleCookieModal);
|
|
this.getDomEl("cookieLinkShowCustomizeModalList").forEach(function (cookieLink) {
|
|
_this12.addEventPrevent(cookieLink, "click", _this12.openCookieModalToCookiePage);
|
|
_this12.addEventKbdValidate(cookieLink, _this12.openCookieModalToCookiePage);
|
|
});
|
|
}
|
|
|
|
/** Get dom element */
|
|
}, {
|
|
key: "getDomEl",
|
|
value: function getDomEl(item) {
|
|
// Exclude null|undefined as elements are verified in initDomElements
|
|
return this.domElList[item];
|
|
}
|
|
|
|
/** Init a Dom cookie switch */
|
|
}, {
|
|
key: "initDomCookieSwitch",
|
|
value: function initDomCookieSwitch(cookieName, cookieConfig) {
|
|
var _this13 = this;
|
|
var cookie = document.createElement("li");
|
|
var childItem = this.getDomEl("template").children.item(0);
|
|
if (childItem === null) {
|
|
throw new Error("Cannot find child item");
|
|
}
|
|
cookie.append(childItem.cloneNode(true));
|
|
var name = cookie.querySelector("span.cn-cookie-name");
|
|
var description = cookie.querySelector("span.cn-cookie-description");
|
|
var link = cookie.querySelector(".cn-cookie-link");
|
|
var cnSwitch = cookie.querySelector(".cn-switch");
|
|
var cnSwitchInput = cookie.querySelector(".cn-switch > input");
|
|
|
|
// * Undertermined state
|
|
cnSwitchInput.indeterminate = true;
|
|
cnSwitchInput.checked = false;
|
|
|
|
// * Assign cookie aside content
|
|
name.textContent = cookieConfig.name;
|
|
description.id = "".concat(cookieName, "-desc");
|
|
description.textContent = cookieConfig.description;
|
|
link.textContent = cookieConfig.labelLink;
|
|
link.setAttribute("href", cookieConfig.link);
|
|
|
|
// * Assign cookie controls
|
|
cnSwitch.id = "".concat(cookieName, "-switch");
|
|
cnSwitch.name = cookieName;
|
|
cnSwitch.dataset.name = cookieName;
|
|
cnSwitch.setAttribute("aria-labelledby", "".concat(cookieName, "-desc"));
|
|
cnSwitch.setAttribute("aria-describedby", "".concat(cookieName, "-desc"));
|
|
var toggleCookie = function toggleCookie(cookieName) {
|
|
var cookieStatus = _enums__WEBPACK_IMPORTED_MODULE_2__.CookieStatus.wait;
|
|
try {
|
|
cookieStatus = _this13.getCnCookieStatus(cookieName);
|
|
} finally {
|
|
_this13.setCnCookieStatus(cookieName, _this13.invertCookieStatus(cookieStatus));
|
|
_this13.refreshCnCookieExpirationDate();
|
|
}
|
|
};
|
|
this.addEvent(cnSwitchInput, "click", function () {
|
|
return toggleCookie(cookieName);
|
|
});
|
|
this.addEventKbdValidate(cnSwitch, function () {
|
|
return cnSwitchInput.click();
|
|
});
|
|
this.getDomEl("cookiesUnorderedList").append(cookie);
|
|
}
|
|
|
|
/** Init Dom elements selector */
|
|
}, {
|
|
key: "initDomElements",
|
|
value: function initDomElements() {
|
|
var _this14 = this;
|
|
// * Inject DOM modal BG
|
|
var modalBg = document.createElement("div");
|
|
modalBg.classList.add("cn-modal-bg");
|
|
document.body.append(modalBg);
|
|
this.domElList.modalBg = modalBg;
|
|
|
|
// * Setup Dom Elements
|
|
this.domElList.cookieLinkShowCustomizeModalList = document.querySelectorAll(".cn-cookie-link");
|
|
var selectorList = {
|
|
"div#cn-wrapper": "cookieContainer",
|
|
"button#cn-cookie-btn": "cookieShowModalBtn",
|
|
"button#cn-close-modal": "cookieCloseModalBtn",
|
|
"div#cn-banner": "bannerContainer",
|
|
"div.cn-banner-content": "bannerContent",
|
|
"div.cn-modal-container": "modalContainer",
|
|
"button#cn-accept-banner": "acceptAllBtn",
|
|
"button#cn-deny-banner": "denyAllBtn",
|
|
"button#cn-settings-banner": "customizeBtn",
|
|
"ul#cn-modal-list": "cookiesUnorderedList",
|
|
"div#cn-li-template": "template"
|
|
};
|
|
Object.entries(selectorList).forEach(function (entry) {
|
|
var selector = entry[0],
|
|
domElItemKey = entry[1];
|
|
var itemEntry = _this14.domElList[domElItemKey];
|
|
var domEl = document.querySelector(selector);
|
|
itemEntry = domEl;
|
|
if (!itemEntry) {
|
|
throw new Error("Cannot find dom element ".concat(selector));
|
|
}
|
|
_this14.domElList = _objectSpread(_objectSpread({}, _this14.domElList), {}, _defineProperty({}, domElItemKey, itemEntry));
|
|
});
|
|
|
|
// * Clone and remove original template node
|
|
var memoryTemplate = this.domElList.template.cloneNode(true);
|
|
this.domElList.template.remove();
|
|
this.domElList.template = memoryTemplate;
|
|
}
|
|
}]);
|
|
}();
|
|
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/ts/classes/DocumentCookie.ts":
|
|
/*!******************************************!*\
|
|
!*** ./src/ts/classes/DocumentCookie.ts ***!
|
|
\******************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ DocumentCookie: function() { return /* binding */ DocumentCookie; }
|
|
/* harmony export */ });
|
|
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); }
|
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
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); }
|
|
var DocumentCookie = /*#__PURE__*/function () {
|
|
function DocumentCookie() {
|
|
_classCallCheck(this, DocumentCookie);
|
|
}
|
|
return _createClass(DocumentCookie, null, [{
|
|
key: "has",
|
|
value: function has(cookieName) {
|
|
return this.getCookies().has(cookieName);
|
|
}
|
|
}, {
|
|
key: "get",
|
|
value: function get(cookieName) {
|
|
return this.getCookies().get(cookieName);
|
|
}
|
|
}, {
|
|
key: "set",
|
|
value: function set(cookieName, value) {
|
|
var date = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
var cookiePolicies = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
var cookieValue = "".concat(cookieName, "=").concat(value, ";path=/").concat(location.hostname ? ";domain=".concat(location.hostname) : "");
|
|
if (date) {
|
|
cookieValue += ";expires=".concat(date.toUTCString());
|
|
}
|
|
if (cookiePolicies) {
|
|
cookieValue += ";sameSite=".concat(cookiePolicies.sameSite).concat(cookiePolicies.secure ? ";secure" : "");
|
|
}
|
|
document.cookie = cookieValue;
|
|
}
|
|
}, {
|
|
key: "getAllStartingWith",
|
|
value: function getAllStartingWith(cookieNameStartingPart) {
|
|
var cookies = this.getCookies();
|
|
var _iterator = _createForOfIteratorHelper(cookies.keys()),
|
|
_step;
|
|
try {
|
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
var cookieName = _step.value;
|
|
if (!cookieName.startsWith(cookieNameStartingPart)) {
|
|
cookies.delete(cookieName);
|
|
}
|
|
}
|
|
} catch (err) {
|
|
_iterator.e(err);
|
|
} finally {
|
|
_iterator.f();
|
|
}
|
|
return cookies;
|
|
}
|
|
|
|
/**
|
|
* Set an older expire parameter to a specific cookie
|
|
*/
|
|
}, {
|
|
key: "markForDeletion",
|
|
value: function markForDeletion(cookieName) {
|
|
if (!DocumentCookie.has(cookieName)) {
|
|
console.debug("No document cookie named ".concat(cookieName));
|
|
}
|
|
// * Suppression du cookie et de sa version precedé d'un point
|
|
document.cookie = "".concat(cookieName, "=;path=/;expires=Thu, 01 Jan 1970 00:00:01 GMT;sameSite=Lax");
|
|
document.cookie = "".concat(cookieName, "=;path=/").concat(location.hostname ? ";domain=.".concat(location.hostname) : "", ";expires=Thu, 01 Jan 1970 00:00:01 GMT;sameSite=Lax");
|
|
document.cookie = "".concat(cookieName, "=;path=/").concat(location.hostname ? ";domain=".concat(location.hostname) : "", ";expires=Thu, 01 Jan 1970 00:00:01 GMT;sameSite=Lax");
|
|
}
|
|
|
|
/** Fetch browser cookies except(http-only ones) the cannot be handled using js */
|
|
}, {
|
|
key: "getCookies",
|
|
value: function getCookies() {
|
|
var out = new Map();
|
|
document.cookie.split(";").filter(function (e) {
|
|
return e;
|
|
}).forEach(function (c) {
|
|
var cookieKeyValue = c.split(/=([\s\S]*)/).filter(function (e) {
|
|
return e;
|
|
});
|
|
out.set(cookieKeyValue[0].trim(), cookieKeyValue[1].trim());
|
|
});
|
|
return out;
|
|
}
|
|
}]);
|
|
}();
|
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
// @ts-ignore
|
|
window.DocumentCookie = DocumentCookie;
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/ts/cookie-defaults.ts":
|
|
/*!***********************************!*\
|
|
!*** ./src/ts/cookie-defaults.ts ***!
|
|
\***********************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony import */ var _enums__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./enums */ "./src/ts/enums.ts");
|
|
|
|
var defaults = {
|
|
cookieName: "cn-init",
|
|
cookieTimeLife: 6,
|
|
cookieExpirationName: "_expiration",
|
|
cookiePolicies: {
|
|
sameSite: _enums__WEBPACK_IMPORTED_MODULE_0__.CookiePolicySameSite.lax,
|
|
secure: false
|
|
},
|
|
restrictCloseModal: true
|
|
};
|
|
/* harmony default export */ __webpack_exports__["default"] = (defaults);
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/ts/cookie-references.ts":
|
|
/*!*************************************!*\
|
|
!*** ./src/ts/cookie-references.ts ***!
|
|
\*************************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony default export */ __webpack_exports__["default"] = (new Map([["youtube", [
|
|
// * https://cookiedatabase.org/service/youtube/
|
|
// * https://tarteaucitron.io/fr/service/youtube/
|
|
"NID", "ENID", "_Secure-ENID", "VISITOR_INFO1_LIVE", "YEC", "__Secure-YEC", "YSC", "GEUP", "PREF", "pm_sess", "CGIC", "SOCS", "GPS", "yt-player-bandwidth", "yt-player-headers-readable"]], ["recaptcha", [
|
|
// * https://developers.google.com/recaptcha/docs/faq?hl=fr
|
|
// * https://cookiedatabase.org/?s=recaptcha&lang=en
|
|
"NID", "_grecaptcha", "__Secure-3PAPISID", "__Secure-3PSID", "__Secure-3PSIDCC", "_GRECAPTCHA", "rc::c", "rc::b", "rc::a", "itsec-recaptcha-opt-in-*"]], ["vimeo", [
|
|
// * https://help.vimeo.com/hc/fr/articles/17670845188113-Comment-puis-je-int%C3%A9grer-des-vid%C3%A9os-tout-en-%C3%A9tant-conforme-au-GDPR
|
|
// * Cookie Database https://cookiedatabase.org/service/vimeo/
|
|
// Ne semble plus placer de cookies
|
|
"vuid", "__utmt_player"]], ["matomo", [
|
|
// * PK* as in doc https://fr.matomo.org/faq/faq_146/
|
|
"_pk*",
|
|
// * Matomo
|
|
"_pk_ref", "_pk_cvar", "_pk_id", "_pk_ses", "_pk_hsr", "piwik_ignore", "_pk_uid",
|
|
// * Matomo Cloud
|
|
"_pk_ref", "_pk_cvar", "_pk_id", "_pk_ses", "_pk_hsr", "mtm_consent", "matomo_ignore", "matomo_sessid"]]]));
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/ts/enums.ts":
|
|
/*!*************************!*\
|
|
!*** ./src/ts/enums.ts ***!
|
|
\*************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
/* harmony export */ CookiePolicySameSite: function() { return /* binding */ CookiePolicySameSite; },
|
|
/* harmony export */ CookieStatus: function() { return /* binding */ CookieStatus; }
|
|
/* harmony export */ });
|
|
/** A cookie status as written in the cn cookie */
|
|
var CookieStatus = /*#__PURE__*/function (CookieStatus) {
|
|
CookieStatus["true"] = "true";
|
|
CookieStatus["false"] = "false";
|
|
CookieStatus["wait"] = "wait";
|
|
return CookieStatus;
|
|
}({});
|
|
|
|
/** A cookie Policy same site */
|
|
var CookiePolicySameSite = /*#__PURE__*/function (CookiePolicySameSite) {
|
|
CookiePolicySameSite["lax"] = "lax";
|
|
CookiePolicySameSite["strict"] = "strict";
|
|
CookiePolicySameSite["none"] = "none";
|
|
return CookiePolicySameSite;
|
|
}({});
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/ts/index.ts":
|
|
/*!*************************!*\
|
|
!*** ./src/ts/index.ts ***!
|
|
\*************************/
|
|
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
/* harmony import */ var _classes_CookieNotice__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./classes/CookieNotice */ "./src/ts/classes/CookieNotice.ts");
|
|
|
|
/* harmony default export */ __webpack_exports__["default"] = (_classes_CookieNotice__WEBPACK_IMPORTED_MODULE_0__["default"]);
|
|
|
|
/***/ }),
|
|
|
|
/***/ "./src/scss/themes/standard.scss":
|
|
/*!***************************************!*\
|
|
!*** ./src/scss/themes/standard.scss ***!
|
|
\***************************************/
|
|
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
|
|
|
|
module.exports = __webpack_require__.p + "css/standard.css";
|
|
|
|
/***/ })
|
|
|
|
/******/ });
|
|
/************************************************************************/
|
|
/******/ // The module cache
|
|
/******/ var __webpack_module_cache__ = {};
|
|
/******/
|
|
/******/ // The require function
|
|
/******/ function __webpack_require__(moduleId) {
|
|
/******/ // Check if module is in cache
|
|
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
/******/ if (cachedModule !== undefined) {
|
|
/******/ return cachedModule.exports;
|
|
/******/ }
|
|
/******/ // Create a new module (and put it into the cache)
|
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
/******/ // no module.id needed
|
|
/******/ // no module.loaded needed
|
|
/******/ exports: {}
|
|
/******/ };
|
|
/******/
|
|
/******/ // Execute the module function
|
|
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
/******/
|
|
/******/ // Return the exports of the module
|
|
/******/ return module.exports;
|
|
/******/ }
|
|
/******/
|
|
/************************************************************************/
|
|
/******/ /* webpack/runtime/define property getters */
|
|
/******/ !function() {
|
|
/******/ // define getter functions for harmony exports
|
|
/******/ __webpack_require__.d = function(exports, definition) {
|
|
/******/ for(var key in definition) {
|
|
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
/******/ }
|
|
/******/ }
|
|
/******/ };
|
|
/******/ }();
|
|
/******/
|
|
/******/ /* webpack/runtime/global */
|
|
/******/ !function() {
|
|
/******/ __webpack_require__.g = (function() {
|
|
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
/******/ try {
|
|
/******/ return this || new Function('return this')();
|
|
/******/ } catch (e) {
|
|
/******/ if (typeof window === 'object') return window;
|
|
/******/ }
|
|
/******/ })();
|
|
/******/ }();
|
|
/******/
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
/******/ !function() {
|
|
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
|
|
/******/ }();
|
|
/******/
|
|
/******/ /* webpack/runtime/make namespace object */
|
|
/******/ !function() {
|
|
/******/ // define __esModule on exports
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
/******/ }
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
/******/ };
|
|
/******/ }();
|
|
/******/
|
|
/******/ /* webpack/runtime/publicPath */
|
|
/******/ !function() {
|
|
/******/ var scriptUrl;
|
|
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
/******/ var document = __webpack_require__.g.document;
|
|
/******/ if (!scriptUrl && document) {
|
|
/******/ if (document.currentScript)
|
|
/******/ scriptUrl = document.currentScript.src;
|
|
/******/ if (!scriptUrl) {
|
|
/******/ var scripts = document.getElementsByTagName("script");
|
|
/******/ if(scripts.length) {
|
|
/******/ var i = scripts.length - 1;
|
|
/******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
|
|
/******/ }
|
|
/******/ }
|
|
/******/ }
|
|
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
|
|
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
|
|
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
|
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
/******/ __webpack_require__.p = scriptUrl;
|
|
/******/ }();
|
|
/******/
|
|
/************************************************************************/
|
|
/******/
|
|
/******/ // startup
|
|
/******/ // Load entry module and return exports
|
|
/******/ __webpack_require__("./src/ts/index.ts");
|
|
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
|
|
/******/ var __webpack_exports__ = __webpack_require__("./src/scss/themes/standard.scss");
|
|
/******/
|
|
/******/ return __webpack_exports__;
|
|
/******/ })()
|
|
;
|
|
});
|
|
//# sourceMappingURL=main.js.map
|