From: Alexander Ebert Date: Tue, 28 Jun 2016 21:37:07 +0000 (+0200) Subject: Open interactive dropdowns by hovering X-Git-Tag: 3.0.0_Beta_1~1319 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=eb45f514fca74b97f0c841cb674a1222343df2d7;p=GitHub%2FWoltLab%2FWCF.git Open interactive dropdowns by hovering --- diff --git a/wcfsetup/install/files/js/WCF.User.js b/wcfsetup/install/files/js/WCF.User.js index ccf0ae4bdc..fb424d7cd9 100644 --- a/wcfsetup/install/files/js/WCF.User.js +++ b/wcfsetup/install/files/js/WCF.User.js @@ -183,6 +183,22 @@ WCF.User.Panel.Abstract = Class.extend({ }); this._triggerElement.click($.proxy(this.toggle, this)); + + var timer = null; + this._triggerElement.hover( + (function() { + if (this._dropdown === null || !this._dropdown.isOpen()) { + timer = window.setTimeout((function() { + this.toggle(undefined, true); + }).bind(this), 300); + } + }).bind(this), + function() { + window.clearTimeout(timer); + timer = null; + } + ); + if (this._options.showAllLink) { this._triggerElement.dblclick($.proxy(this._dblClick, this)); } @@ -201,10 +217,11 @@ WCF.User.Panel.Abstract = Class.extend({ /** * Toggles the interactive dropdown. * - * @param {Event=} event + * @param {Event?} event + * @param {boolean?} openOnly * @return {boolean} */ - toggle: function(event) { + toggle: function(event, openOnly) { if (event instanceof Event) { event.preventDefault(); } @@ -213,6 +230,10 @@ WCF.User.Panel.Abstract = Class.extend({ this._dropdown = this._initDropdown(); } + if (openOnly === true && this._dropdown.isOpen()) { + return false; + } + if (this._dropdown.toggle()) { if (!this._loadData) { // check if there are outstanding items but there are no outstanding ones in the current list diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 06d40f7f46..c60a458e65 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -1196,6 +1196,15 @@ WCF.Dropdown.Interactive.Instance = Class.extend({ this._container.removeClass('open'); }, + /** + * Returns true if dropdown instance is visible. + * + * @returns {boolean} + */ + isOpen: function() { + return this._triggerElement.hasClass('open'); + }, + /** * Toggles the dropdown state, returns true if dropdown is open afterwards, else false. *