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

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

Issue 1015463006: [Audio Player] Cleanup the code along with closure compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 5 years, 9 months 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 Polymer('track-list', { 8 /**
9 * @constructor
10 * @extends {PolymerElement}
11 */
12 var TrackListElement = function() {};
13
14 TrackListElement.prototype = {
9 /** 15 /**
10 * Initializes an element. This method is called automatically when the 16 * Initializes an element. This method is called automatically when the
11 * element is ready. 17 * element is ready.
12 */ 18 */
13 ready: function() { 19 ready: function() {
14 this.observeTrackList(); 20 this.observeTrackList();
15 21
16 window.addEventListener('resize', this.onWindowResize_.bind(this)); 22 window.addEventListener('resize', this.onWindowResize_.bind(this));
17 }, 23 },
18 24
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 105
100 // Invalid index 106 // Invalid index
101 if (this.tracks.length === 0) 107 if (this.tracks.length === 0)
102 this.currentTrackIndex = -1; 108 this.currentTrackIndex = -1;
103 else 109 else
104 this.generatePlayOrder(false /* no need to keep the current track */); 110 this.generatePlayOrder(false /* no need to keep the current track */);
105 }, 111 },
106 112
107 /** 113 /**
108 * Invoked when 'tracks' property is changed. 114 * Invoked when 'tracks' property is changed.
109 * @param {Array.<TrackInfo>} oldValue Old value. 115 * @param {Array.<AudioPlayer.TrackInfo>} oldValue Old value.
110 * @param {Array.<TrackInfo>} newValue New value. 116 * @param {Array.<AudioPlayer.TrackInfo>} newValue New value.
111 */ 117 */
112 tracksChanged: function(oldValue, newValue) { 118 tracksChanged: function(oldValue, newValue) {
113 // Note: Sometimes both oldValue and newValue are null though the actual 119 // Note: Sometimes both oldValue and newValue are null though the actual
114 // values are not null. Maybe it's a bug of Polymer. 120 // values are not null. Maybe it's a bug of Polymer.
115 121
116 // Re-register the observer of 'this.tracks'. 122 // Re-register the observer of 'this.tracks'.
117 this.observeTrackList(); 123 this.observeTrackList();
118 124
119 if (this.tracks.length !== 0) { 125 if (this.tracks.length !== 0) {
120 // Restore the active track. 126 // Restore the active track.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 259
254 /** 260 /**
255 * Request to replay the current music. 261 * Request to replay the current music.
256 */ 262 */
257 replayCurrentTrack: function() { 263 replayCurrentTrack: function() {
258 this.fire('replay'); 264 this.fire('replay');
259 }, 265 },
260 266
261 /** 267 /**
262 * Returns the current track. 268 * Returns the current track.
263 * @param {AudioPlayer.TrackInfo} track TrackInfo of the current track. 269 * @return {AudioPlayer.TrackInfo} track TrackInfo of the current track.
264 */ 270 */
265 getCurrentTrack: function() { 271 getCurrentTrack: function() {
266 if (this.tracks.length === 0) 272 if (this.tracks.length === 0)
267 return null; 273 return null;
268 274
269 return this.tracks[this.currentTrackIndex]; 275 return this.tracks[this.currentTrackIndex];
270 }, 276 },
271 277
272 /** 278 /**
273 * Returns the next (or previous) track in the track list. If there is no 279 * Returns the next (or previous) track in the track list. If there is no
(...skipping 23 matching lines...) Expand all
297 if (newPlayOrder === -1 || newPlayOrder === this.tracks.length) 303 if (newPlayOrder === -1 || newPlayOrder === this.tracks.length)
298 return cyclic ? defaultTrackIndex : -1; 304 return cyclic ? defaultTrackIndex : -1;
299 305
300 var newTrackIndex = this.playOrder[newPlayOrder]; 306 var newTrackIndex = this.playOrder[newPlayOrder];
301 console.assert( 307 console.assert(
302 (0 <= newTrackIndex && newTrackIndex < this.tracks.length), 308 (0 <= newTrackIndex && newTrackIndex < this.tracks.length),
303 'Insufficient TrackList.playOrder. New Play Order: ' + newPlayOrder); 309 'Insufficient TrackList.playOrder. New Play Order: ' + newPlayOrder);
304 310
305 return newTrackIndex; 311 return newTrackIndex;
306 }, 312 },
307 }); // Polymer('track-list') block 313 }; // TrackListElement.prototype for 'track-list'
314
315 Polymer('track-list', TrackListElement.prototype);
308 })(); // Anonymous closure 316 })(); // Anonymous closure
OLDNEW
« no previous file with comments | « ui/file_manager/audio_player/elements/control_panel.js ('k') | ui/file_manager/audio_player/elements/volume_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698