Skip to content
Snippets Groups Projects
Commit ab27b49d authored by Matthew Hodgson's avatar Matthew Hodgson
Browse files

rename autoComplete directive as tabComplete to avoid confusion with the...

rename autoComplete directive as tabComplete to avoid confusion with the autocomplete html attribute
parent 019f3a66
No related branches found
No related tags found
No related merge requests found
......@@ -17,30 +17,30 @@
'use strict';
angular.module('RoomController')
.directive('autoComplete', ['$timeout', function ($timeout) {
.directive('tabComplete', ['$timeout', function ($timeout) {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
// console.log("event: " + event.which);
if (event.which === 9) {
if (!scope.autoCompleting) { // cache our starting text
if (!scope.tabCompleting) { // cache our starting text
// console.log("caching " + element[0].value);
scope.autoCompleteOriginal = element[0].value;
scope.autoCompleting = true;
scope.tabCompleteOriginal = element[0].value;
scope.tabCompleting = true;
}
if (event.shiftKey) {
scope.autoCompleteIndex--;
if (scope.autoCompleteIndex < 0) {
scope.autoCompleteIndex = 0;
scope.tabCompleteIndex--;
if (scope.tabCompleteIndex < 0) {
scope.tabCompleteIndex = 0;
}
}
else {
scope.autoCompleteIndex++;
scope.tabCompleteIndex++;
}
var searchIndex = 0;
var targetIndex = scope.autoCompleteIndex;
var text = scope.autoCompleteOriginal;
var targetIndex = scope.tabCompleteIndex;
var text = scope.tabCompleteOriginal;
// console.log("targetIndex: " + targetIndex + ", text=" + text);
......@@ -90,17 +90,17 @@ angular.module('RoomController')
element[0].className = "";
}, 150);
element[0].value = text;
scope.autoCompleteIndex = 0;
scope.tabCompleteIndex = 0;
}
}
else {
scope.autoCompleteIndex = 0;
scope.tabCompleteIndex = 0;
}
event.preventDefault();
}
else if (event.which !== 16 && scope.autoCompleting) {
scope.autoCompleting = false;
scope.autoCompleteIndex = 0;
else if (event.which !== 16 && scope.tabCompleting) {
scope.tabCompleting = false;
scope.tabCompleteIndex = 0;
}
});
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment