mirror of https://github.com/espruino/BangleApps
fix autoFilter behavior
parent
b54b00dcaa
commit
784dcf9751
16
index.js
16
index.js
|
@ -251,15 +251,17 @@ function showTab(tabname) {
|
|||
|
||||
// =========================================== Library
|
||||
|
||||
var activeFilter = window.location.hash ? window.location.hash.slice(1) : '';
|
||||
var chips = Array.from(document.querySelectorAll('.chip')).map(chip => chip.attributes.filterid.value)
|
||||
var hash = window.location.hash ? window.location.hash.slice(1) : '';
|
||||
|
||||
var activeFilter = !!~chips.indexOf(hash) ? hash : ''//window.location.hash ? window.location.hash.slice(1) : '';
|
||||
var currentSearch = '';
|
||||
|
||||
function refreshFilter(){
|
||||
var filtersContainer = document.querySelector("#librarycontainer .filter-nav");
|
||||
if(activeFilter){
|
||||
filtersContainer.querySelector('.active').classList.remove('active');
|
||||
filtersContainer.querySelector('.chip[filterid="'+activeFilter+'"]').classList.add('active')
|
||||
}
|
||||
filtersContainer.querySelector('.active').classList.remove('active');
|
||||
if(activeFilter) filtersContainer.querySelector('.chip[filterid="'+activeFilter+'"]').classList.add('active')
|
||||
else filtersContainer.querySelector('.chip[filterid]').classList.add('active')
|
||||
}
|
||||
function refreshLibrary() {
|
||||
var panelbody = document.querySelector("#librarycontainer .panel-body");
|
||||
|
@ -515,10 +517,10 @@ Comms.watchConnectionChange(handleConnectionChange);
|
|||
|
||||
var filtersContainer = document.querySelector("#librarycontainer .filter-nav");
|
||||
filtersContainer.addEventListener('click', ({ target }) => {
|
||||
if (!target.hasAttribute('filterid')) return;
|
||||
//if (!target.hasAttribute('filterid')) return;
|
||||
if (target.classList.contains('active')) return;
|
||||
|
||||
activeFilter = target.getAttribute('filterid');
|
||||
activeFilter = target.getAttribute('filterid') || '';
|
||||
refreshFilter();
|
||||
refreshLibrary();
|
||||
window.location.hash = activeFilter
|
||||
|
|
Loading…
Reference in New Issue