mirror of
https://github.com/nasa/openmct.git
synced 2025-06-13 12:48:14 +00:00
[Code Style] Use prototypes in Dialog bundle
WTD-1482.
This commit is contained in:
@ -47,54 +47,51 @@ define(
|
||||
* @constructor
|
||||
*/
|
||||
function OverlayService($document, $compile, $rootScope) {
|
||||
function createOverlay(key, overlayModel) {
|
||||
// Create a new scope for this overlay
|
||||
var scope = $rootScope.$new(),
|
||||
element;
|
||||
this.$document = $document;
|
||||
this.$compile = $compile;
|
||||
this.$rootScope = $rootScope;
|
||||
}
|
||||
|
||||
// Stop showing the overlay; additionally, release the scope
|
||||
// that it uses.
|
||||
function dismiss() {
|
||||
scope.$destroy();
|
||||
element.remove();
|
||||
}
|
||||
/**
|
||||
* Add a new overlay to the document. This will be
|
||||
* prepended to the document body; the overlay's
|
||||
* template (as pointed to by the `key` argument) is
|
||||
* responsible for having a useful z-order, and for
|
||||
* blocking user interactions if appropriate.
|
||||
*
|
||||
* @param {string} key the symbolic key which identifies
|
||||
* the template of the overlay to be shown
|
||||
* @param {object} overlayModel the model to pass to the
|
||||
* included overlay template (this will be passed
|
||||
* in via ng-model)
|
||||
*/
|
||||
OverlayService.prototype.createOverlay = function (key, overlayModel) {
|
||||
// Create a new scope for this overlay
|
||||
var scope = this.$rootScope.$new(),
|
||||
element;
|
||||
|
||||
// If no model is supplied, just fill in a default "cancel"
|
||||
overlayModel = overlayModel || { cancel: dismiss };
|
||||
|
||||
// Populate the scope; will be passed directly to the template
|
||||
scope.overlay = overlayModel;
|
||||
scope.key = key;
|
||||
|
||||
// Create the overlay element and add it to the document's body
|
||||
element = $compile(TEMPLATE)(scope);
|
||||
$document.find('body').prepend(element);
|
||||
|
||||
|
||||
|
||||
return {
|
||||
dismiss: dismiss
|
||||
};
|
||||
// Stop showing the overlay; additionally, release the scope
|
||||
// that it uses.
|
||||
function dismiss() {
|
||||
scope.$destroy();
|
||||
element.remove();
|
||||
}
|
||||
|
||||
// If no model is supplied, just fill in a default "cancel"
|
||||
overlayModel = overlayModel || { cancel: dismiss };
|
||||
|
||||
// Populate the scope; will be passed directly to the template
|
||||
scope.overlay = overlayModel;
|
||||
scope.key = key;
|
||||
|
||||
// Create the overlay element and add it to the document's body
|
||||
element = this.$compile(TEMPLATE)(scope);
|
||||
this.$document.find('body').prepend(element);
|
||||
|
||||
return {
|
||||
/**
|
||||
* Add a new overlay to the document. This will be
|
||||
* prepended to the document body; the overlay's
|
||||
* template (as pointed to by the `key` argument) is
|
||||
* responsible for having a useful z-order, and for
|
||||
* blocking user interactions if appropriate.
|
||||
*
|
||||
* @param {string} key the symbolic key which identifies
|
||||
* the template of the overlay to be shown
|
||||
* @param {object} overlayModel the model to pass to the
|
||||
* included overlay template (this will be passed
|
||||
* in via ng-model)
|
||||
* @memberof platform/commonUI/dialog.OverlayService#
|
||||
*/
|
||||
createOverlay: createOverlay
|
||||
dismiss: dismiss
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
return OverlayService;
|
||||
}
|
||||
|
Reference in New Issue
Block a user