Skip to content

Commit

Permalink
Hide sidebar if #sidebar has no children
Browse files Browse the repository at this point in the history
  • Loading branch information
huandu committed Mar 4, 2014
1 parent 21269f2 commit 8a3044a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions javascripts/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@
"autofocus.time_entry": true
};

var sidebar_btn = $('<div id="sidebar_btn">&nbsp;</div>'),
var sidebar_btn = $('<div id="sidebar_btn">&nbsp;</div>'),
elem = $('#main:not(.nosidebar) #sidebar');

sidebar_btn.on('click', toggle_sidebar);

if (elem != undefined){
elem.before(sidebar_btn);
if ($.cookie('hide_sidebar') == 'yes'){
$('#main').toggleClass('nosidebar');
if (elem.length){
// show sidebar if it has something.
if ($("#sidebar").children().length) {
elem.before(sidebar_btn);
if ($.cookie('hide_sidebar') == 'yes'){
$('#main').toggleClass('nosidebar');
}
} else {
// if #sidebar is empty, hide it completely.
$("#main").toggleClass("nosidebar");
}
}

Expand Down

0 comments on commit 8a3044a

Please sign in to comment.