From d6040fc65b95e9e0df1bbca5f7763d643e36f65e Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Sat, 3 Feb 2018 14:44:46 +0000 Subject: [PATCH] Prevent Settings tab from remaining selected when article is displayed #44 Former-commit-id: 169e5569b86eb903a89680a4be575c76b9b4c714 [formerly 27aab2c6efe25bcf81a8ba9da86a19351e163de6] Former-commit-id: 607dbedb7655a52e4b03f9c277a03512473f6817 --- www/js/app.js | 34 ++++++++++++++++++++-------------- www/js/lib/uiUtil.js | 19 +------------------ 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/www/js/app.js b/www/js/app.js index 5ac5add2..8a84bc0f 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -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", ""); @@ -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", ""); @@ -1484,6 +1489,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module' selectedArchive.resolveRedirect(dirEntry, readArticle); } else { + setHomeTab(); //TESTING// console.log("Initiating HTML load..."); diff --git a/www/js/lib/uiUtil.js b/www/js/lib/uiUtil.js index 236674bc..f957d797 100644 --- a/www/js/lib/uiUtil.js +++ b/www/js/lib/uiUtil.js @@ -95,24 +95,7 @@ define([], function() { var shortTitle = title.substring(0, 25); shortTitle = shortTitle == title ? shortTitle : shortTitle + "..."; var link = '

<< Return to ' + shortTitle + '

'; - 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) { \