scratchpad reloads playlists when logging in/out.

Drag to reorder done on table. template redone to work with jQuery.
This commit is contained in:
naomiaro 2010-09-23 17:04:09 -04:00
parent 1d141c56ae
commit c8e1e7fc9a
9 changed files with 556 additions and 223 deletions

View file

@ -0,0 +1,52 @@
$(document).ready(function() {
$("#pl_sortable").sortable();
$("#pl_sortable" ).bind( "sortstop", function(event, ui) {
var li, newPos, oldPos;
li = ui.item;
newPos = $(this).children().index(li);
oldPos = li.attr('id').split("_").pop();
$.post("ui_handler.php",
{ 'act': 'PL.moveItem', 'oldPos': oldPos, 'newPos': newPos },
function(data){
var ul = $("#pl_sortable");
if(data.error) {
var size,
tmp_ul;
size = $(ul).children().size();
tmp_ul = $("<ul/>");
for(var i=0; i<size; i++)
{
tmp_ul.append(ul.find("#pl_"+i));
}
//restore the UI to the previous order.
$(ul).empty();
$(ul).html(tmp_ul.contents());
alert(data.error);
}
else {
//redo playlist positional ids.
$(ul).children().each(function(index){
var li = $(this);
li.attr('id', 'pl_'+index);
});
}
},
"json"
);
});
});