From 9abd2c898d39e6ec5ae6b2db36fd865a745431eb Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 22 Oct 2012 15:08:58 +0200 Subject: [PATCH] Added prototype for WCF.Collapsible.Sidebar --- wcfsetup/install/files/js/WCF.js | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index a86a5ebcf4..5f1839afc9 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -3450,6 +3450,56 @@ WCF.Collapsible.SimpleRemote = WCF.Collapsible.Remote.extend({ } }); +WCF.Collapsible.Sidebar = Class.extend({ + _button: null, + _isOpen: false, + _proxy: null, + _sidebar: null, + _sidebarName: '', + + init: function() { + this._sidebar = $('.sidebar:eq(0)'); + if (!this._sidebar.length) { + console.debug("[WCF.Collapsible.Sidebar] Could not find sidebar, aborting."); + return; + } + + this._isOpen = (this._sidebar.data('isOpen') === 'false') ? false : true; + this._sidebarName = this._sidebar.data('sidebarName'); + + // add toggle button + this._button = $('').prependTo(this._sidebar); + this._button.click($.proxy(this._click, this)); + + this._proxy = new WCF.Action.Proxy({ + url: 'index.php/CollapsibleSidebar/?t=' + SECURITY_TOKEN + SID_2ND + }); + + this._renderSidebar(); + }, + + _click: function() { + this._isOpen = (this._isOpen) ? false : true; + + this._proxy.setOption('data', { + isOpen: (this._isOpen ? 1 : 0), + sidebarName: this._sidebarName + }); + this._proxy.sendRequest(); + + this._renderSidebar(); + }, + + _renderSidebar: function() { + if (this._isOpen) { + this._sidebar.addClass('sidebarCollapsed'); + } + else { + this._sidebar.removeClass('sidebarCollapsed'); + } + } +}); + /** * Holds userdata of the current user */ -- 2.20.1