mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 22:58:14 +00:00
[Common UI] Add in-line docs for Browse
Add in-line docs for bundle platform/commonUI/browse, which implements Browse mode, one of the common user interface bundles being transitioned in WTD-574.
This commit is contained in:
@ -9,23 +9,34 @@ define(
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
*
|
||||
* The navigate action navigates to a specific domain object.
|
||||
* @constructor
|
||||
*/
|
||||
function NavigateAction(navigationService, context) {
|
||||
function NavigateAction(navigationService, $q, context) {
|
||||
var domainObject = context.domainObject;
|
||||
|
||||
function perform() {
|
||||
return Promise.resolve(
|
||||
navigationService.setNavigation(domainObject)
|
||||
);
|
||||
// Set navigation, and wrap like a promise
|
||||
return $q.when(navigationService.setNavigation(domainObject));
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Navigate to the object described in the context.
|
||||
* @returns {Promise} a promise that is resolved once the
|
||||
* navigation has been updated
|
||||
*/
|
||||
perform: perform
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate as an action is only applicable when a domain object
|
||||
* is described in the action context.
|
||||
* @param {ActionContext} context the context in which the action
|
||||
* will be performed
|
||||
* @returns true if applicable
|
||||
*/
|
||||
NavigateAction.appliesTo = function (context) {
|
||||
return context.domainObject !== undefined;
|
||||
};
|
||||
|
@ -9,17 +9,20 @@ define(
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
*
|
||||
* The navigation service maintains the application's current
|
||||
* navigation state, and allows listening for changes thereto.
|
||||
* @constructor
|
||||
*/
|
||||
function NavigationService() {
|
||||
var navigated,
|
||||
callbacks = [];
|
||||
|
||||
// Getter for current navigation
|
||||
function getNavigation() {
|
||||
return navigated;
|
||||
}
|
||||
|
||||
// Setter for navigation; invokes callbacks
|
||||
function setNavigation(value) {
|
||||
navigated = value;
|
||||
callbacks.forEach(function (callback) {
|
||||
@ -27,10 +30,12 @@ define(
|
||||
});
|
||||
}
|
||||
|
||||
// Adds a callback
|
||||
function addListener(callback) {
|
||||
callbacks.push(callback);
|
||||
}
|
||||
|
||||
// Filters out a callback
|
||||
function removeListener(callback) {
|
||||
callbacks = callbacks.filter(function (cb) {
|
||||
return cb !== callback;
|
||||
@ -38,9 +43,30 @@ define(
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Get the current navigation state.
|
||||
*/
|
||||
getNavigation: getNavigation,
|
||||
/**
|
||||
* Set the current navigation state. Thiswill invoke listeners.
|
||||
* @param {DomainObject} value the domain object to navigate
|
||||
* to
|
||||
*/
|
||||
setNavigation: setNavigation,
|
||||
/**
|
||||
* Listen for changes in navigation. The passed callback will
|
||||
* be invoked with the new domain object of navigation when
|
||||
* this changes.
|
||||
* @param {function} callback the callback to invoke when
|
||||
* navigation state changes
|
||||
*/
|
||||
addListener: addListener,
|
||||
/**
|
||||
* Stop listening for changes in navigation state.
|
||||
* @param {function} callback the callback which should
|
||||
* no longer be invoked when navigation state
|
||||
* changes
|
||||
*/
|
||||
removeListener: removeListener
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user