CC-3799 : Dragging and dropping a track from the library causes the track in the library to be selected

This commit is contained in:
Naomi Aro 2012-05-10 14:19:36 +02:00
parent 9bb8e2ad8e
commit e61924de37
5 changed files with 38 additions and 29 deletions

View file

@ -48,7 +48,7 @@ var AIRTIME = (function(AIRTIME){
$('#library_display tr.lib-audio').draggable({
helper: function(){
mod.selectItem($(this));
mod.addToChosen($(this));
var selected = mod.getChosenAudioFilesLength(),
container,

View file

@ -48,7 +48,7 @@ var AIRTIME = (function(AIRTIME){
$('#library_display tr.lib-audio, tr.lib-pl').draggable({
helper: function(){
mod.selectItem($(this));
mod.addToChosen($(this));
var selected = mod.getChosenItemsLength(),
container,

View file

@ -98,6 +98,21 @@ var AIRTIME = (function(AIRTIME) {
}
};
mod.addToChosen = function($el) {
var id = $el.attr("id");
chosenItems[id] = $el.data('aData');
};
mod.removeFromChosen = function($el) {
var id = $el.attr("id");
//used to not keep dragged items selected.
if (!$el.hasClass(LIB_SELECTED_CLASS)) {
delete chosenItems[id];
}
};
mod.highlightItem = function($el) {
var $input = $el.find("input");
@ -105,26 +120,25 @@ var AIRTIME = (function(AIRTIME) {
$el.addClass(LIB_SELECTED_CLASS);
};
mod.unHighlightItem = function($el) {
var $input = $el.find("input");
$input.attr("checked", false);
$el.removeClass(LIB_SELECTED_CLASS);
};
mod.selectItem = function($el) {
var id;
mod.highlightItem($el);
id = $el.attr("id");
chosenItems[id] = $el.data('aData');
mod.addToChosen($el);
mod.checkToolBarIcons();
};
mod.deselectItem = function($el) {
var id,
$input = $el.find("input");
$input.attr("checked", false);
$el.removeClass(LIB_SELECTED_CLASS);
id = $el.attr("id");
delete chosenItems[id];
mod.unHighlightItem($el);
mod.removeFromChosen($el);
mod.checkToolBarIcons();
};

View file

@ -278,7 +278,8 @@ var AIRTIME = (function(AIRTIME){
function redrawLib() {
var dt = $lib.find("#library_display").dataTable();
dt.fnDraw();
dt.fnStandingRedraw();
AIRTIME.library.redrawChosen();
}
function setPlaylistContent(json) {
@ -523,10 +524,6 @@ var AIRTIME = (function(AIRTIME){
//filter out anything that isn't an audiofile.
aSelected = AIRTIME.library.getSelectedData();
//if nothing is checked select the dragged item.
if (aSelected.length === 0) {
aSelected.push(ui.item.data("aData"));
}
for (i = 0, length = aSelected.length; i < length; i++) {
if (aSelected[i].ftype === "audioclip") {
@ -536,6 +533,8 @@ var AIRTIME = (function(AIRTIME){
aReceiveItems = aItems;
html = ui.helper.html();
AIRTIME.library.removeFromChosen(ui.item);
};
fnUpdate = function(event, ui) {

View file

@ -699,14 +699,10 @@ var AIRTIME = (function(AIRTIME){
var aItems = [];
aItems = AIRTIME.library.getSelectedData();
//if nothing is checked select the dragged item.
if (aItems.length === 0) {
aItems.push(ui.item.data("aData"));
}
origTrs = aItems;
html = ui.helper.html();
AIRTIME.library.removeFromChosen(ui.item);
};
fnUpdate = function(event, ui) {
@ -764,10 +760,10 @@ var AIRTIME = (function(AIRTIME){
height = trfirst.height(),
message;
//if nothing is checked select the dragged item.
if (selected.length === 0) {
selected = [item.data("aData")];
}
//if nothing is checked select the dragged item.
if (selected.length === 0) {
selected = [item.data("aData")];
}
if (selected.length === 1) {
message = "Moving "+selected.length+" Item.";