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

View File

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

View File

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