From eb45f514fca74b97f0c841cb674a1222343df2d7 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 28 Jun 2016 23:37:07 +0200 Subject: [PATCH] Open interactive dropdowns by hovering --- wcfsetup/install/files/js/WCF.User.js | 25 +++++++++++++++++++++++-- wcfsetup/install/files/js/WCF.js | 9 +++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) 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. * -- 2.20.1