Chromium Code Reviews| Index: ui/file_manager/audio_player/elements/volume_controller.js |
| diff --git a/ui/file_manager/audio_player/elements/volume_controller.js b/ui/file_manager/audio_player/elements/volume_controller.js |
| index 4e9fa625d0c8a7f1d877a09abaa7018f6c8510c4..3d808b10051e0e7699303b3249adc4e7215f51bf 100644 |
| --- a/ui/file_manager/audio_player/elements/volume_controller.js |
| +++ b/ui/file_manager/audio_player/elements/volume_controller.js |
| @@ -12,6 +12,50 @@ |
| var VolumeControllerElement = function() {}; |
| VolumeControllerElement.prototype = { |
| + is: 'volume-controller', |
| + |
| + properties: { |
| + /** |
| + * Width of the element in pixels. Must be specified before ready() is |
| + * called. Dynamic change is not supported. |
| + * @type {number} |
| + */ |
| + width: { |
| + type: Number, |
| + value: 32 |
| + }, |
| + |
| + /** |
| + * Height of the element in pixels. Must be specified before ready() is |
| + * called. Dynamic change is not supported. |
| + * @type {number} |
| + */ |
| + height: { |
| + type: Number, |
| + }, |
| + |
| + /** |
| + * Volume. 0 is silent, and 100 is maximum. |
| + * @type {number} |
| + */ |
| + value: { |
| + type: Number, |
| + value: 50, |
| + observer: 'valueChanged', |
| + notify: true |
| + }, |
| + |
| + /** |
| + * Volume. 100 is silent, and 0 is maximum. |
| + * @type {number} |
| + */ |
| + rawValue: { |
| + type: Number, |
| + observer: 'rawValueChanged', |
| + notify: true |
| + } |
| + }, |
| + |
| /** |
| * Initializes an element. This method is called automatically when the |
| * element is ready. |
| @@ -37,71 +81,23 @@ |
| }, |
| /** |
| - * Registers handlers for changing of external variables |
| - */ |
| - observe: { |
| - 'model.volume': 'onVolumeChanged', |
| - }, |
| - |
| - /** |
| - * Model object of the Audio Player. |
| - * @type {AudioPlayerModel} |
| - */ |
| - model: null, |
| - |
| - /** |
| - * Invoked when the model changed. |
| - * @param {AudioPlayerModel} oldValue Old Value. |
| - * @param {AudioPlayerModel} newValue New Value. |
| - */ |
| - modelChanged: function(oldValue, newValue) { |
| - this.onVolumeChanged((oldValue || {}).volume, (newValue || {}).volume); |
| - }, |
| - |
| - /** |
| - * Volume. 0 is silent, and 100 is maximum. |
| - * @type {number} |
| - */ |
| - value: 50, |
| - |
| - /** |
| - * Volume. 1000 is silent, and 0 is maximum. |
| - * @type {number} |
| - */ |
| - rawValue: 0, |
| - |
| - /** |
| - * Height of the element in pixels. Must be specified before ready() is |
| - * called. Dynamic change is not supported. |
| - * @type {number} |
| - */ |
| - height: 100, |
| - |
| - /** |
| - * Width of the element in pixels. Must be specified before ready() is |
| - * called. Dynamic change is not supported. |
| - * @type {number} |
| - */ |
| - width: 32, |
| - |
| - /** |
| - * Invoked when the 'volume' value in the model is changed. |
| - * @param {number} oldValue Old value. |
| + * Invoked when the 'volume' value is changed. |
| * @param {number} newValue New value. |
| + * @param {number} oldValue Old value. |
| */ |
| - onVolumeChanged: function(oldValue, newValue) { |
| + valueChanged: function(newValue, oldValue) { |
| if (oldValue != newValue) |
| this.rawValue = 100 - newValue; |
| }, |
| /** |
| * Invoked when the 'rawValue' property is changed. |
| - * @param {number} oldValue Old value. |
| * @param {number} newValue New value. |
| + * @param {number} oldValue Old value. |
| */ |
| - rawValueChanged: function(oldValue, newValue) { |
| + rawValueChanged: function(newValue, oldValue) { |
| if (oldValue != newValue) |
|
yawano
2015/06/10 05:47:48
very small nit: !==
fukino
2015/06/10 06:24:03
Done.
|
| - this.model.volume = 100 - newValue; |
| + this.value = 100 - newValue; |
| }, |
| /** |
| @@ -120,7 +116,15 @@ |
| break; |
| } |
| }, |
| + |
| + /** |
| + * Computes style for '.filled' element based on raw value. |
| + * @return {string} |
| + */ |
| + computeFilledStyle_: function(rawValue) { |
| + return 'height: ' + rawValue + '%;'; |
| + } |
| }; |
| - Polymer('volume-controller', VolumeControllerElement.prototype); |
| + Polymer(VolumeControllerElement.prototype); |
| })(); // Anonymous closure |