Added user suggestions module
authorAlexander Ebert <ebert@woltlab.com>
Tue, 8 Mar 2016 18:25:35 +0000 (19:25 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 8 Mar 2016 18:25:35 +0000 (19:25 +0100)
wcfsetup/install/files/acp/templates/userSearch.tpl
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/User/Search/Input.js [new file with mode: 0644]

index 21a8ec33e136748b2e1e972a49a4a22d64ec1393..3be1e92649b54ae4eb35da2c3efa593c62bbab4a 100644 (file)
@@ -1,12 +1,9 @@
 {include file='header' pageTitle='wcf.acp.user.search'}
 
 <script data-relocate="true">
-       //<![CDATA[
-       $(function() {
-               WCF.TabMenu.init();
-               new WCF.Search.User('input[name=username]');
+       require(['WoltLab/WCF/Ui/User/Search/Input'], function(UiUserSearchInput) {
+               new UiUserSearchInput(elBySel('input[name="username"]'));
        });
-       //]]>
 </script>
 
 <header class="contentHeader">
index fcf4fb6a4d0d9f8268575e4268c2a7507c53dc08..d0a657f868bf64ecdae14469b54ec49626b307dc 100755 (executable)
@@ -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 (file)
index 0000000..867651a
--- /dev/null
@@ -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 <http://opensource.org/licenses/lgpl-license.php>
+ * @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') ? '<span class="icon icon16 fa-users"></span>' : item.icon;
+                       box.appendChild(listItem.children[0]);
+                       listItem.appendChild(box);
+                       
+                       return listItem;
+               }
+       });
+       
+       return UiUserSearchInput;
+});