<script type="text/javascript">
//<![CDATA[
$(function() {
- new WCF.Action.Delete('wcf\\data\\page\\menu\\item\\PageMenuItemAction', '.sortableNode');
- new WCF.Action.Toggle('wcf\\data\\page\\menu\\item\\PageMenuItemAction', '.sortableNode');
+ new WCF.Action.Delete('wcf\\data\\page\\menu\\item\\PageMenuItemAction', '.sortableNode', '> .sortableNodeLabel .jsDeleteButton');
+ new WCF.Action.Toggle('wcf\\data\\page\\menu\\item\\PageMenuItemAction', '.sortableNode', '> .sortableNodeLabel .jsToggleButton');
{if $headerItems|count}
new WCF.Sortable.List('pageMenuItemHeaderList', 'wcf\\data\\page\\menu\\item\\PageMenuItemAction', undefined, { protectRoot: true }, false, { menuPosition: 'header' });
*
* @param string className
* @param string containerSelector
+ * @param string buttonSelector
*/
WCF.Action.Delete = Class.extend({
+ /**
+ * delete button selector
+ * @var string
+ */
+ _buttonSelector: '',
+
/**
* action class name
* @var string
*
* @param string className
* @param string containerSelector
+ * @param string buttonSelector
*/
- init: function(className, containerSelector) {
+ init: function(className, containerSelector, buttonSelector) {
this._containerSelector = containerSelector;
this._className = className;
+ this._buttonSelector = (buttonSelector) ? buttonSelector : '.jsDeleteButton';
+
this.proxy = new WCF.Action.Proxy({
success: $.proxy(this._success, this)
});
if (!WCF.inArray($containerID, self._containers)) {
self._containers.push($containerID);
- $container.find('.jsDeleteButton').click($.proxy(self._click, self));
+ $container.find(this._buttonSelector).click($.proxy(self._click, self));
}
});
},
*
* @param string className
* @param jQuery containerList
- * @param string toggleButtonSelector
+ * @param string buttonSelector
*/
WCF.Action.Toggle = Class.extend({
+ /**
+ * toogle button selector
+ * @var string
+ */
+ _buttonSelector: '.jsToggleButton',
+
/**
* action class name
* @var string
*/
_containers: [ ],
- /**
- * toogle button selector
- * @var string
- */
- _toggleButtonSelector: '.jsToggleButton',
-
/**
* Initializes 'toggle'-Proxy
*
* @param string className
* @param string containerSelector
- * @param string toggleButtonSelector
+ * @param string buttonSelector
*/
- init: function(className, containerSelector, toggleButtonSelector) {
+ init: function(className, containerSelector, buttonSelector) {
this._containerSelector = containerSelector;
this._className = className;
- if (toggleButtonSelector) {
- this._toggleButtonSelector = toggleButtonSelector;
- }
+ this._buttonSelector = (buttonSelector) ? buttonSelector : '.jsToggleButton';
// initialize proxy
var options = {
if (!WCF.inArray($containerID, this._containers)) {
this._containers.push($containerID);
- $container.find(this._toggleButtonSelector).click($.proxy(this._click, this));
+ $container.find(this._buttonSelector).click($.proxy(this._click, this));
}
}, this));
},
triggerEffect: function(objectIDs) {
for (var $index in this._containers) {
var $container = $('#' + this._containers[$index]);
- var $toggleButton = $container.find(this._toggleButtonSelector);
+ var $toggleButton = $container.find(this._buttonSelector);
if (WCF.inArray($toggleButton.data('objectID'), objectIDs)) {
$container.wcfHighlight();
this._toggleButton($container, $toggleButton);
namespace wcf\data\page\menu\item;
use wcf\data\AbstractDatabaseObjectAction;
use wcf\data\ISortableAction;
+use wcf\data\IToggleAction;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\PermissionDeniedException;
use wcf\system\exception\UserInputException;
* Executes page menu item-related actions.
*
* @author Alexander Ebert
- * @copyright 2001-2012 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage data.page.menu.item
* @category Community Framework
*/
-class PageMenuItemAction extends AbstractDatabaseObjectAction implements ISortableAction {
+class PageMenuItemAction extends AbstractDatabaseObjectAction implements ISortableAction, IToggleAction {
/**
* @see wcf\data\AbstractDatabaseObjectAction::$className
*/
PageMenuItemEditor::updateLandingPage();
}
}
+
+ /**
+ * @see wcf\data\IToggleAction::validateToggle()
+ */
+ public function validateToggle() {
+ $this->menuItemEditor = $this->getSingleObject();
+ if ($this->menuItemEditor->isLandingPage) {
+ throw new PermissionDeniedException();
+ }
+ }
+
+ /**
+ * @see wcf\data\IToggleAction::toggle()
+ */
+ public function toggle() {
+ $this->menuItemEditor->update(array(
+ 'isDisabled' => ($this->menuItemEditor->isDisabled ? 0 : 1)
+ ));
+ }
}