Added highlighting for selected option
authorAlexander Ebert <ebert@woltlab.com>
Sat, 18 Aug 2012 10:57:53 +0000 (12:57 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 18 Aug 2012 10:57:53 +0000 (12:57 +0200)
wcfsetup/install/files/acp/templates/option.tpl
wcfsetup/install/files/lib/acp/form/OptionForm.class.php

index 91b994533243cdb19233e605998ec6ce3f5540ad..b6ebc883cffd57000a36f3f15c5608844e9ee0cd 100644 (file)
@@ -5,6 +5,17 @@
        $(function() {
                WCF.TabMenu.init();
                new WCF.ACP.Options();
+               
+               {if $optionName}
+                       var $option = $('#' + $.wcfEscapeID('{$optionName}'));
+                       new WCF.PeriodicalExecuter(function(pe) {
+                               pe.stop();
+                               
+                               var $scrollHandler = new WCF.Effect.Scroll();
+                               $scrollHandler.scrollTo($option, true);
+                               $option.focus();
+                       }, 200);
+               {/if}
        });
        //]]>
 </script>
index e64797b1a3e69080443f891f45444b299317f0d7..7c6728ac8b08ac83b2d4d2498a1163862f61b2b4 100644 (file)
@@ -6,6 +6,7 @@ use wcf\system\exception\IllegalLinkException;
 use wcf\system\menu\acp\ACPMenu;
 use wcf\system\WCF;
 use wcf\system\WCFACP;
+use wcf\util\StringUtil;
 
 /**
  * Shows the option edit form.
@@ -36,6 +37,12 @@ class OptionForm extends AbstractOptionListForm {
         */
        public $activeTabMenuItem = '';
        
+       /**
+        * option name for highlighting
+        * @var string
+        */
+       public $optionName = '';
+       
        /**
         * the option tree
         * @var array
@@ -58,6 +65,8 @@ class OptionForm extends AbstractOptionListForm {
                }
                $this->categoryName = $this->category->categoryName;
                
+               if (isset($_GET['optionName'])) $this->optionName = StringUtil::trim($_GET['optionName']);
+               
                parent::readParameters();
        }
        
@@ -96,6 +105,11 @@ class OptionForm extends AbstractOptionListForm {
                $this->optionTree = $this->optionHandler->getOptionTree($this->category->categoryName);
                
                if (!count($_POST)) {
+                       // not a valid top (level 1 or 2) category
+                       if (!isset($this->optionTree[0])) {
+                               throw new IllegalLinkException();
+                       }
+                       
                        $this->activeTabMenuItem = $this->optionTree[0]['object']->categoryName;
                }
        }
@@ -107,9 +121,10 @@ class OptionForm extends AbstractOptionListForm {
                parent::assignVariables();
                
                WCF::getTPL()->assign(array(
+                       'activeTabMenuItem' => $this->activeTabMenuItem,
                        'category' => $this->category,
-                       'optionTree' => $this->optionTree,
-                       'activeTabMenuItem' => $this->activeTabMenuItem
+                       'optionName' => $this->optionName,
+                       'optionTree' => $this->optionTree
                ));
        }