diff --git a/javascripts/theme.js b/javascripts/theme.js new file mode 100644 index 0000000..abcf548 --- /dev/null +++ b/javascripts/theme.js @@ -0,0 +1,26 @@ +/** + * Add the sidebar toggle capability when the sidebar exists on the page. + * Requires jQuery cookie support to persist sidebar state. + */ +$.getScript('//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js').done(function() { + var toggleSidebar = function() { + if ($('#main').hasClass('nosidebar')) { + $.removeCookie('hidesidebar', { path: '/' }); + $('#main').removeClass('nosidebar'); + $('#sidebar-toggle').html('»'); + } else { + $.cookie('hidesidebar', '1', { path: '/' }); + $('#main').addClass('nosidebar'); + $('#sidebar-toggle').html('«'); + } + }; + + if ($('#main').hasClass('nosidebar') === false) { + $('#main').append(''); + $('#sidebar-toggle').click(toggleSidebar); + + if ($.cookie('hidesidebar') === '1') { + toggleSidebar(); + } + } +}); diff --git a/sass/application.scss b/sass/application.scss index b9643f7..0810d32 100644 --- a/sass/application.scss +++ b/sass/application.scss @@ -44,6 +44,14 @@ tt, code, pre { background: transparent; margin: 15px 15px 0px 15px; background-color: $background-color; + position: relative; /* Allows the "#sidebar-toggle" to be positioned inside of it. */ +} + +#sidebar-toggle { + position: absolute; + top: 0; + right: 0; + z-index: 10; } #top-menu { @@ -202,7 +210,7 @@ p.breadcrumb { div#content > div.contextual { margin-top: 10px; - margin-right: 10px; + margin-right: 30px; } #roadmap { diff --git a/stylesheets/application.css b/stylesheets/application.css index eff2000..81b88c5 100644 --- a/stylesheets/application.css +++ b/stylesheets/application.css @@ -18,7 +18,9 @@ tt, code, pre { font-family: Consolas, "Liberation Mono", Courier, monospace; fo #header a { color: #4183c4; } #header > h1 { background: url(../images/logo.png) no-repeat 10px 5px; padding: 5px 45px; color: #393939; } -#main { background: transparent; margin: 15px 15px 0px 15px; background-color: white; } +#main { background: transparent; margin: 15px 15px 0px 15px; background-color: white; position: relative; } + +#sidebar-toggle { position: absolute; top: 0; right: 0; z-index: 10; } #top-menu { font: 12px Helvetica, arial, freesans, clean, sans-serif; padding: 10px 10px 2px 20px; background-color: #f3f3f3; background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #f9f9f9), color-stop(100%, #f3f3f3)); background-image: -webkit-linear-gradient(#f9f9f9, #f3f3f3); background-image: -moz-linear-gradient(#f9f9f9, #f3f3f3); background-image: -o-linear-gradient(#f9f9f9, #f3f3f3); background-image: linear-gradient(#f9f9f9, #f3f3f3); background-repeat: repeat-x; text-shadow: 0 1px 0 white; border-bottom: 1px solid #e5e5e5; } #top-menu #loggedas { color: #222; } @@ -55,7 +57,7 @@ div#content h2.contacts_header { padding-bottom: 10px; /* white-space: nowrap;*/ p.breadcrumb { margin: 4px 0 14px 0; } -div#content > div.contextual { margin-top: 10px; margin-right: 10px; } +div#content > div.contextual { margin-top: 10px; margin-right: 30px; } #roadmap { margin: 10px; }