CC-3860 : Timeline: Can knock a current playing song out of place with drag and drop if current playing song has checkbox selected

This commit is contained in:
Naomi Aro 2012-05-23 17:06:04 +02:00
parent 0b84dec86f
commit 0c233c3346
1 changed files with 25 additions and 7 deletions

View File

@ -3,6 +3,7 @@ var AIRTIME = (function(AIRTIME){
oSchedTable, oSchedTable,
SB_SELECTED_CLASS = "sb-selected", SB_SELECTED_CLASS = "sb-selected",
CURSOR_SELECTED_CLASS = "cursor-selected-row", CURSOR_SELECTED_CLASS = "cursor-selected-row",
NOW_PLAYING_CLASS = "sb-now-playing",
$sbContent, $sbContent,
$sbTable, $sbTable,
$toolbar, $toolbar,
@ -80,7 +81,7 @@ var AIRTIME = (function(AIRTIME){
}; };
mod.checkJumpToCurrentButton = function() { mod.checkJumpToCurrentButton = function() {
var $current = $sbTable.find(".sb-now-playing"); var $current = $sbTable.find("."+NOW_PLAYING_CLASS);
if ($current.length !== 0) { if ($current.length !== 0) {
AIRTIME.button.enableButton("sb-button-current"); AIRTIME.button.enableButton("sb-button-current");
@ -122,12 +123,19 @@ var AIRTIME = (function(AIRTIME){
mod.checkToolBarIcons(); mod.checkToolBarIcons();
}; };
mod.getSelectedData = function() { /*
* sNot is an optional string to filter selected elements by. (ex removing the currently playing item)
*/
mod.getSelectedData = function(sNot) {
var $selected = $sbTable.find("tbody").find("input:checkbox").filter(":checked").parents("tr"), var $selected = $sbTable.find("tbody").find("input:checkbox").filter(":checked").parents("tr"),
aData = [], aData = [],
i, length, i, length,
$item; $item;
if (sNot !== undefined) {
$selected = $selected.not("."+sNot);
}
for (i = 0, length = $selected.length; i < length; i++) { for (i = 0, length = $selected.length; i < length; i++) {
$item = $($selected.get(i)); $item = $($selected.get(i));
aData.push($item.data('aData')); aData.push($item.data('aData'));
@ -526,7 +534,7 @@ var AIRTIME = (function(AIRTIME){
$nRow.data({"aData": aData}); $nRow.data({"aData": aData});
if (aData.scheduled === 1) { if (aData.scheduled === 1) {
$nRow.addClass("sb-now-playing"); $nRow.addClass(NOW_PLAYING_CLASS);
} }
else if (aData.scheduled === 0) { else if (aData.scheduled === 0) {
$nRow.addClass("sb-past"); $nRow.addClass("sb-past");
@ -631,7 +639,7 @@ var AIRTIME = (function(AIRTIME){
//order of importance of elements for setting the next timeout. //order of importance of elements for setting the next timeout.
elements = [ elements = [
$sbTable.find("tr.sb-now-playing"), $sbTable.find("tr."+NOW_PLAYING_CLASS),
$sbTable.find("tbody").find("tr.sb-future.sb-footer, tr.sb-future.sb-header").filter(":first") $sbTable.find("tbody").find("tr.sb-future.sb-footer, tr.sb-future.sb-header").filter(":first")
]; ];
@ -789,7 +797,7 @@ var AIRTIME = (function(AIRTIME){
forcePlaceholderSize: true, forcePlaceholderSize: true,
distance: 10, distance: 10,
helper: function(event, item) { helper: function(event, item) {
var selected = mod.getSelectedData(), var selected = mod.getSelectedData(NOW_PLAYING_CLASS),
thead = $("#show_builder_table thead"), thead = $("#show_builder_table thead"),
colspan = thead.find("th").length, colspan = thead.find("th").length,
trfirst = thead.find("tr:first"), trfirst = thead.find("tr:first"),
@ -829,7 +837,17 @@ var AIRTIME = (function(AIRTIME){
receive: fnReceive, receive: fnReceive,
update: fnUpdate, update: fnUpdate,
start: function(event, ui) { start: function(event, ui) {
var elements = $sbTable.find('tr:not(:first) input:checked').parents('tr'); /*
var elements = $sbTable.find('tr input:checked').parents('tr')
.not(ui.item)
.not("."+NOW_PLAYING_CLASS);
//remove all other items from the screen,
//don't remove ui.item or else we can not get position information when the user drops later.
elements.remove();
*/
var elements = $sbTable.find('tr input:checked').parents('tr');
elements.hide(); elements.hide();
} }
@ -908,7 +926,7 @@ var AIRTIME = (function(AIRTIME){
var $scroll = $sbContent.find(".dataTables_scrolling"), var $scroll = $sbContent.find(".dataTables_scrolling"),
scrolled = $scroll.scrollTop(), scrolled = $scroll.scrollTop(),
scrollingTop = $scroll.offset().top, scrollingTop = $scroll.offset().top,
current = $sbTable.find(".sb-now-playing"), current = $sbTable.find("."+NOW_PLAYING_CLASS),
currentTop = current.offset().top; currentTop = current.offset().top;
$scroll.scrollTop(currentTop - scrollingTop + scrolled); $scroll.scrollTop(currentTop - scrollingTop + scrolled);