diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js index ebb3236f0..67ee70aee 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js @@ -3,6 +3,7 @@ var AIRTIME = (function(AIRTIME){ oSchedTable, SB_SELECTED_CLASS = "sb-selected", CURSOR_SELECTED_CLASS = "cursor-selected-row", + NOW_PLAYING_CLASS = "sb-now-playing", $sbContent, $sbTable, $toolbar, @@ -80,7 +81,7 @@ var AIRTIME = (function(AIRTIME){ }; mod.checkJumpToCurrentButton = function() { - var $current = $sbTable.find(".sb-now-playing"); + var $current = $sbTable.find("."+NOW_PLAYING_CLASS); if ($current.length !== 0) { AIRTIME.button.enableButton("sb-button-current"); @@ -122,12 +123,19 @@ var AIRTIME = (function(AIRTIME){ 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"), aData = [], i, length, $item; + if (sNot !== undefined) { + $selected = $selected.not("."+sNot); + } + for (i = 0, length = $selected.length; i < length; i++) { $item = $($selected.get(i)); aData.push($item.data('aData')); @@ -526,7 +534,7 @@ var AIRTIME = (function(AIRTIME){ $nRow.data({"aData": aData}); if (aData.scheduled === 1) { - $nRow.addClass("sb-now-playing"); + $nRow.addClass(NOW_PLAYING_CLASS); } else if (aData.scheduled === 0) { $nRow.addClass("sb-past"); @@ -631,7 +639,7 @@ var AIRTIME = (function(AIRTIME){ //order of importance of elements for setting the next timeout. 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") ]; @@ -789,7 +797,7 @@ var AIRTIME = (function(AIRTIME){ forcePlaceholderSize: true, distance: 10, helper: function(event, item) { - var selected = mod.getSelectedData(), + var selected = mod.getSelectedData(NOW_PLAYING_CLASS), thead = $("#show_builder_table thead"), colspan = thead.find("th").length, trfirst = thead.find("tr:first"), @@ -829,7 +837,17 @@ var AIRTIME = (function(AIRTIME){ receive: fnReceive, update: fnUpdate, 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(); } @@ -908,7 +926,7 @@ var AIRTIME = (function(AIRTIME){ var $scroll = $sbContent.find(".dataTables_scrolling"), scrolled = $scroll.scrollTop(), scrollingTop = $scroll.offset().top, - current = $sbTable.find(".sb-now-playing"), + current = $sbTable.find("."+NOW_PLAYING_CLASS), currentTop = current.offset().top; $scroll.scrollTop(currentTop - scrollingTop + scrolled);