Explicitly add python-numpy dependency to install-build-deps.
[chromium-blink-merge.git] / ui / file_manager / audio_player / elements / volume_controller.js
blobf50abad40a7ca9702233a12d140d18abfc5491a0
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.
5 (function() {
6 'use strict';
8 Polymer('volume-controller', {
9 /**
10 * Initializes an element. This method is called automatically when the
11 * element is ready.
13 ready: function() {
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';
27 this.addEventListener('keydown', this.onKeyDown_.bind(this));
30 /**
31 * Registers handlers for changing of external variables
33 observe: {
34 'model.volume': 'onVolumeChanged',
37 /**
38 * Model object of the Audio Player.
39 * @type {AudioPlayerModel}
41 model: null,
43 /**
44 * Invoked when the model changed.
45 * @param {AudioPlayerModel} oldValue Old Value.
46 * @param {AudioPlayerModel} newValue New Value.
48 modelChanged: function(oldValue, newValue) {
49 this.onVolumeChanged((oldValue || {}).volume, (newValue || {}).volume);
52 /**
53 * Volume. 0 is silent, and 100 is maximum.
54 * @type {number}
56 value: 50,
58 /**
59 * Volume. 1000 is silent, and 0 is maximum.
60 * @type {number}
62 rawValue: 0,
64 /**
65 * Height of the element in pixels. Must be specified before ready() is
66 * called. Dynamic change is not supported.
67 * @type {number}
69 height: 100,
71 /**
72 * Width of the element in pixels. Must be specified before ready() is
73 * called. Dynamic change is not supported.
74 * @type {number}
76 width: 32,
78 /**
79 * Invoked when the 'volume' value in the model is changed.
80 * @param {number} oldValue Old value.
81 * @param {number} newValue New value.
83 onVolumeChanged: function(oldValue, newValue) {
84 if (oldValue != newValue)
85 this.rawValue = 100 - newValue;
88 /**
89 * Invoked when the 'rawValue' property is changed.
90 * @param {number} oldValue Old value.
91 * @param {number} newValue New value.
93 rawValueChanged: function(oldValue, newValue) {
94 if (oldValue != newValue)
95 this.model.volume = 100 - newValue;
98 /**
99 * Invoked when the 'keydown' event is fired.
100 * @param {Event} event The event object.
102 onKeyDown_: function(event) {
103 switch (event.keyIdentifier) {
104 // Prevents the default behavior. These key should be handled in
105 // <audio-player> element.
106 case 'Up':
107 case 'Down':
108 case 'PageUp':
109 case 'PageDown':
110 event.preventDefault();
111 break;
115 })(); // Anonymous closure