Skip to content

Commit

Permalink
DIG-1292 | Added noUI configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
l-besenyei committed Apr 25, 2023
1 parent 3e3ac2b commit cab4b18
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 9 deletions.
19 changes: 16 additions & 3 deletions build/cookieconsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,15 @@ var Interface = /*#__PURE__*/function () {
if (typeof callback === 'undefined') callback = function callback() {};
var that = this;
Utilities.ready(function () {
if (window.CookieConsent.config.noUI) {
that.writeBufferToDOM();
that.buildCookie(function (cookie) {
that.setCookie(cookie);
});
callback();
return;
}

that.render('style', that.buildStyle());
that.render('bar', that.buildBar(), function (bar) {
// Show the bar after a while
Expand Down Expand Up @@ -1817,6 +1826,7 @@ var Configuration = /*#__PURE__*/function () {
modalMainTextMoreLink: null,
showRejectAllButton: false,
barTimeout: 1000,
noUI: false,
theme: {
barColor: '#2b7abb',
barTextColor: '#fff',
Expand Down Expand Up @@ -1926,10 +1936,13 @@ var Configuration = /*#__PURE__*/function () {
if (typeof window.CookieConsent.config.services[service] === 'undefined') {
return removeReload();
}
}); // We we integrate cookie data into the global config object
}); // If we don't have UI we ignore the saved cookie configuration.

for (var _key in cookieData.categories) {
window.CookieConsent.config.categories[_key].checked = window.CookieConsent.config.categories[_key].wanted = cookieData.categories[_key].wanted === true ? true : false;
if (!window.CookieConsent.config.noUI) {
// We integrate cookie data into the global config object
for (var _key in cookieData.categories) {
window.CookieConsent.config.categories[_key].checked = window.CookieConsent.config.categories[_key].wanted = cookieData.categories[_key].wanted === true ? true : false;
}
}

window.CookieConsent.config.cookieExists = true;
Expand Down
2 changes: 1 addition & 1 deletion build/cookieconsent.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs_src/src/assets/js/cookieconsent.min.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions src/lib/Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class Configuration {
modalMainTextMoreLink: null,
showRejectAllButton: false,
barTimeout: 1000,
noUI: false,
theme: {
barColor: '#2b7abb',
barTextColor: '#fff',
Expand Down Expand Up @@ -139,9 +140,12 @@ export default class Configuration {
}
});

// We we integrate cookie data into the global config object
for (let key in cookieData.categories) {
window.CookieConsent.config.categories[key].checked = window.CookieConsent.config.categories[key].wanted = (cookieData.categories[key].wanted === true) ? true : false;
// If we don't have UI we ignore the saved cookie configuration.
if (!window.CookieConsent.config.noUI) {
// We integrate cookie data into the global config object
for (let key in cookieData.categories) {
window.CookieConsent.config.categories[key].checked = window.CookieConsent.config.categories[key].wanted = (cookieData.categories[key].wanted === true) ? true : false;
}
}

window.CookieConsent.config.cookieExists = true;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/CookieConsent.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ export default class CookieConsent {
});
}

}
}
9 changes: 9 additions & 0 deletions src/lib/Interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@ export default class Interface {
var that = this;

Utilities.ready(function() {
if (window.CookieConsent.config.noUI) {
that.writeBufferToDOM();

that.buildCookie((cookie) => {
that.setCookie(cookie);
});
callback();
return;
}

that.render('style', that.buildStyle());

Expand Down

0 comments on commit cab4b18

Please sign in to comment.