Skip to content

Commit

Permalink
Prevent Settings tab from remaining selected when article is displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid committed Feb 3, 2018
1 parent f5d04bc commit 35c9864
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 32 deletions.
34 changes: 20 additions & 14 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,23 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
});
// Top menu :
$('#btnHome').on('click', function (e) {
//setHomeTab();
// Give the focus to the search field, and clean up the page contents
if (!firstRun) {
$('#prefix').focus();
firstRun = false;
}
$("#articleContent").hide();
$("#articleContent").contents().empty();
$('#searchingForArticles').hide();
if (selectedArchive !== null && selectedArchive.isReady()) {
$("#welcomeText").hide();
goToMainArticle();
}
return false;
});

function setHomeTab() {
// Highlight the selected section in the navbar
$('#liHomeNav').attr("class", "active");
$('#liConfigureNav').attr("class", "");
Expand Down Expand Up @@ -382,24 +399,12 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
$('#articleList').show();
$('#articleListHeaderMessage').show();
$('#articleContent').show();
// Give the focus to the search field, and clean up the page contents
$("#prefix").val("");
if (!firstRun) {
$('#prefix').focus();
firstRun = false;
}
$("#articleList").empty();
$('#articleListHeaderMessage').empty();
$("#readingArticle").hide();
$("#articleContent").hide();
$("#articleContent").contents().empty();
$('#searchingForArticles').hide();
if (selectedArchive !== null && selectedArchive.isReady()) {
$("#welcomeText").hide();
goToMainArticle();
}
return false;
});
}

$('#btnConfigure').on('click', function (e) {
// Highlight the selected section in the navbar
$('#liHomeNav').attr("class", "");
Expand Down Expand Up @@ -1484,6 +1489,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
selectedArchive.resolveRedirect(dirEntry, readArticle);
}
else {
setHomeTab();

//TESTING//
console.log("Initiating HTML load...");
Expand Down
19 changes: 1 addition & 18 deletions www/js/lib/uiUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,7 @@ define([], function() {
var shortTitle = title.substring(0, 25);
shortTitle = shortTitle == title ? shortTitle : shortTitle + "...";
var link = '<h4 style="font-size:' + ~~(params.relativeUIFontSize * 1.4 * 0.14) + 'px;"><a href="#">&lt;&lt; Return to ' + shortTitle + '</a></h4>';
var rtnFunction = "(function () { \
$('#configuration').hide(); \
$('#about').hide(); \
if (params.cssTheme == 'light' && params.cssUITheme == 'dark') { \
document.getElementById('search-article').classList.remove('dark'); \
document.getElementById('findInArticle').classList.remove('dark'); \
document.getElementById('prefix').classList.remove('dark'); \
} \
$('#formArticleSearch').show(); \
$('#articleContent').show(); \
$('#liHomeNav').attr('class', 'active'); \
$('#liConfigureNav').attr('class', ''); \
$('#liAboutNav').attr('class', ''); \
document.getElementById('btnConfigure').classList.remove('active'); \
document.getElementById('btnAbout').classList.remove('active'); \
document.getElementById('search-article').style.overflow = 'hidden'; \
checkToolbar(); \
document.getElementById('search-article').scrollTop = 0; \
rtnFunction = "(function () { setHomeTab(); \
if (params.themeChanged) { \
params.themeChanged = false; \
if (history.state !== null) { \
Expand Down

0 comments on commit 35c9864

Please sign in to comment.