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

Commit 95aeadd

Browse files
committed
feat(dialog): added fullscreen option to small screens
Added `smFullscreen` option that if it's set to true `.md-dialog-fullscreen` class is added to `<md-dialog>` that maximizing the dialog to the whole screen. fixes #2148
1 parent b8d3519 commit 95aeadd

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

src/components/dialog/demoBasicUsage/dialog1.tmpl.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h2>Mango (Fruit)</h2>
1010
</div>
1111
</md-toolbar>
1212

13-
<md-dialog-content style="max-width:800px;max-height:810px; ">
13+
<md-dialog-content>
1414
<div class="md-dialog-content">
1515
<h2>Using .md-dialog-content class that sets the padding as the spec</h2>
1616
<p>

src/components/dialog/demoBasicUsage/index.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
Tab Dialog
1919
</md-button>
2020
</div>
21-
21+
<div hide-gt-sm layout="row" layout-align="center center">
22+
<md-checkbox ng-model="customFullscreen" aria-label="Fullscreen Custom Dialog">Custom Dialog Fullscreen</md-checkbox>
23+
</div>
2224
<p class="footer">Note: The <b>Confirm</b> dialog does not use <code>$mdDialog.clickOutsideToClose(true)</code>.</p>
2325

2426
<div ng-if="status">

src/components/dialog/demoBasicUsage/script.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ angular.module('dialogDemo1', ['ngMaterial'])
4242
templateUrl: 'dialog1.tmpl.html',
4343
parent: angular.element(document.body),
4444
targetEvent: ev,
45-
clickOutsideToClose:true
45+
clickOutsideToClose:true,
46+
smFullscreen: $scope.customFullscreen
4647
})
4748
.then(function(answer) {
4849
$scope.status = 'You said the information was "' + answer + '".';

src/components/dialog/dialog.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ function MdDialogProvider($$interimElementProvider) {
424424

425425
return $$interimElementProvider('$mdDialog')
426426
.setDefaults({
427-
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent', 'closeTo', 'openFrom', 'parent'],
427+
methods: ['disableParentScroll', 'hasBackdrop', 'clickOutsideToClose', 'escapeToClose', 'targetEvent', 'closeTo', 'openFrom', 'parent', 'smFullscreen'],
428428
options: dialogDefaultOptions
429429
})
430430
.addPreset('alert', {
@@ -490,6 +490,7 @@ function MdDialogProvider($$interimElementProvider) {
490490
focusOnOpen: true,
491491
disableParentScroll: true,
492492
autoWrap: true,
493+
smFullscreen: false,
493494
transformTemplate: function(template, options) {
494495
return '<div class="md-dialog-container">' + validatedTemplate(template) + '</div>';
495496

@@ -895,6 +896,10 @@ function MdDialogProvider($$interimElementProvider) {
895896
var from = animator.toTransformCss(buildTranslateToOrigin(dialogEl, options.openFrom || options.origin));
896897
var to = animator.toTransformCss(""); // defaults to center display (or parent or $rootElement)
897898

899+
if (options.smFullscreen) {
900+
dialogEl.addClass('md-dialog-fullscreen');
901+
}
902+
898903
return animator
899904
.translate3d(dialogEl, from, to, translateOptions)
900905
.then(function(animateReversal) {

src/components/dialog/dialog.scss

+8
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,11 @@ md-dialog {
119119
border: 1px solid #fff;
120120
}
121121
}
122+
123+
@media (max-width: $layout-breakpoint-sm) {
124+
md-dialog.md-dialog-fullscreen {
125+
min-height: 100%;
126+
min-width: 100%;
127+
border-radius: 0;
128+
}
129+
}

0 commit comments

Comments
 (0)