|
21 | 21 |
|
22 | 22 | /** |
23 | 23 | * List of mediaQuery breakpoints and associated suffixes |
24 | | - * |
25 | 24 | * [ |
26 | 25 | * { suffix: "sm", mediaQuery: "screen and (max-width: 599px)" }, |
27 | 26 | * { suffix: "md", mediaQuery: "screen and (min-width: 600px) and (max-width: 959px)" } |
|
55 | 54 | * browsers... mainly IE. |
56 | 55 | * |
57 | 56 | * This module registers directives that allow the same layout attributes to be |
58 | | - * interpreted and converted to class selectors. The directive will add equivalent classes to each element that |
59 | | - * contains a Layout directive. |
| 57 | + * interpreted and converted to class selectors. The directive will add equivalent classes to |
| 58 | + * each element that contains a Layout directive. |
60 | 59 | * |
61 | 60 | * ```html |
62 | 61 | * <div layout="column" class="layout layout-column"> My Content </div> |
63 | | - *``` |
| 62 | + * ``` |
64 | 63 | * |
65 | 64 | * ```css |
66 | 65 | * .layout { |
|
101 | 100 |
|
102 | 101 | // Register other, special directive functions for the Layout features: |
103 | 102 | module |
104 | | - |
105 | | - .provider('$$mdLayout' , function() { |
| 103 | + .provider('$$mdLayout', function() { |
106 | 104 | // Publish internal service for Layouts |
107 | 105 | return { |
108 | 106 | $get : angular.noop, |
|
126 | 124 | .directive('layoutNoWrap' , attributeWithoutValue('layout-no-wrap')) |
127 | 125 | .directive('layoutFill' , attributeWithoutValue('layout-fill')) |
128 | 126 |
|
129 | | - // !! Deprecated attributes: use the `-lt` (aka less-than) notations |
130 | | - |
131 | | - .directive('layoutLtMd' , warnAttrNotSupported('layout-lt-md', true)) |
132 | | - .directive('layoutLtLg' , warnAttrNotSupported('layout-lt-lg', true)) |
133 | | - .directive('flexLtMd' , warnAttrNotSupported('flex-lt-md', true)) |
134 | | - .directive('flexLtLg' , warnAttrNotSupported('flex-lt-lg', true)) |
135 | | - |
136 | | - .directive('layoutAlignLtMd', warnAttrNotSupported('layout-align-lt-md')) |
137 | | - .directive('layoutAlignLtLg', warnAttrNotSupported('layout-align-lt-lg')) |
138 | | - .directive('flexOrderLtMd' , warnAttrNotSupported('flex-order-lt-md')) |
139 | | - .directive('flexOrderLtLg' , warnAttrNotSupported('flex-order-lt-lg')) |
140 | | - .directive('offsetLtMd' , warnAttrNotSupported('flex-offset-lt-md')) |
141 | | - .directive('offsetLtLg' , warnAttrNotSupported('flex-offset-lt-lg')) |
142 | | - |
143 | | - .directive('hideLtMd' , warnAttrNotSupported('hide-lt-md')) |
144 | | - .directive('hideLtLg' , warnAttrNotSupported('hide-lt-lg')) |
145 | | - .directive('showLtMd' , warnAttrNotSupported('show-lt-md')) |
146 | | - .directive('showLtLg' , warnAttrNotSupported('show-lt-lg')) |
147 | | - |
148 | 127 | // Determine if |
149 | 128 | .config(detectDisabledLayouts); |
150 | 129 |
|
|
160 | 139 | return offset ? letter.toUpperCase() : letter; |
161 | 140 | }); |
162 | 141 | } |
163 | | - |
164 | 142 | } |
165 | 143 |
|
166 | 144 |
|
|
169 | 147 | * If yes, then immediately disable all layout API features |
170 | 148 | * |
171 | 149 | * Note: this attribute should be specified on either the HTML or BODY tags |
172 | | - */ |
173 | | - /** |
174 | 150 | * @ngInject |
175 | 151 | */ |
176 | 152 | function detectDisabledLayouts() { |
|
196 | 172 | * |
197 | 173 | * Another option is to use the LayoutProvider to configure and disable the attribute |
198 | 174 | * conversions; this would obviate the use of the `md-layout-css` directive |
199 | | - * |
200 | 175 | */ |
201 | 176 | function disableLayoutDirective() { |
202 | 177 | // Return a 1x-only, first-match attribute directive |
|
239 | 214 |
|
240 | 215 | // ********************************************************************************* |
241 | 216 | // |
242 | | - // These functions create registration functions for AngularJS Material Layout attribute directives |
243 | | - // This provides easy translation to switch AngularJS Material attribute selectors to |
244 | | - // CLASS selectors and directives; which has huge performance implications |
245 | | - // for IE Browsers |
| 217 | + // These functions create registration functions for AngularJS Material Layout attribute |
| 218 | + // directives. This provides easy translation to switch AngularJS Material attribute selectors to |
| 219 | + // CLASS selectors and directives; which has huge performance implications for IE Browsers. |
246 | 220 | // |
247 | 221 | // ********************************************************************************* |
248 | 222 |
|
|
282 | 256 | }]; |
283 | 257 |
|
284 | 258 | /** |
285 | | - * Add as transformed class selector(s), then |
286 | | - * remove the deprecated attribute selector |
| 259 | + * Observe deprecated layout attributes and update the element's layout classes to match. |
287 | 260 | */ |
288 | 261 | function translateWithValueToCssClass(scope, element, attrs) { |
289 | 262 | var updateFn = updateClassWithValue(element, className, attrs); |
|
297 | 270 | /** |
298 | 271 | * Creates a registration function for AngularJS Material Layout attribute directive. |
299 | 272 | * This is a `simple` transpose of attribute usage to class usage; where we ignore |
300 | | - * any attribute value |
| 273 | + * any attribute value. |
301 | 274 | */ |
302 | 275 | function attributeWithoutValue(className) { |
303 | 276 | return ['$mdUtil', '$interpolate', "$log", function(_$mdUtil_, _$interpolate_, _$log_) { |
|
329 | 302 | }]; |
330 | 303 |
|
331 | 304 | /** |
332 | | - * Add as transformed class selector, then |
333 | | - * remove the deprecated attribute selector |
| 305 | + * Add transformed class selector. |
334 | 306 | */ |
335 | 307 | function translateToCssClass(scope, element) { |
336 | 308 | element.addClass(className); |
337 | 309 | } |
338 | 310 | } |
339 | 311 |
|
340 | | - |
341 | | - |
342 | 312 | /** |
343 | 313 | * After link-phase, do NOT remove deprecated layout attribute selector. |
344 | 314 | * Instead watch the attribute so interpolated data-bindings to layout |
|
351 | 321 | * NOTE: The value must match one of the specified styles in the CSS. |
352 | 322 | * For example `flex-gt-md="{{size}}` where `scope.size == 47` will NOT work since |
353 | 323 | * only breakpoints for 0, 5, 10, 15... 100, 33, 34, 66, 67 are defined. |
354 | | - * |
355 | 324 | */ |
356 | 325 | function updateClassWithValue(element, className) { |
357 | 326 | var lastClass; |
|
366 | 335 | }; |
367 | 336 | } |
368 | 337 |
|
369 | | - /** |
370 | | - * Provide console warning that this layout attribute has been deprecated |
371 | | - * |
372 | | - */ |
373 | | - function warnAttrNotSupported(className) { |
374 | | - var parts = className.split("-"); |
375 | | - return ["$log", function($log) { |
376 | | - $log.warn(className + "has been deprecated. Please use a `" + parts[0] + "-gt-<xxx>` variant."); |
377 | | - return angular.noop; |
378 | | - }]; |
379 | | - } |
380 | | - |
381 | 338 | /** |
382 | 339 | * Centralize warnings for known flexbox issues (especially IE-related issues) |
383 | 340 | */ |
|
387 | 344 |
|
388 | 345 | switch (className.replace(SUFFIXES,"")) { |
389 | 346 | case "flex": |
390 | | - if ((nodeName == "md-button") || (nodeName == "fieldset")){ |
| 347 | + if ((nodeName === "md-button") || (nodeName === "fieldset")){ |
391 | 348 | // @see https://github.com/philipwalton/flexbugs#9-some-html-elements-cant-be-flex-containers |
392 | 349 | // Use <div flex> wrapper inside (preferred) or outside |
393 | 350 |
|
|
398 | 355 | $log.warn($mdUtil.supplant(message, [usage, url])); |
399 | 356 | } |
400 | 357 | } |
401 | | - |
402 | 358 | } |
403 | 359 |
|
404 | 360 |
|
405 | 361 | /** |
406 | | - * For the Layout attribute value, validate or replace with default |
407 | | - * fallback value |
| 362 | + * For the Layout attribute value, validate or replace with default fallback value. |
408 | 363 | */ |
409 | 364 | function validateAttributeValue(className, value, updateFn) { |
410 | 365 | var origValue = value; |
|
446 | 401 | break; |
447 | 402 | } |
448 | 403 |
|
449 | | - if (value != origValue) { |
| 404 | + if (value !== origValue) { |
450 | 405 | (updateFn || angular.noop)(value); |
451 | 406 | } |
452 | 407 | } |
|
478 | 433 |
|
479 | 434 | function getNormalizedAttrValue(className, attrs, defaultVal) { |
480 | 435 | var normalizedAttr = attrs.$normalize(className); |
481 | | - return attrs[normalizedAttr] ? attrs[normalizedAttr].trim().replace(WHITESPACE, "-") : defaultVal || null; |
| 436 | + return attrs[normalizedAttr] ? attrs[normalizedAttr].trim().replace(WHITESPACE, "-") : |
| 437 | + defaultVal || null; |
482 | 438 | } |
483 | 439 |
|
484 | 440 | function findIn(item, list, replaceWith) { |
|
521 | 477 |
|
522 | 478 | return axis; |
523 | 479 | } |
524 | | - |
525 | | - |
526 | 480 | })(); |
0 commit comments