From e9989ae00df73036e707a25a6ad5704355b00903 Mon Sep 17 00:00:00 2001 From: Sarah Hale Date: Wed, 1 Jul 2015 14:32:49 -0700 Subject: [PATCH] [Browse] Some progress Still doesn't work. --- platform/commonUI/browse/bundle.json | 2 +- .../res/templates/browse/object-header.html | 3 - .../browse/src/MenuArrowController.js | 18 ++- platform/representation/bundle.json | 2 +- .../src/actions/ContextMenuAction.js | 121 +++++++++--------- .../src/gestures/ContextMenuGesture.js | 24 +++- 6 files changed, 95 insertions(+), 75 deletions(-) diff --git a/platform/commonUI/browse/bundle.json b/platform/commonUI/browse/bundle.json index 1869e0d8f9..20ccbbe5ad 100644 --- a/platform/commonUI/browse/bundle.json +++ b/platform/commonUI/browse/bundle.json @@ -36,7 +36,7 @@ { "key": "MenuArrowController", "implementation": "MenuArrowController", - "depends": [ "$scope" ] + "depends": [ "$scope", "$route", "objectService" ] } ], "controls": [ diff --git a/platform/commonUI/browse/res/templates/browse/object-header.html b/platform/commonUI/browse/res/templates/browse/object-header.html index 48f494466e..895761f514 100644 --- a/platform/commonUI/browse/res/templates/browse/object-header.html +++ b/platform/commonUI/browse/res/templates/browse/object-header.html @@ -25,9 +25,6 @@ {{parameters.mode}} {{type.getName()}} {{model.name}} - \ No newline at end of file diff --git a/platform/commonUI/browse/src/MenuArrowController.js b/platform/commonUI/browse/src/MenuArrowController.js index 5507cf67f6..0623b62400 100644 --- a/platform/commonUI/browse/src/MenuArrowController.js +++ b/platform/commonUI/browse/src/MenuArrowController.js @@ -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 }; diff --git a/platform/representation/bundle.json b/platform/representation/bundle.json index b3d24a790d..231a73c461 100644 --- a/platform/representation/bundle.json +++ b/platform/representation/bundle.json @@ -26,7 +26,7 @@ { "key": "menu", "implementation": "gestures/ContextMenuGesture.js", - "depends": [ "$compile", "$document", "$window", "$rootScope" ] + "depends": [] } ], "components": [ diff --git a/platform/representation/src/actions/ContextMenuAction.js b/platform/representation/src/actions/ContextMenuAction.js index cc08936edd..ba929bb170 100644 --- a/platform/representation/src/actions/ContextMenuAction.js +++ b/platform/representation/src/actions/ContextMenuAction.js @@ -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(); - } } }; } diff --git a/platform/representation/src/gestures/ContextMenuGesture.js b/platform/representation/src/gestures/ContextMenuGesture.js index d390fdc386..4b182d00b3 100644 --- a/platform/representation/src/gestures/ContextMenuGesture.js +++ b/platform/representation/src/gestures/ContextMenuGesture.js @@ -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;