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

Commit 663b5ca

Browse files
rschmuklerrobertmesserle
authored andcommitted
refactor(): use strict, consolidate material.core, interimElement chaining
Closes #643. Closes #650. Closes #597. Closes #596. Closes #525.
1 parent d231ef2 commit 663b5ca

File tree

8 files changed

+123
-162
lines changed

8 files changed

+123
-162
lines changed

src/components/animate/_effects.scss

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/components/progressLinear/progressLinear.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@ angular.module('material.components.progressLinear', [
2525
*
2626
* For operations where the user is asked to wait a moment while something finishes up, and it’s not necessary to expose what's happening behind the scenes and how long it will take, use an indeterminate indicator.
2727
*
28-
* @param {string} mdMode Select from one of four modes: determinate, indeterminate, buffer or query.
28+
* @param {string} mode Select from one of four modes: determinate, indeterminate, buffer or query.
2929
* @param {number=} value In determinate and buffer modes, this number represents the percentage of the primary progress bar. Default: 0
30-
* @param {number=} mdBufferValue In the buffer mode, this number represents the precentage of the secondary progress bar. Default: 0
30+
* @param {number=} secondaryValue In the buffer mode, this number represents the precentage of the secondary progress bar. Default: 0
3131
*
3232
* @usage
3333
* <hljs lang="html">
34-
* <md-progress-linear md-mode="determinate" value="..."></md-progress-linear>
34+
* <md-progress-linear mode="determinate" value="..."></md-progress-linear>
3535
*
36-
* <md-progress-linear md-mode="determinate" ng-value="..."></md-progress-linear>
36+
* <md-progress-linear mode="determinate" ng-value="..."></md-progress-linear>
3737
*
38-
* <md-progress-linear md-mode="indeterminate"></md-progress-linear>
38+
* <md-progress-linear mode="indeterminate"></md-progress-linear>
3939
*
40-
* <md-progress-linear md-mode="buffer" value="..." md-buffer-value="..."></md-progress-linear>
40+
* <md-progress-linear mode="buffer" value="..." secondaryValue="..."></md-progress-linear>
4141
*
42-
* <md-progress-linear md-mode="query"></md-progress-linear>
42+
* <md-progress-linear mode="query"></md-progress-linear>
4343
* </hljs>
4444
*/
4545
function MdProgressLinearDirective($$rAF, $mdConstant, $mdTheming) {
@@ -68,7 +68,7 @@ function MdProgressLinearDirective($$rAF, $mdConstant, $mdTheming) {
6868
container = angular.element(element[0].querySelector('.md-container'));
6969

7070
attr.$observe('value', function(value) {
71-
if (attr.mdMode == 'query') {
71+
if (attr.mode == 'query') {
7272
return;
7373
}
7474

@@ -77,7 +77,7 @@ function MdProgressLinearDirective($$rAF, $mdConstant, $mdTheming) {
7777
bar2Style[$mdConstant.CSS.TRANSFORM] = transforms[clamped];
7878
});
7979

80-
attr.$observe('mdBufferValue', function(value) {
80+
attr.$observe('secondaryvalue', function(value) {
8181
bar1Style[$mdConstant.CSS.TRANSFORM] = transforms[clamp(value)];
8282
});
8383

src/components/progressLinear/progressLinear.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ describe('mdProgressLinear', function() {
3333
expect(progress.eq(0).attr('aria-valuenow')).toEqual('50');
3434
}));
3535

36-
it('should set transform based on buffer value', inject(function($compile, $rootScope, $mdConstant) {
36+
it('should set transform based on secondaryvalue', inject(function($compile, $rootScope, $mdConstant) {
3737
var element = $compile('<div>' +
38-
'<md-progress-linear value="{{progress}}" md-buffer-value="{{progress2}}">' +
38+
'<md-progress-linear value="{{progress}}" secondaryvalue="{{progress2}}">' +
3939
'</md-progress-linear>' +
4040
'</div>')($rootScope);
4141

@@ -52,7 +52,7 @@ describe('mdProgressLinear', function() {
5252

5353
it('should not set transform in query mode', inject(function($compile, $rootScope, $mdConstant) {
5454
var element = $compile('<div>' +
55-
'<md-progress-linear md-mode="query" value="{{progress}}">' +
55+
'<md-progress-linear mode="query" value="{{progress}}">' +
5656
'</md-progress-linear>' +
5757
'</div>')($rootScope);
5858

src/components/sidenav/sidenav.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function mdSidenavController($scope, $element, $attrs, $timeout, $mdSidenav, $md
3131

3232
var self = this;
3333

34-
this.destroy = $mdComponentRegistry.register(this, $attrs.mdComponentId);
34+
this.destroy = $mdComponentRegistry.register(this, $attrs.componentId);
3535

3636
this.isOpen = function() {
3737
return !!$scope.isOpen;
@@ -109,7 +109,7 @@ function mdSidenavService($mdComponentRegistry) {
109109
* @usage
110110
* <hljs lang="html">
111111
* <div layout="horizontal" ng-controller="MyController">
112-
* <md-sidenav md-component-id="left" class="md-sidenav-left">
112+
* <md-sidenav component-id="left" class="md-sidenav-left">
113113
* Left Nav!
114114
* </md-sidenav>
115115
*
@@ -120,8 +120,8 @@ function mdSidenavService($mdComponentRegistry) {
120120
* </md-button>
121121
* </md-content>
122122
*
123-
* <md-sidenav md-component-id="right"
124-
* md-is-locked-open="$media('min-width: 333px')"
123+
* <md-sidenav component-id="right"
124+
* is-locked-open="$media('min-width: 333px')"
125125
* class="md-sidenav-right">
126126
* Right Nav!
127127
* </md-sidenav>
@@ -137,25 +137,25 @@ function mdSidenavService($mdComponentRegistry) {
137137
* });
138138
* </hljs>
139139
*
140-
* @param {expression=} mdIsOpen A model bound to whether the sidenav is opened.
141-
* @param {string=} mdComponentId componentId to use with $mdSidenav service.
142-
* @param {expression=} mdIsLockedOpen When this expression evalutes to true,
140+
* @param {expression=} is-open A model bound to whether the sidenav is opened.
141+
* @param {string=} component-id componentId to use with $mdSidenav service.
142+
* @param {expression=} is-locked-open When this expression evalutes to true,
143143
* the sidenav 'locks open': it falls into the content's flow instead
144144
* of appearing over it. This overrides the `is-open` attribute.
145145
*
146146
* A $media() function is exposed to the is-locked-open attribute, which
147147
* can be given a media query or one of the `sm`, `md` or `lg` presets.
148148
* Examples:
149149
*
150-
* - `<md-sidenav md-is-locked-open="shouldLockOpen"></md-sidenav>`
151-
* - `<md-sidenav md-is-locked-open="$media('min-width: 1000px')"></md-sidenav>`
152-
* - `<md-sidenav md-is-locked-open="$media('sm')"></md-sidenav>` <!-- locks open on small screens !-->
150+
* - `<md-sidenav is-locked-open="shouldLockOpen"></md-sidenav>`
151+
* - `<md-sidenav is-locked-open="$media('min-width: 1000px')"></md-sidenav>`
152+
* - `<md-sidenav is-locked-open="$media('sm')"></md-sidenav>` <!-- locks open on small screens !-->
153153
*/
154154
function mdSidenavDirective($timeout, $animate, $parse, $mdMedia, $mdConstant, $compile, $mdTheming) {
155155
return {
156156
restrict: 'E',
157157
scope: {
158-
isOpen: '=?mdIsOpen'
158+
isOpen: '=?'
159159
},
160160
controller: '$mdSidenavController',
161161
compile: function(element) {
@@ -166,7 +166,7 @@ function mdSidenavDirective($timeout, $animate, $parse, $mdMedia, $mdConstant, $
166166
};
167167

168168
function postLink(scope, element, attr, sidenavCtrl) {
169-
var isLockedOpenParsed = $parse(attr.mdIsLockedOpen);
169+
var isLockedOpenParsed = $parse(attr.isLockedOpen);
170170
var backdrop = $compile(
171171
'<md-backdrop class="md-sidenav-backdrop md-opaque">'
172172
)(scope);
@@ -270,7 +270,7 @@ function mdMediaFactory($window, $mdUtil, $timeout) {
270270
function add(query) {
271271
return cache.put(query, !!$window.matchMedia(query).matches);
272272
}
273-
273+
274274
function updateAll() {
275275
var keys = cache.keys();
276276
if (keys.length) {
@@ -283,7 +283,7 @@ function mdMediaFactory($window, $mdUtil, $timeout) {
283283
}
284284

285285
}
286-
286+
287287
function mdComponentRegistry($log) {
288288
var instances = [];
289289

src/components/slider/slider.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ angular.module('material.components.slider', [
2323
* of values, and 'discrete' mode, where the user slides between only a few
2424
* select values.
2525
*
26-
* To enable discrete mode, add the `md-discrete` attribute to a slider,
26+
* To enable discrete mode, add the `discrete` attribute to a slider,
2727
* and use the `step` attribute to change the distance between
2828
* values the user is allowed to pick.
2929
*
@@ -35,11 +35,11 @@ angular.module('material.components.slider', [
3535
* </hljs>
3636
* <h4>Discrete Mode</h4>
3737
* <hljs lang="html">
38-
* <md-slider md-discrete ng-model="myDiscreteValue" step="10" min="10" max="130">
38+
* <md-slider discrete ng-model="myDiscreteValue" step="10" min="10" max="130">
3939
* </md-slider>
4040
* </hljs>
4141
*
42-
* @param {boolean=} mdDiscrete Whether to enable discrete mode.
42+
* @param {boolean=} discrete Whether to enable discrete mode.
4343
* @param {number=} step The distance between values the user is allowed to pick. Default 1.
4444
* @param {number=} min The minimum value the user is allowed to pick. Default 0.
4545
* @param {number=} max The maximum value the user is allowed to pick. Default 100.
@@ -180,7 +180,7 @@ function SliderController($scope, $element, $attrs, $$rAF, $window, $mdAria, $md
180180
// which could quickly become a performance bottleneck.
181181
var tickCanvas, tickCtx;
182182
function redrawTicks() {
183-
if (!angular.isDefined($attrs.mdDiscrete)) return;
183+
if (!angular.isDefined($attrs.discrete)) return;
184184

185185
var numSteps = Math.floor( (max - min) / step );
186186
if (!tickCanvas) {
@@ -286,7 +286,7 @@ function SliderController($scope, $element, $attrs, $$rAF, $window, $mdAria, $md
286286
* Slide listeners
287287
*/
288288
var isSliding = false;
289-
var isDiscrete = angular.isDefined($attrs.mdDiscrete);
289+
var isDiscrete = angular.isDefined($attrs.discrete);
290290

291291
function onInput(ev) {
292292
if (!isSliding && ev.eventType === Hammer.INPUT_START &&

src/components/swipe/swipe.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function MdSwipeFactory() {
118118
* HammerJS horizontal swipe left and pan left support will be active. The swipe/pan action
119119
* can result in custom activity trigger by evaluating `expression`.
120120
*
121-
* @param {boolean=} mdNoPan Use of attribute indicates flag to disable detection of `panleft` activity
121+
* @param {boolean=} noPan Use of attribute indicates flag to disable detection of `panleft` activity
122122
*
123123
* @usage
124124
* <hljs lang="html">
@@ -151,7 +151,7 @@ function MdSwipeLeftDirective($parse, $mdSwipe) {
151151
* that attaches HammerJS horizontal swipe right and pan right support to an element. The swipe/pan action
152152
* can result in activity trigger by evaluating `expression`
153153
*
154-
* @param {boolean=} mdNoPan Use of attribute indicates flag to disable detection of `panright` activity
154+
* @param {boolean=} noPan Use of attribute indicates flag to disable detection of `panright` activity
155155
*
156156
* @usage
157157
* <hljs lang="html">

src/components/toolbar/toolbar.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@ angular.module('material.components.toolbar', [
4848
* </div>
4949
* </hljs>
5050
*
51-
* @param {boolean=} mdScrollShrink Whether the header should shrink away as
52-
* the user scrolls down, and reveal itself as the user scrolls up.
53-
* Note: for scrollShrink to work, the toolbar must be a sibling of a
51+
* @param {boolean=} scrollShrink Whether the header should shrink away as
52+
* the user scrolls down, and reveal itself as the user scrolls up.
53+
* Note: for scrollShrink to work, the toolbar must be a sibling of a
5454
* `md-content` element, placed before it. See the scroll shrink demo.
5555
*
5656
*
57-
* @param {number=} mdShrinkSpeedFactor How much to change the speed of the toolbar's
57+
* @param {number=} shrinkSpeedFactor How much to change the speed of the toolbar's
5858
* shrinking by. For example, if 0.25 is given then the toolbar will shrink
5959
* at one fourth the rate at which the user scrolls down. Default 0.5.
60-
*/
60+
*/
6161
function mdToolbarDirective($$rAF, $mdConstant, $mdUtil, $mdTheming) {
6262

6363
return {
@@ -66,7 +66,7 @@ function mdToolbarDirective($$rAF, $mdConstant, $mdUtil, $mdTheming) {
6666
link: function(scope, element, attr) {
6767
$mdTheming(element);
6868

69-
if (angular.isDefined(attr.mdScrollShrink)) {
69+
if (angular.isDefined(attr.scrollShrink)) {
7070
setupScrollShrink();
7171
}
7272

@@ -76,7 +76,7 @@ function mdToolbarDirective($$rAF, $mdConstant, $mdUtil, $mdTheming) {
7676
// Store the last scroll top position
7777
var prevScrollTop = 0;
7878

79-
var shrinkSpeedFactor = attr.mdShrinkSpeedFactor || 0.5;
79+
var shrinkSpeedFactor = attr.shrinkSpeedFactor || 0.5;
8080

8181
var toolbarHeight;
8282
var contentElement;
@@ -114,7 +114,7 @@ function mdToolbarDirective($$rAF, $mdConstant, $mdUtil, $mdTheming) {
114114
// As the user scrolls down, the content will be transformed up slowly
115115
// to put the content underneath where the toolbar was.
116116
contentElement.css(
117-
'margin-top',
117+
'margin-top',
118118
(-toolbarHeight * shrinkSpeedFactor) + 'px'
119119
);
120120
onContentScroll();
@@ -126,16 +126,16 @@ function mdToolbarDirective($$rAF, $mdConstant, $mdUtil, $mdTheming) {
126126
debouncedUpdateHeight();
127127

128128
y = Math.min(
129-
toolbarHeight / shrinkSpeedFactor,
129+
toolbarHeight / shrinkSpeedFactor,
130130
Math.max(0, y + scrollTop - prevScrollTop)
131131
);
132132

133133
element.css(
134-
$mdConstant.CSS.TRANSFORM,
134+
$mdConstant.CSS.TRANSFORM,
135135
'translate3d(0,' + (-y * shrinkSpeedFactor) + 'px,0)'
136136
);
137137
contentElement.css(
138-
$mdConstant.CSS.TRANSFORM,
138+
$mdConstant.CSS.TRANSFORM,
139139
'translate3d(0,' + ((toolbarHeight - y) * shrinkSpeedFactor) + 'px,0)'
140140
);
141141

0 commit comments

Comments
 (0)