diff --git a/modules/angular2/src/facade/browser.dart b/modules/angular2/src/facade/browser.dart index db3ff02cd4..adf287a47d 100644 --- a/modules/angular2/src/facade/browser.dart +++ b/modules/angular2/src/facade/browser.dart @@ -11,7 +11,9 @@ export 'dart:html' show location, window, Element, - Node; + Node, + KeyboardEvent, + Event; final _gc = context['gc']; diff --git a/modules/angular2_material/src/components/checkbox/checkbox.js b/modules/angular2_material/src/components/checkbox/checkbox.js index dcd27a5079..2cecb7f31f 100644 --- a/modules/angular2_material/src/components/checkbox/checkbox.js +++ b/modules/angular2_material/src/components/checkbox/checkbox.js @@ -1,6 +1,7 @@ import {Component, View, Attribute, PropertySetter} from 'angular2/angular2'; import {isPresent} from 'angular2/src/facade/lang'; -import {KeyCodes} from 'angular2_material/src/core/constants' +import {KEY_SPACE} from 'angular2_material/src/core/constants' +import {KeyboardEvent} from 'angular2/src/facade/browser'; @Component({ selector: 'md-checkbox', @@ -20,6 +21,9 @@ export class MdCheckbox { /** Whether this checkbox is checked. */ checked_: boolean; + /** Whether this checkbox is disabled. */ + disabled_: boolean; + /** Setter for `aria-checked` attribute. */ ariaCheckedSetter: Function; @@ -59,7 +63,7 @@ export class MdCheckbox { } onKeydown(event: KeyboardEvent) { - if (event.keyCode == KeyCodes.SPACE) { + if (event.keyCode == KEY_SPACE) { event.preventDefault(); this.toggle(event); } diff --git a/modules/angular2_material/src/components/grid_list/grid_list.js b/modules/angular2_material/src/components/grid_list/grid_list.js index d8ab4d6b5b..71e7affab6 100644 --- a/modules/angular2_material/src/components/grid_list/grid_list.js +++ b/modules/angular2_material/src/components/grid_list/grid_list.js @@ -1,8 +1,7 @@ import {Component, View, onAllChangesDone, Parent} from 'angular2/angular2'; import {onDestroy, onChange} from 'angular2/src/core/annotations/annotations'; import {ListWrapper} from 'angular2/src/facade/collection'; -import {CONST} from 'angular2/src/facade/lang'; -import {isPresent, isString, NumberWrapper} from 'angular2/src/facade/lang'; +import {isPresent, isString, NumberWrapper, stringify} from 'angular2/src/facade/lang'; import {PropertySetter} from 'angular2/src/core/annotations/di'; // TODO(jelbourn): Set appropriate aria attributes for grid list elements. @@ -20,7 +19,7 @@ import {PropertySetter} from 'angular2/src/core/annotations/di'; }) export class MdGridList { /** List of tiles that are being rendered. */ - tiles: Array; + tiles: List; /** Number of columns being rendered. Can be either string or number */ cols; @@ -37,8 +36,8 @@ export class MdGridList { /** The amount of space between tiles. This will be something like '5px' or '2em'. */ gutterSize: string; - /** Array used to track the amount of space available. */ - spaceTracker: Array; + /** List used to track the amount of space available. */ + spaceTracker: List; constructor() { this.tiles = []; @@ -144,8 +143,8 @@ export class MdGridList { switch (this.rowHeightMode) { case 'fixed': // In fixed mode, simply use the given row height. - tileStyle.top = getTilePosition(this.fixedRowHeight, rowIndex); - tileStyle.height = getTileSize(this.fixedRowHeight, tile.rowspan); + tileStyle.top = getTilePosition(stringify(this.fixedRowHeight), rowIndex); + tileStyle.height = getTileSize(stringify(this.fixedRowHeight), tile.rowspan); break; case 'ratio': @@ -160,8 +159,6 @@ export class MdGridList { break; case 'fit': - var percentHeightPerTile; - break; } diff --git a/modules/angular2_material/src/components/input/input.js b/modules/angular2_material/src/components/input/input.js index 17dbd3e1fc..7c18377d69 100644 --- a/modules/angular2_material/src/components/input/input.js +++ b/modules/angular2_material/src/components/input/input.js @@ -1,5 +1,4 @@ import {Decorator} from 'angular2/angular2'; -import {PropertySetter} from 'angular2/src/core/annotations/di'; @Decorator({ selector: 'md-input-container input' diff --git a/modules/angular2_material/src/components/progress-circular/progress_circular.js b/modules/angular2_material/src/components/progress-circular/progress_circular.js index 00e0abcb4a..5cfc2044d9 100644 --- a/modules/angular2_material/src/components/progress-circular/progress_circular.js +++ b/modules/angular2_material/src/components/progress-circular/progress_circular.js @@ -1,6 +1,4 @@ import {Component, View} from 'angular2/angular2'; -import {isPresent} from 'angular2/src/facade/lang'; - @Component({ selector: 'md-progress-circular' diff --git a/modules/angular2_material/src/components/radio/radio_button.js b/modules/angular2_material/src/components/radio/radio_button.js index 379cd1f32e..cf96e01589 100644 --- a/modules/angular2_material/src/components/radio/radio_button.js +++ b/modules/angular2_material/src/components/radio/radio_button.js @@ -1,12 +1,12 @@ import {Component, View, Parent, Ancestor, Attribute, PropertySetter} from 'angular2/angular2'; import {Optional} from 'angular2/src/di/annotations'; import {MdRadioDispatcher} from 'angular2_material/src/components/radio/radio_dispatcher' -import {MdTheme} from 'angular2_material/src/core/theme' import {onChange} from 'angular2/src/core/annotations/annotations'; import {isPresent, StringWrapper} from 'angular2/src/facade/lang'; import {ObservableWrapper, EventEmitter} from 'angular2/src/facade/async'; -import {Math} from 'angular2/src/facade/math'; import {ListWrapper} from 'angular2/src/facade/collection'; +import {KEY_UP, KEY_DOWN, KEY_SPACE} from 'angular2_material/src/core/constants' +import {Event, KeyboardEvent} from 'angular2/src/facade/browser'; // TODO(jelbourn): Behaviors to test // Disabled radio don't select @@ -159,14 +159,14 @@ export class MdRadioButton { this.checked = true; - if (this.radioGroup) { + if (isPresent(this.radioGroup)) { this.radioGroup.updateValue(this.value, this.id); } } /** Handles pressing the space key to select this focused radio button. */ onKeydown(event: KeyboardEvent) { - if (event.keyCode == KeyCodes.SPACE) { + if (event.keyCode == KEY_SPACE) { event.preventDefault(); this.select(event); } @@ -293,13 +293,11 @@ export class MdRadioGroup { } switch (event.keyCode) { - //case KeyCodes.UP: - case 38: + case KEY_UP: this.stepSelectedRadio(-1); event.preventDefault(); break; - //case KeyCodes.DOWN: - case 40: + case KEY_DOWN: this.stepSelectedRadio(1); event.preventDefault(); break; diff --git a/modules/angular2_material/src/components/radio/radio_dispatcher.js b/modules/angular2_material/src/components/radio/radio_dispatcher.js index 0f77ef3500..5b766d9e0a 100644 --- a/modules/angular2_material/src/components/radio/radio_dispatcher.js +++ b/modules/angular2_material/src/components/radio/radio_dispatcher.js @@ -1,4 +1,4 @@ -import {ListWrapper} from 'angular2/src/facade/collection'; +import {List, ListWrapper} from 'angular2/src/facade/collection'; /** * Class for radio buttons to coordinate unique selection based on name. @@ -6,7 +6,7 @@ import {ListWrapper} from 'angular2/src/facade/collection'; */ export class MdRadioDispatcher { // TODO(jelbourn): Change this to TypeScript syntax when supported. - listeners_: Array; + listeners_: List; constructor() { this.listeners_ = []; diff --git a/modules/angular2_material/src/components/switcher/switch.js b/modules/angular2_material/src/components/switcher/switch.js index 96f01d8ab8..8e5cc27fef 100644 --- a/modules/angular2_material/src/components/switcher/switch.js +++ b/modules/angular2_material/src/components/switcher/switch.js @@ -1,6 +1,7 @@ import {Component, View, Attribute, PropertySetter} from 'angular2/angular2'; import {isPresent} from 'angular2/src/facade/lang'; -import {KeyCodes} from 'angular2_material/src/core/constants' +import {KEY_SPACE} from 'angular2_material/src/core/constants' +import {KeyboardEvent} from 'angular2/src/facade/browser'; // TODO(jelbourn): without gesture support, this is identical to MdCheckbox. @@ -22,6 +23,9 @@ export class MdSwitch { /** Whether this switch is checked. */ checked_: boolean; + /** Whether this switch is disabled. */ + disabled_: boolean; + /** Setter for `aria-checked` attribute. */ ariaCheckedSetter: Function; @@ -61,7 +65,7 @@ export class MdSwitch { } onKeydown(event: KeyboardEvent) { - if (event.keyCode == KeyCodes.SPACE) { + if (event.keyCode == KEY_SPACE) { event.preventDefault(); this.toggle(event); } diff --git a/modules/angular2_material/src/core/constants.js b/modules/angular2_material/src/core/constants.js index 4ff33039ad..6b724f074b 100644 --- a/modules/angular2_material/src/core/constants.js +++ b/modules/angular2_material/src/core/constants.js @@ -1,8 +1,6 @@ +// TODO: switch to proper enums when we support them. -// TODO: this is not how TS&Dart enums are defined and it definitely won't -// work in Dart. Switch to proper enums when we support them. -//export var KeyCodes = { -// SPACE: 32, -// UP: 38, -// DOWN: 40 -//}; +// Key codes +export const KEY_SPACE = 32; +export const KEY_UP = 38; +export const KEY_DOWN = 40; diff --git a/tools/build/dartanalyzer.js b/tools/build/dartanalyzer.js index 144d018f9b..24c1cc16f9 100644 --- a/tools/build/dartanalyzer.js +++ b/tools/build/dartanalyzer.js @@ -34,7 +34,7 @@ module.exports = function(gulp, plugins, config) { function analyze(dirName, done) { // analyze files in lib directly – or you mess up package: urls - var sources = [].slice.call(glob.sync('lib/*.dart', { + var sources = [].slice.call(glob.sync('lib/**/*.dart', { cwd: dirName }));