}
});
+/**
+ * Provides collapsible sidebars with persistency support.
+ */
WCF.Collapsible.Sidebar = Class.extend({
+ /**
+ * trigger button object
+ * @var jQuery
+ */
_button: null,
+
+ /**
+ * sidebar state
+ * @var boolean
+ */
_isOpen: false,
+
+ /**
+ * action proxy
+ * @var WCF.Action.Proxy
+ */
_proxy: null,
+
+ /**
+ * sidebar object
+ * @var jQuery
+ */
_sidebar: null,
+
+ /**
+ * sidebar identifier
+ * @var string
+ */
_sidebarName: '',
+ /**
+ * Creates a new WCF.Collapsible.Sidebar object.
+ */
init: function() {
this._sidebar = $('.sidebar:eq(0)');
if (!this._sidebar.length) {
this._button.click($.proxy(this._click, this));
this._proxy = new WCF.Action.Proxy({
- url: 'index.php/CollapsibleSidebar/?t=' + SECURITY_TOKEN + SID_2ND
+ url: 'index.php/AJAXInvoke/?t=' + SECURITY_TOKEN + SID_2ND
});
this._renderSidebar();
},
+ /**
+ * Handles clicks on the trigger button.
+ */
_click: function() {
this._isOpen = (this._isOpen) ? false : true;
this._proxy.setOption('data', {
+ actionName: 'toggle',
+ className: 'wcf\\system\\user\\collapsible\\content\\UserCollapsibleSidebarHandler',
isOpen: (this._isOpen ? 1 : 0),
sidebarName: this._sidebarName
});
this._renderSidebar();
},
+ /**
+ * Renders the sidebar state.
+ */
_renderSidebar: function() {
if (this._isOpen) {
this._sidebar.addClass('sidebarCollapsed');
--- /dev/null
+<?php
+namespace wcf\system\user\collapsible\content;
+use wcf\system\exception\UserInputException;
+use wcf\system\IAJAXInvokeAction;
+use wcf\system\SingletonFactory;
+use wcf\util\StringUtil;
+
+/**
+ * Provides methods for handling collapsible sidebars.
+ *
+ * @author Alexander Ebert
+ * @copyright 2001-2012 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.user.collapsible.content
+ * @category Community Framework
+ */
+class UserCollapsibleSidebarHandler extends SingletonFactory implements IAJAXInvokeAction {
+ /**
+ * Toggles a sidebar.
+ */
+ public function toggle() {
+ $isOpen = (isset($_POST['isOpen'])) ? intval($_POST['isOpen']) : 1;
+ $objectID = (isset($_POST['sidebarName'])) ? StringUtil::trim($_POST['sidebarName']) : '';
+ if (empty($objectID)) {
+ throw new UserInputException('sidebarName');
+ }
+
+ $objectTypeID = UserCollapsibleContentHandler::getInstance()->getObjectTypeID('com.woltlab.wcf.collapsibleSidebar');
+ if ($isOpen) {
+ UserCollapsibleContentHandler::getInstance()->markAsOpened($objectTypeID, $objectID);
+ }
+ else {
+ UserCollapsibleContentHandler::getInstance()->markAsCollapsed($objectTypeID, $objectID);
+ }
+ }
+}