Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
refactor(sidenav): remove deprecated access to $media in md-is-locked…
Browse files Browse the repository at this point in the history
…-open

- improved layout and position of `$mdMedia` docs section in Sidenav API docs

BREAKING CHANGE: Removed access for the deprecated `$media` service in `md-is-locked-open`. This was deprecated in favor of the `$mdMedia` service. The functionality is the same and only a rename to the current name of the service is required.
  • Loading branch information
Splaktar committed Jul 27, 2020
1 parent e3b52a0 commit baa7563
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
28 changes: 15 additions & 13 deletions src/components/sidenav/sidenav.js
Expand Up @@ -208,18 +208,24 @@ function SidenavService($mdComponentRegistry, $mdUtil, $q, $log) {
* pressing the 'Escape' key will not close the sidenav.
* @param {string=} md-component-id componentId to use with $mdSidenav service.
* @param {expression=} md-is-locked-open When this expression evaluates to true,
* the sidenav 'locks open': it falls into the content's flow instead
* of appearing over it. This overrides the `md-is-open` attribute.
* @param {string=} md-disable-scroll-target Selector, pointing to an element, whose scrolling will
* be disabled when the sidenav is opened. By default this is the sidenav's direct parent.
* the sidenav "locks open": it falls into the content's flow instead of appearing over it. This
* overrides the `md-is-open` attribute.
*
* The $mdMedia() service is exposed to the is-locked-open attribute, which
* The `$mdMedia()` service is exposed to the `md-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:
* <br><br>Examples:
*
* Lock open when `true`:<br>
* `<md-sidenav md-is-locked-open="shouldLockOpen"></md-sidenav>`
*
* Lock open when the width is `1000px` or greater:<br>
* `<md-sidenav md-is-locked-open="$mdMedia('min-width: 1000px')"></md-sidenav>`
*
* - `<md-sidenav md-is-locked-open="shouldLockOpen"></md-sidenav>`
* - `<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)
* Lock open on small screens:<br>
* `<md-sidenav md-is-locked-open="$mdMedia('sm')"></md-sidenav>`
*
* @param {string=} md-disable-scroll-target Selector, pointing to an element, whose scrolling will
* be disabled when the sidenav is opened. By default this is the sidenav's direct parent.
*/
function SidenavDirective($mdMedia, $mdUtil, $mdConstant, $mdTheming, $mdInteraction, $animate,
$compile, $parse, $log, $q, $document, $window, $$rAF) {
Expand Down Expand Up @@ -251,10 +257,6 @@ function SidenavDirective($mdMedia, $mdUtil, $mdConstant, $mdTheming, $mdInterac
var ngWindow = angular.element($window);
var isLocked = function() {
return isLockedOpenParsed(scope.$parent, {
$media: function(arg) {
$log.warn("$media is deprecated for is-locked-open. Use $mdMedia instead.");
return $mdMedia(arg);
},
$mdMedia: $mdMedia
});
};
Expand Down
6 changes: 3 additions & 3 deletions src/components/sidenav/sidenav.spec.js
Expand Up @@ -169,20 +169,20 @@ describe('mdSidenav', function() {
expect(el.parent().find('md-backdrop').hasClass('md-locked-open')).toBe(true);
}));

it('should expose $mdMedia service as $media local in is-locked-open attribute', function() {
it('should expose $mdMedia service as local in is-locked-open attribute', function() {
var mdMediaSpy = jasmine.createSpy('$mdMedia');
module(function($provide) {
$provide.value('$mdMedia', mdMediaSpy);
});
inject(function($rootScope, $animate, $document, $mdMedia) {
var el = setup('md-is-locked-open="$mdMedia(123)"');
setup('md-is-locked-open="$mdMedia(123)"');
expect($mdMedia).toHaveBeenCalledWith(123);
});
});

it('should trigger a resize event when opening',
inject(function($rootScope, $animate, $$rAF, $window) {
var el = setup('md-is-open="show"');
setup('md-is-open="show"');
var obj = { callback: function() {} };

spyOn(obj, 'callback');
Expand Down

0 comments on commit baa7563

Please sign in to comment.