Scroll up when search results options are clicked (find/next/prev)
This commit is contained in:
parent
b3cd06bedd
commit
58f003392a
|
@ -1,7 +1,5 @@
|
||||||
html, body {
|
html, body {
|
||||||
height: min-content;
|
height: min-content;
|
||||||
overflow-y: auto;
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
body.search-results-shown {
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
#disable-all-wrapper {
|
#disable-all-wrapper {
|
||||||
border-bottom: solid 1px #000;
|
border-bottom: solid 1px #000;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
|
|
|
@ -9,14 +9,23 @@
|
||||||
$('#find-styles-link').onclick = event => {
|
$('#find-styles-link').onclick = event => {
|
||||||
// Only load search results inline if option is selected.
|
// Only load search results inline if option is selected.
|
||||||
if ($('#find-styles-inline').checked) {
|
if ($('#find-styles-inline').checked) {
|
||||||
|
// Hide 'inline' checkbox.
|
||||||
$('#find-styles-inline-group').classList.add('hidden');
|
$('#find-styles-inline-group').classList.add('hidden');
|
||||||
$('#find-styles-inline').checked = false;
|
$('#find-styles-inline').checked = false;
|
||||||
|
|
||||||
const searchResults = searchResultsController();
|
const searchResults = searchResultsController();
|
||||||
$('#searchResultsNav-prev').onclick = searchResults.prev;
|
$('#searchResultsNav-prev').onclick = searchResults.prev;
|
||||||
$('#searchResultsNav-next').onclick = searchResults.next;
|
$('#searchResultsNav-next').onclick = searchResults.next;
|
||||||
// Intercept event to avoid opening the search page.
|
searchResults.load();
|
||||||
return searchResults.load(event);
|
document.body.classList.add('search-results-shown');
|
||||||
|
|
||||||
|
window.scrollTo(0, 0);
|
||||||
|
|
||||||
|
// Avoid propagating click to anchor/href
|
||||||
|
event.preventDefault();
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
// Open anchor href in new tab.
|
||||||
handleEvent.openURLandHide.call($('#find-styles-link'), event);
|
handleEvent.openURLandHide.call($('#find-styles-link'), event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -99,22 +108,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Increments currentDisplayedPage and loads results. */
|
/** Increments currentDisplayedPage and loads results. */
|
||||||
function next(event) {
|
function next() {
|
||||||
if (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
currentDisplayedPage += 1;
|
currentDisplayedPage += 1;
|
||||||
render();
|
render();
|
||||||
|
window.scrollTo(0, 0);
|
||||||
loadMoreIfNeeded();
|
loadMoreIfNeeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Decrements currentPage and loads results. */
|
/** Decrements currentPage and loads results. */
|
||||||
function prev(event) {
|
function prev() {
|
||||||
if (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
currentDisplayedPage = Math.max(1, currentDisplayedPage - 1);
|
currentDisplayedPage = Math.max(1, currentDisplayedPage - 1);
|
||||||
render();
|
render();
|
||||||
|
window.scrollTo(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,13 +141,8 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes search results container, starts fetching results.
|
* Initializes search results container, starts fetching results.
|
||||||
* @param {Object} event The click event
|
|
||||||
*/
|
*/
|
||||||
function load(event) {
|
function load() {
|
||||||
if (event) {
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
loading = true;
|
loading = true;
|
||||||
render();
|
render();
|
||||||
|
|
||||||
|
@ -175,8 +175,6 @@
|
||||||
})
|
})
|
||||||
.catch(error);
|
.catch(error);
|
||||||
});
|
});
|
||||||
// Find styles for the current active tab
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user