2017-01-15 16:20:55 +00:00
|
|
|
import { each } from 'lodash'
|
|
|
|
|
2016-11-26 03:25:35 +00:00
|
|
|
import { queueStore, playlistStore, favoriteStore } from '../stores'
|
2016-03-05 09:01:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Includes the methods triggerable on a song (context) menu.
|
|
|
|
* Each component including this mixin must have a `songs` array as either data, prop, or computed.
|
|
|
|
* Note that for some components, some of the methods here may not be applicable, or overridden,
|
|
|
|
* for example close() and open().
|
|
|
|
*/
|
|
|
|
export default {
|
2016-11-26 03:25:35 +00:00
|
|
|
data () {
|
2016-06-25 16:05:24 +00:00
|
|
|
return {
|
|
|
|
shown: false,
|
|
|
|
top: 0,
|
2016-11-26 03:25:35 +00:00
|
|
|
left: 0
|
|
|
|
}
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
2016-03-05 09:01:12 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
methods: {
|
2016-11-26 03:25:35 +00:00
|
|
|
open () {},
|
2016-03-05 09:01:12 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
/**
|
|
|
|
* Close all submenus.
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
close () {
|
2017-01-15 16:20:55 +00:00
|
|
|
each(this.$el.querySelectorAll('.submenu'), el => {
|
2016-12-20 15:44:47 +00:00
|
|
|
el.style.display = 'none'
|
|
|
|
})
|
2016-11-26 03:25:35 +00:00
|
|
|
this.shown = false
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
2016-03-05 09:01:12 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
/**
|
|
|
|
* Queue select songs after the current song.
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
queueSongsAfterCurrent () {
|
|
|
|
queueStore.queueAfterCurrent(this.songs)
|
|
|
|
this.close()
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
2016-04-07 10:49:08 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
/**
|
|
|
|
* Queue selected songs to bottom of queue.
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
queueSongsToBottom () {
|
|
|
|
queueStore.queue(this.songs)
|
|
|
|
this.close()
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
2016-03-05 09:01:12 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
/**
|
|
|
|
* Queue selected songs to top of queue.
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
queueSongsToTop () {
|
|
|
|
queueStore.queue(this.songs, false, true)
|
|
|
|
this.close()
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
2016-03-05 09:01:12 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
/**
|
|
|
|
* Add the selected songs into Favorites.
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
addSongsToFavorite () {
|
|
|
|
favoriteStore.like(this.songs)
|
|
|
|
this.close()
|
2016-06-25 16:05:24 +00:00
|
|
|
},
|
2016-03-05 09:01:12 +00:00
|
|
|
|
2016-06-25 16:05:24 +00:00
|
|
|
/**
|
|
|
|
* Add the selected songs into the chosen playlist.
|
|
|
|
*
|
|
|
|
* @param {Object} playlist The playlist.
|
|
|
|
*/
|
2016-11-26 03:25:35 +00:00
|
|
|
addSongsToExistingPlaylist (playlist) {
|
|
|
|
playlistStore.addSongs(playlist, this.songs)
|
|
|
|
this.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|