From a7e5cd3f6f1b5145277811a29bf1f3269d4f1752 Mon Sep 17 00:00:00 2001 From: mossroy Date: Fri, 2 Aug 2013 10:22:19 +0200 Subject: [PATCH] A click on the Home section empties its content, so that the user he finds the same home page as when he started the application. Fixes #38 --- js/app.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/js/app.js b/js/app.js index 4cb28c07..d8f5f780 100644 --- a/js/app.js +++ b/js/app.js @@ -35,46 +35,56 @@ define(function(require) { }); // Navigation bar : $('#btnHome').on('click', function(e) { + // Highlight the selected section in the navbar $('#liHomeNav').attr("class","active"); $('#liConfigureNav').attr("class",""); $('#liAboutNav').attr("class",""); + if ($('#navbarToggle').is(":visible") && $('#liHomeNav').is(':visible')) { + $('#navbarToggle').click(); + } + // Show the selected content in the page $('#about').hide(); $('#configuration').hide(); $('#formTitleSearch').show(); $('#titleList').show(); $('#articleContent').show(); - if ($('#navbarToggle').is(":visible") && $('#liHomeNav').is(':visible')) { - $('#navbarToggle').click(); - } + // Give the focus to the search field, and clean up the page contents + $("#prefix").val(""); $('#prefix').focus(); + $("#titleList").html(""); + $("#articleContent").html(""); return false; }); $('#btnConfigure').on('click', function(e) { + // 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(); + } + // Show the selected content in the page $('#about').hide(); $('#configuration').show(); $('#formTitleSearch').hide(); $('#titleList').hide(); $('#articleContent').hide(); - if ($('#navbarToggle').is(":visible") && $('#liHomeNav').is(':visible')) { - $('#navbarToggle').click(); - } return false; }); $('#btnAbout').on('click', function(e) { + // 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(); + } + // Show the selected content in the page $('#about').show(); $('#configuration').hide(); $('#formTitleSearch').hide(); $('#titleList').hide(); $('#articleContent').hide(); - if ($('#navbarToggle').is(":visible") && $('#liHomeNav').is(':visible')) { - $('#navbarToggle').click(); - } return false; });