Skip to content

Commit

Permalink
Move returnToCurrentPage function to uiUtil.js #1248 (#1249)
Browse files Browse the repository at this point in the history
Signed off by @D3V-D.
  • Loading branch information
D3V-D authored May 6, 2024
1 parent 9e25c75 commit affca03
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
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
};

0 comments on commit affca03

Please sign in to comment.