Jamstash/app/queue/queue.js
Hyzual efa604265d Adds a repeat directive to manage a 3-state repeat button
It will cycle through "repeat the playing queue", "repeat the playing song" and "don't repeat anything".

- Adds a custom "loop-single" icon based on iconic's loop icon.
- Removes the LoopQueue setting which is now the "queue" value of Repeat
- Moves the Repeat setting to player-service.js. That way, it does not depend on saving the settings in any way. It also allows us to remove a dependency from player-service.js.
- Adds a player css which will hold all the player-related styles
- Removes the former png icons (we can always find them back thanks to Git)
2015-05-22 00:05:37 +02:00

68 lines
1.9 KiB
JavaScript

/**
* jamstash.queue.controller Module
*
* Manages the playing queue. Gives access to the player service's queue-related functions,
* like adding, removing and shuffling the queue.
*/
angular.module('jamstash.queue.controller', ['jamstash.player.service', 'jamstash.settings.service'])
.controller('QueueController', ['$scope', 'globals', 'player',
function ($scope, globals, player) {
'use strict';
$scope.settings = globals.settings;
$scope.player = player;
$scope.playSong = function (song) {
player.play(song);
};
$scope.emptyQueue = function () {
player.emptyQueue();
//TODO: Hyz: Shouldn't it be in a directive ?
$.fancybox.close();
};
$scope.shuffleQueue = function () {
player.shuffleQueue();
//TODO: Hyz: Shouldn't it be in a directive ?
$('#SideBar').stop().scrollTo('.header', 400);
};
$scope.addSongToQueue = function (song) {
player.addSong(song);
};
$scope.removeSongFromQueue = function (song) {
player.removeSong(song);
};
$scope.removeSelectedSongsFromQueue = function () {
player.removeSongs($scope.selectedSongs);
};
$scope.isPlayingSong = function (song) {
return angular.equals(song, player.getPlayingSong());
};
$scope.$watch(function () {
return player.getPlayingSong();
}, function (newSong) {
if(newSong !== undefined) {
//TODO: Hyz: Shouldn't it be in a directive ?
$('#SideBar').stop().scrollTo('.song.id' + newSong.id, 400);
}
});
/**
* Change the queue's order through jQuery UI's sortable
*/
$scope.dragStart = function (e, ui) {
ui.item.data('start', ui.item.index());
};
$scope.dragEnd = function (e, ui) {
var start = ui.item.data('start'),
end = ui.item.index();
player.queue.splice(end, 0, player.queue.splice(start, 1)[0]);
};
}]);