From 0dcde1e2e34a0fcb35dce9591f27534832963a71 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 1 Aug 2013 17:51:42 +0200 Subject: [PATCH] Improved UI for inline editors --- wcfsetup/install/files/js/WCF.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 57b293e989..51f2051d08 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -6331,7 +6331,7 @@ WCF.InlineEditor = Class.extend({ } else if (this._validate($elementID, $option.optionName) || this._validateCallbacks($elementID, $option.optionName)) { var $listItem = $('
  • ' + $option.label + '
  • ').appendTo(this._dropdowns[$elementID]); - $listItem.data('elementID', $elementID).data('optionName', $option.optionName).click($.proxy(this._click, this)); + $listItem.data('elementID', $elementID).data('optionName', $option.optionName).data('isQuickOption', ($option.isQuickOption ? true : false)).click($.proxy(this._click, this)); $hasOptions = true; $lastElementType = $option.optionName; @@ -6344,6 +6344,32 @@ WCF.InlineEditor = Class.extend({ if ($lastChild.hasClass('dropdownDivider')) { $lastChild.remove(); } + + // check if only element is a quick option + var $quickOption = null; + var $count = 0; + this._dropdowns[$elementID].children().each(function(index, child) { + var $child = $(child); + if (!$child.hasClass('dropdownDivider')) { + if ($child.data('isQuickOption')) { + $quickOption = $child; + } + else { + $count++; + } + } + }); + console.debug($quickOption); + console.debug($count); + if (!$count) { + $quickOption.trigger('click'); + + if ($trigger === null) { + WCF.Dropdown.close($trigger.parents('.dropdown').wcfIdentify()); + } + + return false; + } } if ($trigger !== null) { -- 2.20.1