Added proper active tab save/restore
authorAlexander Ebert <ebert@woltlab.com>
Mon, 18 Apr 2016 10:35:21 +0000 (12:35 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 18 Apr 2016 10:35:26 +0000 (12:35 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Ui/TabMenu/Simple.js

index 0359e94ef676c739da79f10b011583b57bd3cf28..d320c0d6291e1c629646eff7641368b508db51fe 100644 (file)
@@ -17,6 +17,7 @@ define(['Dictionary', 'EventHandler', 'Dom/Traverse', 'Dom/Util'], function(Dict
                this._container = container;
                this._containers = new Dictionary();
                this._isLegacy = null;
+               this._store = null;
                this._tabs = new Dictionary();
        }
        
@@ -139,7 +140,7 @@ define(['Dictionary', 'EventHandler', 'Dom/Traverse', 'Dom/Util'], function(Dict
                                }
                                
                                if (!selectTab) {
-                                       var preselect = elData(this._container, 'preselect');
+                                       var preselect = elData(this._container, 'preselect') || elData(this._container, 'active');
                                        if (preselect === "true" || !preselect) preselect = true;
                                        
                                        if (preselect === true) {
@@ -161,6 +162,17 @@ define(['Dictionary', 'EventHandler', 'Dom/Traverse', 'Dom/Util'], function(Dict
                                        
                                        this.select(null, selectTab, true);
                                }
+                               
+                               var store = elData(this._container, 'store');
+                               if (store) {
+                                       var input = elCreate('input');
+                                       input.type = 'hidden';
+                                       input.name = store;
+                                       
+                                       this._container.appendChild(input);
+                                       
+                                       this._store = input;
+                               }
                        }
                        
                        return returnValue;
@@ -228,6 +240,10 @@ define(['Dictionary', 'EventHandler', 'Dom/Traverse', 'Dom/Util'], function(Dict
                                newContent.classList.remove('hidden');
                        }
                        
+                       if (this._store) {
+                               this._store.value = name;
+                       }
+                       
                        if (!disableEvent) {
                                EventHandler.fire('com.woltlab.wcf.simpleTabMenu_' + this._container.id, 'select', {
                                        active: tab,