Explorar el Código

Added better match when using graphite function autocomplete, hit tab key and the first match will be used, you no longer need to use the down arrow to select the typeahead match you want, just hit tab key

Torkel Ödegaard hace 11 años
padre
commit
d2421bb216
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  1. 8 0
      src/app/directives/addGraphiteFunc.js

+ 8 - 0
src/app/directives/addGraphiteFunc.js

@@ -38,6 +38,14 @@ function (angular, app, _, $, gfunc) {
             items: 10,
             items: 10,
             updater: function (value) {
             updater: function (value) {
               var funcDef = gfunc.getFuncDef(value);
               var funcDef = gfunc.getFuncDef(value);
+              if (!funcDef) {
+                // try find close match
+                funcDef = _.find(allFunctions, function(funcName) {
+                  return funcName.toLowerCase().indexOf(value) === 0;
+                });
+
+                if (!funcDef) { return; }
+              }
 
 
               $scope.$apply(function() {
               $scope.$apply(function() {
                 $scope.addFunction(funcDef);
                 $scope.addFunction(funcDef);