[Browse] Right click works
Right clicking for a context menu now works again. #33.
This commit is contained in:
@@ -37,79 +37,69 @@ define(
|
|||||||
dismissExistingMenu;
|
dismissExistingMenu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add listeners to a representation such that it launches a
|
* Launches a custom context menu for the domain object it contains.
|
||||||
* custom context menu for the domain object it contains.
|
|
||||||
*
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param $compile Angular's $compile service
|
* @param $compile Angular's $compile service
|
||||||
* @param $document the current document
|
* @param $document the current document
|
||||||
* @param $window the active window
|
* @param $window the active window
|
||||||
* @param $rootScope Angular's root scope
|
* @param $rootScope Angular's root scope
|
||||||
* @param element the jqLite-wrapped element which should exhibit
|
* @param actionContexr the context in which the action
|
||||||
* the context mennu
|
* should be performed
|
||||||
* @param {DomainObject} domainObject the object on which actions
|
|
||||||
* in the context menu will be performed
|
|
||||||
*/
|
*/
|
||||||
function ContextMenuAction($compile, $document, $window, $rootScope, actionContext) {
|
function ContextMenuAction($compile, $document, $window, $rootScope, actionContext) {
|
||||||
//var turnOffMenu;
|
|
||||||
|
|
||||||
console.log('in ContextMenuAction');
|
function perform() {
|
||||||
console.log('contextMenuAction event ', event);
|
//console.log('in perform()');
|
||||||
|
var winDim = [$window.innerWidth, $window.innerHeight],
|
||||||
//function showMenu(event) {
|
eventCoors = [actionContext.event.pageX, actionContext.event.pageY],
|
||||||
var winDim = [$window.innerWidth, $window.innerHeight],
|
menuDim = GestureConstants.MCT_MENU_DIMENSIONS,
|
||||||
eventCoors = [actionContext.event.pageX, actionContext.event.pageY],
|
body = $document.find('body'),
|
||||||
menuDim = GestureConstants.MCT_MENU_DIMENSIONS,
|
scope = $rootScope.$new(),
|
||||||
body = $document.find('body'),
|
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
|
||||||
scope = $rootScope.$new(),
|
goUp = eventCoors[1] + menuDim[1] > winDim[1],
|
||||||
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
|
menu;
|
||||||
goUp = eventCoors[1] + menuDim[1] > winDim[1],
|
|
||||||
menu;
|
|
||||||
|
|
||||||
// Remove the context menu
|
// Remove the context menu
|
||||||
function dismiss() {
|
function dismiss() {
|
||||||
menu.remove();
|
menu.remove();
|
||||||
body.off("click", dismiss);
|
body.off("click", dismiss);
|
||||||
dismissExistingMenu = undefined;
|
dismissExistingMenu = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dismiss any menu which was already showing
|
||||||
|
if (dismissExistingMenu) {
|
||||||
|
dismissExistingMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ...and record the presence of this menu.
|
||||||
|
dismissExistingMenu = dismiss;
|
||||||
|
|
||||||
|
// Set up the scope, including menu positioning
|
||||||
|
scope.domainObject = actionContext.domainObject;
|
||||||
|
scope.menuStyle = {};
|
||||||
|
scope.menuStyle[goLeft ? "right" : "left"] =
|
||||||
|
(goLeft ? (winDim[0] - eventCoors[0]) : eventCoors[0]) + 'px';
|
||||||
|
scope.menuStyle[goUp ? "bottom" : "top"] =
|
||||||
|
(goUp ? (winDim[1] - eventCoors[1]) : eventCoors[1]) + 'px';
|
||||||
|
scope.menuClass = {
|
||||||
|
"go-left": goLeft,
|
||||||
|
"go-up": goUp,
|
||||||
|
"context-menu-holder": true
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create the context menu
|
||||||
|
menu = $compile(MENU_TEMPLATE)(scope);
|
||||||
|
|
||||||
|
// Add the menu to the body
|
||||||
|
body.append(menu);
|
||||||
|
|
||||||
|
// Dismiss the menu when body is clicked elsewhere
|
||||||
|
body.on('click', dismiss);
|
||||||
|
|
||||||
|
// Don't launch browser's context menu
|
||||||
|
actionContext.event.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dismiss any menu which was already showing
|
|
||||||
if (dismissExistingMenu) {
|
|
||||||
dismissExistingMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ...and record the presence of this menu.
|
|
||||||
dismissExistingMenu = dismiss;
|
|
||||||
|
|
||||||
// Set up the scope, including menu positioning
|
|
||||||
scope.domainObject = domainObject;
|
|
||||||
scope.menuStyle = {};
|
|
||||||
scope.menuStyle[goLeft ? "right" : "left"] =
|
|
||||||
(goLeft ? (winDim[0] - eventCoors[0]) : eventCoors[0]) + 'px';
|
|
||||||
scope.menuStyle[goUp ? "bottom" : "top"] =
|
|
||||||
(goUp ? (winDim[1] - eventCoors[1]) : eventCoors[1]) + 'px';
|
|
||||||
scope.menuClass = {
|
|
||||||
"go-left": goLeft,
|
|
||||||
"go-up": goUp,
|
|
||||||
"context-menu-holder": true
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log("ContextMenuAction scope ", scope);
|
|
||||||
|
|
||||||
// Create the context menu
|
|
||||||
menu = $compile(MENU_TEMPLATE)(scope);
|
|
||||||
|
|
||||||
console.log("ContextMenuAction menu ", menu);
|
|
||||||
|
|
||||||
// Add the menu to the body
|
|
||||||
body.append(menu);
|
|
||||||
|
|
||||||
// Dismiss the menu when body is clicked elsewhere
|
|
||||||
body.on('click', dismiss);
|
|
||||||
|
|
||||||
// Don't launch browser's context menu
|
|
||||||
actionContext.event.preventDefault();
|
|
||||||
//}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
@@ -122,7 +112,8 @@ define(
|
|||||||
if (dismissExistingMenu) {
|
if (dismissExistingMenu) {
|
||||||
dismissExistingMenu();
|
dismissExistingMenu();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
perform: perform
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ define(
|
|||||||
console.log('event ', event);
|
console.log('event ', event);
|
||||||
console.log('domainObject ', domainObject);
|
console.log('domainObject ', domainObject);
|
||||||
console.log('domainObject action', domainObject.getCapability('action'));
|
console.log('domainObject action', domainObject.getCapability('action'));
|
||||||
console.log('domainObject actions', domainObject.getCapability('action').getActions('contextMenu'));
|
console.log('domainObject actions', domainObject.getCapability('action').getActions('menu'));
|
||||||
|
|
||||||
actionContext = {key: 'menu', domainObject: domainObject, event: event};
|
actionContext = {key: 'menu', domainObject: domainObject, event: event};
|
||||||
stop = domainObject.getCapability('action').perform(actionContext);
|
stop = domainObject.getCapability('action').perform(actionContext);
|
||||||
|
|||||||
Reference in New Issue
Block a user