Improved editable item list
authorAlexander Ebert <ebert@woltlab.com>
Mon, 13 May 2013 19:50:02 +0000 (21:50 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 13 May 2013 19:50:02 +0000 (21:50 +0200)
wcfsetup/install/files/js/WCF.js

index 03acac9226b428e58b294faf70ccda3f927c2b1b..24439cbadf8d8744b8880c23a21ed35cfd13a033 100755 (executable)
@@ -7372,8 +7372,15 @@ WCF.EditableItemList = Class.extend({
         * @param       object          event
         */
        _keyDown: function(event) {
+               // 188 = [,]
                if (event === null || event.which === 188) {
                        var $value = $.trim(this._searchInput.val());
+                       
+                       // read everything left from caret position
+                       if (event.which === 188) {
+                               $value = $value.substring(0, this._searchInput.getCaret());
+                       }
+                       
                        if ($value === '') {
                                return true;
                        }
@@ -7384,7 +7391,12 @@ WCF.EditableItemList = Class.extend({
                        });
                        
                        // reset input
-                       this._searchInput.val('');
+                       if (event.which === 188) {
+                               this._searchInput.val($.trim(this._searchInput.val().substr(this._searchInput.getCaret())));
+                       }
+                       else {
+                               this._searchInput.val('');
+                       }
                        
                        if (event !== null) {
                                event.stopPropagation();