Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
feat(dialog): allow specifying parent by string selector.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBurleson committed Sep 11, 2015
1 parent 6681e82 commit 5551699
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,6 @@ function MdDialogProvider($$interimElementProvider) {
* Show method for dialogs
*/
function onShow(scope, element, options, controller) {
element = $mdUtil.extractElementByName(element, 'md-dialog');
angular.element($document[0].body).addClass('md-dialog-is-showing');

wrapSimpleContent();
Expand Down Expand Up @@ -549,8 +548,11 @@ function MdDialogProvider($$interimElementProvider) {
* unless overridden in the options.parent
*/
function captureSourceAndParent(element, options) {
var origin = {element: null, bounds: null, focus: angular.noop};
options.origin = angular.extend({}, origin, options.origin || {});
options.origin = angular.extend({
element: null,
bounds: null,
focus: angular.noop
}, options.origin || {});

var source = angular.element((options.targetEvent || {}).target);
if (source && source.length) {
Expand All @@ -564,7 +566,14 @@ function MdDialogProvider($$interimElementProvider) {
}
}

// In case the user provides a raw dom element, always wrap it in jqLite
// If the parent specifier is a simple string selector, then query for
// the DOM element.
if ( angular.isString(options.parent) ) {
var simpleSelector = options.parent;
container = $document[0].querySelectorAll(selector);
options.parent = container.length ? container[0] : null;
}
// If we have a reference to a raw dom element, always wrap it in jqLite
options.parent = angular.element(options.parent || $rootElement);

}
Expand Down

3 comments on commit 5551699

@dylang
Copy link

@dylang dylang commented on 5551699 Sep 11, 2015

Choose a reason for hiding this comment

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

Hi @ThomasBurleson!

Was there a test added with this change?

@ThomasBurleson
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dylang
Copy link

@dylang dylang commented on 5551699 Sep 12, 2015

Choose a reason for hiding this comment

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

Thanks for this fix! It fixes the issue I mentioned I was having here 22c34ba#diff-a1919fe5ddcba0e8888df1ee8f3f3727R466.

Have a good weekend!

Please sign in to comment.