This commit is contained in:
An Phan 2016-01-15 16:13:23 +08:00
parent d449076e2b
commit 03017604ae
5 changed files with 41 additions and 47 deletions

View file

@ -168,9 +168,10 @@
* Load (display) a main panel (view).
*
* @param string view The view, which can be found under components/main-wrapper/main-content.
* @param [...args] Extra data to attach to the view.
*/
loadMainView(view) {
this.$broadcast('main-content-view:load', view);
loadMainView(view, ...args) {
this.$broadcast('main-content-view:load', view, ...args);
},
/**
@ -179,15 +180,13 @@
* @param {Object} playlist The playlist object
*/
loadPlaylist(playlist) {
this.$broadcast('playlist:load', playlist);
this.loadMainView('playlist');
this.loadMainView('playlist', playlist);
},
/**
* Load the Favorites view.
*/
loadFavorites() {
this.$broadcast('favorites:load');
this.loadMainView('favorites');
},
@ -197,8 +196,7 @@
* @param {Object} album The album object
*/
loadAlbum(album) {
this.$broadcast('album:load', album);
this.loadMainView('album');
this.loadMainView('album', album);
},
/**
@ -207,8 +205,7 @@
* @param {Object} artist The artist object
*/
loadArtist(artist) {
this.$broadcast('artist:load', artist);
this.loadMainView('artist');
this.loadMainView('artist', artist);
},
/**

View file

@ -69,13 +69,16 @@
events: {
/**
* Listen to 'album:load' event (triggered from $root currently)
* to load the requested album into view.
* Listen to 'main-content-view:load' event (triggered from $root currently)
* to load the requested album into view if applicable.
*
* @param {Object} album
* @param {string} view The view name
* @param {Object} album The album object
*/
'album:load': function (album) {
'main-content-view:load': function (view, album) {
if (view === 'album') {
this.album = album;
}
},
},

View file

@ -69,14 +69,17 @@
events: {
/**
* Listen to 'artist:load' event (triggered from $root currently)
* to load the requested artist into view.
* Listen to 'main-content-view:load' event (triggered from $root currently)
* to load the requested artist into view if applicable.
*
* @param {string} view The view's name
* @param {Object} artist
*/
'artist:load': function (artist) {
'main-content-view:load': function (view, artist) {
if (view === 'artist') {
artistStore.getSongsByArtist(artist);
this.artist = artist;
}
},
},

View file

@ -76,13 +76,16 @@
events: {
/**
* Listen to 'playlist:load' event (triggered from $root currently)
* to load the requested playlist into view.
* Listen to 'main-content-view:load' event (triggered from $root currently)
* to load the requested playlist into view if applicable.
*
* @param {string} view The view's name.
* @param {Object} playlist
*/
'playlist:load': function (playlist) {
'main-content-view:load': function (view, playlist) {
if (view === 'playlist') {
this.playlist = playlist;
}
},
},

View file

@ -151,24 +151,12 @@
},
events: {
/**
* Listen to 'playlist:load' event to determine if the current item should be highlighted.
*
* @param {Object} playlist The playlist being loaded.
*/
'playlist:load': function (playlist) {
this.active = this.playlist === playlist;
},
/**
* Listen to 'favorites:load' event to highlight the Favorites item if need be.
*/
'favorites:load': function () {
'main-content-view:load': function (view, playlist) {
if (view === 'favorites') {
this.active = this.isFavorites;
},
'main-content-view:load': function (view) {
if (view !== 'playlist' && view !== 'favorites') {
} else if (view === 'playlist') {
this.active = this.playlist === playlist;
} else {
this.active = false;
}
},