Refactored changes to ContextMenuGesture.js

This commit is contained in:
Henry
2015-11-27 13:00:23 -08:00
parent 9eb8158c4e
commit 4b23e3fbcb
4 changed files with 28 additions and 13 deletions

View File

@@ -39,6 +39,7 @@
class="mobile-hide" class="mobile-hide"
key="'label'" key="'label'"
mct-object="domainObject" mct-object="domainObject"
parameters="{suppressMenuOnEdit: true}"
ng-click="treeNode.select()" ng-click="treeNode.select()"
> >
</mct-representation> </mct-representation>

View File

@@ -27,7 +27,8 @@
{ {
"key": "menu", "key": "menu",
"implementation": "gestures/ContextMenuGesture.js", "implementation": "gestures/ContextMenuGesture.js",
"depends": ["$timeout", "agentService"] "depends": ["$timeout", "$parse", "agentService",
"navigationService"]
} }
], ],
"components": [ "components": [

View File

@@ -82,11 +82,7 @@ define(
initiatingEvent = this.agentService.isMobile() ? initiatingEvent = this.agentService.isMobile() ?
'touchstart' : 'mousedown', 'touchstart' : 'mousedown',
menu, menu,
popup; popup
if (this.navigationService.getNavigation() && this.navigationService.getNavigation().hasCapability('editor')){
return;
}
// Remove the context menu // Remove the context menu
function dismiss() { function dismiss() {

View File

@@ -41,16 +41,33 @@ define(
* in the context menu will be performed * in the context menu will be performed
* @implements {Gesture} * @implements {Gesture}
*/ */
function ContextMenuGesture($timeout, agentService, element, domainObject) { function ContextMenuGesture($timeout, $parse, agentService, navigationService, element, domainObject) {
var isPressing, var isPressing,
longTouchTime = 500; longTouchTime = 500,
parameters = element && element.attr('parameters') && $parse(element.attr('parameters'))()
function suppressMenu(){
return parameters
&& parameters.suppressMenuOnEdit
&& navigationService.getNavigation()
&& navigationService.getNavigation().hasCapability('editor');
}
function showMenu(event) { function showMenu(event) {
domainObject.getCapability('action').perform({ /**
key: 'menu', * Some menu items should have the context menu action
domainObject: domainObject, * suppressed (eg. the navigation menu on the left)
event: event */
}); if (suppressMenu()){
return;
} else {
domainObject.getCapability('action').perform({
key: 'menu',
domainObject: domainObject,
event: event,
element: element
});
}
} }
// When context menu event occurs, show object actions instead // When context menu event occurs, show object actions instead