| Index: ui/file_manager/audio_player/elements/track_list.js
|
| diff --git a/ui/file_manager/audio_player/elements/track_list.js b/ui/file_manager/audio_player/elements/track_list.js
|
| index e887f177192195be9d29f5c38ea0e9c91cd0c546..b53fa038a24500ece0c6bc258ca40147834804dc 100644
|
| --- a/ui/file_manager/audio_player/elements/track_list.js
|
| +++ b/ui/file_manager/audio_player/elements/track_list.js
|
| @@ -12,6 +12,41 @@
|
| var TrackListElement = function() {};
|
|
|
| TrackListElement.prototype = {
|
| + is: 'track-list',
|
| +
|
| + properties: {
|
| + /**
|
| + * List of tracks.
|
| + * @type {Array<AudioPlayer.TrackInfo>}
|
| + */
|
| + tracks: {
|
| + type: Array,
|
| + value: [],
|
| + observer: 'tracksChanged'
|
| + },
|
| +
|
| + /**
|
| + * Track index of the current track.
|
| + * If the tracks property is empty, it should be -1. Otherwise, be a valid
|
| + * track number.
|
| + */
|
| + currentTrackIndex: {
|
| + type: Number,
|
| + value: -1,
|
| + observer: 'currentTrackIndexChanged',
|
| + notify: true
|
| + },
|
| +
|
| + /**
|
| + * Whether shuffling play order is enabled or not.
|
| + */
|
| + shuffle: {
|
| + type: Boolean,
|
| + value: false,
|
| + observer: 'shuffleChanged'
|
| + }
|
| + },
|
| +
|
| /**
|
| * Initializes an element. This method is called automatically when the
|
| * element is ready.
|
| @@ -38,65 +73,37 @@
|
| },
|
|
|
| /**
|
| - * Registers handlers for changing of external variables
|
| - */
|
| - observe: {
|
| - 'model.shuffle': 'onShuffleChanged',
|
| - },
|
| -
|
| - /**
|
| - * Model object of the Audio Player.
|
| - * @type {AudioPlayerModel}
|
| - */
|
| - model: null,
|
| -
|
| - /**
|
| - * List of tracks.
|
| - * @type {Array<AudioPlayer.TrackInfo>}
|
| - */
|
| - tracks: [],
|
| -
|
| - /**
|
| * Play order of the tracks. Each value is the index of 'this.tracks'.
|
| * @type {Array<number>}
|
| */
|
| playOrder: [],
|
|
|
| /**
|
| - * Track index of the current track.
|
| - * If the tracks property is empty, it should be -1. Otherwise, be a valid
|
| - * track number.
|
| - *
|
| - * @type {number}
|
| - */
|
| - currentTrackIndex: -1,
|
| -
|
| - /**
|
| * Invoked when 'shuffle' property is changed.
|
| - * @param {boolean} oldValue Old value.
|
| * @param {boolean} newValue New value.
|
| + * @param {boolean} oldValue Old value.
|
| */
|
| - onShuffleChanged: function(oldValue, newValue) {
|
| + shuffleChanged: function(newValue, oldValue) {
|
| this.generatePlayOrder(true /* keep the current track */);
|
| },
|
|
|
| /**
|
| * Invoked when the current track index is changed.
|
| - * @param {number} oldValue old value.
|
| * @param {number} newValue new value.
|
| + * @param {number} oldValue old value.
|
| */
|
| - currentTrackIndexChanged: function(oldValue, newValue) {
|
| + currentTrackIndexChanged: function(newValue, oldValue) {
|
| if (oldValue === newValue)
|
| return;
|
|
|
| if (!isNaN(oldValue) && 0 <= oldValue && oldValue < this.tracks.length)
|
| - this.tracks[oldValue].active = false;
|
| + this.set('tracks.' + oldValue + '.active', false);
|
|
|
| if (0 <= newValue && newValue < this.tracks.length) {
|
| var currentPlayOrder = this.playOrder.indexOf(newValue);
|
| if (currentPlayOrder !== -1) {
|
| // Success
|
| - this.tracks[newValue].active = true;
|
| + this.set('tracks.' + newValue + '.active', true);
|
|
|
| this.ensureTrackInViewport_(newValue /* trackIndex */);
|
| return;
|
| @@ -112,10 +119,10 @@
|
|
|
| /**
|
| * Invoked when 'tracks' property is changed.
|
| - * @param {Array<AudioPlayer.TrackInfo>} oldValue Old value.
|
| * @param {Array<AudioPlayer.TrackInfo>} newValue New value.
|
| + * @param {Array<AudioPlayer.TrackInfo>} oldValue Old value.
|
| */
|
| - tracksChanged: function(oldValue, newValue) {
|
| + tracksChanged: function(newValue, oldValue) {
|
| // Note: Sometimes both oldValue and newValue are null though the actual
|
| // values are not null. Maybe it's a bug of Polymer.
|
|
|
| @@ -126,7 +133,7 @@
|
| // Restore the active track.
|
| if (this.currentTrackIndex !== -1 &&
|
| this.currentTrackIndex < this.tracks.length) {
|
| - this.tracks[this.currentTrackIndex].active = true;
|
| + this.set('tracks.' + this.currentTrackIndex + '.active', true);
|
| }
|
|
|
| // Reset play order and current index.
|
| @@ -145,7 +152,7 @@
|
| if (this.tracks.length === 0)
|
| this.currentTrackIndex = -1;
|
| else
|
| - this.tracks[this.currentTrackIndex].active = true;
|
| + this.set('tracks.' + this.currentTrackIndex + '.active', true);
|
| },
|
|
|
| /**
|
| @@ -212,7 +219,7 @@
|
| this.tracks.
|
| map(function(unused, index) { return index; });
|
|
|
| - if (this.model && this.model.shuffle) {
|
| + if (this.shuffle) {
|
| // Randomizes the play order array (Schwarzian-transform algorithm).
|
| this.playOrder = this.playOrder
|
| .map(function(a) {
|
| @@ -312,5 +319,5 @@
|
| },
|
| }; // TrackListElement.prototype for 'track-list'
|
|
|
| - Polymer('track-list', TrackListElement.prototype);
|
| + Polymer(TrackListElement.prototype);
|
| })(); // Anonymous closure
|
|
|