Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #1248; moved returnToCurrentPage function to uiUtil.js #1249

Merged
merged 12 commits into from
May 6, 2024
12 changes: 1 addition & 11 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1659,7 +1659,7 @@ function handleGlobalDragleave (e) {
globalDropZone.classList.remove('dragging-over');
// Only return to page if a ZIM is actually loaded
if (selectedArchive.isReady()) {
returnToCurrentPage();
uiUtil.returnToCurrentPage();
}
}
}
Expand Down Expand Up @@ -1700,16 +1700,6 @@ function hasType (typesList, type) {
return false;
}

// Function to switch back to currently loaded page from config page after dragleave event
function returnToCurrentPage () {
document.getElementById('liConfigureNav').classList.remove('active');
document.getElementById('liHomeNav').classList.add('active');
uiUtil.tabTransitionToSection('home', params.showUIAnimations);
const welcomeText = document.getElementById('welcomeText');
welcomeText.style.display = 'none';
viewArticle.style.display = 'none';
}

async function handleFileDrop (packet) {
packet.stopPropagation();
packet.preventDefault();
Expand Down
23 changes: 13 additions & 10 deletions www/js/lib/uiUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -926,15 +926,17 @@ function applyAppTheme (theme) {
function showReturnLink () {
var viewArticle = document.getElementById('viewArticle');
viewArticle.style.display = 'block';
viewArticle.addEventListener('click', function (e) {
e.preventDefault();
document.getElementById('liConfigureNav').classList.remove('active');
document.getElementById('liHomeNav').classList.add('active');
tabTransitionToSection('home', params.showUIAnimations);
const welcomeText = document.getElementById('welcomeText');
welcomeText.style.display = 'none';
viewArticle.style.display = 'none';
});
viewArticle.addEventListener('click', returnToCurrentPage);
}

// Function to switch back to currently loaded page
function returnToCurrentPage () {
document.getElementById('liConfigureNav').classList.remove('active');
document.getElementById('liHomeNav').classList.add('active');
tabTransitionToSection('home', params.showUIAnimations);
const welcomeText = document.getElementById('welcomeText');
welcomeText.style.display = 'none';
viewArticle.style.display = 'none';
}

// Reports an error in loading one of the ASM or WASM machines to the UI API Status Panel
Expand Down Expand Up @@ -1077,5 +1079,6 @@ export default {
reportSearchProviderToAPIStatusPanel: reportSearchProviderToAPIStatusPanel,
warnAndOpenExternalLinkInNewTab: warnAndOpenExternalLinkInNewTab,
closestAnchorEnclosingElement: closestAnchorEnclosingElement,
getBrowserLanguage: getBrowserLanguage
getBrowserLanguage: getBrowserLanguage,
returnToCurrentPage: returnToCurrentPage
};
Loading