Add autocompletion in textarea for user mentions

This commit is contained in:
Frederic Guillot
2015-12-29 18:44:21 +01:00
parent b4c5e36ee4
commit 178eda1887
18 changed files with 2773 additions and 7 deletions

View File

@@ -40,6 +40,21 @@ Dropdown.prototype.listen = function() {
$(this).find('a:visible')[0].click(); // Calling native click() not the jQuery one
}
});
// User mention autocomplete
$('textarea[data-mention-search-url]').textcomplete([{
match: /(^|\s)@(\w*)$/,
search: function (term, callback) {
var url = $('textarea[data-mention-search-url]').data('mention-search-url');
$.getJSON(url, { q: term })
.done(function (resp) { callback(resp); })
.fail(function () { callback([]); });
},
replace: function (value) {
return '$1@' + value + ' ';
},
cache: true
}], {className: "textarea-dropdown"});
};
Dropdown.prototype.close = function() {