Upgrade for 'default' theme: collapsiblesidebar works with rightsidebar

This commit is contained in:
Denis 2012-12-10 14:13:35 +04:00
parent c69b7b4253
commit 5b54c253bb
2 changed files with 27 additions and 14 deletions

View File

@ -111,8 +111,7 @@ These themes are:
- **collapsiblesidebar** (true or false): Add an *experimental* JavaScript
snippet that makes the sidebar collapsible via a button on its side.
*Doesn't work together with "rightsidebar" or "stickysidebar".* Defaults to
false.
*Doesn't work with "stickysidebar".* Defaults to false.
- **externalrefs** (true or false): Display external links differently from
internal links. Defaults to false.

View File

@ -22,6 +22,20 @@
*/
$(function() {
{% if theme_rightsidebar|tobool %}
{% set side = 'right' %}
{% set opposite = 'left' %}
{% set initial_label = '»' %}
{% set expand_label = '«' %}
{% set collapse_label = '»' %}
{% else %}
{% set side = 'left' %}
{% set opposite = 'right' %}
{% set initial_label = '«' %}
{% set expand_label = '»' %}
{% set collapse_label = '«' %}
{% endif %}
// global elements used by the functions.
// the 'sidebarbutton' element is defined as global after its
// creation, in the add_sidebar_button function
@ -34,7 +48,7 @@ $(function() {
// original margin-left of the bodywrapper and width of the sidebar
// with the sidebar expanded
var bw_margin_expanded = bodywrapper.css('margin-left');
var bw_margin_expanded = bodywrapper.css('margin-{{side}}');
var ssb_width_expanded = sidebar.width();
// margin-left of the bodywrapper and width of the sidebar
@ -60,38 +74,38 @@ $(function() {
function collapse_sidebar() {
sidebarwrapper.hide();
sidebar.css('width', ssb_width_collapsed);
bodywrapper.css('margin-left', bw_margin_collapsed);
bodywrapper.css('margin-{{side}}', bw_margin_collapsed);
sidebarbutton.css({
'margin-left': '0',
'margin-{{side}}': '0',
'height': bodywrapper.height()
});
sidebarbutton.find('span').text('»');
sidebarbutton.find('span').text('{{expand_label}}');
sidebarbutton.attr('title', _('Expand sidebar'));
document.cookie = 'sidebar=collapsed';
}
function expand_sidebar() {
bodywrapper.css('margin-left', bw_margin_expanded);
bodywrapper.css('margin-{{side}}', bw_margin_expanded);
sidebar.css('width', ssb_width_expanded);
sidebarwrapper.show();
sidebarbutton.css({
'margin-left': ssb_width_expanded-12,
'margin-{{side}}': ssb_width_expanded-12,
'height': bodywrapper.height()
});
sidebarbutton.find('span').text('«');
sidebarbutton.find('span').text('{{collapse_label}}');
sidebarbutton.attr('title', _('Collapse sidebar'));
document.cookie = 'sidebar=expanded';
}
function add_sidebar_button() {
sidebarwrapper.css({
'float': 'left',
'margin-right': '0',
'float': '{{side}}',
'margin-{{opposite}}': '0',
'width': ssb_width_expanded - 28
});
// create the button
sidebar.append(
'<div id="sidebarbutton"><span>&laquo;</span></div>'
'<div id="sidebarbutton"><span>{{initial_label}}</span></div>'
);
var sidebarbutton = $('#sidebarbutton');
light_color = sidebarbutton.css('background-color');
@ -110,12 +124,12 @@ $(function() {
sidebarbutton.attr('title', _('Collapse sidebar'));
sidebarbutton.css({
'color': '#FFFFFF',
'border-left': '1px solid ' + dark_color,
'border-{{side}}': '1px solid ' + dark_color,
'font-size': '1.2em',
'cursor': 'pointer',
'height': bodywrapper.height(),
'padding-top': '1px',
'margin-left': ssb_width_expanded - 12
'margin-{{side}}': ssb_width_expanded - 12
});
sidebarbutton.hover(