[Mobile] Update agentService usages
This commit is contained in:
@@ -71,6 +71,7 @@ define(
|
||||
scope = $rootScope.$new(),
|
||||
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
|
||||
goUp = eventCoors[1] + menuDim[1] > winDim[1],
|
||||
initiatingEvent = this.agentService.isMobile() ? 'touchstart' : 'mousedown',
|
||||
menu;
|
||||
|
||||
// Remove the context menu
|
||||
@@ -107,27 +108,16 @@ define(
|
||||
body.append(menu);
|
||||
|
||||
// Stop propagation so that clicks or touches on the menu do not close the menu
|
||||
if (!(this.agentService.isMobile(navigator.userAgent))) {
|
||||
menu.on('mousedown', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
} else if ((this.agentService.isMobile(navigator.userAgent))) {
|
||||
menu.on('touchstart', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
}
|
||||
menu.on(initiatingEvent, function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
// Dismiss the menu when body is clicked/touched elsewhere
|
||||
// ('mousedown' because 'click' breaks left-click context menus)
|
||||
// ('touchstart' because 'touch' breaks context menus up)
|
||||
if (!(this.agentService.isMobile(navigator.userAgent))) {
|
||||
body.on('mousedown', dismiss);
|
||||
// NOTE: Apply to mobile?
|
||||
menu.on('click', dismiss);
|
||||
} else if (this.agentService.isMobile(navigator.userAgent)) {
|
||||
body.on('touchstart', dismiss);
|
||||
}
|
||||
|
||||
body.on(initiatingEvent, dismiss);
|
||||
// NOTE: Apply to mobile?
|
||||
menu.on('click', dismiss);
|
||||
|
||||
// Don't launch browser's context menu
|
||||
actionContext.event.preventDefault();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
/*global define,Promise*/
|
||||
|
||||
/**
|
||||
* Module defining ContextMenuGesture.
|
||||
* Module defining ContextMenuGesture.
|
||||
* Created by vwoeltje on 11/17/14. Modified by shale on 06/30/2015.
|
||||
*/
|
||||
define(
|
||||
@@ -44,7 +44,7 @@ define(
|
||||
function ContextMenuGesture($timeout, agentService, element, domainObject) {
|
||||
var isPressing,
|
||||
longTouchTime = 500;
|
||||
|
||||
|
||||
function showMenu(event) {
|
||||
domainObject.getCapability('action').perform({
|
||||
key: 'menu',
|
||||
@@ -52,20 +52,20 @@ define(
|
||||
event: event
|
||||
});
|
||||
}
|
||||
|
||||
// When context menu event occurs, show object actions instead
|
||||
if (!agentService.isMobile(navigator.userAgent)) {
|
||||
|
||||
|
||||
// When context menu event occurs, show object actions instead
|
||||
if (!agentService.isMobile()) {
|
||||
|
||||
// When context menu event occurs, show object actions instead
|
||||
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
|
||||
// during the timeout 'isPressing' is true.
|
||||
element.on('touchstart', function (event) {
|
||||
if (event.touches.length < 2) {
|
||||
isPressing = true;
|
||||
|
||||
|
||||
// After the timeout, if 'isPressing' is
|
||||
// true, display context menu for object
|
||||
$timeout(function () {
|
||||
@@ -75,7 +75,7 @@ define(
|
||||
}, longTouchTime);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Whenever the touch event ends, 'isPressing' is false.
|
||||
element.on('touchend', function (event) {
|
||||
isPressing = false;
|
||||
|
||||
Reference in New Issue
Block a user