Force display of first erroneous tab menu item
authorAlexander Ebert <ebert@woltlab.com>
Mon, 29 Oct 2012 11:52:33 +0000 (12:52 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 29 Oct 2012 11:52:33 +0000 (12:52 +0100)
Fixes #864

wcfsetup/install/files/js/WCF.js

index d0df0e1750e33756a7f749ce5ae39047b780d24f..2d4d532305ce8299317d9f64434caae36a97b08e 100755 (executable)
@@ -2847,6 +2847,14 @@ WCF.TabMenu = {
                                        }
                                });
                        }
+                       
+                       $tabMenu.data('isParent', ($tabMenu.children('.tabMenuContainer').length)).data('parent', false);
+                       if (!$tabMenu.data('isParent')) {
+                               // check if we're a child element
+                               if ($tabMenu.parent().hasClass('tabMenuContainer')) {
+                                       $tabMenu.data('parent', $tabMenu.parent());
+                               }
+                       }
                });
                
                // try to resolve location hash
@@ -2855,6 +2863,22 @@ WCF.TabMenu = {
                        $(window).bind('hashchange', $.proxy(this.selectTabs, this));
                }
                
+               // force display of first erroneous tab
+               for (var $containerID in this._containers) {
+                       var $tabMenu = this._containers[$containerID];
+                       if (!$tabMenu.data('isParent') && $tabMenu.find('.formError').length) {
+                               while (true) {
+                                       if ($tabMenu.data('parent') === false) {
+                                               break;
+                                       }
+                                       
+                                       $tabMenu = $tabMenu.data('parent').wcfTabs('select', $tabMenu.wcfIdentify());
+                               }
+                               
+                               break;
+                       }
+               }
+               
                this._didInit = true;
        },