1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

Playlist reordering with drag'n drop working.

This commit is contained in:
SUTJael 2013-11-28 23:14:28 +01:00
parent 0599214703
commit 2e1ae29f17
7 changed files with 76 additions and 67 deletions

View file

@ -108,20 +108,29 @@ function check_inline_song_edit(type, song) {
$(document).ready(function () {
$('#sortableplaylist').sortable({
axis: 'y',
delay: 200,
start: function (event, ui) {
$(ui.item).data("startindex", ui.item.index());
},
stop: function (event, ui) {
playlistUpdatedIndex(ui.item);
}
delay: 200
});
});
function playlistUpdatedIndex(item) {
var startIndex = item.data("startindex");
var newIndex = item.index();
if (newIndex != startIndex) {
alert('Start index {' + startIndex + '} Stop index {' + newIndex + '}');
function submitPlaylistOrder(playlistUrl, tableid) {
var table = document.getElementById(tableid);
var rowLength = table.rows.length;
var finalOrder = '';
for (var i = 0; i < rowLength; ++i) {
var row = table.rows[i];
if (row.id != '') {
var songid = row.id.replace('track_', '');
finalOrder += songid + ";"
}
}
if (finalOrder != '') {
$.ajax({
url : playlistUrl,
type : 'GET',
data : 'order=' + finalOrder
});
}
}