mirror of
https://github.com/nasa/openmct.git
synced 2025-06-11 03:41:37 +00:00
[Mobile] Update agentService usages
This commit is contained in:
parent
0b4f44f00d
commit
fa186a1556
@ -19,7 +19,7 @@
|
|||||||
* this source code distribution or the Licensing information page available
|
* this source code distribution or the Licensing information page available
|
||||||
* at runtime from the About dialog for additional information.
|
* at runtime from the About dialog for additional information.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
/*global define,Promise,window*/
|
/*global define,Promise*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module defining TreeNodeController. Created by vwoeltje on 11/10/14.
|
* Module defining TreeNodeController. Created by vwoeltje on 11/10/14.
|
||||||
@ -77,7 +77,7 @@ define(
|
|||||||
((navPath[index] === nodePath[index]) &&
|
((navPath[index] === nodePath[index]) &&
|
||||||
checkPath(nodePath, navPath, index + 1));
|
checkPath(nodePath, navPath, index + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Consider the currently-navigated object and update
|
// Consider the currently-navigated object and update
|
||||||
// parameters which support display.
|
// parameters which support display.
|
||||||
function checkSelection() {
|
function checkSelection() {
|
||||||
@ -176,20 +176,19 @@ define(
|
|||||||
TreeNodeController.prototype.isSelected = function () {
|
TreeNodeController.prototype.isSelected = function () {
|
||||||
return this.isSelectedFlag;
|
return this.isSelectedFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Sets the selected object in the tree, to be the
|
// Sets the selected object in the tree, to be the
|
||||||
// currently represented object. If the user is on phone
|
// currently represented object. If the user is on phone
|
||||||
// and in portrait mode, than, hide the tree menu
|
// and in portrait mode, than, hide the tree menu
|
||||||
TreeNodeController.prototype.setObject = function (ngModel, domainObject) {
|
TreeNodeController.prototype.setObject = function (ngModel, domainObject) {
|
||||||
ngModel.selectedObject = domainObject;
|
ngModel.selectedObject = domainObject;
|
||||||
if (this.agentService.getOrientation(window.innerWidth, window.innerHeight) === "portrait" &&
|
if (this.agentService.isPhone() && this.agentService.isPortrait()) {
|
||||||
this.agentService.isPhone(navigator.userAgent)) {
|
|
||||||
this.$scope.$emit('select-obj');
|
this.$scope.$emit('select-obj');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TreeNodeController.prototype.checkMobile = function () {
|
TreeNodeController.prototype.checkMobile = function () {
|
||||||
return this.agentService.isMobile(navigator.userAgent);
|
return this.agentService.isMobile();
|
||||||
};
|
};
|
||||||
|
|
||||||
return TreeNodeController;
|
return TreeNodeController;
|
||||||
|
@ -58,11 +58,11 @@ define(
|
|||||||
dismissBubble();
|
dismissBubble();
|
||||||
dismissBubble = undefined;
|
dismissBubble = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detaches body touch listener
|
// Detaches body touch listener
|
||||||
body.off('touchstart', hideBubble);
|
body.off('touchstart', hideBubble);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Displays the bubble by tracking position of
|
// Displays the bubble by tracking position of
|
||||||
// touch, using infoService to display the bubble,
|
// touch, using infoService to display the bubble,
|
||||||
// and then on any body touch the bubble is dismissed
|
// and then on any body touch the bubble is dismissed
|
||||||
@ -77,7 +77,7 @@ define(
|
|||||||
domainObject.useCapability('metadata'),
|
domainObject.useCapability('metadata'),
|
||||||
touchPosition
|
touchPosition
|
||||||
);
|
);
|
||||||
|
|
||||||
// On any touch on the body, default body touches/events
|
// On any touch on the body, default body touches/events
|
||||||
// are prevented, the bubble is dismissed, and the touchstart
|
// are prevented, the bubble is dismissed, and the touchstart
|
||||||
// body event is unbound, reallowing gestures
|
// body event is unbound, reallowing gestures
|
||||||
@ -87,12 +87,12 @@ define(
|
|||||||
body.unbind('touchstart');
|
body.unbind('touchstart');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if you are on a mobile device, if the device is
|
// Checks if you are on a mobile device, if the device is
|
||||||
// mobile (agentService.isMobile() = true), then
|
// mobile (agentService.isMobile() = true), then
|
||||||
// the a click on something (info button) brings up
|
// the a click on something (info button) brings up
|
||||||
// the bubble
|
// the bubble
|
||||||
if (agentService.isMobile(navigator.userAgent)) {
|
if (agentService.isMobile()) {
|
||||||
element.on('click', showBubble);
|
element.on('click', showBubble);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ define(
|
|||||||
this.infoService = infoService;
|
this.infoService = infoService;
|
||||||
this.delay = delay;
|
this.delay = delay;
|
||||||
this.domainObject = domainObject;
|
this.domainObject = domainObject;
|
||||||
|
|
||||||
// Checks if you are on a mobile device, if the device is
|
// Checks if you are on a mobile device, if the device is
|
||||||
// not mobile (agentService.isMobile() = false), then
|
// not mobile (agentService.isMobile() = false), then
|
||||||
// the pendingBubble and therefore hovering is allowed
|
// the pendingBubble and therefore hovering is allowed
|
||||||
if (!agentService.isMobile(navigator.userAgent)) {
|
if (!agentService.isMobile()) {
|
||||||
// Show bubble (on a timeout) on mouse over
|
// Show bubble (on a timeout) on mouse over
|
||||||
element.on('mouseenter', this.showBubbleCallback);
|
element.on('mouseenter', this.showBubbleCallback);
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ define(
|
|||||||
// arrays allocated while user mouses over things
|
// arrays allocated while user mouses over things
|
||||||
this.mousePosition = undefined;
|
this.mousePosition = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
InfoGesture.prototype.showBubble = function (event) {
|
InfoGesture.prototype.showBubble = function (event) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ define(
|
|||||||
|
|
||||||
this.element.on('mouseleave', this.hideBubbleCallback);
|
this.element.on('mouseleave', this.hideBubbleCallback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detach any event handlers associated with this gesture.
|
* Detach any event handlers associated with this gesture.
|
||||||
|
@ -31,17 +31,20 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function MobileBrowseTreeController($scope, navigationService, agentService) {
|
function MobileBrowseTreeController($scope, navigationService, agentService) {
|
||||||
var object = navigationService.getNavigation();
|
var object = navigationService.getNavigation(),
|
||||||
|
self = this;
|
||||||
|
|
||||||
// Collapse tree when navigation changes
|
// Collapse tree when navigation changes
|
||||||
function changeObject(newObject) {
|
function changeObject(newObject) {
|
||||||
if (newObject !== object) {
|
if (newObject !== object && agentService.isPortrait()) {
|
||||||
object = newObject;
|
object = newObject;
|
||||||
this.state = false;
|
self.state = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationService.listen(changeObject);
|
if (agentService.isMobile()) {
|
||||||
|
navigationService.listen(changeObject);
|
||||||
|
}
|
||||||
|
|
||||||
this.state = true;
|
this.state = true;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ define(
|
|||||||
scope = $rootScope.$new(),
|
scope = $rootScope.$new(),
|
||||||
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
|
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
|
||||||
goUp = eventCoors[1] + menuDim[1] > winDim[1],
|
goUp = eventCoors[1] + menuDim[1] > winDim[1],
|
||||||
|
initiatingEvent = this.agentService.isMobile() ? 'touchstart' : 'mousedown',
|
||||||
menu;
|
menu;
|
||||||
|
|
||||||
// Remove the context menu
|
// Remove the context menu
|
||||||
@ -107,27 +108,16 @@ define(
|
|||||||
body.append(menu);
|
body.append(menu);
|
||||||
|
|
||||||
// Stop propagation so that clicks or touches on the menu do not close the menu
|
// Stop propagation so that clicks or touches on the menu do not close the menu
|
||||||
if (!(this.agentService.isMobile(navigator.userAgent))) {
|
menu.on(initiatingEvent, function (event) {
|
||||||
menu.on('mousedown', function (event) {
|
event.stopPropagation();
|
||||||
event.stopPropagation();
|
});
|
||||||
});
|
|
||||||
} else if ((this.agentService.isMobile(navigator.userAgent))) {
|
|
||||||
menu.on('touchstart', function (event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dismiss the menu when body is clicked/touched elsewhere
|
// Dismiss the menu when body is clicked/touched elsewhere
|
||||||
// ('mousedown' because 'click' breaks left-click context menus)
|
// ('mousedown' because 'click' breaks left-click context menus)
|
||||||
// ('touchstart' because 'touch' breaks context menus up)
|
// ('touchstart' because 'touch' breaks context menus up)
|
||||||
if (!(this.agentService.isMobile(navigator.userAgent))) {
|
body.on(initiatingEvent, dismiss);
|
||||||
body.on('mousedown', dismiss);
|
// NOTE: Apply to mobile?
|
||||||
// NOTE: Apply to mobile?
|
menu.on('click', dismiss);
|
||||||
menu.on('click', dismiss);
|
|
||||||
} else if (this.agentService.isMobile(navigator.userAgent)) {
|
|
||||||
body.on('touchstart', dismiss);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Don't launch browser's context menu
|
// Don't launch browser's context menu
|
||||||
actionContext.event.preventDefault();
|
actionContext.event.preventDefault();
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
/*global define,Promise*/
|
/*global define,Promise*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module defining ContextMenuGesture.
|
* Module defining ContextMenuGesture.
|
||||||
* Created by vwoeltje on 11/17/14. Modified by shale on 06/30/2015.
|
* Created by vwoeltje on 11/17/14. Modified by shale on 06/30/2015.
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
@ -44,7 +44,7 @@ define(
|
|||||||
function ContextMenuGesture($timeout, agentService, element, domainObject) {
|
function ContextMenuGesture($timeout, agentService, element, domainObject) {
|
||||||
var isPressing,
|
var isPressing,
|
||||||
longTouchTime = 500;
|
longTouchTime = 500;
|
||||||
|
|
||||||
function showMenu(event) {
|
function showMenu(event) {
|
||||||
domainObject.getCapability('action').perform({
|
domainObject.getCapability('action').perform({
|
||||||
key: 'menu',
|
key: 'menu',
|
||||||
@ -52,20 +52,20 @@ define(
|
|||||||
event: event
|
event: event
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// When context menu event occurs, show object actions instead
|
// When context menu event occurs, show object actions instead
|
||||||
if (!agentService.isMobile(navigator.userAgent)) {
|
if (!agentService.isMobile()) {
|
||||||
|
|
||||||
// When context menu event occurs, show object actions instead
|
// When context menu event occurs, show object actions instead
|
||||||
element.on('contextmenu', showMenu);
|
element.on('contextmenu', showMenu);
|
||||||
} else if (agentService.isMobile(navigator.userAgent)) {
|
} else if (agentService.isMobile()) {
|
||||||
|
|
||||||
// If on mobile device, then start timeout for the single touch event
|
// If on mobile device, then start timeout for the single touch event
|
||||||
// during the timeout 'isPressing' is true.
|
// during the timeout 'isPressing' is true.
|
||||||
element.on('touchstart', function (event) {
|
element.on('touchstart', function (event) {
|
||||||
if (event.touches.length < 2) {
|
if (event.touches.length < 2) {
|
||||||
isPressing = true;
|
isPressing = true;
|
||||||
|
|
||||||
// After the timeout, if 'isPressing' is
|
// After the timeout, if 'isPressing' is
|
||||||
// true, display context menu for object
|
// true, display context menu for object
|
||||||
$timeout(function () {
|
$timeout(function () {
|
||||||
@ -75,7 +75,7 @@ define(
|
|||||||
}, longTouchTime);
|
}, longTouchTime);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Whenever the touch event ends, 'isPressing' is false.
|
// Whenever the touch event ends, 'isPressing' is false.
|
||||||
element.on('touchend', function (event) {
|
element.on('touchend', function (event) {
|
||||||
isPressing = false;
|
isPressing = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user