Disable next/prev search result buttons when loading
This commit is contained in:
parent
da6ea2b69b
commit
826605242b
|
@ -60,13 +60,18 @@
|
||||||
function setLoading(isLoading) {
|
function setLoading(isLoading) {
|
||||||
if (loading !== isLoading) {
|
if (loading !== isLoading) {
|
||||||
loading = isLoading;
|
loading = isLoading;
|
||||||
if (loading) {
|
|
||||||
|
render(); // Refresh elements that depend on `loading` state.
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
// Show spinner
|
||||||
$('#searchResults').appendChild(
|
$('#searchResults').appendChild(
|
||||||
$create(
|
$create(
|
||||||
'.lds-spinner',
|
'.lds-spinner',
|
||||||
new Array(12).fill($create('div')).map(e => e.cloneNode()))
|
new Array(12).fill($create('div')).map(e => e.cloneNode()))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
// Hide spinner
|
||||||
$.remove('#searchResults > .lds-spinner');
|
$.remove('#searchResults > .lds-spinner');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +87,7 @@
|
||||||
createSearchResultNode(resultToDisplay);
|
createSearchResultNode(resultToDisplay);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#searchResultsNav-prev').disabled = (currentDisplayedPage <= 1);
|
$('#searchResultsNav-prev').disabled = (currentDisplayedPage <= 1 || loading);
|
||||||
$('#searchResultsNav-currentPage').textContent = currentDisplayedPage;
|
$('#searchResultsNav-currentPage').textContent = currentDisplayedPage;
|
||||||
|
|
||||||
let totalResultsCount = processedResults.length;
|
let totalResultsCount = processedResults.length;
|
||||||
|
@ -91,7 +96,7 @@
|
||||||
totalResultsCount += DISPLAYED_RESULTS_PER_PAGE;
|
totalResultsCount += DISPLAYED_RESULTS_PER_PAGE;
|
||||||
}
|
}
|
||||||
const totalPageCount = Math.ceil(Math.max(1, totalResultsCount / DISPLAYED_RESULTS_PER_PAGE));
|
const totalPageCount = Math.ceil(Math.max(1, totalResultsCount / DISPLAYED_RESULTS_PER_PAGE));
|
||||||
$('#searchResultsNav-next').disabled = (currentDisplayedPage >= totalPageCount);
|
$('#searchResultsNav-next').disabled = (currentDisplayedPage >= totalPageCount || loading);
|
||||||
$('#searchResultsNav-totalPages').textContent = totalPageCount;
|
$('#searchResultsNav-totalPages').textContent = totalPageCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user