From 38d131ce285183b895932daa9c225094d4079514 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 25 May 2013 17:44:41 +0200 Subject: [PATCH] Fixed a few issues with the recent dropdown changes --- wcfsetup/install/files/js/WCF.Label.js | 12 +++++----- wcfsetup/install/files/js/WCF.Message.js | 6 ++--- wcfsetup/install/files/js/WCF.js | 26 ++++++++++++++++++++-- wcfsetup/install/files/style/dropdown.less | 2 +- wcfsetup/install/files/style/message.less | 2 +- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.Label.js b/wcfsetup/install/files/js/WCF.Label.js index 23d3eb39a2..c0093ab922 100644 --- a/wcfsetup/install/files/js/WCF.Label.js +++ b/wcfsetup/install/files/js/WCF.Label.js @@ -139,7 +139,7 @@ WCF.Label.Chooser = Class.extend({ // pre-select labels if ($.getLength(selectedLabelIDs)) { for (var $groupID in selectedLabelIDs) { - this._groups[$groupID].find('.dropdownMenu > li').each($.proxy(function(index, label) { + WCF.Dropdown.getDropdownMenu(this._groups[$groupID].wcfIdentify()).children('li').each($.proxy(function(index, label) { var $label = $(label); var $labelID = $label.data('labelID') || 0; if ($labelID && selectedLabelIDs[$groupID] == $labelID) { @@ -178,19 +178,19 @@ WCF.Label.Chooser = Class.extend({ if (!this._groups[$groupID]) { this._groups[$groupID] = $group; - var $dropdownMenu = $group.find('.dropdownMenu'); - $dropdownMenu.find('li').click($.proxy(this._click, this)); + var $dropdownMenu = WCF.Dropdown.getDropdownMenu($group.wcfIdentify()); + $dropdownMenu.children('li').data('groupID', $groupID).click($.proxy(this._click, this)); if (!$group.data('forceSelection') || this._showWithoutSelection) { $('
  • ' + WCF.Language.get('wcf.label.withoutSelection') + '
  • ').appendTo($dropdownMenu).click($.proxy(this._click, this)); + $('
  • ' + WCF.Language.get('wcf.label.withoutSelection') + '
  • ').data('groupID', $groupID).appendTo($dropdownMenu).click($.proxy(this._click, this)); } if (!$group.data('forceSelection')) { - var $buttonEmpty = $('
  • ' + WCF.Language.get('wcf.label.none') + '
  • ').appendTo($dropdownMenu); + var $buttonEmpty = $('
  • ' + WCF.Language.get('wcf.label.none') + '
  • ').data('groupID', $groupID).appendTo($dropdownMenu); $buttonEmpty.click($.proxy(this._click, this)); } } @@ -213,7 +213,7 @@ WCF.Label.Chooser = Class.extend({ * @param boolean onInit */ _selectLabel: function(label, onInit) { - var $group = label.parents('.dropdown'); + var $group = this._groups[label.data('groupID')]; // already initialized, ignore if (onInit && $group.data('labelID') !== undefined) { diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index 41eddba791..676d7bf4ef 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -1163,11 +1163,11 @@ WCF.Message.InlineEditor = Class.extend({ /** * Forces message options to stay visible if toggling dropdown menu. * - * @param jQuery dropdown + * @param string containerID * @param string action */ - _toggleDropdown: function(dropdown, action) { - dropdown.parents('.messageOptions').toggleClass('forceOpen'); + _toggleDropdown: function(containerID, action) { + WCF.Dropdown.getDropdown(containerID).parents('.messageOptions').toggleClass('forceOpen'); }, /** diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index a20904860f..560f5d8706 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -756,6 +756,24 @@ WCF.Dropdown = { } }, + /** + * Initializes a dropdown fragment which behaves like a usual dropdown + * but is not controlled by a trigger element. + * + * @param jQuery dropdown + * @param jQuery dropdownMenu + */ + initDropdownFragment: function(dropdown, dropdownMenu) { + var $containerID = dropdown.wcfIdentify(); + if (this._dropdowns[$containerID]) { + console.debug("[WCF.Dropdown] Cannot register dropdown identified by '" + $containerID + "' as a fragement."); + return; + } + + this._dropdowns[$containerID] = dropdown; + this._menus[$containerID] = dropdownMenu.detach().appendTo(this._menuContainer); + }, + /** * Registers a callback notified upon dropdown state change. * @@ -805,8 +823,10 @@ WCF.Dropdown = { } } - event.stopPropagation(); - return false; + if (event !== null) { + event.stopPropagation(); + return false; + } }, /** @@ -5208,6 +5228,8 @@ WCF.Search.Base = Class.extend({ } this._searchInput.blur($.proxy(this._blur, this)); + + WCF.Dropdown.initDropdownFragment(this._searchInput.parent(), this._list); }, /** diff --git a/wcfsetup/install/files/style/dropdown.less b/wcfsetup/install/files/style/dropdown.less index a70af791f0..56ccedc1ea 100644 --- a/wcfsetup/install/files/style/dropdown.less +++ b/wcfsetup/install/files/style/dropdown.less @@ -104,7 +104,7 @@ padding: 4px 0; position: absolute; text-align: left; - z-index: 350; + z-index: 450; .boxShadow(2px, 2px, rgba(0, 0, 0, .2), 10px); diff --git a/wcfsetup/install/files/style/message.less b/wcfsetup/install/files/style/message.less index 494417e07f..ba7a862a5a 100644 --- a/wcfsetup/install/files/style/message.less +++ b/wcfsetup/install/files/style/message.less @@ -208,7 +208,7 @@ position: relative; &.forceHidden nav { - opacity: 0 !important; + display: none !important; } &.forceOpen nav { -- 2.20.1