Changed regex typeahead lookup, also works with literal regex patterns

This commit is contained in:
Torkel Ödegaard 2015-06-26 09:40:55 +02:00
parent 43afd7dff9
commit dd8d6bc705
2 changed files with 17 additions and 1 deletions

View File

@ -103,8 +103,19 @@ function (angular, app, _, $) {
return value;
};
$scope.matcher = function(item) {
var str = this.query;
if (str[0] === '/') { str = str.substring(1); }
if (str[str.length - 1] === '/') { str = str.substring(0, str.length-1); }
try {
return item.toLowerCase().match(str);
} catch(e) {
return false;
}
};
$input.attr('data-provide', 'typeahead');
$input.typeahead({ source: $scope.source, minLength: 0, items: 10000, updater: $scope.updater });
$input.typeahead({ source: $scope.source, minLength: 0, items: 10000, updater: $scope.updater, matcher: $scope.matcher });
var typeahead = $input.data('typeahead');
typeahead.lookup = function () {

View File

@ -2069,6 +2069,11 @@
, move: function (e) {
if (!this.shown) return
// grafana change, shift+left paranthesis
if (e.shiftKey && e.keyCode === 40) {
return;
}
switch(e.keyCode) {
case 9: // tab
case 13: // enter