Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
update(dialog, toast): add support for .parent( ) method
Browse files Browse the repository at this point in the history
Refs #1350
Closes #1767.
  • Loading branch information
ThomasBurleson committed Mar 11, 2015
1 parent 69f2421 commit a65934e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ function MdDialogProvider($$interimElementProvider) {

return $$interimElementProvider('$mdDialog')
.setDefaults({
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent'],
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent', 'parent'],
options: dialogDefaultOptions
})
.addPreset('alert', {
Expand Down
6 changes: 3 additions & 3 deletions src/components/dialog/dialog.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ describe('$mdDialog', function() {
var parent = angular.element('<div>');
var resolved = false;
$mdDialog.show(
$mdDialog.alert({
parent: parent
})
$mdDialog
.alert()
.parent( parent )
.title('Title')
.content('Hello world')
.theme('some-theme')
Expand Down
4 changes: 2 additions & 2 deletions src/components/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ function MdToastProvider($$interimElementProvider) {
var activeToastContent;
var $mdToast = $$interimElementProvider('$mdToast')
.setDefaults({
methods: ['position', 'hideDelay', 'capsule'],
methods: ['position', 'hideDelay', 'capsule' ],
options: toastDefaultOptions
})
.addPreset('simple', {
argOption: 'content',
methods: ['content', 'action', 'highlightAction', 'theme'],
methods: ['content', 'action', 'highlightAction', 'theme', 'parent'],
options: /* @ngInject */ function($mdToast, $mdTheming) {
var opts = {
template: [
Expand Down
19 changes: 19 additions & 0 deletions src/components/toast/toast.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ describe('$mdToast service', function() {
expect(content.text()).toBe('Do something');
expect(button.text()).toBe('Click me');
}));


it('displays correctly with parent()', inject(function($mdToast, $rootScope) {
var parent = angular.element('<div>');
var toast = $mdToast.simple({
content: 'Do something',
})
.parent(parent)
.action('Click me');

$mdToast.show(toast);
$rootScope.$digest();

var content = parent.find('span').eq(0);
var button = parent.find('button');

expect(content.text()).toBe('Do something');
expect(button.text()).toBe('Click me');
}));
});

function hasConfigMethods(methods) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/services/interimElement/interimElement.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('$$interimElement service', function() {

var builder = interimTest.build();
[ 'controller', 'controllerAs', 'onRemove', 'onShow', 'resolve',
'template', 'templateUrl', 'themable', 'transformTemplate'
'template', 'templateUrl', 'themable', 'transformTemplate', 'parent'
].forEach(function(methodName) {
expect(builder[methodName]).toBeOfType('function');
});
Expand Down

0 comments on commit a65934e

Please sign in to comment.