mirror of
https://github.com/nasa/openmct.git
synced 2025-01-19 19:27:07 +00:00
[Mobile] AgentService & Tests
Adjusted the getOrientation of agentService to inject the window instead of calling for it in agentService. Also adjusted treeNodeController for this. Added tests for the agentService's getOrientation function.
This commit is contained in:
parent
d80c359a86
commit
9cd57614e4
@ -182,7 +182,7 @@ define(
|
||||
// and in portrait mode, than, hide the tree menu
|
||||
TreeNodeController.prototype.setObject = function (ngModel, domainObject) {
|
||||
ngModel.selectedObject = domainObject;
|
||||
if (this.agentService.getOrientation() === "portrait" &&
|
||||
if (this.agentService.getOrientation(window.innerWidth, window.innerHeight) === "portrait" &&
|
||||
this.agentService.isPhone(navigator.userAgent)) {
|
||||
this.$scope.$emit('select-obj');
|
||||
}
|
||||
|
@ -67,11 +67,12 @@ define(
|
||||
}
|
||||
|
||||
// Returns the orientation of the device based on the
|
||||
// device's window dimensions
|
||||
function getOrientation() {
|
||||
if (window.innerWidth > window.innerHeight) {
|
||||
// device's window dimensions, pass in the innerWidth
|
||||
// and innerheight of the current window
|
||||
function getOrientation(innerWidth, innerHeight) {
|
||||
if (innerWidth > innerHeight) {
|
||||
return "landscape";
|
||||
} else if (window.innerWidth < window.innerHeight) {
|
||||
} else if (innerWidth < innerHeight) {
|
||||
return "portrait";
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ define(
|
||||
// Creates a mockLocation, used to
|
||||
// do the view search
|
||||
mockWindow = jasmine.createSpyObj(
|
||||
"$window",
|
||||
[ "outerWidth", "outerHeight" ]
|
||||
"window",
|
||||
[ "innerWidth", "innerHeight" ]
|
||||
);
|
||||
|
||||
mockNavigator = jasmine.createSpyObj(
|
||||
@ -47,7 +47,7 @@ define(
|
||||
[ "userAgent" ]
|
||||
);
|
||||
|
||||
agentService = new AgentService(mockWindow);
|
||||
agentService = new AgentService();
|
||||
});
|
||||
|
||||
it("get current device user agent", function () {
|
||||
@ -61,13 +61,8 @@ define(
|
||||
});
|
||||
|
||||
it("get orientation of the current device", function () {
|
||||
mockWindow.outerWidth = 768;
|
||||
mockWindow.outerHeight = 1024;
|
||||
agentService.getOrientation();
|
||||
|
||||
mockWindow.outerWidth = 1024;
|
||||
mockWindow.outerHeight = 768;
|
||||
agentService.getOrientation();
|
||||
agentService.getOrientation(1024, 768);
|
||||
agentService.getOrientation(768, 1024);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user