From 9499b7bf3d7b44c7ec8e95705758d418027e2fa6 Mon Sep 17 00:00:00 2001 From: Fredrik Erlandsson Date: Mon, 9 Jan 2012 16:06:41 +0100 Subject: [PATCH] Attempt to fix #3, support for a sidebar --- admin/controllers/admin_theme_options.php | 14 +++++-- js/pear.js | 48 +++++++++++++++++------ theme.info | 2 +- views/album.html.php | 8 +++- 4 files changed, 53 insertions(+), 19 deletions(-) diff --git a/admin/controllers/admin_theme_options.php b/admin/controllers/admin_theme_options.php index 8cd09ab2..583d869e 100644 --- a/admin/controllers/admin_theme_options.php +++ b/admin/controllers/admin_theme_options.php @@ -46,6 +46,10 @@ class Admin_Theme_Options_Controller extends Admin_Controller { module::clear_var("th_pear4gallery3", "show_logo"); module::set_var("th_pear4gallery3", "hide_logo", FALSE); endif; + if (module::get_var("th_pear4gallery3", "show_sidebar")): + module::clear_var("th_pear4gallery3", "show_sidebar"); + module::set_var("th_pear4gallery3", "sidebar_view", "toggle"); + endif; } protected function get_edit_form_admin() { @@ -99,9 +103,10 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $group->checkbox("show_breadcrumbs") ->label(t("Show breadcrumbs for navigation.")) ->checked(module::get_var("th_pear4gallery3", "show_breadcrumbs")); - $group->checkbox("show_sidebar") - ->label(t("Show Sidebar")) - ->checked(module::get_var("th_pear4gallery3", "show_sidebar")); + $group->dropdown("sidebar_view") + ->label(t("Show Sidebar mode")) + ->options(array("hidden" => t("Hidden (Default)"), "static" => t("Always visible"), "toggle" => t("Toggleable"))) + ->selected(module::get_var("th_pear4gallery3", "sidebar_view")); $group->input("ga_code") ->label(t("Google analytics code.")) ->value(module::get_var("th_pear4gallery3", "ga_code")); @@ -189,6 +194,7 @@ class Admin_Theme_Options_Controller extends Admin_Controller { module::clear_var("th_pear4gallery3", "background"); module::clear_var("th_pear4gallery3", "show_breadcrumbs"); module::clear_var("th_pear4gallery3", "show_sidebar"); + module::clear_var("th_pear4gallery3", "sidebar_view"); module::clear_var("th_pear4gallery3", "ga_code"); } @@ -274,7 +280,7 @@ class Admin_Theme_Options_Controller extends Admin_Controller { $this->save_item_state("show_guest_menu",$form->edit_theme_adv_main->show_guest_menu->value, TRUE); $this->save_item_state("background", $form->edit_theme_adv_main->background->value != "black", $form->edit_theme_adv_main->background->value); $this->save_item_state("show_breadcrumbs",$form->edit_theme_adv_main->show_breadcrumbs->value, TRUE); - $this->save_item_state("show_sidebar",$form->edit_theme_adv_main->show_sidebar->value, TRUE); + $this->save_item_state("sidebar_view",$form->edit_theme_adv_main->sidebar_view->value != "hidden", $form->edit_theme_adv_main->sidebar_view->value); $this->save_item_state("ga_code", $form->edit_theme_adv_main->ga_code->value, $form->edit_theme_adv_main->ga_code->value); // * Advanced Options - Photo page *************************************** diff --git a/js/pear.js b/js/pear.js index 1aa46017..74ca88dc 100644 --- a/js/pear.js +++ b/js/pear.js @@ -50,16 +50,6 @@ function getCookie(c_name) { } return ""; } -function toggleSidebar() { - if ($('#sidebar').length === 0) { return; } - if ($('#sidebar').is(':visible')) { - $('#sidebar').hide('slide', { direction: 'right'}, 1000); - $('#mosaicGridContainer').animate( { width: '+=220' }, 1000, function () { mosaicResize(); }); - } else { - $('#sidebar').show('slide', { direction: 'right'}, 1000); - $('#mosaicGridContainer').animate( { width: '-=220' }, 1000, function () { mosaicResize(); }); - } -} function mosaicResize() { if ($('#mosaicGridContainer').length === 0) { @@ -101,8 +91,8 @@ function mosaicResize() { myHeight += 18; } /*Sidebar*/ - if ($('#sidebar').is(':visible')) { myWidth = myWidth - 220; } - $('#sidebar').css('height', (myHeight + 53) + "px"); + if ($('#sidebarContainer').is(':visible')) { myWidth = myWidth - $('#sidebarContainer').width(); } + $('#sidebarContainer').css('height', (myHeight + 53) + "px"); if (!mosaicView) { $('#mosaicGridContainer').css({'height': (myHeight + 33) + "px", 'width': myWidth + "px"}); } else { @@ -585,3 +575,37 @@ function preFetch() { } } +function toggleSidebar() { + if ($('#sidebar').length === 0) { return; } + if ($('#sidebar').is(':visible')) { + $('#sidebar').hide('slide', { direction: 'right'}, 1000); + $('#mosaicGridContainer').animate( { width: '+=220' }, 1000, function () { mosaicResize(); }); + } else { + $('#sidebar').show('slide', { direction: 'right'}, 1000); + $('#mosaicGridContainer').animate( { width: '-=220' }, 1000, function () { mosaicResize(); }); + } +} + +function sidebarInit(mode) { + switch (mode) { + case 'toggle': + $('#sidebarContainer').width(5); + $('#sidebarContainer').hover(function () { + $('#sidebarContainer').animate( { width: '225' }, 500); + //$('#sidebar').show('slide', { direction: 'right'}, 1000); + $('#mosaicGridContainer').animate( { width: '-=225' }, 500, function () { mosaicResize(); }); }, + function () { + $('#sidebarContainer').animate( { width: '5' }, 500); + //$('#sidebar').hide('slide', { direction: 'right'}, 1000); + $('#mosaicGridContainer').animate( { width: '+=225' }, 500, function () { mosaicResize(); }); + }); + break; + case 'static': + break; + //case 'hidden': + default: + $('#sidebarContainer').hide(); + break; + } +} + diff --git a/theme.info b/theme.info index bdc88fe7..23fabfa6 100644 --- a/theme.info +++ b/theme.info @@ -1,6 +1,6 @@ name = ".Pear Theme" description = "A theme with the intention to mimic Apples mobile me gallery." -version = 2.7.1 +version = 2.7.2 author = "Fredrik Erlandsson " site = 1 admin = 0 diff --git a/views/album.html.php b/views/album.html.php index c8c12eee..ce17abed 100644 --- a/views/album.html.php +++ b/views/album.html.php @@ -2,6 +2,7 @@