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.
9 is
: 'volume-controller',
13 * Width of the element in pixels. Must be specified before ready() is
14 * called. Dynamic change is not supported.
23 * Height of the element in pixels. Must be specified before ready() is
24 * called. Dynamic change is not supported.
33 * Volume. 0 is silent, and 100 is maximum.
39 observer
: 'valueChanged',
44 * Volume. 100 is silent, and 0 is maximum.
50 observer
: 'rawValueChanged',
56 * Initializes an element. This method is called automatically when the
60 this.style
.width
= this.width
+ 'px';
61 this.style
.height
= this.height
+ 'px';
63 this.rawValueInput
= this.$.rawValueInput
;
64 this.bar
= this.$.bar
;
66 this.rawValueInput
.style
.width
= this.height
+ 'px';
67 this.rawValueInput
.style
.height
= this.width
+ 'px';
68 this.rawValueInput
.style
.webkitTransformOrigin
=
69 (this.width
/ 2) + 'px ' +
70 (this.width
/ 2 - 2) + 'px';
72 var barLeft
= (this.width
/ 2 - 1);
73 this.bar
.style
.left
= barLeft
+ 'px';
74 this.bar
.style
.right
= barLeft
+ 'px';
76 this.addEventListener('keydown', this.onKeyDown_
.bind(this));
80 * Invoked when the 'volume' value is changed.
81 * @param {number} newValue New value.
82 * @param {number} oldValue Old value.
84 valueChanged: function(newValue
, oldValue
) {
85 if (oldValue
!= newValue
)
86 this.rawValue
= 100 - newValue
;
90 * Invoked when the 'rawValue' property is changed.
91 * @param {number} newValue New value.
92 * @param {number} oldValue Old value.
94 rawValueChanged: function(newValue
, oldValue
) {
95 if (oldValue
!== newValue
)
96 this.value
= 100 - newValue
;
100 * Invoked when the 'keydown' event is fired.
101 * @param {Event} event The event object.
103 onKeyDown_: function(event
) {
104 switch (event
.keyIdentifier
) {
105 // Prevents the default behavior. These key should be handled in
106 // <audio-player> element.
111 event
.preventDefault();
117 * Computes style for '.filled' element based on raw value.
120 computeFilledStyle_: function(rawValue
) {
121 return 'height: ' + rawValue
+ '%;';
124 })(); // Anonymous closure