From 38886714209484d5740534afc48fbe9e770ea9b0 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 10 Nov 2011 00:14:15 +0100 Subject: [PATCH] Implemented a toggleable sidebar for WCF --- wcfsetup/install/files/acp/js/WCF.ACP.js | 5 +- wcfsetup/install/files/acp/style/style.css | 23 ++++++ .../install/files/acp/templates/header.tpl | 2 + wcfsetup/install/files/js/WCF.js | 70 +++++++++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index 9a1fab0493..72f8697cbd 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -75,8 +75,11 @@ WCF.ACP.Menu.prototype = { if ($target.hasClass('activeMenuItem')) { return; } - + this._renderSidebar($target.data('menuItem'), []); + + // force sidebar to be displayed + this._sidebarNavigation.wcfSidebar('show'); }, /** diff --git a/wcfsetup/install/files/acp/style/style.css b/wcfsetup/install/files/acp/style/style.css index 7aced9639d..f3f383e3b1 100644 --- a/wcfsetup/install/files/acp/style/style.css +++ b/wcfsetup/install/files/acp/style/style.css @@ -3703,7 +3703,30 @@ div#profileButtonContainer button:hover { +/* TODO: This is just a prototype for collapsible sidebars */ +.collapsibleSidebarButton { + background-color: rgb(216, 231, 245); + border: 1px solid rgb(192, 192, 192); + border-left-width: 0; + border-radius: 0 3px 3px 0; + padding: 3px; + opacity: 0.6; + position: absolute; + right: -15px; + top: 46%; + z-index: 101; + + -webkit-transition: opacity .2s linear; + -moz-transition: opacity .2s linear; + -ms-transition: opacity .2s linear; + -o-transition: opacity .2s linear; + transition: opacity .2s linear; +} +.collapsibleSidebarButton:hover { + cursor: pointer; + opacity: 1.0; +} diff --git a/wcfsetup/install/files/acp/templates/header.tpl b/wcfsetup/install/files/acp/templates/header.tpl index 2c7237e7cc..e7859cc266 100644 --- a/wcfsetup/install/files/acp/templates/header.tpl +++ b/wcfsetup/install/files/acp/templates/header.tpl @@ -70,6 +70,8 @@ new WCF.Effect.SmoothScroll(); new WCF.Effect.BalloonTooltip(); $('').appendTo('.innerError'); + + $('#sidebarMenu').wcfSidebar(); }); //]]> diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 99b16236e2..b6bda14825 100644 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -2992,6 +2992,76 @@ WCF.DOMNodeInsertedHandler = { } }; +/** + * Provides a toggleable sidebar. + */ +$.widget('ui.wcfSidebar', { + /** + * toggle button + * @var jQuery + */ + _button: null, + + /** + * sidebar visibility + * @var boolean + */ + _visible: true, + + /** + * Creates a new toggleable sidebar. + */ + _create: function() { + this.element.wrap('
'); + + // create toggle button + this._button = $('«').appendTo(this.element.parent('div')); + + // bind event + this._button.click($.proxy(this._toggle, this)); + }, + + /** + * Toggles visibility on button click. + */ + _toggle: function() { + if (this._visible) { + this.hide(); + } + else { + this.show(); + } + }, + + /** + * Shows sidebar content. + */ + show: function() { + if (this._visible) { + return; + } + + this._visible = true; + this.element.wcfBlindIn('horizontal', $.proxy(function() { + this._button.html('«'); + }, this)); + }, + + /** + * Hides the sidebar content. + */ + hide: function() { + if (!this._visible) { + return; + } + + this._visible = false; + this.element.wcfBlindOut('horizontal', $.proxy(function() { + this._button.html('»'); + }, this)); + } +}); + /** * Basic implementation for WCF dialogs. */ -- 2.20.1