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:
@ -36,7 +36,7 @@
|
|||||||
{
|
{
|
||||||
"key": "MenuArrowController",
|
"key": "MenuArrowController",
|
||||||
"implementation": "MenuArrowController",
|
"implementation": "MenuArrowController",
|
||||||
"depends": [ "$scope" ]
|
"depends": [ "$scope", "$route", "objectService" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"controls": [
|
"controls": [
|
||||||
|
@ -25,9 +25,6 @@
|
|||||||
<span ng-if="parameters.mode" class='action'>{{parameters.mode}}</span>
|
<span ng-if="parameters.mode" class='action'>{{parameters.mode}}</span>
|
||||||
<span class='type-name'>{{type.getName()}}</span>
|
<span class='type-name'>{{type.getName()}}</span>
|
||||||
<span class='title-label'>{{model.name}}</span>
|
<span class='title-label'>{{model.name}}</span>
|
||||||
<!--a id='actions-menu'
|
|
||||||
class='ui-symbol context-available'
|
|
||||||
ng-click='ObjectHeaderController.contextMenu()'>v</a-->
|
|
||||||
<mct-representation key="'menu-arrow'"></mct-representation>
|
<mct-representation key="'menu-arrow'"></mct-representation>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
@ -22,12 +22,15 @@
|
|||||||
/*global define*/
|
/*global define*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module defining ObjectHeaderController. Created by shale on 06/30/2015.
|
* Module defining MenuArrowController. Created by shale on 06/30/2015.
|
||||||
*/
|
*/
|
||||||
define(
|
define(
|
||||||
[],
|
[],
|
||||||
function () {
|
function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var ROOT_ID = "ROOT",
|
||||||
|
DEFAULT_PATH = "mine";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A left-click on the menu arrow should display a
|
* A left-click on the menu arrow should display a
|
||||||
@ -35,10 +38,10 @@ define(
|
|||||||
* menu.
|
* menu.
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
function MenuArrowController($scope) {
|
function MenuArrowController($scope, $route, domainObject) {
|
||||||
|
|
||||||
function showMenu(event) {
|
function showMenu(event) {
|
||||||
console.log('contextMenu() called');
|
console.log('showMenu() called');
|
||||||
//console.log('editor? ', $scope.domainObject.hasCapability('editor'));
|
//console.log('editor? ', $scope.domainObject.hasCapability('editor'));
|
||||||
/*
|
/*
|
||||||
if (true || $scope.domainObject.hasCapability('editor')) {
|
if (true || $scope.domainObject.hasCapability('editor')) {
|
||||||
@ -46,9 +49,14 @@ define(
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$scope.domainObject.getCapability('action').perform({key: 'contextMenu', event: event});
|
//console.log('domainObject ', domainObject);
|
||||||
|
//console.log('$scope.domainObject ', $scope.domainObject);
|
||||||
|
console.log('event ', event);
|
||||||
|
|
||||||
|
//$scope.domainObject.getCapability('action').perform({key: 'contextMenu', event: event});
|
||||||
|
domainObject.getCapability('action').perform({key: 'contextMenu', event: event});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
showMenu: showMenu
|
showMenu: showMenu
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
{
|
{
|
||||||
"key": "menu",
|
"key": "menu",
|
||||||
"implementation": "gestures/ContextMenuGesture.js",
|
"implementation": "gestures/ContextMenuGesture.js",
|
||||||
"depends": [ "$compile", "$document", "$window", "$rootScope" ]
|
"depends": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"components": [
|
"components": [
|
||||||
|
@ -50,82 +50,77 @@ define(
|
|||||||
* @param {DomainObject} domainObject the object on which actions
|
* @param {DomainObject} domainObject the object on which actions
|
||||||
* in the context menu will be performed
|
* in the context menu will be performed
|
||||||
*/
|
*/
|
||||||
function ContextMenuAction($compile, $document, $window, $rootScope, element, domainObject) {
|
function ContextMenuAction($compile, $document, $window, $rootScope, element, domainObject, event) {
|
||||||
var turnOffMenu;
|
//var turnOffMenu;
|
||||||
|
console.log('in ContextMenuAction');
|
||||||
|
console.log('contextMenuAction event ', event);
|
||||||
|
|
||||||
function showMenu(event) {
|
//function showMenu(event) {
|
||||||
var winDim = [$window.innerWidth, $window.innerHeight],
|
var winDim = [$window.innerWidth, $window.innerHeight],
|
||||||
eventCoors = [event.pageX, event.pageY],
|
eventCoors = [event.pageX, event.pageY],
|
||||||
menuDim = GestureConstants.MCT_MENU_DIMENSIONS,
|
menuDim = GestureConstants.MCT_MENU_DIMENSIONS,
|
||||||
body = $document.find('body'),
|
body = $document.find('body'),
|
||||||
scope = $rootScope.$new(),
|
scope = $rootScope.$new(),
|
||||||
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
|
goLeft = eventCoors[0] + menuDim[0] > winDim[0],
|
||||||
goUp = eventCoors[1] + menuDim[1] > winDim[1],
|
goUp = eventCoors[1] + menuDim[1] > winDim[1],
|
||||||
menu;
|
menu;
|
||||||
|
|
||||||
console.log('in showMenu() in ContextMenuAction');
|
|
||||||
|
|
||||||
// Remove the context menu
|
|
||||||
function dismiss() {
|
|
||||||
menu.remove();
|
|
||||||
body.off("click", dismiss);
|
|
||||||
dismissExistingMenu = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dismiss any menu which was already showing
|
// Remove the context menu
|
||||||
if (dismissExistingMenu) {
|
function dismiss() {
|
||||||
dismissExistingMenu();
|
menu.remove();
|
||||||
}
|
body.off("click", dismiss);
|
||||||
|
dismissExistingMenu = undefined;
|
||||||
// ...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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 {
|
return {
|
||||||
/**
|
/**
|
||||||
* Detach any event handlers associated with this gesture,
|
* Dismiss any visible menu.
|
||||||
* and dismiss any visible menu.
|
|
||||||
* @method
|
* @method
|
||||||
* @memberof ContextMenuGesture
|
* @memberof ContextMenuAction
|
||||||
*/
|
*/
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
// Scope has been destroyed, so remove all listeners.
|
// Scope has been destroyed, so remove all listeners.
|
||||||
if (dismissExistingMenu) {
|
if (dismissExistingMenu) {
|
||||||
dismissExistingMenu();
|
dismissExistingMenu();
|
||||||
}
|
}
|
||||||
element.off('contextmenu', showMenu);
|
|
||||||
if (turnOffMenu) {
|
|
||||||
turnOffMenu();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -40,11 +40,31 @@ define(
|
|||||||
* in the context menu will be performed
|
* in the context menu will be performed
|
||||||
*/
|
*/
|
||||||
function ContextMenuGesture(element, domainObject) {
|
function ContextMenuGesture(element, domainObject) {
|
||||||
|
var actionContext,
|
||||||
|
stop;
|
||||||
|
|
||||||
// When context menu event occurs, show object actions instead
|
// When context menu event occurs, show object actions instead
|
||||||
element.on('contextmenu', function () {
|
element.on('contextmenu', function (event) {
|
||||||
domainObject.getCapability('action').perform({key: "contextMenu", event: $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;
|
return ContextMenuGesture;
|
||||||
|
Reference in New Issue
Block a user