mirror of
https://github.com/nasa/openmct.git
synced 2025-02-20 17:33:23 +00:00
Fix code style and add missing semicolons
This commit is contained in:
parent
17a067752f
commit
f20c8b7d99
@ -67,7 +67,7 @@ define([
|
||||
timeFormat = self.use24 ?
|
||||
baseFormat.replace('hh', "HH") : baseFormat;
|
||||
// If wrong timezone is provided, the UTC will be used
|
||||
zoneName = momentTimezone.tz.names().includes(model.timezone) ?
|
||||
zoneName = momentTimezone.tz.names().includes(model.timezone) ?
|
||||
model.timezone : "UTC";
|
||||
update();
|
||||
}
|
||||
|
@ -39,18 +39,24 @@ define(
|
||||
},
|
||||
autocompleteInputElement = $element[0].getElementsByClassName('autocompleteInput')[0];
|
||||
|
||||
if($scope.options[0].name) {
|
||||
if ($scope.options[0].name) {
|
||||
// If "options" include name, value pair
|
||||
$scope.optionNames = $scope.options.map(function(opt) {
|
||||
$scope.optionNames = $scope.options.map(function (opt) {
|
||||
return opt.name;
|
||||
})
|
||||
});
|
||||
} else {
|
||||
// If options is only an array of string.
|
||||
$scope.optionNames = $scope.options;
|
||||
}
|
||||
|
||||
function fillInputWithIndexedOption() {
|
||||
if ($scope.filteredOptions[$scope.optionIndex]) {
|
||||
$scope.ngModel[$scope.field] = $scope.filteredOptions[$scope.optionIndex].name;
|
||||
}
|
||||
}
|
||||
|
||||
function decrementOptionIndex() {
|
||||
if($scope.optionIndex === 0) {
|
||||
if ($scope.optionIndex === 0) {
|
||||
$scope.optionIndex = $scope.filteredOptions.length;
|
||||
}
|
||||
$scope.optionIndex--;
|
||||
@ -58,7 +64,7 @@ define(
|
||||
}
|
||||
|
||||
function incrementOptionIndex() {
|
||||
if($scope.optionIndex === $scope.filteredOptions.length-1) {
|
||||
if ($scope.optionIndex === $scope.filteredOptions.length - 1) {
|
||||
$scope.optionIndex = -1;
|
||||
}
|
||||
$scope.optionIndex++;
|
||||
@ -70,22 +76,16 @@ define(
|
||||
$scope.ngModel[$scope.field] = string;
|
||||
}
|
||||
|
||||
function fillInputWithIndexedOption() {
|
||||
if($scope.filteredOptions[$scope.optionIndex]) {
|
||||
$scope.ngModel[$scope.field] = $scope.filteredOptions[$scope.optionIndex].name;
|
||||
}
|
||||
}
|
||||
|
||||
function showOptions(string) {
|
||||
$scope.hideOptions = false;
|
||||
$scope.filterOptions(string);
|
||||
$scope.optionIndex = 0;
|
||||
}
|
||||
|
||||
$scope.keyDown = function($event) {
|
||||
if($scope.filteredOptions) {
|
||||
$scope.keyDown = function ($event) {
|
||||
if ($scope.filteredOptions) {
|
||||
var keyCode = $event.keyCode;
|
||||
switch(keyCode) {
|
||||
switch (keyCode) {
|
||||
case key.down:
|
||||
incrementOptionIndex();
|
||||
break;
|
||||
@ -94,45 +94,45 @@ define(
|
||||
decrementOptionIndex();
|
||||
break;
|
||||
case key.enter:
|
||||
if($scope.filteredOptions[$scope.optionIndex]) {
|
||||
if ($scope.filteredOptions[$scope.optionIndex]) {
|
||||
fillInputWithString($scope.filteredOptions[$scope.optionIndex].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.filterOptions = function(string) {
|
||||
$scope.filterOptions = function (string) {
|
||||
$scope.hideOptions = false;
|
||||
$scope.filteredOptions = $scope.optionNames.filter(function(option) {
|
||||
$scope.filteredOptions = $scope.optionNames.filter(function (option) {
|
||||
return option.toLowerCase().indexOf(string.toLowerCase()) >= 0;
|
||||
}).map(function(option, index) {
|
||||
}).map(function (option, index) {
|
||||
return {
|
||||
optionId: index,
|
||||
name: option
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.inputClicked = function() {
|
||||
$scope.inputClicked = function () {
|
||||
autocompleteInputElement.select();
|
||||
showOptions(autocompleteInputElement.value);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.arrowClicked = function() {
|
||||
$scope.arrowClicked = function () {
|
||||
autocompleteInputElement.select();
|
||||
showOptions('');
|
||||
}
|
||||
|
||||
$scope.fillInput = function(string) {
|
||||
fillInputWithString(string);
|
||||
}
|
||||
};
|
||||
|
||||
$scope.optionMouseover = function(optionId) {
|
||||
$scope.fillInput = function (string) {
|
||||
fillInputWithString(string);
|
||||
};
|
||||
|
||||
$scope.optionMouseover = function (optionId) {
|
||||
$scope.optionIndex = optionId;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return AutocompleteController;
|
||||
|
||||
}
|
||||
);
|
||||
);
|
||||
|
@ -41,18 +41,18 @@ define(
|
||||
|
||||
it("filters options by returning array containing optionId and name", function () {
|
||||
mockScope.filterOptions('Asia');
|
||||
var filteredOptions = [ { optionId : 0, name : 'Asia/Dhaka' },
|
||||
{ optionId : 1, name : 'Asia/Shanghai' } ];
|
||||
var filteredOptions = [{ optionId : 0, name : 'Asia/Dhaka' },
|
||||
{ optionId : 1, name : 'Asia/Shanghai' }];
|
||||
expect(mockScope.filteredOptions).toEqual(filteredOptions);
|
||||
});
|
||||
|
||||
|
||||
it("fills input with given string", function () {
|
||||
var str = "UTC";
|
||||
mockScope.fillInput(str);
|
||||
expect(mockScope.hideOptions).toEqual(true);
|
||||
expect(mockScope.ngModel[4]).toEqual(str);
|
||||
});
|
||||
|
||||
|
||||
it("sets a new optionIndex on mouse hover", function () {
|
||||
mockScope.optionMouseover(1);
|
||||
expect(mockScope.optionIndex).toEqual(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user