[Browse] Some progress

Still doesn't work.
This commit is contained in:
Sarah Hale 2015-07-01 14:32:49 -07:00
parent 9ad1c25d53
commit e9989ae00d
6 changed files with 95 additions and 75 deletions
platform
commonUI/browse
representation

@ -36,7 +36,7 @@
{
"key": "MenuArrowController",
"implementation": "MenuArrowController",
"depends": [ "$scope" ]
"depends": [ "$scope", "$route", "objectService" ]
}
],
"controls": [

@ -25,9 +25,6 @@
<span ng-if="parameters.mode" class='action'>{{parameters.mode}}</span>
<span class='type-name'>{{type.getName()}}</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>
</span>
</div>

@ -22,12 +22,15 @@
/*global define*/
/**
* Module defining ObjectHeaderController. Created by shale on 06/30/2015.
* Module defining MenuArrowController. Created by shale on 06/30/2015.
*/
define(
[],
function () {
"use strict";
var ROOT_ID = "ROOT",
DEFAULT_PATH = "mine";
/**
* A left-click on the menu arrow should display a
@ -35,10 +38,10 @@ define(
* menu.
* @constructor
*/
function MenuArrowController($scope) {
function MenuArrowController($scope, $route, domainObject) {
function showMenu(event) {
console.log('contextMenu() called');
console.log('showMenu() called');
//console.log('editor? ', $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 {
showMenu: showMenu
};

@ -26,7 +26,7 @@
{
"key": "menu",
"implementation": "gestures/ContextMenuGesture.js",
"depends": [ "$compile", "$document", "$window", "$rootScope" ]
"depends": []
}
],
"components": [

@ -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;