$(function() { // original width of the sidebar and margin-left of the bodywrapper // with the sidebar expanded var bw_margin_expanded = $('.bodywrapper').css("margin-left"); var ssb_width_expanded = $('.sphinxsidebar').css("width"); // width of the sidebar and margin-left of the bodywrapper // with the sidebar collapsed var bw_margin_collapsed = ".8em"; var ssb_width_collapsed = ".8em"; function toggle_sidebar() { //alert('toggling!'); if ($('.sphinxsidebarwrapper').is(':visible')) { collapse_sidebar(); } else { expand_sidebar(); } } function collapse_sidebar() { //alert('collapsing!'); $('.sphinxsidebarwrapper').hide(); $('.sphinxsidebar').css("width", ssb_width_collapsed); $('.bodywrapper').css("margin-left", bw_margin_collapsed); $('#sidebarbutton').text("»"); $('#sidebarbutton').attr('title', 'Expand sidebar'); } function expand_sidebar() { //alert('expanding!'); $('.bodywrapper').css("margin-left", bw_margin_expanded); $('.sphinxsidebar').css("width", ssb_width_expanded); $('.sphinxsidebarwrapper').css('display', 'table-cell'); $('#sidebarbutton').text("«"); $('#sidebarbutton').attr('title', 'Collapse sidebar'); } function add_sidebar_button() { //alert('adding button!'); $('.sphinxsidebar').append( '«'); $('#sidebarbutton').click(toggle_sidebar); $('#sidebarbutton').attr('title', 'Collapse sidebar'); // change the css to center the button // in the middle of the sidebar // XXX broken in a number of ways on ie6 // and probably on ie<6 and ie>6 too $('#sidebarbutton').css({ "display": "table-cell", "vertical-align": "middle", "color": "white", "background-color": "inherit", "border-left": "1px solid #133f52", "font-size": "1.2em", "cursor": "pointer"}); $('.sphinxsidebar').css({ "display": "table", "height": "100%"}); $('.sphinxsidebarwrapper').css('display', 'table-cell'); $('html, body, .document').css('height', '100%'); } add_sidebar_button(); });