2016-06-25 05:24:55 +00:00
|
|
|
/**
|
|
|
|
* Other common methods.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import { event } from '../utils'
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load (display) a main panel (view).
|
|
|
|
*
|
2016-06-25 16:05:24 +00:00
|
|
|
* @param {String} view The view, which can be found under components/main-wrapper/main-content.
|
|
|
|
* @param {...*} Extra data to attach to the view.
|
2016-06-25 05:24:55 +00:00
|
|
|
*/
|
|
|
|
export function loadMainView(view, ...args) {
|
2016-06-25 16:05:24 +00:00
|
|
|
event.emit('main-content-view:load', view, ...args);
|
2016-06-25 05:24:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Force reloading window regardless of "Confirm before reload" setting.
|
|
|
|
* This is handy for certain cases, for example Last.fm connect/disconnect.
|
|
|
|
*/
|
|
|
|
export function forceReloadWindow() {
|
2016-06-25 16:05:24 +00:00
|
|
|
window.onbeforeunload = function() {};
|
|
|
|
window.location.reload();
|
2016-06-25 05:24:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a playlist into the main panel.
|
|
|
|
*
|
|
|
|
* @param {Object} playlist The playlist object
|
|
|
|
*/
|
|
|
|
export function loadPlaylistView(playlist) {
|
2016-06-25 16:05:24 +00:00
|
|
|
loadMainView('playlist', playlist);
|
2016-06-25 05:24:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load the Favorites view.
|
|
|
|
*/
|
|
|
|
export function loadFavoritesView() {
|
2016-06-25 16:05:24 +00:00
|
|
|
loadMainView('favorites');
|
2016-06-25 05:24:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load an album into the main panel.
|
|
|
|
*
|
|
|
|
* @param {Object} album The album object
|
|
|
|
*/
|
|
|
|
export function loadAlbumView(album) {
|
2016-06-25 16:05:24 +00:00
|
|
|
loadMainView('album', album);
|
2016-06-25 05:24:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load an artist into the main panel.
|
|
|
|
*
|
|
|
|
* @param {Object} artist The artist object
|
|
|
|
*/
|
|
|
|
export function loadArtistView(artist) {
|
2016-06-25 16:05:24 +00:00
|
|
|
loadMainView('artist', artist);
|
2016-06-25 05:24:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the overlay.
|
|
|
|
* @param {String} message
|
|
|
|
* @param {String} type
|
|
|
|
* @param {Boolean} dismissable
|
|
|
|
*/
|
|
|
|
export function showOverlay(message = 'Just a little patience…', type = 'loading', dismissable = false) {
|
2016-06-25 16:05:24 +00:00
|
|
|
event.emit('overlay:show', { message, type, dismissable });
|
2016-06-25 05:24:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hide the overlay
|
|
|
|
* @return {[type]} [description]
|
|
|
|
*/
|
|
|
|
export function hideOverlay() {
|
2016-06-25 16:05:24 +00:00
|
|
|
event.emit('overlay:hide');
|
2016-06-25 05:24:55 +00:00
|
|
|
};
|