Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | |
| 6 * @typedef {?{ | |
| 7 * mute: string, | |
| 8 * next: string, | |
| 9 * pause: string, | |
| 10 * play: string, | |
| 11 * playList: string, | |
| 12 * previous: string, | |
| 13 * repeat: string, | |
| 14 * seekSlider: string, | |
| 15 * shuffle: string, | |
| 16 * unmute: string, | |
| 17 * volume: string, | |
| 18 * volumeSlider: string, | |
| 19 * }} | |
| 20 */ | |
| 21 var AriaLabels; | |
| 22 | |
| 5 (function() { | 23 (function() { |
| 6 'use strict'; | 24 'use strict'; |
| 7 | 25 |
| 8 /** | 26 /** |
| 9 * Moves |target| element above |anchor| element, in order to match the | 27 * Moves |target| element above |anchor| element, in order to match the |
| 10 * bottom lines. | 28 * bottom lines. |
| 11 * @param {HTMLElement} target Target element. | 29 * @param {HTMLElement} target Target element. |
| 12 * @param {HTMLElement} anchor Anchor element. | 30 * @param {HTMLElement} anchor Anchor element. |
| 13 */ | 31 */ |
| 14 function matchBottomLine(target, anchor) { | 32 function matchBottomLine(target, anchor) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 dragging: { | 130 dragging: { |
| 113 type: Boolean, | 131 type: Boolean, |
| 114 value: false, | 132 value: false, |
| 115 notify: true | 133 notify: true |
| 116 }, | 134 }, |
| 117 | 135 |
| 118 /** | 136 /** |
| 119 * Dictionary which contains aria-labels for each controls. | 137 * Dictionary which contains aria-labels for each controls. |
| 120 */ | 138 */ |
| 121 ariaLabels: { | 139 ariaLabels: { |
| 122 type: Object, | 140 type: Object, |
|
oka
2016/12/26 10:33:12
Why don't you update Obejct to AriaLabels?
Then yo
fukino
2016/12/26 11:32:22
Done. Adding annotation for ariaLabels worked. Tha
| |
| 123 observer: 'ariaLabelsChanged_' | 141 observer: 'ariaLabelsChanged_' |
| 124 } | 142 } |
| 125 }, | 143 }, |
| 126 | 144 |
| 127 /** | 145 /** |
| 128 * Initializes an element. This method is called automatically when the | 146 * Initializes an element. This method is called automatically when the |
| 129 * element is ready. | 147 * element is ready. |
| 130 */ | 148 */ |
| 131 ready: function() { | 149 ready: function() { |
| 132 var timeSlider = /** @type {PaperSliderElement} */ (this.$.timeSlider); | 150 var timeSlider = /** @type {PaperSliderElement} */ (this.$.timeSlider); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 /** | 290 /** |
| 273 * Invoked when the volume property is changed. | 291 * Invoked when the volume property is changed. |
| 274 * @param {number} volume | 292 * @param {number} volume |
| 275 * @private | 293 * @private |
| 276 */ | 294 */ |
| 277 volumeChanged_: function(volume) { | 295 volumeChanged_: function(volume) { |
| 278 if (!this.$.volumeSlider.dragging) | 296 if (!this.$.volumeSlider.dragging) |
| 279 this.$.volumeSlider.value = volume; | 297 this.$.volumeSlider.value = volume; |
| 280 | 298 |
| 281 if (this.ariaLabels) { | 299 if (this.ariaLabels) { |
| 300 this.ariaLabels = /** @type {!AriaLabels} */ (this.ariaLabels); | |
| 282 this.$.volumeButton.setAttribute('aria-label', | 301 this.$.volumeButton.setAttribute('aria-label', |
| 283 volume !== 0 ? this.ariaLabels.mute : this.ariaLabels.unmute); | 302 volume !== 0 ? this.ariaLabels.mute : this.ariaLabels.unmute); |
| 284 } | 303 } |
| 285 }, | 304 }, |
| 286 | 305 |
| 287 /** | 306 /** |
| 288 * Invoked when the ariaLabels property is changed. | 307 * Invoked when the ariaLabels property is changed. |
| 289 * @param {Object} ariaLabels | 308 * @param {Object} ariaLabels |
| 290 * @private | 309 * @private |
| 291 */ | 310 */ |
| 292 ariaLabelsChanged_: function(ariaLabels) { | 311 ariaLabelsChanged_: function(ariaLabels) { |
| 293 assert(ariaLabels); | 312 assert(ariaLabels); |
| 313 ariaLabels = /** @type {!AriaLabels} */ (ariaLabels); | |
| 294 // TODO(fukino): Use data bindings. | 314 // TODO(fukino): Use data bindings. |
| 295 this.$.volumeSlider.setAttribute('aria-label', ariaLabels.volumeSlider); | 315 this.$.volumeSlider.setAttribute('aria-label', ariaLabels.volumeSlider); |
| 296 this.$.shuffle.setAttribute('aria-label', ariaLabels.shuffle); | 316 this.$.shuffle.setAttribute('aria-label', ariaLabels.shuffle); |
| 297 this.$.repeat.setAttribute('aria-label', ariaLabels.repeat); | 317 this.$.repeat.setAttribute('aria-label', ariaLabels.repeat); |
| 298 this.$.previous.setAttribute('aria-label', ariaLabels.previous); | 318 this.$.previous.setAttribute('aria-label', ariaLabels.previous); |
| 299 this.$.play.setAttribute('aria-label', | 319 this.$.play.setAttribute('aria-label', |
| 300 this.playing ? ariaLabels.pause : ariaLabels.play); | 320 this.playing ? ariaLabels.pause : ariaLabels.play); |
| 301 this.$.next.setAttribute('aria-label', ariaLabels.next); | 321 this.$.next.setAttribute('aria-label', ariaLabels.next); |
| 302 this.$.volumeButton.setAttribute('aria-label', ariaLabels.volume); | 322 this.$.volumeButton.setAttribute('aria-label', ariaLabels.volume); |
| 303 this.$.playList.setAttribute('aria-label', ariaLabels.playList); | 323 this.$.playList.setAttribute('aria-label', ariaLabels.playList); |
| 304 this.$.timeSlider.setAttribute('aria-label', ariaLabels.seekSlider); | 324 this.$.timeSlider.setAttribute('aria-label', ariaLabels.seekSlider); |
| 305 this.$.volumeButton.setAttribute('aria-label', | 325 this.$.volumeButton.setAttribute('aria-label', |
| 306 this.volume !== 0 ? ariaLabels.mute : ariaLabels.unmute); | 326 this.volume !== 0 ? ariaLabels.mute : ariaLabels.unmute); |
| 307 this.$.volumeSlider.setAttribute('aria-label', ariaLabels.volumeSlider); | 327 this.$.volumeSlider.setAttribute('aria-label', ariaLabels.volumeSlider); |
| 308 }, | 328 }, |
| 309 }); | 329 }); |
| 310 })(); // Anonymous closure | 330 })(); // Anonymous closure |
| OLD | NEW |