Commit 0492c455 authored by Ryan Herbert's avatar Ryan Herbert
Browse files

autocomplete.js fix autocomplete for brackets.

altering the highlighter callback in order to accept brackets in the
regex. Otherwise, atwho would crash when attempting to highlight a query
containing brackets.
parent 15a6fa95
......@@ -146,6 +146,19 @@ VidjilAutoComplete.prototype = {
return null;
};
// code taken directly from atwho source in order to allow use of brackets in inputs
callbacks.highlighter = function(li, query) {
var regexp;
if (!query) {
return li;
}
regexp = new RegExp(">\\s*(\\w*?)(" + query.replace(/[\+\[\]\(\)]/g, function(s) { return "\\" + s; }) + ")(\\w*)\\s*<", 'ig');
return li.replace(regexp, function(str, $1, $2, $3) {
return '> ' + $1 + '<strong>' + $2 + '</strong>' + $3 + ' <';
});
};
callbacks.beforeInsert = function(value) {
return value + ", "
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment