diff --git a/src/components/dialog/dialog.js b/src/components/dialog/dialog.js index 42fc0bf2ebf..f4e6b5786fa 100644 --- a/src/components/dialog/dialog.js +++ b/src/components/dialog/dialog.js @@ -227,7 +227,6 @@ function MdDialogDirective($$rAF, $mdTheming) { * to the root element of the application. * - `onComplete` `{function=}`: Callback function used to announce when the show() action is * finished. - * - `theme` `{string=}`: Theme to be applied to the dialog, when using a `$mdDialogPreset`. * * @returns {promise} A promise that can be resolved with `$mdDialog.hide()` or * rejected with `$mdDialog.cancel()`. @@ -259,20 +258,20 @@ function MdDialogProvider($$interimElementProvider) { return $$interimElementProvider('$mdDialog') .setDefaults({ - methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent', 'theme'], + methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent'], options: dialogDefaultOptions }) .addPreset('alert', { - methods: ['title', 'content', 'ariaLabel', 'ok'], + methods: ['title', 'content', 'ariaLabel', 'ok', 'theme'], options: advancedDialogOptions }) .addPreset('confirm', { - methods: ['title', 'content', 'ariaLabel', 'ok', 'cancel'], + methods: ['title', 'content', 'ariaLabel', 'ok', 'cancel', 'theme'], options: advancedDialogOptions }); /* @ngInject */ - function advancedDialogOptions($mdDialog) { + function advancedDialogOptions($mdDialog, $mdTheming) { return { template: [ '', @@ -299,7 +298,8 @@ function MdDialogProvider($$interimElementProvider) { }; }, controllerAs: 'dialog', - bindToController: true + bindToController: true, + theme: $mdTheming.defaultTheme() }; } @@ -307,7 +307,6 @@ function MdDialogProvider($$interimElementProvider) { function dialogDefaultOptions($timeout, $rootElement, $compile, $animate, $mdAria, $document, $mdUtil, $mdConstant, $mdTheming, $$rAF, $q, $mdDialog) { return { - theme: $mdTheming.defaultTheme(), hasBackdrop: true, isolateScope: true, onShow: onShow, diff --git a/src/components/toast/toast.js b/src/components/toast/toast.js index f78965d75e2..937fe9e2150 100644 --- a/src/components/toast/toast.js +++ b/src/components/toast/toast.js @@ -80,6 +80,7 @@ function MdToastDirective() { * - $mdToastPreset#action(string) - adds an action button, which resolves the promise returned from `show()` if clicked. * - $mdToastPreset#highlightAction(boolean) - sets action button to be highlighted * - $mdToastPreset#capsule(boolean) - adds 'md-capsule' class to the toast (curved corners) + * - $mdToastPreset#theme(boolean) - sets the theme on the toast to theme (default is `$mdThemingProvider`'s default theme) */ /** @@ -173,11 +174,11 @@ function MdToastProvider($$interimElementProvider) { }) .addPreset('simple', { argOption: 'content', - methods: ['content', 'action', 'highlightAction'], - options: /* @ngInject */ function($mdToast) { + methods: ['content', 'action', 'highlightAction', 'theme'], + options: /* @ngInject */ function($mdToast, $mdTheming) { return { template: [ - '', + '', '{{ toast.content }}', '', '{{ toast.action }}', @@ -193,6 +194,7 @@ function MdToastProvider($$interimElementProvider) { $mdToast.hide(); }; }, + theme: $mdTheming.defaultTheme(), controllerAs: 'toast', bindToController: true }; @@ -205,7 +207,7 @@ function MdToastProvider($$interimElementProvider) { return $mdToast; /* @ngInject */ - function toastDefaultOptions($timeout, $animate, $mdTheming, $mdToast) { + function toastDefaultOptions($timeout, $animate, $mdToast) { return { onShow: onShow, onRemove: onRemove, diff --git a/src/components/toast/toast.spec.js b/src/components/toast/toast.spec.js index 2f8bdff4aaf..3b5e94f736f 100644 --- a/src/components/toast/toast.spec.js +++ b/src/components/toast/toast.spec.js @@ -12,7 +12,7 @@ describe('$mdToast service', function() { } describe('simple()', function() { - hasConfigMethods(['content', 'action', 'capsule', 'highlightAction']); + hasConfigMethods(['content', 'action', 'capsule', 'highlightAction', 'theme']); it('supports a basic toast', inject(function($mdToast, $rootScope, $timeout, $animate) { var rejected = false; @@ -21,6 +21,7 @@ describe('$mdToast service', function() { $mdToast.simple({ parent: parent, content: 'Do something', + theme: 'some-theme', capsule: true }) ).catch(function() { @@ -29,6 +30,7 @@ describe('$mdToast service', function() { $rootScope.$digest(); expect(parent.find('span').text()).toBe('Do something'); expect(parent.find('md-toast')).toHaveClass('md-capsule'); + expect(parent.find('md-toast').attr('md-theme')).toBe('some-theme'); $animate.triggerCallbacks(); $timeout.flush(); $animate.triggerCallbacks();