From dd8d6bc70599adf48d7f4524b416eaa10a12c051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 26 Jun 2015 09:40:55 +0200 Subject: [PATCH] Changed regex typeahead lookup, also works with literal regex patterns --- public/app/directives/metric.segment.js | 13 ++++++++++++- public/vendor/bootstrap/bootstrap.js | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/public/app/directives/metric.segment.js b/public/app/directives/metric.segment.js index 4f5677ca3ed..4202cfdc332 100644 --- a/public/app/directives/metric.segment.js +++ b/public/app/directives/metric.segment.js @@ -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 () { diff --git a/public/vendor/bootstrap/bootstrap.js b/public/vendor/bootstrap/bootstrap.js index 0a427f05858..bec8dee3c3c 100644 --- a/public/vendor/bootstrap/bootstrap.js +++ b/public/vendor/bootstrap/bootstrap.js @@ -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