diff --git a/platform/commonUI/dialog/src/DialogService.js b/platform/commonUI/dialog/src/DialogService.js index b606c1743e..344a407b94 100644 --- a/platform/commonUI/dialog/src/DialogService.js +++ b/platform/commonUI/dialog/src/DialogService.js @@ -76,8 +76,8 @@ define( // Add the overlay using the OverlayService, which // will handle actual insertion into the DOM overlay = overlayService.createOverlay( - overlayModel, - "overlay-dialog" + "overlay-dialog", + overlayModel ); // Track that a dialog is already visible, to diff --git a/platform/commonUI/dialog/src/OverlayService.js b/platform/commonUI/dialog/src/OverlayService.js index 580595162d..32fd0c54b4 100644 --- a/platform/commonUI/dialog/src/OverlayService.js +++ b/platform/commonUI/dialog/src/OverlayService.js @@ -25,11 +25,21 @@ define( * @constructor */ function OverlayService($document, $compile, $rootScope) { - function createOverlay(overlayModel, key) { + function createOverlay(key, overlayModel) { // Create a new scope for this overlay var scope = $rootScope.$new(), element; + // 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; @@ -38,12 +48,7 @@ define( element = $compile(TEMPLATE)(scope); $document.find('body').prepend(element); - // Stop showing the overlay; additionally, release the scope - // that it uses. - function dismiss() { - scope.$destroy(); - element.remove(); - } + return { dismiss: dismiss @@ -57,11 +62,12 @@ define( * 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) - * @param {string} key the symbolic key which identifies - * the template of the overlay to be shown */ createOverlay: createOverlay };