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
3 // found in the LICENSE file.
8 Polymer('volume-controller', {
10 * Initializes an element. This method is called automatically when the
14 this.style.width = this.width + 'px';
15 this.style.height = this.height + 'px';
17 this.$.rawValueInput.style.width = this.height + 'px';
18 this.$.rawValueInput.style.height = this.width + 'px';
19 this.$.rawValueInput.style.webkitTransformOrigin =
20 (this.width / 2) + 'px ' +
21 (this.width / 2 - 2) + 'px';
23 var barLeft = (this.width / 2 - 1);
24 this.$.bar.style.left = barLeft + 'px';
25 this.$.bar.style.right = barLeft + 'px';
29 * Registers handlers for changing of external variables
32 'model.volume': 'onVolumeChanged',
36 * Model object of the Audio Player.
37 * @type {AudioPlayerModel}
42 * Invoked when the model changed.
43 * @param {AudioPlayerModel} oldValue Old Value.
44 * @param {AudioPlayerModel} newValue Nld Value.
46 modelChanged: function(oldValue, newValue) {
47 this.onVolumeChanged((oldValue || {}).volume, (newValue || {}).volume);
51 * Volume. 0 is silent, and 100 is maximum.
57 * Volume. 1000 is silent, and 0 is maximum.
63 * Height of the element in pixels. Must be specified before ready() is
64 * called. Dynamic change is not supprted.
70 * Width of the element in pixels. Must be specified before ready() is
71 * called. Dynamic change is not supported.
77 * Invoked the 'volume' value in the model is changed.
78 * @param {number} oldValue Old value.
79 * @param {number} newValue New value.
81 onVolumeChanged: function(oldValue, newValue) {
82 if (oldValue != newValue)
83 this.rawValue = 100 - newValue;
87 * Invoked the 'rawValue' property is changed.
88 * @param {number} oldValue Old value.
89 * @param {number} newValue New value.
91 rawValueChanged: function(oldValue, newValue) {
92 if (oldValue != newValue)
93 this.model.volume = 100 - newValue;
96 })(); // Anonymous closure