Skip to content

Commit

Permalink
[FINNA-2477] Fix event listeners (NatLibFi#3016)
Browse files Browse the repository at this point in the history
  • Loading branch information
LuomaJuha authored Sep 4, 2024
1 parent 8c0f164 commit ffb9991
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions themes/finna2/js/finna-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,12 @@ finna.layout = (function finnaLayout() {
if (!document.addEventListener) {
return;
}
document.addEventListener('VuFind.sidefacets.loaded', function onSideFacetsLoaded() {
VuFind.listen('VuFind.sidefacets.loaded', function onSideFacetsLoaded() {
finna.dateRangeVis.init();
initToolTips($('.sidebar'));
initMobileNarrowSearch();
VuFind.lightbox.bind($('.sidebar'));
});
}, {once: true});
}

function initPiwikPopularSearches() {
Expand Down Expand Up @@ -467,7 +467,7 @@ finna.layout = (function finnaLayout() {
if (!document.addEventListener) {
return;
}
document.addEventListener('VuFind.lightbox.login', function onLightboxLogin(e) {
VuFind.listen('lightbox.login', function onLightboxLogin(e) {
if ($('body').hasClass('template-name-home') && !e.detail.formUrl.match(/catalogLogin/) && !e.detail.formUrl.match(/\Save/) && !e.detail.formUrl.match(/%2[fF]Save/)) {
window.location.href = VuFind.path + '/MyResearch/Home';
e.preventDefault();
Expand Down
4 changes: 1 addition & 3 deletions themes/finna2/js/finna-video-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,7 @@ class VideoElement extends HTMLElement {
connectedCallback() {
// Wait for the cookie consent to be initialized
if (VuFind.cookie.getConsentConfig() === null) {
document.addEventListener('vf-cookie-consent-initialized', () => {
this.onConsentInitialized();
});
VuFind.listen('cookie-consent-initialized', () => this.onConsentInitialized(), {once: true});
} else {
this.onConsentInitialized();
}
Expand Down

0 comments on commit ffb9991

Please sign in to comment.