Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
| Download
Sage Reference Manual
Project: SageManifolds
Views: 717109/*1* sidebar.js2* ~~~~~~~~~~3*4* This script makes the Sphinx sidebar collapsible.5*6* .sphinxsidebar contains .sphinxsidebarwrapper. This script adds7* in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton8* used to collapse and expand the sidebar.9*10* When the sidebar is collapsed the .sphinxsidebarwrapper is hidden11* and the width of the sidebar and the margin-left of the document12* are decreased. When the sidebar is expanded the opposite happens.13* This script saves a per-browser/per-session cookie used to14* remember the position of the sidebar among the pages.15* Once the browser is closed the cookie is deleted and the position16* reset to the default (expanded).17*18* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.19* :license: BSD, see LICENSE for details.20*21*/2223$(function() {242526272829303132// global elements used by the functions.33// the 'sidebarbutton' element is defined as global after its34// creation, in the add_sidebar_button function35var bodywrapper = $('.bodywrapper');36var sidebar = $('.sphinxsidebar');37var sidebarwrapper = $('.sphinxsidebarwrapper');3839// for some reason, the document has no sidebar; do not run into errors40if (!sidebar.length) return;4142// original margin-left of the bodywrapper and width of the sidebar43// with the sidebar expanded44var bw_margin_expanded = bodywrapper.css('margin-left');45var ssb_width_expanded = sidebar.width();4647// margin-left of the bodywrapper and width of the sidebar48// with the sidebar collapsed49var bw_margin_collapsed = '.8em';50var ssb_width_collapsed = '.8em';5152// colors used by the current theme53var dark_color = $('.related').css('background-color');54var light_color = $('.document').css('background-color');5556function sidebar_is_collapsed() {57return sidebarwrapper.is(':not(:visible)');58}5960function toggle_sidebar() {61if (sidebar_is_collapsed())62expand_sidebar();63else64collapse_sidebar();65}6667function collapse_sidebar() {68sidebarwrapper.hide();69sidebar.css('width', ssb_width_collapsed);70bodywrapper.css('margin-left', bw_margin_collapsed);71sidebarbutton.css({72'margin-left': '0',73'height': bodywrapper.height()74});75sidebarbutton.find('span').text('»');76sidebarbutton.attr('title', _('Expand sidebar'));77document.cookie = 'sidebar=collapsed';78}7980function expand_sidebar() {81bodywrapper.css('margin-left', bw_margin_expanded);82sidebar.css('width', ssb_width_expanded);83sidebarwrapper.show();84sidebarbutton.css({85'margin-left': ssb_width_expanded-12,86'height': bodywrapper.height()87});88sidebarbutton.find('span').text('«');89sidebarbutton.attr('title', _('Collapse sidebar'));90document.cookie = 'sidebar=expanded';91}9293function add_sidebar_button() {94sidebarwrapper.css({95'float': 'left',96'margin-right': '0',97'width': ssb_width_expanded - 2898});99// create the button100sidebar.append(101'<div id="sidebarbutton"><span>«</span></div>'102);103var sidebarbutton = $('#sidebarbutton');104light_color = sidebarbutton.css('background-color');105// find the height of the viewport to center the '<<' in the page106var viewport_height;107if (window.innerHeight)108viewport_height = window.innerHeight;109else110viewport_height = $(window).height();111sidebarbutton.find('span').css({112'display': 'block',113'margin-top': (viewport_height - sidebar.position().top - 20) / 2114});115116sidebarbutton.click(toggle_sidebar);117sidebarbutton.attr('title', _('Collapse sidebar'));118sidebarbutton.css({119'color': '#FFFFFF',120'border-left': '1px solid ' + dark_color,121'font-size': '1.2em',122'cursor': 'pointer',123'height': bodywrapper.height(),124'padding-top': '1px',125'margin-left': ssb_width_expanded - 12126});127128sidebarbutton.hover(129function () {130$(this).css('background-color', dark_color);131},132function () {133$(this).css('background-color', light_color);134}135);136}137138function set_position_from_cookie() {139if (!document.cookie)140return;141var items = document.cookie.split(';');142for(var k=0; k<items.length; k++) {143var key_val = items[k].split('=');144var key = key_val[0].replace(/ /, ""); // strip leading spaces145if (key == 'sidebar') {146var value = key_val[1];147if ((value == 'collapsed') && (!sidebar_is_collapsed()))148collapse_sidebar();149else if ((value == 'expanded') && (sidebar_is_collapsed()))150expand_sidebar();151}152}153}154155add_sidebar_button();156var sidebarbutton = $('#sidebarbutton');157set_position_from_cookie();158});159160