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

Commit 19c2df8

Browse files
EladBezalelThomasBurleson
authored andcommitted
feat(dialog): added fullscreen option to dialog
Added `fullscreen` 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. closes #5793.
1 parent 681a8fb commit 19c2df8

File tree

6 files changed

+37
-7
lines changed

6 files changed

+37
-7
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
@@ -14,11 +14,13 @@
1414
<md-button class="md-primary md-raised" ng-click="showAdvanced($event)" flex-sm="100" flex-md="100" flex-gt-md="auto">
1515
Custom Dialog
1616
</md-button>
17+
<div hide-gt-sm layout="row" layout-align="center center" flex>
18+
<md-checkbox ng-model="customFullscreen" aria-label="Fullscreen Custom Dialog">Custom Dialog Fullscreen</md-checkbox>
19+
</div>
1720
<md-button class="md-primary md-raised" ng-click="showTabDialog($event)" flex-sm="100" flex-md="100" flex-gt-md="auto">
1821
Tab Dialog
1922
</md-button>
2023
</div>
21-
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

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
angular.module('dialogDemo1', ['ngMaterial'])
22

3-
.controller('AppCtrl', function($scope, $mdDialog) {
3+
.controller('AppCtrl', function($scope, $mdDialog, $mdMedia) {
44
$scope.status = ' ';
5+
$scope.customFullscreen = $mdMedia('sm');
56

67
$scope.showAlert = function(ev) {
78
// Appending dialog to document.body to cover sidenav in docs app
@@ -42,13 +43,23 @@ angular.module('dialogDemo1', ['ngMaterial'])
4243
templateUrl: 'dialog1.tmpl.html',
4344
parent: angular.element(document.body),
4445
targetEvent: ev,
45-
clickOutsideToClose:true
46+
clickOutsideToClose:true,
47+
fullscreen: $mdMedia('sm') && $scope.customFullscreen
4648
})
4749
.then(function(answer) {
4850
$scope.status = 'You said the information was "' + answer + '".';
4951
}, function() {
5052
$scope.status = 'You cancelled the dialog.';
5153
});
54+
55+
56+
57+
$scope.$watch(function() {
58+
return $mdMedia('sm');
59+
}, function(sm) {
60+
$scope.customFullscreen = (sm === true);
61+
});
62+
5263
};
5364

5465
$scope.showTabDialog = function(ev) {

src/components/dialog/dialog.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ function MdDialogDirective($$rAF, $mdTheming, $mdDialog) {
391391
* finished.
392392
* - `onRemoving` `{function=}`: Callback function used to announce the close/hide() action is
393393
* starting. This allows developers to run custom animations in parallel the close animations.
394-
*
394+
* - `fullscreen` `{boolean=}`: An option to apply `.md-dialog-fullscreen` class on open.
395395
* @returns {promise} A promise that can be resolved with `$mdDialog.hide()` or
396396
* rejected with `$mdDialog.cancel()`.
397397
*/
@@ -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', 'fullscreen'],
428428
options: dialogDefaultOptions
429429
})
430430
.addPreset('alert', {
@@ -490,6 +490,7 @@ function MdDialogProvider($$interimElementProvider) {
490490
focusOnOpen: true,
491491
disableParentScroll: true,
492492
autoWrap: true,
493+
fullscreen: 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.fullscreen) {
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+
}

src/core/util/media.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ function mdMediaFactory($mdConstant, $rootScope, $window) {
6262
}
6363

6464
function add(query) {
65-
var result = mqls[query] = $window.matchMedia(query);
65+
var result = mqls[query];
66+
if ( !result ) {
67+
result = mqls[query] = $window.matchMedia(query);
68+
}
69+
6670
result.addListener(onQueryChange);
6771
return (results[result.media] = !!result.matches);
6872
}

0 commit comments

Comments
 (0)