Moves drag & drop support from main-controller.js to queue.js

Adds a indexOfSong method to player-service. It is used in play, nextTrack and previousTrack so the player can adapt to changes to the queue order. Previously it wasn't taken into account and when we changed the order of the queue (through drag & drop or shuffle), the next song wasn't what we expected it to be.
This commit is contained in:
Hyzual 2015-01-12 22:08:28 +01:00
parent 09fb66f2fe
commit 8b3a12f052
6 changed files with 107 additions and 23 deletions

View file

@ -105,7 +105,6 @@ angular.module('JamStash')
$scope.$watchCollection(function () {
return player.queue;
}, function(newQueue) {
console.log('newQueue', newQueue);
if (newQueue !== undefined && newQueue.length > 0 && globals.settings.ShowQueue) {
$scope.showQueue();
}
@ -172,16 +171,6 @@ angular.module('JamStash')
}
};
$rootScope.showIndex = false;
$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]);
$scope.$apply();
};
$(document).on( 'click', 'message', function() {
$(this).fadeOut(function () { $(this).remove(); });
return false;