[API] Update GestureAPI to match docs

This commit is contained in:
Victor Woeltjen 2016-09-29 17:16:56 -07:00
parent d4d9f9c467
commit 6fe1e775e0
2 changed files with 23 additions and 7 deletions

View File

@ -4,8 +4,9 @@ define([], function () {
* @interface GestureAPI
* @memberof module:openmct
*/
function GestureAPI() {
function GestureAPI(selectGesture, contextMenuGesture) {
this.selectGesture = selectGesture;
this.contextMenuGesture = contextMenuGesture;
}
/**
@ -21,7 +22,24 @@ define([], function () {
* @memberof module:openmct.GestureAPI#
*/
GestureAPI.prototype.selectable = function (htmlElement, item) {
return this.selectGesture.apply(htmlElement, item);
};
/**
* Designate an HTML element as having a context menu associated with
* the provided item.
*
* @private
* @param {HTMLElement} htmlElement the element to make selectable
* @param {*} item the object for which a context menu should appear
* @returns {Function} a function to remove this geture from this
* HTML element.
* @method selectable
* @memberof module:openmct.GestureAPI#
*/
GestureAPI.prototype.contextMenu = function (htmlElement, item) {
return this.contextMenuGesture.apply(htmlElement, item);
};
return GestureAPI;

View File

@ -24,6 +24,7 @@ define([
'EventEmitter',
'./MCT',
'./api/Type',
'./api/ui/GestureAPI',
'./Registry',
'./selection/Selection',
'./selection/ContextManager',
@ -35,6 +36,7 @@ define([
EventEmitter,
MCT,
Type,
GestureAPI,
Registry,
Selection,
ContextManager,
@ -72,11 +74,7 @@ define([
openmct.selection = selection;
openmct.inspectors = new ViewRegistry();
openmct.gestures = {
selectable: select.apply.bind(select),
contextual: contextMenu.apply.bind(contextMenu)
};
openmct.gestures = new GestureAPI(select, contextMenu);
return openmct;
});