v1.18.x
barisusakli 8 years ago
parent 51b41a9b44
commit 2c77a88ba4

@ -640,18 +640,24 @@ app.cacheBuster = null;
} else if (window.localStorage.getItem('cookieconsent') === '1') {
return;
}
templates.parse('partials/cookie-consent', config.cookies, function (html) {
$(document.body).append(html);
var warningEl = $('.cookie-consent');
var dismissEl = warningEl.find('button');
dismissEl.on('click', function () {
// Save consent cookie and remove warning element
var now = new Date();
window.localStorage.setItem('cookieconsent', '1');
warningEl.remove();
require(['translator'], function (translator) {
config.cookies.message = translator.unescape(config.cookies.message);
config.cookies.dismiss = translator.unescape(config.cookies.dismiss);
config.cookies.link = translator.unescape(config.cookies.link)
app.parseAndTranslate('partials/cookie-consent', config.cookies, function (html) {
$(document.body).append(html);
var warningEl = $('.cookie-consent');
var dismissEl = warningEl.find('button');
dismissEl.on('click', function () {
// Save consent cookie and remove warning element
var now = new Date();
window.localStorage.setItem('cookieconsent', '1');
warningEl.remove();
});
});
});
};
}());

@ -12,6 +12,7 @@ var categories = require('../categories');
var privileges = require('../privileges');
var plugins = require('../plugins');
var widgets = require('../widgets');
var translator = require('../../public/src/modules/translator');
var accountHelpers = require('../controllers/accounts/helpers');
var apiController = {};
@ -66,9 +67,9 @@ apiController.getConfig = function (req, res, next) {
config.cookies = {
enabled: parseInt(meta.config.cookieConsentEnabled, 10) === 1,
message: meta.config.cookieConsentMessage || '[[global:cookies.message]]',
dismiss: meta.config.cookieConsentDismiss || '[[global:cookies.accept]]',
link: meta.config.cookieConsentLink || '[[global:cookies.learn_more]]'
message: translator.escape(meta.config.cookieConsentMessage || '[[global:cookies.message]]').replace(/\\/g, '\\\\'),
dismiss: translator.escape(meta.config.cookieConsentDismiss || '[[global:cookies.accept]]').replace(/\\/g, '\\\\'),
link: translator.escape(meta.config.cookieConsentLink || '[[global:cookies.learn_more]]').replace(/\\/g, '\\\\')
};
async.waterfall([

Loading…
Cancel
Save