Skip to content

Commit

Permalink
Merge pull request #398 from City-of-Helsinki/UHF-X_minor_bug_fixes
Browse files Browse the repository at this point in the history
UHF-X: Fix cookie dialog Power BI charts logic
  • Loading branch information
Arkkimaagi authored Nov 15, 2022
2 parents 905882d + 442c97e commit 9e76190
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,26 @@

var loadHelfiCharts = function () {
if (Drupal.eu_cookie_compliance.hasAgreed('statistics')) {
$('.helfi-charts-content').show();
}
else {
var chartContentElements = document.querySelectorAll('.helfi-charts-content');

// Populate all chart content elements with iframes on page
for (var i = 0; i < chartContentElements.length; ++i) {
if (chartContentElements[i].dataset && chartContentElements[i].dataset.src && chartContentElements[i].dataset.title) {
var iframeElement = document.createElement('iframe');
iframeElement.src = chartContentElements[i].dataset.src;
iframeElement.title = chartContentElements[i].dataset.title;
iframeElement.allow = 'fullscreen';
chartContentElements[i].replaceChildren(iframeElement);
}
}
} else {
$('.js-helfi-charts-cookie-compliance').show();
}

// Only load once.
loadHelfiCharts = function () {};
};

// Run after choosing cookie settings.
$(document).on('eu_cookie_compliance.changeStatus', loadHelfiCharts);

// Run after page is ready.
$(document).ready(function () {
loadHelfiCharts();
Expand Down

0 comments on commit 9e76190

Please sign in to comment.