From b0ce529862f3e7f94f8cb276190748ea2d96dc53 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 13 Aug 2012 15:06:13 +0200 Subject: [PATCH] WCF.Search.Base now supports standalone calls A callback is no longer necessary, by default the value is just auto-completed. Furthermore we're suppressing the browsers default auto-complete, as it collides with the suggestion itself. --- .../install/files/acp/templates/userSearch.tpl | 7 +------ wcfsetup/install/files/js/WCF.js | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/userSearch.tpl b/wcfsetup/install/files/acp/templates/userSearch.tpl index b2ada61065..cf05441bab 100644 --- a/wcfsetup/install/files/acp/templates/userSearch.tpl +++ b/wcfsetup/install/files/acp/templates/userSearch.tpl @@ -4,6 +4,7 @@ // @@ -46,12 +47,6 @@
-
diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index d96096000e..4ae278cb58 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -4005,12 +4005,12 @@ WCF.Search.Base = Class.extend({ * @param boolean commaSeperated */ init: function(searchInput, callback, excludedSearchValues, commaSeperated) { - if ((callback === null && !commaSeperated) && !$.isFunction(callback)) { + if (callback !== null && callback !== undefined && !$.isFunction(callback)) { console.debug("[WCF.Search.Base] The given callback is invalid, aborting."); return; } - - this._callback = callback; + + this._callback = (callback) ? callback : null; this._excludedSearchValues = []; if (excludedSearchValues) { this._excludedSearchValues = excludedSearchValues; @@ -4024,6 +4024,10 @@ WCF.Search.Base = Class.extend({ this._proxy = new WCF.Action.Proxy({ success: $.proxy(this._success, this) }); + + if (this._searchInput.getTagName() === 'input') { + this._searchInput.attr('autocomplete', 'off'); + } }, /** @@ -4153,6 +4157,7 @@ WCF.Search.Base = Class.extend({ * @param object event */ _executeCallback: function(event) { + var $clearSearchInput = false; var $listItem = $(event.currentTarget); // notify callback if (this._commaSeperated) { @@ -4175,7 +4180,12 @@ WCF.Search.Base = Class.extend({ } } else { - var $clearSearchInput = this._callback($listItem.data()); + if (this._callback === null) { + this._searchInput.val($listItem.data('label')); + } + else { + $clearSearchInput = (this._callback($listItem.data()) === true) ? true : false; + } } // close list and revert input -- 2.20.1