mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
[Browse] Some progress
Still doesn't work.
This commit is contained in:
@ -50,82 +50,77 @@ define(
|
||||
* @param {DomainObject} domainObject the object on which actions
|
||||
* in the context menu will be performed
|
||||
*/
|
||||
function ContextMenuAction($compile, $document, $window, $rootScope, element, domainObject) {
|
||||
var turnOffMenu;
|
||||
function ContextMenuAction($compile, $document, $window, $rootScope, element, domainObject, event) {
|
||||
//var turnOffMenu;
|
||||
console.log('in ContextMenuAction');
|
||||
console.log('contextMenuAction event ', event);
|
||||
|
||||
function showMenu(event) {
|
||||
var winDim = [$window.innerWidth, $window.innerHeight],
|
||||
eventCoors = [event.pageX, event.pageY],
|
||||
menuDim = GestureConstants.MCT_MENU_DIMENSIONS,
|
||||
body = $document.find('body'),
|
||||
scope = $rootScope.$new(),
|
||||
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
|
||||
goUp = eventCoors[1] + menuDim[1] > winDim[1],
|
||||
menu;
|
||||
|
||||
console.log('in showMenu() in ContextMenuAction');
|
||||
|
||||
// Remove the context menu
|
||||
function dismiss() {
|
||||
menu.remove();
|
||||
body.off("click", dismiss);
|
||||
dismissExistingMenu = undefined;
|
||||
}
|
||||
//function showMenu(event) {
|
||||
var winDim = [$window.innerWidth, $window.innerHeight],
|
||||
eventCoors = [event.pageX, event.pageY],
|
||||
menuDim = GestureConstants.MCT_MENU_DIMENSIONS,
|
||||
body = $document.find('body'),
|
||||
scope = $rootScope.$new(),
|
||||
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
|
||||
goUp = eventCoors[1] + menuDim[1] > winDim[1],
|
||||
menu;
|
||||
|
||||
// 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
|
||||
event.preventDefault();
|
||||
// Remove the context menu
|
||||
function dismiss() {
|
||||
menu.remove();
|
||||
body.off("click", dismiss);
|
||||
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 = 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
|
||||
event.preventDefault();
|
||||
//}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Detach any event handlers associated with this gesture,
|
||||
* and dismiss any visible menu.
|
||||
* Dismiss any visible menu.
|
||||
* @method
|
||||
* @memberof ContextMenuGesture
|
||||
* @memberof ContextMenuAction
|
||||
*/
|
||||
destroy: function () {
|
||||
// Scope has been destroyed, so remove all listeners.
|
||||
if (dismissExistingMenu) {
|
||||
dismissExistingMenu();
|
||||
}
|
||||
element.off('contextmenu', showMenu);
|
||||
if (turnOffMenu) {
|
||||
turnOffMenu();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -40,11 +40,31 @@ define(
|
||||
* in the context menu will be performed
|
||||
*/
|
||||
function ContextMenuGesture(element, domainObject) {
|
||||
var actionContext,
|
||||
stop;
|
||||
|
||||
// When context menu event occurs, show object actions instead
|
||||
element.on('contextmenu', function () {
|
||||
domainObject.getCapability('action').perform({key: "contextMenu", event: $event});
|
||||
element.on('contextmenu', function (event) {
|
||||
console.log('in ContextMenuGesture');
|
||||
console.log('domainObject ', domainObject);
|
||||
console.log('domainObject action', domainObject.getCapability('action'));
|
||||
console.log('domainObject actions', domainObject.getCapability('action').getActions('contextMenu'));
|
||||
|
||||
|
||||
actionContext = {key: 'contextMenu', /*element: element,*/ domainObject: domainObject, event: event};
|
||||
stop = domainObject.getCapability('action').perform(actionContext);
|
||||
});
|
||||
|
||||
return {
|
||||
/**
|
||||
* Detach any event handlers associated with this gesture.
|
||||
* @method
|
||||
* @memberof ContextMenuGesture
|
||||
*/
|
||||
destroy: function () {
|
||||
//element.off('contextmenu', stop.destroy);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return ContextMenuGesture;
|
||||
|
Reference in New Issue
Block a user