Added support for activeTabMenuItem
authorAlexander Ebert <ebert@woltlab.com>
Mon, 29 Oct 2012 13:54:08 +0000 (14:54 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 29 Oct 2012 13:54:08 +0000 (14:54 +0100)
Fixes #863

wcfsetup/install/files/acp/templates/userGroupAdd.tpl
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/lib/acp/form/OptionForm.class.php
wcfsetup/install/files/lib/acp/form/UserGroupAddForm.class.php
wcfsetup/install/files/lib/form/AbstractForm.class.php

index 77b936e178da54ae41738f99e95990256232721a..3bd35660b7695e6a5bf4c24ad6eae602667856bd 100644 (file)
@@ -67,7 +67,7 @@
                
                {event name='fieldsets'}
                
-               <div class="tabMenuContainer" data-active="{$activeMenuItem}" data-store="activeTabMenuItem">
+               <div class="tabMenuContainer" data-active="{$activeTabMenuItem}" data-store="activeTabMenuItem">
                        <nav class="tabMenu">
                                <ul>
                                        {foreach from=$optionTree item=categoryLevel1}
@@ -77,7 +77,7 @@
                        </nav>
                        
                        {foreach from=$optionTree item=categoryLevel1}
-                               <div id="{@$categoryLevel1[object]->categoryName}" class="container containerPadding tabMenuContainer tabMenuContent" data-active="{$activeTabMenuItem}" data-store="activeMenuItem">
+                               <div id="{@$categoryLevel1[object]->categoryName}" class="container containerPadding tabMenuContainer tabMenuContent">
                                        <nav class="menu">
                                                <ul>
                                                        {foreach from=$categoryLevel1[categories] item=$categoryLevel2}
index 2d4d532305ce8299317d9f64434caae36a97b08e..c89eec6087595a63893ee2c061742ce7d7bd51e1 100755 (executable)
@@ -2815,6 +2815,10 @@ WCF.TabMenu = {
                                return true;
                        }
                        
+                       if ($tabMenu.data('store') && !$('#' + $tabMenu.data('store')).length) {
+                               $('<input type="hidden" name="' + $tabMenu.data('store') + '" value="" id="' + $tabMenu.data('store') + '" />').appendTo($tabMenu.parents('form').find('.formSubmit'));
+                       }
+                       
                        // init jQuery UI TabMenu
                        self._containers[$containerID] = $tabMenu;
                        $tabMenu.wcfTabs({
@@ -2823,9 +2827,22 @@ WCF.TabMenu = {
                                        var $container = $panel.closest('.tabMenuContainer');
                                        
                                        // store currently selected item
-                                       if ($container.data('store')) {
-                                               if ($.wcfIsset($container.data('store'))) {
-                                                       $('#' + $container.data('store')).attr('value', $panel.attr('id'));
+                                       var $tabMenu = $container;
+                                       while (true) {
+                                               // do not trigger on init
+                                               if ($tabMenu.data('isParent') === undefined) {
+                                                       break;
+                                               }
+                                               
+                                               if ($tabMenu.data('isParent')) {
+                                                       if ($tabMenu.data('store')) {
+                                                               $('#' + $tabMenu.data('store')).val($panel.attr('id'));
+                                                       }
+                                                       
+                                                       break;
+                                               }
+                                               else {
+                                                       $tabMenu = $tabMenu.data('parent');
                                                }
                                        }
                                        
@@ -2848,7 +2865,7 @@ WCF.TabMenu = {
                                });
                        }
                        
-                       $tabMenu.data('isParent', ($tabMenu.children('.tabMenuContainer').length)).data('parent', false);
+                       $tabMenu.data('isParent', ($tabMenu.children('.tabMenuContainer').length > 0)).data('parent', false);
                        if (!$tabMenu.data('isParent')) {
                                // check if we're a child element
                                if ($tabMenu.parent().hasClass('tabMenuContainer')) {
index 03d2fa8a55770b419e9a8600537e4da28229177a..e4f3775b307d291bbabec479cf375e7ab7be85c6 100644 (file)
@@ -31,12 +31,6 @@ class OptionForm extends AbstractOptionListForm {
         */
        public $categoryID = 0;
        
-       /**
-        * active tab menu item name
-        * @var string
-        */
-       public $activeTabMenuItem = '';
-       
        /**
         * option name for highlighting
         * @var string
@@ -70,15 +64,6 @@ class OptionForm extends AbstractOptionListForm {
                parent::readParameters();
        }
        
-       /**
-        * @see wcf\form\IForm::readFormParameters()
-        */
-       public function readFormParameters() {
-               parent::readFormParameters();
-               
-               if (isset($_POST['activeTabMenuItem'])) $this->activeTabMenuItem = $_POST['activeTabMenuItem'];
-       }
-       
        /**
         * @see wcf\form\IForm::save()
         */
@@ -121,7 +106,6 @@ class OptionForm extends AbstractOptionListForm {
                parent::assignVariables();
                
                WCF::getTPL()->assign(array(
-                       'activeTabMenuItem' => $this->activeTabMenuItem,
                        'category' => $this->category,
                        'optionName' => $this->optionName,
                        'optionTree' => $this->optionTree
index c6f48bc4a55472b7205c7d25b1e696a5ca5e10f2..4bded886d64b4c348a7c90571941d9e24dd73b74 100755 (executable)
@@ -36,18 +36,6 @@ class UserGroupAddForm extends AbstractOptionListForm {
         */
        public $cacheName = 'userGroup-option';
        
-       /**
-        * active tab menu item name
-        * @var string
-        */
-       public $activeTabMenuItem = '';
-       
-       /**
-        * active sub tab menu item name
-        * @var string
-        */
-       public $activeMenuItem = '';
-       
        /**
         * option tree
         * @var array
@@ -100,8 +88,6 @@ class UserGroupAddForm extends AbstractOptionListForm {
                I18nHandler::getInstance()->readValues();
                
                if (I18nHandler::getInstance()->isPlainValue('groupName')) $this->groupName = I18nHandler::getInstance()->getValue('groupName');
-               if (isset($_POST['activeTabMenuItem'])) $this->activeTabMenuItem = $_POST['activeTabMenuItem'];
-               if (isset($_POST['activeMenuItem'])) $this->activeMenuItem = $_POST['activeMenuItem'];
        }
        
        /**
@@ -201,9 +187,7 @@ class UserGroupAddForm extends AbstractOptionListForm {
                WCF::getTPL()->assign(array(
                        'groupName' => $this->groupName,
                        'optionTree' => $this->optionTree,
-                       'action' => 'add',
-                       'activeTabMenuItem' => $this->activeTabMenuItem,
-                       'activeMenuItem' => $this->activeMenuItem
+                       'action' => 'add'
                ));
        }
        
index 42f01a3455e70ab0409c69e6ec854ebc32997c0e..6e75ca42938ad5f107e0fbaac59c6b3fa55c97b0 100644 (file)
@@ -4,6 +4,7 @@ use wcf\page\AbstractPage;
 use wcf\system\event\EventHandler;
 use wcf\system\exception\UserInputException;
 use wcf\system\WCF;
+use wcf\util\StringUtil;
 
 /**
  * This class provides default implementations for the Form interface.
@@ -17,6 +18,12 @@ use wcf\system\WCF;
  * @category   Community Framework
  */
 abstract class AbstractForm extends AbstractPage implements IForm {
+       /**
+        * active tab menu item
+        * @var string
+        */
+       public $activeTabMenuItem = '';
+       
        /**
         * name of error field
         * @var string
@@ -61,6 +68,8 @@ abstract class AbstractForm extends AbstractPage implements IForm {
        public function readFormParameters() {
                // call readFormParameters event
                EventHandler::getInstance()->fireAction($this, 'readFormParameters');
+               
+               if (isset($_POST['activeTabMenuItem'])) $this->activeTabMenuItem = StringUtil::trim($_POST['activeTabMenuItem']);
        }
        
        /**
@@ -106,6 +115,7 @@ abstract class AbstractForm extends AbstractPage implements IForm {
                
                // assign default variables
                WCF::getTPL()->assign(array(
+                       'activeTabMenuItem' => $this->activeTabMenuItem,
                        'errorField' => $this->errorField,
                        'errorType' => $this->errorType
                ));