From: Alexander Ebert Date: Mon, 18 May 2015 12:54:32 +0000 (+0200) Subject: Improved popover implementation X-Git-Tag: 3.0.0_Beta_1~2395 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f7a703378cf0062ae52ad12e6eb9662fd32229a1;p=GitHub%2FWoltLab%2FWCF.git Improved popover implementation --- diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js index bf8b5a6fb5..b0207aa8ed 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js @@ -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 diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js index eeeb5e1774..e2e81d042f 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js @@ -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: { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js index 4d3a13f2e6..5841090083 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js @@ -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: { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js b/wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js index 3002ba4d26..97ee658bea 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js @@ -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) {