Fixed style region marker position
authorAlexander Ebert <ebert@woltlab.com>
Tue, 27 Dec 2016 11:44:39 +0000 (12:44 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 27 Dec 2016 11:44:44 +0000 (12:44 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Page/Menu.js
wcfsetup/install/files/js/WoltLabSuite/Core/Acp/Ui/Style/Editor.js

index 16d27500e63cd9d4225511c88c1f238684dbed4f..59837658e86a1823f212ff033fa4feafb7e300be 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLabSuite/Core/Acp/Ui/Page/Menu
  */
-define(['Dictionary'], function(Dictionary) {
+define(['Dictionary', 'EventHandler'], function(Dictionary, EventHandler) {
        "use strict";
        
        var _activeMenuItem = '';
@@ -66,6 +66,8 @@ define(['Dictionary'], function(Dictionary) {
                                
                                _activeMenuItem = menuItem;
                        }
+                       
+                       EventHandler.fire('com.woltlab.wcf.AcpMenu', 'resize');
                }
        };
 });
index 089c1b6f963af9bff04146adfe1c88c197c608fa..7d5d2d7031803162c4ce6891e790147b5212ff28 100644 (file)
@@ -12,10 +12,13 @@ define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'EventHandler', 'Ui/Screen'],
        var _stylePreviewRegions = new Dictionary();
        var _stylePreviewRegionMarker = null;
        
+       var _isVisible = true;
+       var _updateRegionMarker = null;
+       
        /**
         * @module      WoltLabSuite/Core/Acp/Ui/Style/Editor
         */
-       var AcpUiStyleEditor = {
+       return {
                /**
                 * Sets up dynamic style options.
                 */
@@ -34,6 +37,16 @@ define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'EventHandler', 'Ui/Screen'],
                                unmatch: this.showVisualEditor.bind(this),
                                setup: this.hideVisualEditor.bind(this)
                        });
+                       
+                       var callbackRegionMarker = function () {
+                               if (_isVisible) _updateRegionMarker();
+                       };
+                       window.addEventListener('resize', callbackRegionMarker);
+                       EventHandler.add('com.woltlab.wcf.AcpMenu', 'resize', callbackRegionMarker);
+                       EventHandler.add('com.woltlab.wcf.simpleTabMenu_styleTabMenuContainer', 'select', function (data) {
+                               _isVisible = (data.activeName == 'colors');
+                               callbackRegionMarker();
+                       });
                },
                
                /**
@@ -125,7 +138,7 @@ define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'EventHandler', 'Ui/Screen'],
                        var select = elById('spCategories');
                        var lastValue = select.value;
                        
-                       function updateRegionMarker() {
+                       _updateRegionMarker = function() {
                                if (lastValue === 'none') {
                                        elHide(_stylePreviewRegionMarker);
                                        updateWrapperPosition(null);
@@ -149,7 +162,7 @@ define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'EventHandler', 'Ui/Screen'],
                                
                                updateWrapperPosition(region);
                                scrollToRegion(top);
-                       }
+                       };
                        
                        var variablesWrapper = elById('spVariablesWrapper');
                        function updateWrapperPosition(region) {
@@ -205,7 +218,7 @@ define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'EventHandler', 'Ui/Screen'],
                                elShow(element);
                                
                                // set region marker
-                               updateRegionMarker();
+                               _updateRegionMarker();
                                
                                selectContainer.classList[(lastValue === 'none' ? 'remove' : 'add')]('pointer');
                        });
@@ -284,6 +297,4 @@ define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'EventHandler', 'Ui/Screen'],
                        }, 100);
                }
        };
-       
-       return AcpUiStyleEditor;
 });