CC-3174 : showbuilder

group drag and drop for playlist.
This commit is contained in:
Naomi Aro 2012-02-20 20:44:35 +01:00
parent a633d69c8d
commit 378d3d3ef4
3 changed files with 28 additions and 24 deletions

View File

@ -19,20 +19,15 @@ var AIRTIME = (function(AIRTIME){
mod.fnDrawCallback = function() { mod.fnDrawCallback = function() {
$('#library_display tr[id ^= "au"]').draggable({ $('#library_display tr[id ^= "au"]').draggable({
helper: 'clone', helper: function(){
/* customize the helper on dragging to look like a pl item var selected = $('#library_display input:checked').parents('tr[id^="au"]');
* if (selected.length === 0) {
helper: function(ev) { selected = $(this);
var data, li; }
var container = $('<div/>').attr('id', 'draggingContainer');
data = $(ev.currentTarget).data("aData"); container.append(selected.clone());
return container;
li = $("<li></li>"); },
li.append(data.track_title);
return li;
},
*/
cursor: 'pointer', cursor: 'pointer',
connectToSortable: '#spl_sortable' connectToSortable: '#spl_sortable'
}); });

View File

@ -19,7 +19,6 @@ var AIRTIME = (function(AIRTIME){
mod.fnDrawCallback = function() { mod.fnDrawCallback = function() {
$('#library_display tr:not(:first)').draggable({ $('#library_display tr:not(:first)').draggable({
//helper: 'clone',
helper: function(){ helper: function(){
var selected = $('#library_display input:checked').parents('tr'); var selected = $('#library_display input:checked').parents('tr');
if (selected.length === 0) { if (selected.length === 0) {

View File

@ -500,17 +500,19 @@ var AIRTIME = (function(AIRTIME){
}); });
sortableConf = (function(){ sortableConf = (function(){
var origRow, var origTrs,
html,
fnReceive, fnReceive,
fnUpdate; fnUpdate;
fnReceive = function(event, ui) { fnReceive = function(event, ui) {
origRow = ui.item; origTrs = ui.helper.find('tr[id^="au"]');
html = ui.helper.html();
}; };
fnUpdate = function(event, ui) { fnUpdate = function(event, ui) {
var prev, var prev,
aItem = [], aItems = [],
iAfter, iAfter,
sAddType; sAddType;
@ -525,15 +527,23 @@ var AIRTIME = (function(AIRTIME){
} }
//item was dragged in from library datatable //item was dragged in from library datatable
if (origRow !== undefined) { if (origTrs !== undefined) {
aItem.push(origRow.data("aData").id);
origRow = undefined; playlist.find("tr.ui-draggable")
AIRTIME.playlist.fnAddItems(aItem, iAfter, sAddType); .after(html)
.empty();
origTrs.each(function(i, el){
aItems.push($("#"+$(el).attr("id")).data("aData").id);
});
origTrs = undefined;
AIRTIME.playlist.fnAddItems(aItems, iAfter, sAddType);
} }
//item was reordered. //item was reordered.
else { else {
aItem.push(parseInt(ui.item.attr("id").split("_").pop(), 10)); aItems.push(parseInt(ui.item.attr("id").split("_").pop(), 10));
AIRTIME.playlist.fnMoveItems(aItem, iAfter); AIRTIME.playlist.fnMoveItems(aItems, iAfter);
} }
}; };