python/mock-1.0.0/html/_static/sidebar.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/python/mock-1.0.0/html/_static/sidebar.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,148 @@
     1.4 +/*
     1.5 + * sidebar.js
     1.6 + * ~~~~~~~~~~
     1.7 + *
     1.8 + * This script makes the Sphinx sidebar collapsible.
     1.9 + *
    1.10 + * .sphinxsidebar contains .sphinxsidebarwrapper.  This script adds
    1.11 + * in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton
    1.12 + * used to collapse and expand the sidebar.
    1.13 + *
    1.14 + * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden
    1.15 + * and the width of the sidebar and the margin-left of the document
    1.16 + * are decreased. When the sidebar is expanded the opposite happens.
    1.17 + * This script saves a per-browser/per-session cookie used to
    1.18 + * remember the position of the sidebar among the pages.
    1.19 + * Once the browser is closed the cookie is deleted and the position
    1.20 + * reset to the default (expanded).
    1.21 + *
    1.22 + * :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
    1.23 + * :license: BSD, see LICENSE for details.
    1.24 + *
    1.25 + */
    1.26 +
    1.27 +$(function() {
    1.28 +  // global elements used by the functions.
    1.29 +  // the 'sidebarbutton' element is defined as global after its
    1.30 +  // creation, in the add_sidebar_button function
    1.31 +  var bodywrapper = $('.bodywrapper');
    1.32 +  var sidebar = $('.sphinxsidebar');
    1.33 +  var sidebarwrapper = $('.sphinxsidebarwrapper');
    1.34 +
    1.35 +  // original margin-left of the bodywrapper and width of the sidebar
    1.36 +  // with the sidebar expanded
    1.37 +  var bw_margin_expanded = bodywrapper.css('margin-left');
    1.38 +  var ssb_width_expanded = sidebar.width();
    1.39 +
    1.40 +  // margin-left of the bodywrapper and width of the sidebar
    1.41 +  // with the sidebar collapsed
    1.42 +  var bw_margin_collapsed = '.8em';
    1.43 +  var ssb_width_collapsed = '.8em';
    1.44 +
    1.45 +  // colors used by the current theme
    1.46 +  var dark_color = $('.related').css('background-color');
    1.47 +  var light_color = $('.document').css('background-color');
    1.48 +
    1.49 +  function sidebar_is_collapsed() {
    1.50 +    return sidebarwrapper.is(':not(:visible)');
    1.51 +  }
    1.52 +
    1.53 +  function toggle_sidebar() {
    1.54 +    if (sidebar_is_collapsed())
    1.55 +      expand_sidebar();
    1.56 +    else
    1.57 +      collapse_sidebar();
    1.58 +  }
    1.59 +
    1.60 +  function collapse_sidebar() {
    1.61 +    sidebarwrapper.hide();
    1.62 +    sidebar.css('width', ssb_width_collapsed);
    1.63 +    bodywrapper.css('margin-left', bw_margin_collapsed);
    1.64 +    sidebarbutton.css({
    1.65 +        'margin-left': '0',
    1.66 +        'height': bodywrapper.height()
    1.67 +    });
    1.68 +    sidebarbutton.find('span').text('»');
    1.69 +    sidebarbutton.attr('title', _('Expand sidebar'));
    1.70 +    document.cookie = 'sidebar=collapsed';
    1.71 +  }
    1.72 +
    1.73 +  function expand_sidebar() {
    1.74 +    bodywrapper.css('margin-left', bw_margin_expanded);
    1.75 +    sidebar.css('width', ssb_width_expanded);
    1.76 +    sidebarwrapper.show();
    1.77 +    sidebarbutton.css({
    1.78 +        'margin-left': ssb_width_expanded-12,
    1.79 +        'height': bodywrapper.height()
    1.80 +    });
    1.81 +    sidebarbutton.find('span').text('«');
    1.82 +    sidebarbutton.attr('title', _('Collapse sidebar'));
    1.83 +    document.cookie = 'sidebar=expanded';
    1.84 +  }
    1.85 +
    1.86 +  function add_sidebar_button() {
    1.87 +    sidebarwrapper.css({
    1.88 +        'float': 'left',
    1.89 +        'margin-right': '0',
    1.90 +        'width': ssb_width_expanded - 28
    1.91 +    });
    1.92 +    // create the button
    1.93 +    sidebar.append(
    1.94 +        '<div id="sidebarbutton"><span>&laquo;</span></div>'
    1.95 +    );
    1.96 +    var sidebarbutton = $('#sidebarbutton');
    1.97 +    light_color = sidebarbutton.css('background-color');
    1.98 +    // find the height of the viewport to center the '<<' in the page
    1.99 +    var viewport_height;
   1.100 +    if (window.innerHeight)
   1.101 + 	  viewport_height = window.innerHeight;
   1.102 +    else
   1.103 +	  viewport_height = $(window).height();
   1.104 +    sidebarbutton.find('span').css({
   1.105 +        'display': 'block',
   1.106 +        'margin-top': (viewport_height - sidebar.position().top - 20) / 2
   1.107 +    });
   1.108 +
   1.109 +    sidebarbutton.click(toggle_sidebar);
   1.110 +    sidebarbutton.attr('title', _('Collapse sidebar'));
   1.111 +    sidebarbutton.css({
   1.112 +        'color': '#FFFFFF',
   1.113 +        'border-left': '1px solid ' + dark_color,
   1.114 +        'font-size': '1.2em',
   1.115 +        'cursor': 'pointer',
   1.116 +        'height': bodywrapper.height(),
   1.117 +        'padding-top': '1px',
   1.118 +        'margin-left': ssb_width_expanded - 12
   1.119 +    });
   1.120 +
   1.121 +    sidebarbutton.hover(
   1.122 +      function () {
   1.123 +          $(this).css('background-color', dark_color);
   1.124 +      },
   1.125 +      function () {
   1.126 +          $(this).css('background-color', light_color);
   1.127 +      }
   1.128 +    );
   1.129 +  }
   1.130 +
   1.131 +  function set_position_from_cookie() {
   1.132 +    if (!document.cookie)
   1.133 +      return;
   1.134 +    var items = document.cookie.split(';');
   1.135 +    for(var k=0; k<items.length; k++) {
   1.136 +      var key_val = items[k].split('=');
   1.137 +      var key = key_val[0];
   1.138 +      if (key == 'sidebar') {
   1.139 +        var value = key_val[1];
   1.140 +        if ((value == 'collapsed') && (!sidebar_is_collapsed()))
   1.141 +          collapse_sidebar();
   1.142 +        else if ((value == 'expanded') && (sidebar_is_collapsed()))
   1.143 +          expand_sidebar();
   1.144 +      }
   1.145 +    }
   1.146 +  }
   1.147 +
   1.148 +  add_sidebar_button();
   1.149 +  var sidebarbutton = $('#sidebarbutton');
   1.150 +  set_position_from_cookie();
   1.151 +});

mercurial