Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: ui/file_manager/audio_player/elements/control_panel.js

Issue 1442583002: Revert of AudioPlayer: Update control panel with playback progress bar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 (function() { 5 (function() {
6 'use strict'; 6 'use strict';
7 7
8 /** 8 /**
9 * Moves |target| element above |anchor| element, in order to match the 9 * Moves |target| element above |anchor| element, in order to match the
10 * bottom lines. 10 * bottom lines.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 }, 92 },
93 93
94 /** 94 /**
95 * Whether the volume slider is expanded or not. 95 * Whether the volume slider is expanded or not.
96 */ 96 */
97 volumeSliderShown: { 97 volumeSliderShown: {
98 type: Boolean, 98 type: Boolean,
99 value: false, 99 value: false,
100 observer: 'volumeSliderShownChanged', 100 observer: 'volumeSliderShownChanged',
101 notify: true 101 notify: true
102 },
103
104 /**
105 * Whether the knob of time slider is being dragged.
106 */
107 dragging: {
108 type: Boolean,
109 value: false,
110 notify: true
111 } 102 }
112 }, 103 },
113 104
114 /** 105 /**
115 * Initializes an element. This method is called automatically when the 106 * Initializes an element. This method is called automatically when the
116 * element is ready. 107 * element is ready.
117 */ 108 */
118 ready: function() { 109 ready: function() {
119 var onFocusoutBound = this.onVolumeControllerFocusout_.bind(this); 110 var onFocusoutBound = this.onVolumeControllerFocusout_.bind(this);
120 111
121 this.$.volumeSlider.addEventListener('focusout', onFocusoutBound); 112 this.$.volumeSlider.addEventListener('focusout', onFocusoutBound);
122 this.$.volumeButton.addEventListener('focusout', onFocusoutBound); 113 this.$.volumeButton.addEventListener('focusout', onFocusoutBound);
123 114
124 this.$.timeSlider.addEventListener('value-change', function() { 115 // Prevent the time slider from being moved by arrow keys.
125 if (this.dragging) 116 this.$.timeInput.addEventListener('keydown', function(event) {
126 this.dragging = false; 117 switch (event.keyCode) {
127 }.bind(this)); 118 case 37: // Left arrow
128 this.$.timeSlider.addEventListener('immediate-value-change', function() { 119 case 38: // Up arrow
129 if (!this.dragging) 120 case 39: // Right arrow
130 this.dragging = true; 121 case 40: // Down arrow
131 }.bind(this)); 122 event.preventDefault();
123 break;
124 };
125 });
132 }, 126 },
133 127
134 /** 128 /**
135 * Invoked when the next button is clicked. 129 * Invoked when the next button is clicked.
136 */ 130 */
137 nextClick: function() { 131 nextClick: function() {
138 this.fire('next-clicked'); 132 this.fire('next-clicked');
139 }, 133 },
140 134
141 /** 135 /**
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 /** 187 /**
194 * Converts the time into human friendly string. 188 * Converts the time into human friendly string.
195 * @param {number} time Time to be converted. 189 * @param {number} time Time to be converted.
196 * @return {string} String representation of the given time 190 * @return {string} String representation of the given time
197 */ 191 */
198 time2string_: function(time) { 192 time2string_: function(time) {
199 return ~~(time / 60000) + ':' + ('0' + ~~(time / 1000 % 60)).slice(-2); 193 return ~~(time / 60000) + ':' + ('0' + ~~(time / 1000 % 60)).slice(-2);
200 }, 194 },
201 195
202 /** 196 /**
203 * Converts the time and duration into human friendly string.
204 * @param {number} time Time to be converted.
205 * @param {number} duration Duration to be converted.
206 * @return {string} String representation of the given time
207 */
208 computeTimeString_: function(time, duration) {
209 return this.time2string_(time) + ' / ' + this.time2string_(duration);
210 },
211
212 /**
213 * Computes state for play button based on 'playing' property. 197 * Computes state for play button based on 'playing' property.
214 * @return {string} 198 * @return {string}
215 */ 199 */
216 computePlayState_: function(playing) { 200 computePlayState_: function(playing) {
217 return playing ? "playing" : "ended"; 201 return playing ? "playing" : "ended";
218 }, 202 },
219 203
220 /** 204 /**
221 * Computes style for '.filled' element of progress bar. 205 * Computes style for '.filled' element of progress bar.
222 * @return {string} 206 * @return {string}
223 */ 207 */
224 computeProgressBarStyle_: function(time, duration) { 208 computeProgressBarStyle_: function(time, duration) {
225 return 'width: ' + (time / duration * 100) + '%;'; 209 return 'width: ' + (time / duration * 100) + '%;';
226 } 210 }
227 }); 211 });
228 })(); // Anonymous closure 212 })(); // Anonymous closure
OLDNEW
« no previous file with comments | « ui/file_manager/audio_player/elements/control_panel.html ('k') | ui/file_manager/audio_player/elements/track_list.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698