68publishers-cookie-consent
Advanced tools
Comparing version 0.3.5 to 0.3.6-beta.0
{ | ||
"name": "68publishers-cookie-consent", | ||
"version": "0.3.5", | ||
"version": "0.3.6-beta.0", | ||
"description": "Cookie consent wrapper based on orestbida/cookieconsent with GTM integration.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://www.68publishers.io/", |
@@ -104,2 +104,3 @@ <div align="center" style="text-align: center; margin-bottom: 50px"> | ||
| Synchronize consent with | The consent can be synchronized with another storage. The option is available only if the option `Display in the widget` is not checked. | | ||
| Show the modal again if storage is denied | The settings modal will be opened again after the specified number of days if the storage is denied. The option is available only if the option `Display in the widget` is not checked. | | ||
| Event trigger name | The name of an event trigger that will be invoked on `granted` consent with storage. The name may not be unique for each storage (unique triggers are invoked only). No trigger is invoked if the option has an empty value. | | ||
@@ -106,0 +107,0 @@ |
@@ -18,2 +18,4 @@ 'use strict'; | ||
} | ||
this._updateLastActionDate(); | ||
} | ||
@@ -23,2 +25,3 @@ | ||
this._updateConsent(); | ||
this._showModalAgainIfAnyStorageIsExpired(); | ||
} | ||
@@ -42,2 +45,4 @@ | ||
} | ||
this._updateLastActionDate(); | ||
} | ||
@@ -128,4 +133,55 @@ | ||
} | ||
_updateLastActionDate() { | ||
this._cookieConsent.set('data', { | ||
value: { | ||
last_action_date: (new Date()).toJSON(), | ||
}, | ||
mode: 'update' | ||
}); | ||
} | ||
_showModalAgainIfAnyStorageIsExpired() { | ||
let lastActionDate = this._cookieConsent.get('data').last_action_date; | ||
if (!lastActionDate) { | ||
return; | ||
} | ||
lastActionDate = new Date(lastActionDate); | ||
if ('Invalid Date' === lastActionDate || isNaN(lastActionDate)) { | ||
this._updateLastActionDate(); | ||
return; | ||
} | ||
const storageArr = this._storagePool.all(); | ||
for (let storageKey in storageArr) { | ||
if (!storageArr.hasOwnProperty(storageKey)) { | ||
continue; | ||
} | ||
const storage = storageArr[storageKey]; | ||
if ('number' !== typeof storage.showModalAgainExpiration) { | ||
continue; | ||
} | ||
const now = new Date(); | ||
const expirationDate = new Date(lastActionDate.valueOf()); | ||
expirationDate.setDate(expirationDate.getDate() + storage.showModalAgainExpiration); | ||
if (now >= expirationDate) { | ||
this._cookieConsent.showSettings(0); | ||
this._updateLastActionDate(); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
module.exports = ConsentManager; |
@@ -30,4 +30,8 @@ 'use strict'; | ||
} | ||
get showModalAgainExpiration() { | ||
return this._config.show_modal_again_expiration; | ||
} | ||
} | ||
module.exports = Storage; |
@@ -14,2 +14,3 @@ 'use strict'; | ||
this.sync_consent_with = config.sync_consent_with || null; | ||
this.show_modal_again_expiration = config.show_modal_again_expiration || null; | ||
} | ||
@@ -16,0 +17,0 @@ } |
Sorry, the diff of this file is too big to display
127851
990
329