From: Alexander Ebert Date: Wed, 26 Jun 2013 12:47:05 +0000 (+0200) Subject: Added support for pasting of tags X-Git-Tag: 2.0.0_Beta_5~128 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3289653dc8502768f9a84e065f548bf4980c0097;p=GitHub%2FWoltLab%2FWCF.git Added support for pasting of tags --- 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.