[Mobile] Context Menu
Context menu next to object header now dismisses when touching away from it. Also, when long touching an object, the context menu appears. Set on 500ms timeout.
This commit is contained in:
@@ -47,7 +47,7 @@ define(
|
||||
* @param actionContexr the context in which the action
|
||||
* should be performed
|
||||
*/
|
||||
function ContextMenuAction($compile, $document, $window, $rootScope, actionContext) {
|
||||
function ContextMenuAction($compile, $document, $window, $rootScope, queryService, actionContext) {
|
||||
|
||||
function perform() {
|
||||
var winDim = [$window.innerWidth, $window.innerHeight],
|
||||
@@ -94,13 +94,26 @@ define(
|
||||
body.append(menu);
|
||||
|
||||
// Stop propagation so that clicks on the menu do not close the menu
|
||||
menu.on('mousedown', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
// Stop propagation so that touches on the menu do not close the menu
|
||||
if (!queryService.isMobile(navigator.userAgent)) {
|
||||
menu.on('mousedown', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
} else if (queryService.isMobile(navigator.userAgent)) {
|
||||
menu.on('touchstart', function (event) {
|
||||
event.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
// Dismiss the menu when body is clicked elsewhere
|
||||
// Dismiss the menu when body is clicked/touched elsewhere
|
||||
// ('mousedown' because 'click' breaks left-click context menus)
|
||||
body.on('mousedown', dismiss);
|
||||
// ('touchstart' because 'touch' breaks context menus up)
|
||||
if (!queryService.isMobile(navigator.userAgent)) {
|
||||
body.on('mousedown', dismiss);
|
||||
} else if (queryService.isMobile(navigator.userAgent)) {
|
||||
body.on('touchstart', dismiss);
|
||||
}
|
||||
|
||||
|
||||
// Don't launch browser's context menu
|
||||
actionContext.event.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user