Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vufind-org/vufind
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ec044950f28fd5e698c2bb375e362b7840f53713
Choose a base ref
..
head repository: vufind-org/vufind
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c17d041c780666d275a88cefb6d4f140884a694a
Choose a head ref
Showing with 8 additions and 4 deletions.
  1. +8 −4 themes/bootstrap5/js/facets.js
12 changes: 8 additions & 4 deletions themes/bootstrap5/js/facets.js
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@ VuFind.register('multiFacetsSelection', function multiFacetsSelection() {
const activation_event = 'facet-selection-begin';
const deactivation_event = 'facet-selection-cancel';
const apply_event = 'facet-selection-done';
const localStorageVariableName = 'multiFacetsSelection';
const local_storage_variable_name = 'multiFacetsSelection';

/**
* Normalize a filter value
@@ -299,12 +299,17 @@ VuFind.register('multiFacetsSelection', function multiFacetsSelection() {
}

function saveUserSelectionLastState(state) {
localStorage.setItem(localStorageVariableName, state);
localStorage.setItem(local_storage_variable_name, state);
}

function getUserSelectionLastState() {
return localStorage.getItem(local_storage_variable_name) === 'true';
}

function toggleMultiFacetsSelection(enable) {
if (typeof enable !== 'undefined') {
isMultiFacetsSelectionActivated = enable;
saveUserSelectionLastState(isMultiFacetsSelectionActivated);
}
document.querySelectorAll('.multi-facet-selection').forEach( el => el.classList.toggle('multi-facet-selection-active', isMultiFacetsSelectionActivated) );
const checkboxes = document.getElementsByClassName('js-user-selection-multi-filters');
@@ -318,7 +323,6 @@ VuFind.register('multiFacetsSelection', function multiFacetsSelection() {
toggleSelectedFacetStyle(elem);
}
}
saveUserSelectionLastState(isMultiFacetsSelectionActivated);
const event = isMultiFacetsSelectionActivated ? activation_event : deactivation_event;
VuFind.emit(event);
}
@@ -344,7 +348,7 @@ VuFind.register('multiFacetsSelection', function multiFacetsSelection() {
const activationElem = context.querySelector('.js-user-selection-multi-filters');
if (activationElem) {
activationElem.addEventListener('change', function multiFacetSelectionChange() { toggleMultiFacetsSelection(this.checked); } );
toggleMultiFacetsSelection(localStorage.getItem(localStorageVariableName) === 'true');
toggleMultiFacetsSelection(getUserSelectionLastState());
}
// Listener on apply filters button
const applyElem = context.querySelector('.js-apply-multi-facets-selection');