Added event before tab change
authorAlexander Ebert <ebert@woltlab.com>
Sat, 10 Dec 2016 22:28:20 +0000 (23:28 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 10 Dec 2016 22:28:26 +0000 (23:28 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu/Simple.js

index ae9d26c2cf2aa6c3da12bc3b78f0f03af548b9f2..5fc784fd23d52188b812679922fdc255a60b813d 100644 (file)
@@ -215,11 +215,19 @@ define(['Dictionary', 'EventHandler', 'Dom/Traverse', 'Dom/Util'], function(Dict
                        var oldTab = this.getActiveTab();
                        var oldContent = null;
                        if (oldTab) {
-                               if (elData(oldTab, 'name') === name) {
+                               var oldTabName = elData(oldTab, 'name');
+                               if (oldTabName === name) {
                                        // same tab
                                        return;
                                }
                                
+                               if (!disableEvent) {
+                                       EventHandler.fire('com.woltlab.wcf.simpleTabMenu_' + this._container.id, 'beforeSelect', {
+                                               tab: oldTab,
+                                               tabName: oldTabName
+                                       });
+                               }
+                               
                                oldTab.classList.remove('active');
                                oldContent = this._containers.get(elData(oldTab, 'name'));
                                oldContent.classList.remove('active');