diff --git a/src/components/dialog/dialog.js b/src/components/dialog/dialog.js index 359333eac10..42fc0bf2ebf 100644 --- a/src/components/dialog/dialog.js +++ b/src/components/dialog/dialog.js @@ -166,6 +166,7 @@ function MdDialogDirective($$rAF, $mdTheming) { * - $mdDialogPreset#title(string) - sets title to string * - $mdDialogPreset#content(string) - sets content / message to string * - $mdDialogPreset#ok(string) - sets okay button text to string + * - $mdDialogPreset#theme(string) - sets the theme of the dialog * */ @@ -185,6 +186,7 @@ function MdDialogDirective($$rAF, $mdTheming) { * - $mdDialogPreset#content(string) - sets content / message to string * - $mdDialogPreset#ok(string) - sets okay button text to string * - $mdDialogPreset#cancel(string) - sets cancel button text to string + * - $mdDialogPreset#theme(string) - sets the theme of the dialog * */ @@ -225,6 +227,7 @@ 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()`. @@ -256,7 +259,7 @@ function MdDialogProvider($$interimElementProvider) { return $$interimElementProvider('$mdDialog') .setDefaults({ - methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent'], + methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent', 'theme'], options: dialogDefaultOptions }) .addPreset('alert', { @@ -272,7 +275,7 @@ function MdDialogProvider($$interimElementProvider) { function advancedDialogOptions($mdDialog) { return { template: [ - '', + '', '', '

{{ dialog.title }}

', '

{{ dialog.content }}

', @@ -304,6 +307,7 @@ 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/dialog/dialog.spec.js b/src/components/dialog/dialog.spec.js index b9f030e85c6..4d824234a4d 100644 --- a/src/components/dialog/dialog.spec.js +++ b/src/components/dialog/dialog.spec.js @@ -16,7 +16,7 @@ describe('$mdDialog', function() { describe('#alert()', function() { hasConfigurationMethods('alert', [ 'title', 'content', 'ariaLabel', - 'ok', 'targetEvent' + 'ok', 'targetEvent', 'theme' ]); it('shows a basic alert dialog', inject(function($animate, $rootScope, $mdDialog, $mdConstant) { @@ -28,6 +28,7 @@ describe('$mdDialog', function() { }) .title('Title') .content('Hello world') + .theme('some-theme') .ok('Next') ).then(function() { resolved = true; @@ -45,6 +46,10 @@ describe('$mdDialog', function() { var buttons = parent.find('md-button'); expect(buttons.length).toBe(1); expect(buttons.eq(0).text()).toBe('Next'); + var theme = parent.find('md-dialog').attr('md-theme'); + expect(theme).toBe('some-theme'); + + buttons.eq(0).triggerHandler('click'); $rootScope.$apply(); parent.find('md-dialog').triggerHandler('transitionend'); @@ -57,7 +62,7 @@ describe('$mdDialog', function() { describe('#confirm()', function() { hasConfigurationMethods('confirm', [ 'title', 'content', 'ariaLabel', - 'ok', 'cancel', 'targetEvent' + 'ok', 'cancel', 'targetEvent', 'theme' ]); it('shows a basic confirm dialog', inject(function($rootScope, $mdDialog, $animate, $mdConstant) { diff --git a/src/core/services/theming/theming.js b/src/core/services/theming/theming.js index c5e98a87597..9da93b3687a 100644 --- a/src/core/services/theming/theming.js +++ b/src/core/services/theming/theming.js @@ -310,6 +310,9 @@ function ThemingProvider($mdColorPalette) { }; applyTheme.registered = registered; + applyTheme.defaultTheme = function() { + return defaultTheme; + }; return applyTheme; diff --git a/src/core/services/theming/theming.spec.js b/src/core/services/theming/theming.spec.js index 492d42f30ee..6d8eeb0e2b4 100644 --- a/src/core/services/theming/theming.spec.js +++ b/src/core/services/theming/theming.spec.js @@ -348,6 +348,10 @@ describe('$mdTheming service', function() { expect(child.hasClass('md-dark-theme')).toBe(false); expect(child.hasClass('md-space-theme')).toBe(true); })); + + it('exposes a getter for the default theme', inject(function($mdTheming) { + expect($mdTheming.defaultTheme()).toBe('default'); + })); }); describe('md-theme directive', function() {