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

Commit 8afc08d

Browse files
committed
refactor(sidenav): BREAKING: change to $media to $mdMedia
`$media` in mdSidenav `is-locked-open` is now changed to `$mdMedia`. `$media` is deprecated and will warn via the console. closes #1745
1 parent 6861bad commit 8afc08d

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

docs/config/template/index.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<md-sidenav class="site-sidenav md-sidenav-left md-whiteframe-z2"
2020
md-component-id="left"
21-
md-is-locked-open="$media('gt-sm')">
21+
md-is-locked-open="$mdMedia('gt-sm')">
2222

2323
<md-toolbar>
2424
<h1 class="md-toolbar-tools">

src/components/sidenav/demoBasicUsage/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<section layout="row" flex>
55

6-
<md-sidenav class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="$media('gt-md')">
6+
<md-sidenav class="md-sidenav-left md-whiteframe-z2" md-component-id="left" md-is-locked-open="$mdMedia('gt-md')">
77

88
<md-toolbar class="md-theme-indigo">
99
<h1 class="md-toolbar-tools">Sidenav Left</h1>

src/components/sidenav/sidenav.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function SidenavService($mdComponentRegistry, $q) {
107107
* </md-content>
108108
*
109109
* <md-sidenav md-component-id="right"
110-
* md-is-locked-open="$media('min-width: 333px')"
110+
* md-is-locked-open="$mdMedia('min-width: 333px')"
111111
* class="md-sidenav-right">
112112
* Right Nav!
113113
* </md-sidenav>
@@ -129,15 +129,15 @@ function SidenavService($mdComponentRegistry, $q) {
129129
* the sidenav 'locks open': it falls into the content's flow instead
130130
* of appearing over it. This overrides the `is-open` attribute.
131131
*
132-
* A $media() function is exposed to the is-locked-open attribute, which
132+
* The $mdMedia() service is exposed to the is-locked-open attribute, which
133133
* can be given a media query or one of the `sm`, `gt-sm`, `md`, `gt-md`, `lg` or `gt-lg` presets.
134134
* Examples:
135135
*
136136
* - `<md-sidenav md-is-locked-open="shouldLockOpen"></md-sidenav>`
137-
* - `<md-sidenav md-is-locked-open="$media('min-width: 1000px')"></md-sidenav>`
138-
* - `<md-sidenav md-is-locked-open="$media('sm')"></md-sidenav>` (locks open on small screens)
137+
* - `<md-sidenav md-is-locked-open="$mdMedia('min-width: 1000px')"></md-sidenav>`
138+
* - `<md-sidenav md-is-locked-open="$mdMedia('sm')"></md-sidenav>` (locks open on small screens)
139139
*/
140-
function SidenavDirective($timeout, $animate, $parse, $mdMedia, $mdConstant, $compile, $mdTheming, $q, $document) {
140+
function SidenavDirective($timeout, $animate, $parse, $log, $mdMedia, $mdConstant, $compile, $mdTheming, $q, $document) {
141141
return {
142142
restrict: 'E',
143143
scope: {
@@ -161,7 +161,8 @@ function SidenavDirective($timeout, $animate, $parse, $mdMedia, $mdConstant, $co
161161
var isLockedOpenParsed = $parse(attr.mdIsLockedOpen);
162162
var isLocked = function() {
163163
return isLockedOpenParsed(scope.$parent, {
164-
$media: $mdMedia
164+
$media: function(arg) { $log.warn("$media is deprecated for is-locked-open. Use $mdMedia instead."); return $mdMedia(arg); },
165+
$mdMedia: $mdMedia
165166
});
166167
};
167168
var backdrop = $compile(

src/components/sidenav/sidenav.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('mdSidenav', function() {
7777
$provide.value('$mdMedia', mdMediaSpy);
7878
});
7979
inject(function($rootScope, $animate, $document, $mdMedia) {
80-
var el = setup('md-is-locked-open="$media(123)"');
80+
var el = setup('md-is-locked-open="$mdMedia(123)"');
8181
expect($mdMedia).toHaveBeenCalledWith(123);
8282
});
8383
});

src/core/util/media.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ angular.module('material.core')
2121
* @usage
2222
* <hljs lang="js">
2323
* app.controller('MyController', function($mdMedia, $scope) {
24-
* $scope.$watch(function() { return $mdMedia('lg'); } function(big) {
24+
* $scope.$watch(function() { return $mdMedia('lg'); }, function(big) {
2525
* $scope.bigScreen = big;
2626
* });
2727
*

0 commit comments

Comments
 (0)