components/jansson/doc/html/_static/sidebar.js
author Tomas Heran <tomas.heran@oracle.com>
Wed, 29 Oct 2014 17:55:16 +0100
changeset 2190 0e3f360be1b9
permissions -rw-r--r--
PSARC/2014/362 Jansson 19903653 Jansson - C library for working with JSON should be added to Userland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2190
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     1
/*
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     2
 * sidebar.js
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     3
 * ~~~~~~~~~~
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     4
 *
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     5
 * This script makes the Sphinx sidebar collapsible.
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     6
 *
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     7
 * .sphinxsidebar contains .sphinxsidebarwrapper.  This script adds
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     8
 * in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
     9
 * used to collapse and expand the sidebar.
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    10
 *
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    11
 * When the sidebar is collapsed the .sphinxsidebarwrapper is hidden
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    12
 * and the width of the sidebar and the margin-left of the document
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    13
 * are decreased. When the sidebar is expanded the opposite happens.
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    14
 * This script saves a per-browser/per-session cookie used to
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    15
 * remember the position of the sidebar among the pages.
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    16
 * Once the browser is closed the cookie is deleted and the position
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    17
 * reset to the default (expanded).
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    18
 *
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    19
 * :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    20
 * :license: BSD, see LICENSE for details.
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    21
 *
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    22
 */
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    23
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    24
$(function() {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    25
  
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    26
  
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    27
  
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    28
  
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    29
  
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    30
  
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    31
  
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    32
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    33
  // global elements used by the functions.
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    34
  // the 'sidebarbutton' element is defined as global after its
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    35
  // creation, in the add_sidebar_button function
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    36
  var bodywrapper = $('.bodywrapper');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    37
  var sidebar = $('.sphinxsidebar');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    38
  var sidebarwrapper = $('.sphinxsidebarwrapper');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    39
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    40
  // for some reason, the document has no sidebar; do not run into errors
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    41
  if (!sidebar.length) return;
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    42
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    43
  // original margin-left of the bodywrapper and width of the sidebar
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    44
  // with the sidebar expanded
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    45
  var bw_margin_expanded = bodywrapper.css('margin-left');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    46
  var ssb_width_expanded = sidebar.width();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    47
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    48
  // margin-left of the bodywrapper and width of the sidebar
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    49
  // with the sidebar collapsed
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    50
  var bw_margin_collapsed = '.8em';
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    51
  var ssb_width_collapsed = '.8em';
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    52
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    53
  // colors used by the current theme
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    54
  var dark_color = $('.related').css('background-color');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    55
  var light_color = $('.document').css('background-color');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    56
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    57
  function sidebar_is_collapsed() {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    58
    return sidebarwrapper.is(':not(:visible)');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    59
  }
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    60
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    61
  function toggle_sidebar() {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    62
    if (sidebar_is_collapsed())
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    63
      expand_sidebar();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    64
    else
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    65
      collapse_sidebar();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    66
  }
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    67
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    68
  function collapse_sidebar() {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    69
    sidebarwrapper.hide();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    70
    sidebar.css('width', ssb_width_collapsed);
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    71
    bodywrapper.css('margin-left', bw_margin_collapsed);
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    72
    sidebarbutton.css({
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    73
        'margin-left': '0',
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    74
        'height': bodywrapper.height()
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    75
    });
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    76
    sidebarbutton.find('span').text('»');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    77
    sidebarbutton.attr('title', _('Expand sidebar'));
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    78
    document.cookie = 'sidebar=collapsed';
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    79
  }
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    80
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    81
  function expand_sidebar() {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    82
    bodywrapper.css('margin-left', bw_margin_expanded);
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    83
    sidebar.css('width', ssb_width_expanded);
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    84
    sidebarwrapper.show();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    85
    sidebarbutton.css({
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    86
        'margin-left': ssb_width_expanded-12,
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    87
        'height': bodywrapper.height()
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    88
    });
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    89
    sidebarbutton.find('span').text('«');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    90
    sidebarbutton.attr('title', _('Collapse sidebar'));
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    91
    document.cookie = 'sidebar=expanded';
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    92
  }
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    93
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    94
  function add_sidebar_button() {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    95
    sidebarwrapper.css({
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    96
        'float': 'left',
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    97
        'margin-right': '0',
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    98
        'width': ssb_width_expanded - 28
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
    99
    });
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   100
    // create the button
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   101
    sidebar.append(
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   102
        '<div id="sidebarbutton"><span>&laquo;</span></div>'
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   103
    );
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   104
    var sidebarbutton = $('#sidebarbutton');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   105
    light_color = sidebarbutton.css('background-color');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   106
    // find the height of the viewport to center the '<<' in the page
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   107
    var viewport_height;
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   108
    if (window.innerHeight)
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   109
 	  viewport_height = window.innerHeight;
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   110
    else
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   111
	  viewport_height = $(window).height();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   112
    sidebarbutton.find('span').css({
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   113
        'display': 'block',
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   114
        'margin-top': (viewport_height - sidebar.position().top - 20) / 2
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   115
    });
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   116
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   117
    sidebarbutton.click(toggle_sidebar);
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   118
    sidebarbutton.attr('title', _('Collapse sidebar'));
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   119
    sidebarbutton.css({
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   120
        'color': '#FFFFFF',
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   121
        'border-left': '1px solid ' + dark_color,
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   122
        'font-size': '1.2em',
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   123
        'cursor': 'pointer',
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   124
        'height': bodywrapper.height(),
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   125
        'padding-top': '1px',
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   126
        'margin-left': ssb_width_expanded - 12
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   127
    });
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   128
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   129
    sidebarbutton.hover(
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   130
      function () {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   131
          $(this).css('background-color', dark_color);
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   132
      },
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   133
      function () {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   134
          $(this).css('background-color', light_color);
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   135
      }
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   136
    );
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   137
  }
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   138
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   139
  function set_position_from_cookie() {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   140
    if (!document.cookie)
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   141
      return;
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   142
    var items = document.cookie.split(';');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   143
    for(var k=0; k<items.length; k++) {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   144
      var key_val = items[k].split('=');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   145
      var key = key_val[0].replace(/ /, "");  // strip leading spaces
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   146
      if (key == 'sidebar') {
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   147
        var value = key_val[1];
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   148
        if ((value == 'collapsed') && (!sidebar_is_collapsed()))
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   149
          collapse_sidebar();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   150
        else if ((value == 'expanded') && (sidebar_is_collapsed()))
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   151
          expand_sidebar();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   152
      }
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   153
    }
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   154
  }
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   155
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   156
  add_sidebar_button();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   157
  var sidebarbutton = $('#sidebarbutton');
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   158
  set_position_from_cookie();
0e3f360be1b9 PSARC/2014/362 Jansson
Tomas Heran <tomas.heran@oracle.com>
parents:
diff changeset
   159
});