Skip to content

Commit

Permalink
Add support for multiple dialogs for 0.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
benn0r committed Mar 6, 2015
1 parent c9aae9b commit 1650734
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ function MdDialogProvider($$interimElementProvider) {
var computeFrom = (options.parent[0] == $document[0].body && $document[0].documentElement
&& $document[0].scrollTop) ? angular.element($document[0].documentElement) : options.parent;
var parentOffset = computeFrom.prop('scrollTop');
options.backdrop = angular.element('<md-backdrop class="md-dialog-backdrop md-opaque">');
options.backdrop = angular.element('<md-backdrop class="md-dialog-backdrop md-opaque" style="z-index: ' + options.zIndex + '">');
$mdTheming.inherit(options.backdrop, options.parent);
$animate.enter(options.backdrop, options.parent);
element.css('top', parentOffset +'px');
Expand All @@ -429,7 +429,9 @@ function MdDialogProvider($$interimElementProvider) {
if (options.escapeToClose) {
options.rootElementKeyupCallback = function(e) {
if (e.keyCode === $mdConstant.KEY_CODE.ESCAPE) {
$timeout($mdDialog.cancel);
if (options.stack.indexOf(options.interimElement) == 0) {
$timeout($mdDialog.cancel);
}
}
};
$rootElement.on('keyup', options.rootElementKeyupCallback);
Expand Down
25 changes: 13 additions & 12 deletions src/core/services/interimElement/interimElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,12 @@ function InterimElementProvider() {
*
*/
function show(options) {
if (stack.length) {
return service.cancel().then(function() {
return show(options);
});
} else {
var interimElement = new InterimElement(options);
stack.push(interimElement);
return interimElement.show().then(function() {
return interimElement.deferred.promise;
});
}
options.zIndex = 80 + stack.length;
var interimElement = new InterimElement(options);
stack.unshift(interimElement);
return interimElement.show().then(function() {
return interimElement.deferred.promise;
});
}

/*
Expand Down Expand Up @@ -336,7 +331,7 @@ function InterimElementProvider() {
options.template = processTemplate(options.template);
}

return self = {
self = {
options: options,
deferred: $q.defer(),
show: function() {
Expand Down Expand Up @@ -371,6 +366,7 @@ function InterimElementProvider() {
if (!options.parent.length) options.parent = $rootElement;
}

element.css('z-index', options.zIndex);
if (options.themable) $mdTheming(element);
var ret = options.onShow(options.scope, element, options);
return $q.when(ret)
Expand Down Expand Up @@ -404,6 +400,11 @@ function InterimElementProvider() {
});
}
};

options.interimElement = self;
options.stack = stack;

return self;
}
};

Expand Down

4 comments on commit 1650734

@bobmanz
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was exactly what I was looking for. However, it seems to have broken md-Selects. Are you seeing similar behavior?

@benn0r
Copy link
Member Author

@benn0r benn0r commented on 1650734 Apr 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks. fixed it in cb05f92 and also updated to v0.9.0-rc3

@bobmanz
Copy link

@bobmanz bobmanz commented on 1650734 Apr 30, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benn0r
Copy link
Member Author

@benn0r benn0r commented on 1650734 Apr 30, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.