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

Commit

Permalink
refactor(sidenav): BREAKING: change to $media to $mdMedia
Browse files Browse the repository at this point in the history
`$media` in mdSidenav `is-locked-open` is now changed to `$mdMedia`.
`$media` is deprecated and will warn via the console.

closes #1745
  • Loading branch information
rschmukler committed Mar 2, 2015
1 parent 6861bad commit 8afc08d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion docs/config/template/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

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

<md-toolbar>
<h1 class="md-toolbar-tools">
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidenav/demoBasicUsage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<section layout="row" flex>

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

<md-toolbar class="md-theme-indigo">
<h1 class="md-toolbar-tools">Sidenav Left</h1>
Expand Down
13 changes: 7 additions & 6 deletions src/components/sidenav/sidenav.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function SidenavService($mdComponentRegistry, $q) {
* </md-content>
*
* <md-sidenav md-component-id="right"
* md-is-locked-open="$media('min-width: 333px')"
* md-is-locked-open="$mdMedia('min-width: 333px')"
* class="md-sidenav-right">
* Right Nav!
* </md-sidenav>
Expand All @@ -129,15 +129,15 @@ function SidenavService($mdComponentRegistry, $q) {
* the sidenav 'locks open': it falls into the content's flow instead
* of appearing over it. This overrides the `is-open` attribute.
*
* A $media() function is exposed to the is-locked-open attribute, which
* The $mdMedia() service is exposed to the is-locked-open attribute, which
* can be given a media query or one of the `sm`, `gt-sm`, `md`, `gt-md`, `lg` or `gt-lg` presets.
* Examples:
*
* - `<md-sidenav md-is-locked-open="shouldLockOpen"></md-sidenav>`
* - `<md-sidenav md-is-locked-open="$media('min-width: 1000px')"></md-sidenav>`
* - `<md-sidenav md-is-locked-open="$media('sm')"></md-sidenav>` (locks open on small screens)
* - `<md-sidenav md-is-locked-open="$mdMedia('min-width: 1000px')"></md-sidenav>`
* - `<md-sidenav md-is-locked-open="$mdMedia('sm')"></md-sidenav>` (locks open on small screens)
*/
function SidenavDirective($timeout, $animate, $parse, $mdMedia, $mdConstant, $compile, $mdTheming, $q, $document) {
function SidenavDirective($timeout, $animate, $parse, $log, $mdMedia, $mdConstant, $compile, $mdTheming, $q, $document) {
return {
restrict: 'E',
scope: {
Expand All @@ -161,7 +161,8 @@ function SidenavDirective($timeout, $animate, $parse, $mdMedia, $mdConstant, $co
var isLockedOpenParsed = $parse(attr.mdIsLockedOpen);
var isLocked = function() {
return isLockedOpenParsed(scope.$parent, {
$media: $mdMedia
$media: function(arg) { $log.warn("$media is deprecated for is-locked-open. Use $mdMedia instead."); return $mdMedia(arg); },
$mdMedia: $mdMedia
});
};
var backdrop = $compile(
Expand Down
2 changes: 1 addition & 1 deletion src/components/sidenav/sidenav.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('mdSidenav', function() {
$provide.value('$mdMedia', mdMediaSpy);
});
inject(function($rootScope, $animate, $document, $mdMedia) {
var el = setup('md-is-locked-open="$media(123)"');
var el = setup('md-is-locked-open="$mdMedia(123)"');
expect($mdMedia).toHaveBeenCalledWith(123);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/core/util/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ angular.module('material.core')
* @usage
* <hljs lang="js">
* app.controller('MyController', function($mdMedia, $scope) {
* $scope.$watch(function() { return $mdMedia('lg'); } function(big) {
* $scope.$watch(function() { return $mdMedia('lg'); }, function(big) {
* $scope.bigScreen = big;
* });
*
Expand Down

0 comments on commit 8afc08d

Please sign in to comment.