koel/resources/assets/js/mixins/song-menu-methods.js

75 lines
1.8 KiB
JavaScript
Raw Normal View History

2016-03-05 09:01:12 +00:00
import $ from 'jquery';
import queueStore from '../stores/queue';
import playlistStore from '../stores/playlist';
import favoriteStore from '../stores/favorite';
/**
* 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 {
data() {
return {
shown: false,
top: 0,
left: 0,
};
},
methods: {
open() {},
close() {
// Close all submenus
$(this.$el).find('.submenu').hide();
this.shown = false;
},
2016-04-07 10:49:08 +00:00
/**
* Queue select songs after the current song.
*/
queueSongsAfterCurrent() {
queueStore.queueAfterCurrent(this.songs);
this.close();
},
2016-03-05 09:01:12 +00:00
/**
* Queue selected songs to bottom of queue.
*/
queueSongsToBottom() {
queueStore.queue(this.songs);
this.close();
},
/**
* Queue selected songs to top of queue.
*/
queueSongsToTop() {
queueStore.queue(this.songs, false, true);
this.close();
},
/**
* Add the selected songs into Favorite.
*/
addSongsToFavorite() {
favoriteStore.like(this.songs);
this.close();
},
/**
* Add the selected songs into the chosen playlist.
*
* @param {Object} playlist The playlist.
*/
addSongsToExistingPlaylist(playlist) {
playlistStore.addSongs(playlist, this.songs);
this.close();
},
},
};