Improved popover implementation
authorAlexander Ebert <ebert@woltlab.com>
Mon, 18 May 2015 12:54:32 +0000 (14:54 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 18 May 2015 12:54:32 +0000 (14:54 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js

index bf8b5a6fb5a17e7c72fb7c38230a75a4a56f1a7b..b0207aa8ed52ac546c5b5e20aa50ce5bc06fa4f5 100644 (file)
@@ -15,7 +15,6 @@ define(['Dictionary', 'DOM/Util', 'UI/Alignment'], function(Dictionary, DOMUtil,
        var _elements = null;
        var _handlers = null;
        var _hoverId = null;
-       var _suspended = false;
        var _timeoutEnter = null;
        var _timeoutLeave = null;
        
@@ -85,6 +84,8 @@ define(['Dictionary', 'DOM/Util', 'UI/Alignment'], function(Dictionary, DOMUtil,
                                }
                        });
                        
+                       _popover.addEventListener('transitionend', this._clearContent.bind(this));
+                       
                        window.addEventListener('beforeunload', (function() {
                                _suspended = true;
                                this._hide(true);
@@ -132,7 +133,7 @@ define(['Dictionary', 'DOM/Util', 'UI/Alignment'], function(Dictionary, DOMUtil,
                                loadCallback: options.loadCallback
                        });
                        
-                       this._init(options.identifier)
+                       this._init(options.identifier);
                },
                
                /**
@@ -174,7 +175,7 @@ define(['Dictionary', 'DOM/Util', 'UI/Alignment'], function(Dictionary, DOMUtil,
                                element.addEventListener('mouseleave', _callbackMouseLeave);
                                
                                if (element.nodeName === 'A' && element.getAttribute('href')) {
-                                       element.addEventListener('click', _callbackClick)
+                                       element.addEventListener('click', _callbackClick);
                                }
                                
                                var cacheId = identifier + "-" + objectId;
@@ -294,13 +295,6 @@ define(['Dictionary', 'DOM/Util', 'UI/Alignment'], function(Dictionary, DOMUtil,
                        }
                        
                        var disableAnimation = (_activeId !== null && _activeId !== _hoverId);
-                       if (disableAnimation) {
-                               var activeElData = _cache.get(_elements.get(_activeId).element.getAttribute('data-cache-id'));
-                               while (_popoverContent.childNodes.length) {
-                                       activeElData.content.appendChild(_popoverContent.childNodes[0]);
-                               }
-                       }
-                       
                        if (_popover.classList.contains('active')) {
                                this._hide(disableAnimation);
                        }
@@ -344,6 +338,22 @@ define(['Dictionary', 'DOM/Util', 'UI/Alignment'], function(Dictionary, DOMUtil,
                                
                                // force reflow
                                _popover.offsetHeight;
+                               
+                               this._clearContent();
+                       }
+               },
+               
+               /**
+                * Clears popover content by moving it back into the cache.
+                */
+               _clearContent: function() {
+                       if (_activeId && _popoverContent.childElementCount && !_popover.classList.contains('active')) {
+                               var activeElData = _cache.get(_elements.get(_activeId).element.getAttribute('data-cache-id'));
+                               while (_popoverContent.childNodes.length) {
+                                       activeElData.content.appendChild(_popoverContent.childNodes[0]);
+                               }
+                               
+                               _popoverContent.style.removeProperty('height');
                        }
                },
                
@@ -369,8 +379,6 @@ define(['Dictionary', 'DOM/Util', 'UI/Alignment'], function(Dictionary, DOMUtil,
                                        _popoverContent.style.removeProperty('height');
                                        
                                        var height = _popoverContent.offsetHeight;
-                                       console.debug(_baseHeight);
-                                       console.debug(height);
                                        _popoverContent.style.setProperty('height', _baseHeight + 'px');
                                        
                                        // force reflow
index eeeb5e1774aedf7ccdde783a52bcd68981e3c0c4..e2e81d042fca67c104a3128cd8375a7a2e09eb9f 100644 (file)
@@ -32,7 +32,7 @@ define(['EventHandler', 'Language', 'DOM/Util', 'UI/Dialog', 'UI/TabMenu'], func
                _click: function(event) {
                        event.preventDefault();
                        
-                       if (UIDialog.getDialog('sitemapDialog') === null) {
+                       if (UIDialog.getDialog('sitemapDialog') === undefined) {
                                new WCF.Action.Proxy({
                                        autoSend: true,
                                        data: {
index 4d3a13f2e6594050c446cf9cbb5ec710bca0888d..5841090083920696b5feb8836c8806567366ea7a 100644 (file)
@@ -43,7 +43,7 @@ define(['Language', 'UI/Dialog'], function(Language, UIDialog) {
                showDialog: function(event) {
                        event.preventDefault();
                        
-                       if (UIDialog.getDialog('styleChanger') === null) {
+                       if (UIDialog.getDialog('styleChanger') === undefined) {
                                new WCF.Action.Proxy({
                                        autoSend: true,
                                        data: {
index 3002ba4d2601dda564f209b4aad8a362ea44e219..97ee658bea3f60dd84bb8faf47a7d75e2838f823 100644 (file)
@@ -137,7 +137,7 @@ define(['jquery', 'enquire', 'Core', 'Dictionary', 'Language', 'DOM/Util'], func
                        var dialog = document.createElement('div');
                        dialog.classList.add('dialogContainer');
                        dialog.setAttribute('aria-hidden', 'true');
-                       dialog.setAttribute('role', 'dialog')
+                       dialog.setAttribute('role', 'dialog');
                        dialog.setAttribute('data-id', id);
                        
                        if (options.disposeOnClose) {