From 3289653dc8502768f9a84e065f548bf4980c0097 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 26 Jun 2013 14:47:05 +0200 Subject: [PATCH] Added support for pasting of tags --- wcfsetup/install/files/js/WCF.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 6bc0e08ede..530f027c2f 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -7589,7 +7589,10 @@ WCF.EditableItemList = Class.extend({ this._form = this._itemList.parents('form').submit($.proxy(this._submit, this)); if (this._allowCustomInput) { - this._searchInput.keydown($.proxy(this._keyDown, this)); + var self = this; + this._searchInput.keydown($.proxy(this._keyDown, this)).on('paste', function() { + setTimeout(function() { self._onPaste(); }, 100); + }); } }, @@ -7635,6 +7638,29 @@ WCF.EditableItemList = Class.extend({ return true; }, + /** + * Handle paste event. + */ + _onPaste: function() { + // split content by comma + var $value = $.trim(this._searchInput.val()); + $value = $value.split(','); + + for (var $i = 0, $length = $value.length; $i < $length; $i++) { + var $label = $.trim($value[$i]); + if ($label === '') { + continue; + } + + this.addItem({ + objectID: 0, + label: $label + }); + } + + this._searchInput.val(''); + }, + /** * Loads raw data and converts it into internal structure. Override this methods * in your derived classes. -- 2.20.1