Persistent sidebar state

This commit is contained in:
Dominik Süß 2016-10-22 11:13:35 +02:00 committed by Simon Michael
parent 5b4d61f198
commit 5d677fc174
2 changed files with 10 additions and 4 deletions

View File

@ -36,10 +36,13 @@ hledgerLayout vd title content = do
toWidget [hamlet| toWidget [hamlet|
^{topbar vd} ^{topbar vd}
^{sidebar vd} ^{sidebar vd}
<div #main-content .col-md-8 .col-xs-12 .col-sm-8> <div #main-content .col-xs-12 .#{showmd} .#{showsm}>
^{searchform vd} ^{searchform vd}
^{content} ^{content}
|] |]
where
showmd = if showsidebar vd then "col-md-8" else "col-md-12" :: String
showsm = if showsidebar vd then "col-sm-8" else "col-sm-12" :: String
-- | Global toolbar/heading area. -- | Global toolbar/heading area.
topbar :: ViewData -> HtmlUrl AppRoute topbar :: ViewData -> HtmlUrl AppRoute
@ -59,7 +62,7 @@ topbar VD{..} = [hamlet|
sidebar :: ViewData -> HtmlUrl AppRoute sidebar :: ViewData -> HtmlUrl AppRoute
sidebar vd@VD{..} = sidebar vd@VD{..} =
[hamlet| [hamlet|
<div #sidebar-menu .col-md-4 .col-sm-4 .sidebar-offcanvas> <div #sidebar-menu .#{showmd} .#{showsm} .sidebar-offcanvas>
<ul .main-menu .nav .nav-stacked .affix-top> <ul .main-menu .nav .nav-stacked .affix-top>
<li .top> <li .top>
<a href=@{JournalR} .#{journalcurrent} title="Show general journal entries, most recent first">Journal <a href=@{JournalR} .#{journalcurrent} title="Show general journal entries, most recent first">Journal
@ -68,6 +71,8 @@ sidebar vd@VD{..} =
where where
journalcurrent = if here == JournalR then "inacct" else "" :: String journalcurrent = if here == JournalR then "inacct" else "" :: String
accounts = balanceReportAsHtml opts vd $ balanceReport (reportopts_ $ cliopts_ opts){empty_=True} am j accounts = balanceReportAsHtml opts vd $ balanceReport (reportopts_ $ cliopts_ opts){empty_=True} am j
showmd = if showsidebar then "col-md-4" else "col-any-0" :: String
showsm = if showsidebar then "col-sm-4" else "" :: String
-- -- | Navigation link, preserving parameters and possibly highlighted. -- -- | Navigation link, preserving parameters and possibly highlighted.
-- navlink :: ViewData -> String -> AppRoute -> String -> HtmlUrl AppRoute -- navlink :: ViewData -> String -> AppRoute -> String -> HtmlUrl AppRoute

View File

@ -221,8 +221,9 @@ function addformDeletePosting() {
// SIDEBAR // SIDEBAR
function sidebarToggle() { function sidebarToggle() {
$('#sidebar-menu').toggleClass('col-md-4 col-any-0'); $('#sidebar-menu').toggleClass('col-md-4 col-sm-4 col-any-0');
$('#main-content').toggleClass('col-md-8 col-md-12'); $('#main-content').toggleClass('col-md-8 col-sm-8 col-md-12 col-sm-12');
$.cookie('showsidebar', $('#sidebar-menu').hasClass('col-any-0') ? '0' : '1');
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------