Added support for excluded values
authorAlexander Ebert <ebert@woltlab.com>
Wed, 22 Feb 2017 15:18:55 +0000 (16:18 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 22 Feb 2017 15:19:00 +0000 (16:19 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js

index 760975f150502dc11c0b3c469c38fbe78fc30c75..5e3fbb0f25261feb5da07dd65becc58935ed3554 100644 (file)
@@ -47,6 +47,7 @@ define(['Ajax', 'Core', 'EventKey', 'Dom/Util', 'Ui/SimpleDropdown'], function(A
                                callbackDropdownInit: null,
                                callbackSelect: null,
                                delay: 500,
+                               excludedSearchValues: [],
                                minLength: 3,
                                noResultPlaceholder: '',
                                preventSubmit: false
@@ -59,6 +60,29 @@ define(['Ajax', 'Core', 'EventKey', 'Dom/Util', 'Ui/SimpleDropdown'], function(A
                        this._element.addEventListener('keyup', this._keyup.bind(this));
                },
                
+               /**
+                * Adds an excluded search value.
+                * 
+                * @param       {string}        value   excluded value
+                */
+               addExcludedSearchValues: function (value) {
+                       if (this._options.excludedSearchValues.indexOf(value) === -1) {
+                               this._options.excludedSearchValues.push(value);
+                       }
+               },
+               
+               /**
+                * Removes a value from the excluded search values.
+                * 
+                * @param       {string}        value   excluded value
+                */
+               removeExcludedSearchValues: function (value) {
+                       var index = this._options.excludedSearchValues.indexOf(value);
+                       if (index !== -1) {
+                               this._options.excludedSearchValues.splice(index, 1);
+                       }
+               },
+               
                /**
                 * Handles the 'keydown' event.
                 * 
@@ -172,6 +196,7 @@ define(['Ajax', 'Core', 'EventKey', 'Dom/Util', 'Ui/SimpleDropdown'], function(A
                        return {
                                parameters: {
                                        data: {
+                                               excludedSearchValues: this._options.excludedSearchValues,
                                                searchString: value
                                        }
                                }