Skip to content

Commit

Permalink
[TASK] Optimize events on status-changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikdro authored May 24, 2018
1 parent 8c9751b commit 1fd0c4d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Resources/Private/Templates/FusionObjects/Initialize.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
}
};

settings.onStatusChange = function () {
settings.onStatusChange = function (status) {
var type = this.options.type;
var didConsent = this.hasConsented();
if (type === 'opt-in' && didConsent) {
document.dispatchEvent(new CustomEvent("kd-cookieconsent", {detail: "enable-cookies"}));
if (type === 'opt-in') {
if (status === 'allow') {
document.dispatchEvent(new CustomEvent("kd-cookieconsent", {detail: "enable-cookies"}));
} else {
document.dispatchEvent(new CustomEvent("kd-cookieconsent", {detail: "disable-cookies"}));
}
}
if (type === 'opt-out' && !didConsent) {
document.dispatchEvent(new CustomEvent("kd-cookieconsent", {detail: "disable-cookies"}));
Expand Down

0 comments on commit 1fd0c4d

Please sign in to comment.