Skip to content

Commit

Permalink
Implements "unclicking" functionality of #44
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaifroid committed Feb 4, 2018
1 parent 3abafb6 commit 1f5c088
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,13 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'

$('#findText').on('click', function (e) {
var innerDocument = window.frames[0].frameElement.contentDocument || window.frames[0].frameElement.contentWindow.document;
if (innerDocument.body.innerHTML.length < 10) return;
innerDocument = innerDocument.body;
if (!innerDocument) return;
innerDocument = innerDocument ? innerDocument.body : null;
if (!innerDocument || innerDocument.innerHTML.length < 10) return;
var searchDiv = document.getElementById('row2');
var findInArticle = document.getElementById('findInArticle');
if (searchDiv.style.display == 'none') {
setHomeTab('findText');
searchDiv.style.display = "inline";
setActiveBtn('findText');
findInArticle.focus();
} else {
clearFindInArticle();
Expand Down Expand Up @@ -416,15 +415,26 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
}

$('#btnConfigure').on('click', function (e) {
var searchDiv = document.getElementById('configuration');
if (searchDiv.style.display != 'none') {
setHomeTab();
if (params.themeChanged) {
params.themeChanged = false;
if (history.state !== null) {
var thisURL = decodeURIComponent(history.state.title);
goToArticle(thisURL);
}
}
return;
}
setHomeTab('btnConfigure');
// Highlight the selected section in the navbar
$('#liHomeNav').attr("class", "");
$('#liConfigureNav').attr("class", "active");
$('#liAboutNav').attr("class", "");
if ($('#navbarToggle').is(":visible") && $('#liHomeNav').is(':visible')) {
$('#navbarToggle').click();
}
setActiveBtn('btnConfigure');
clearFindInArticle();
//Return navbar to dark state if we switched it earlier
if (params.cssTheme == "light" && params.cssUITheme == "dark") {
document.getElementById('search-article').classList.add("dark");
Expand All @@ -434,16 +444,8 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
//Hide footer toolbar
document.getElementById('footer').style.display = "none";
// Show the selected content in the page
$('#about').hide();
$('#configuration').show();
//$('#formArticleSearch').hide();
$("#welcomeText").hide();
$('#articleList').hide();
$('#articleListHeaderMessage').hide();
$("#readingArticle").hide();
$("#articleContent").hide();
$('#articleContent').hide();
$('#searchingForArticles').hide();
$('#downloadLinks').hide();
$('#serverResponse').hide();
refreshAPIStatus();
Expand All @@ -469,15 +471,20 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
return false;
});
$('#btnAbout').on('click', function (e) {
//Check if we're 'unclicking' the button
var searchDiv = document.getElementById('about');
if (searchDiv.style.display != 'none') {
setHomeTab();
return;
}
// Highlight the selected section in the navbar
$('#liHomeNav').attr("class", "");
$('#liConfigureNav').attr("class", "");
$('#liAboutNav').attr("class", "active");
if ($('#navbarToggle').is(":visible") && $('#liHomeNav').is(':visible')) {
$('#navbarToggle').click();
}
setActiveBtn('btnAbout');
clearFindInArticle();
setHomeTab('btnAbout');
if (params.cssTheme == "light" && params.cssUITheme == "dark") {
document.getElementById('search-article').classList.add("dark");
document.getElementById('findInArticle').classList.add("dark");
Expand All @@ -487,15 +494,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies', 'q', 'module'
document.getElementById('footer').style.display = "none";
// Show the selected content in the page
$('#about').show();
$('#configuration').hide();
//$('#formArticleSearch').hide();
$("#welcomeText").hide();
$('#articleList').hide();
$('#articleListHeaderMessage').hide();
$("#readingArticle").hide();
$("#articleContent").hide();
$('#articleContent').hide();
$('#searchingForArticles').hide();
//Re-enable top-level scrolling
document.getElementById('top').style.position = "relative";
document.getElementById('scrollbox').style.position = "fixed";
Expand Down

0 comments on commit 1f5c088

Please sign in to comment.