From 0aa633c93f593e6870e602fbd38c665f00d9a4f1 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 8 Mar 2016 19:25:35 +0100 Subject: [PATCH] Added user suggestions module --- .../files/acp/templates/userSearch.tpl | 7 +-- wcfsetup/install/files/js/WCF.js | 1 + .../js/WoltLab/WCF/Ui/User/Search/Input.js | 51 +++++++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 wcfsetup/install/files/js/WoltLab/WCF/Ui/User/Search/Input.js diff --git a/wcfsetup/install/files/acp/templates/userSearch.tpl b/wcfsetup/install/files/acp/templates/userSearch.tpl index 21a8ec33e1..3be1e92649 100644 --- a/wcfsetup/install/files/acp/templates/userSearch.tpl +++ b/wcfsetup/install/files/acp/templates/userSearch.tpl @@ -1,12 +1,9 @@ {include file='header' pageTitle='wcf.acp.user.search'}
diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index fcf4fb6a4d..d0a657f868 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -4932,6 +4932,7 @@ WCF.Search.Base = Class.extend({ * Provides quick search for users and user groups. * * @see WCF.Search.Base + * @deprecated 2.2 - please use `WoltLab/WCF/Ui/User/Search/Input` instead */ WCF.Search.User = WCF.Search.Base.extend({ /** diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/User/Search/Input.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/User/Search/Input.js new file mode 100644 index 0000000000..867651a63e --- /dev/null +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/User/Search/Input.js @@ -0,0 +1,51 @@ +/** + * Provides suggestions for users, optionally supporting groups. + * + * @author Alexander Ebert + * @copyright 2001-2016 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLab/WCF/Ui/User/Search/Input + * @see module:WoltLab/WCF/Ui/Search/Input + */ +define(['Core', 'WoltLab/WCF/Ui/Search/Input'], function(Core, UiSearchInput) { + "use strict"; + + /** + * @param {Element} element input element + * @param {Object=} options search options and settings + * @constructor + */ + function UiUserSearchInput(element, options) { this.init(element, options); } + Core.inherit(UiUserSearchInput, UiSearchInput, { + init: function(element, options) { + var includeUserGroups = (Core.isPlainObject(options) && options.includeUserGroups === true); + + options = Core.extend({ + ajax: { + className: 'wcf\\data\\user\\UserAction', + parameters: { + data: { + includeUserGroups: (includeUserGroups ? 1 : 0) + } + } + } + }, options); + + UiUserSearchInput._super.prototype.init.call(this, element, options); + }, + + _createListItem: function(item) { + var listItem = UiUserSearchInput._super.prototype._createListItem.call(this, item); + + var box = elCreate('div'); + box.className = 'box16'; + box.innerHTML = (item.type === 'group') ? '' : item.icon; + box.appendChild(listItem.children[0]); + listItem.appendChild(box); + + return listItem; + } + }); + + return UiUserSearchInput; +}); -- 2.20.1