Purpose
This Macro hides the Sidebar on the Themes
Details
Macro Name | hide-sidebar | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Macro-Title | Hide sidebar | ||||||||
| Description | This Macro hides the Sidebar | ||||||||
| Categories | Confluence Content | ||||||||
| Documentation URL | |||||||||
Definition of User Macro |
| ||||||||
| Reference | https://answers.atlassian.com/questions/3308/how-can-i-hide-the-left-sidebar-on-some-pages-when-using-the-documentation-theme |
Macro Code
## @noparams
<script>
// Find out the initial state of the sidebar and set a cookie
jQuery.cookie("showsidebar",AJS.$("div#splitter-sidebar").width(), {expires:5});
//If the sidebar is visible, hide it and the split bar...
if (AJS.$("div#splitter-sidebar").width() > 0) {
AJS.$(".vsplitbar").hide();
AJS.$("div#splitter-sidebar").width(0);
// ...then change the width and position of the content
AJS.$('#splitter-content').css({'width':'100%', 'left':'0'});
};
// The unload function runs when the user navigates away from the page
jQuery(window).unload(function() {
// Read the cookie to find out where the sidebar was originally
var origstate = jQuery.cookie("showsidebar");
// If the sidebar is now hidden and it wasn't originally,
// Click the button
if (AJS.$("div#splitter-sidebar").width() != 300 && origstate == 300) {
AJS.$("#splitter-button").click();
};
// Then delete the local cookie
jQuery.cookie("showsidebar", null);
});
</script>