can drag to side playlist
This commit is contained in:
parent
9fd60932bd
commit
83d8975110
|
@ -10,7 +10,7 @@ function contextMenu(action, el, pos) {
|
||||||
else if (method === 'add-item') {
|
else if (method === 'add-item') {
|
||||||
url = action + '/format/json';
|
url = action + '/format/json';
|
||||||
url = url + '/id/' + $(el).attr('id');
|
url = url + '/id/' + $(el).attr('id');
|
||||||
$.post(url, addToPlaylist);
|
$.post(url, setSPLContent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,21 +26,6 @@ function deleteItem(json){
|
||||||
$("#library_display tr#" +id).remove();
|
$("#library_display tr#" +id).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToPlaylist(json){
|
|
||||||
|
|
||||||
if(json.message) {
|
|
||||||
alert(json.message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#spl_name').empty()
|
|
||||||
.append(json.name);
|
|
||||||
$('#spl_length').empty()
|
|
||||||
.append(json.length);
|
|
||||||
$('#spl_sortable').empty()
|
|
||||||
.append(json.html);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setLibraryContents(data){
|
function setLibraryContents(data){
|
||||||
$("#library_display tr:not(:first-child)").remove();
|
$("#library_display tr:not(:first-child)").remove();
|
||||||
$("#library_display").append(data);
|
$("#library_display").append(data);
|
||||||
|
@ -56,6 +41,11 @@ function setLibraryContents(data){
|
||||||
|
|
||||||
function setSPLContent(json) {
|
function setSPLContent(json) {
|
||||||
|
|
||||||
|
if(json.message) {
|
||||||
|
alert(json.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$('#spl_name').empty()
|
$('#spl_name').empty()
|
||||||
.append(json.name);
|
.append(json.name);
|
||||||
$('#spl_length').empty()
|
$('#spl_length').empty()
|
||||||
|
@ -64,6 +54,23 @@ function setSPLContent(json) {
|
||||||
.append(json.html);
|
.append(json.html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addSPLItem(event, ui){
|
||||||
|
|
||||||
|
var url, tr, id;
|
||||||
|
|
||||||
|
tr = ui.helper;
|
||||||
|
|
||||||
|
if(tr.get(0).tagName === 'LI')
|
||||||
|
return;
|
||||||
|
|
||||||
|
id = tr.attr('id');
|
||||||
|
|
||||||
|
url = '/Playlist/add-item/format/json';
|
||||||
|
url = url + '/id/'+id;
|
||||||
|
|
||||||
|
$.post(url, setSPLContent);
|
||||||
|
}
|
||||||
|
|
||||||
function deleteSPLItem(){
|
function deleteSPLItem(){
|
||||||
|
|
||||||
var url, pos;
|
var url, pos;
|
||||||
|
@ -126,14 +133,19 @@ $(document).ready(function() {
|
||||||
$.post(url, setLibraryContents);
|
$.post(url, setLibraryContents);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#library_display tr:not(:first-child)").contextMenu(
|
$("#library_display tr:not(:first-child)")
|
||||||
{menu: 'myMenu'}, contextMenu
|
.contextMenu({menu: 'myMenu'}, contextMenu)
|
||||||
);
|
.draggable({
|
||||||
|
helper: 'clone'
|
||||||
|
});
|
||||||
|
|
||||||
$("#spl_sortable").sortable();
|
$("#spl_sortable").sortable();
|
||||||
$("#spl_sortable" ).bind( "sortstop", moveSPLItem);
|
$("#spl_sortable" ).bind( "sortstop", moveSPLItem);
|
||||||
$("#spl_remove_selected").click(deleteSPLItem);
|
$("#spl_remove_selected").click(deleteSPLItem);
|
||||||
|
|
||||||
|
$("#spl_sortable").droppable();
|
||||||
|
$("#spl_sortable" ).bind( "drop", addSPLItem);
|
||||||
|
|
||||||
$('input[name="all"]').click(function(){
|
$('input[name="all"]').click(function(){
|
||||||
$('form[name="SPL"]').find('input').attr("checked", $(this).attr("checked"));
|
$('form[name="SPL"]').find('input').attr("checked", $(this).attr("checked"));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue