CC-3545 : Calendar->AddRemove (Now Playing Tab->Add Files to Show) -> changing order of tracks is not correct

removing table tools.
replacing with something simpler that will preserve order on screen.
This commit is contained in:
Naomi Aro 2012-04-02 19:03:11 +02:00
parent c5b761bff3
commit 6c25423f4e
9 changed files with 240 additions and 243 deletions

View File

@ -120,7 +120,6 @@ class PlaylistController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -131,7 +130,6 @@ class PlaylistController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/spl.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/playlist_builder.css?'.$CC_CONFIG['airtime_version']);

View File

@ -30,7 +30,6 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColVis.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.ColReorder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.FixedColumns.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.TableTools.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
@ -40,7 +39,6 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'/css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
$this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version']),'text/javascript'); $this->view->headScript()->appendFile($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version']),'text/javascript');

View File

@ -1,7 +1,7 @@
.lib-content .fg-toolbar ul { .lib-content .fg-toolbar ul {
float: left; float: left;
padding: 0; padding: 0;
margin: 0.5em 0 0 0; margin: 0.5em 0 0 10px;
cursor: pointer; cursor: pointer;
} }
@ -12,6 +12,13 @@
margin-right: 5px; margin-right: 5px;
} }
.lib-selected.even {
background-color: rgba(240, 109, 53, 1);
}
.lib-selected.odd {
background-color: rgba(255, 136, 56, 1);
}
#library_content { #library_content {
float: left; float: left;
width: 50%; width: 50%;

View File

@ -12,6 +12,13 @@
margin-left: -16px; margin-left: -16px;
} }
.sb-selected.even {
background-color: rgba(240, 109, 53, 1);
}
.sb-selected.odd {
background-color: rgba(255, 136, 56, 1);
}
#sb_edit { #sb_edit {
position: relative; position: relative;
top: 2px; top: 2px;
@ -24,7 +31,7 @@
.sb-content .fg-toolbar ul { .sb-content .fg-toolbar ul {
float: left; float: left;
padding: 0; padding: 0;
margin: 0.5em 10px 0 0; margin: 0.5em 0 0 10px;
cursor: pointer; cursor: pointer;
} }

View File

@ -93,8 +93,7 @@ var AIRTIME = (function(AIRTIME){
return; return;
} }
var oLibTT = TableTools.fnGetInstance('library_display'), var aData = AIRTIME.library.getSelectedData(),
aData = oLibTT.fnGetSelectedData(),
i, i,
temp, temp,
length, length,

View File

@ -77,7 +77,8 @@ var AIRTIME = (function(AIRTIME){
}; };
mod.setupLibraryToolbar = function() { mod.setupLibraryToolbar = function() {
var $toolbar = $(".lib-content .fg-toolbar:first"); var $toolbar = $(".lib-content .fg-toolbar:first"),
$libTable = $("#library_display");
$toolbar $toolbar
.append("<ul />") .append("<ul />")
@ -93,8 +94,8 @@ var AIRTIME = (function(AIRTIME){
return; return;
} }
var oLibTT = TableTools.fnGetInstance('library_display'), var selected = AIRTIME.library.getSelectedData(),
aData = oLibTT.fnGetSelectedData(), data,
i, i,
length, length,
temp, temp,
@ -102,9 +103,9 @@ var AIRTIME = (function(AIRTIME){
aSchedIds = []; aSchedIds = [];
//process selected files/playlists. //process selected files/playlists.
for (i = 0, length = aData.length; i < length; i++) { for (i = 0, length = selected.length; i < length; i++) {
temp = aData[i]; data = selected[i];
aMediaIds.push({"id": temp.id, "type": temp.ftype}); aMediaIds.push({"id": data.id, "type": data.ftype});
} }
aData = []; aData = [];

View File

@ -1,15 +1,40 @@
var AIRTIME = (function(AIRTIME) { var AIRTIME = (function(AIRTIME) {
var mod, var mod,
libraryInit; libraryInit,
oTable,
$libContent,
$libTable,
LIB_SELECTED_CLASS = "lib-selected";
if (AIRTIME.library === undefined) { if (AIRTIME.library === undefined) {
AIRTIME.library = {}; AIRTIME.library = {};
} }
mod = AIRTIME.library; mod = AIRTIME.library;
mod.getSelectedData = function() {
var $selected = $libTable.find("tbody").find("input:checkbox").filter(":checked").parents("tr"),
aData = [],
i, length,
$item;
for (i = 0, length = $selected.length; i < length; i++) {
$item = $($selected.get(i));
aData.push($item.data('aData'));
}
return aData.reverse();
};
mod.selectAll = function () {
$libTable.find("input:checkbox").attr("checked", true);
};
mod.selectNone = function () {
$libTable.find("input:checkbox").attr("checked", false);
$libTable.find("tr").removeClass(LIB_SELECTED_CLASS);
};
mod.fnDeleteItems = function(aMedia) { mod.fnDeleteItems = function(aMedia) {
var oLibTT = TableTools.fnGetInstance('library_display'),
oLibTable = $("#library_display").dataTable();
$.post("/library/delete", $.post("/library/delete",
{"format": "json", "media": aMedia}, {"format": "json", "media": aMedia},
@ -18,14 +43,12 @@ var AIRTIME = (function(AIRTIME) {
alert(json.message); alert(json.message);
} }
oLibTT.fnSelectNone(); oTable.fnDraw();
oLibTable.fnDraw();
}); });
}; };
mod.fnDeleteSelectedItems = function() { mod.fnDeleteSelectedItems = function() {
var oLibTT = TableTools.fnGetInstance('library_display'), var aData = AIRTIME.library.getSelectedData(),
aData = oLibTT.fnGetSelectedData(),
item, item,
temp, temp,
aMedia = []; aMedia = [];
@ -42,14 +65,13 @@ var AIRTIME = (function(AIRTIME) {
}; };
libraryInit = function() { libraryInit = function() {
var oTable, oTable,
libContentDiv = $("#library_content"), $libContent = $("#library_content"),
tableHeight = libContentDiv.height() - 130, $libTable = $libContent.find("table");
libLength,
libType,
libFilter;
oTable = $('#library_display').dataTable( { var tableHeight = $libContent.height() - 130;
oTable = $libTable.dataTable( {
//put hidden columns at the top to insure they can never be visible on the table through column reordering. //put hidden columns at the top to insure they can never be visible on the table through column reordering.
"aoColumns": [ "aoColumns": [
@ -231,14 +253,7 @@ var AIRTIME = (function(AIRTIME) {
}, },
"fnDrawCallback": AIRTIME.library.events.fnDrawCallback, "fnDrawCallback": AIRTIME.library.events.fnDrawCallback,
"fnHeaderCallback": function(nHead) { "fnHeaderCallback": function(nHead) {
var oTT, $(nHead).find("input[type=checkbox]").attr("checked", false);
checked = $(nHead).find("input[type=checkbox]").filter(":checked");
if (checked.length > 0) {
oTT = TableTools.fnGetInstance('library_display');
checked.attr("checked", false);
oTT.fnSelectNone();
}
}, },
"aaSorting": [[3, 'asc']], "aaSorting": [[3, 'asc']],
@ -249,49 +264,8 @@ var AIRTIME = (function(AIRTIME) {
"sSearch": "" "sSearch": ""
}, },
// R = ColReorder, C = ColVis, T = TableTools // R = ColReorder, C = ColVis
"sDom": 'Rl<"#library_display_type">f<"dt-process-rel"r><"H"T<"library_toolbar"C>><"dataTables_scrolling"t><"F"ip>', "sDom": 'Rl<"#library_display_type">f<"dt-process-rel"r><"H"<"library_toolbar"C>><"dataTables_scrolling"t><"F"ip>',
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [],
"fnRowSelected": function ( node ) {
var selected;
//seems to happen if everything is selected
if ( node === null) {
selected = oTable.find("input[type=checkbox]");
selected.attr("checked", true);
}
else {
$(node).find("input[type=checkbox]").attr("checked", true);
selected = oTable.find("input[type=checkbox]").filter(":checked");
}
//checking to enable buttons
AIRTIME.button.enableButton("lib-button-delete");
AIRTIME.library.events.enableAddButtonCheck();
},
"fnRowDeselected": function ( node ) {
var selected;
//seems to happen if everything is deselected
if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", false);
selected = [];
}
else {
$(node).find("input[type=checkbox]").attr("checked", false);
selected = oTable.find("input[type=checkbox]").filter(":checked");
}
//checking to disable buttons
if (selected.length === 0) {
AIRTIME.button.disableButton("lib-button-delete");
}
AIRTIME.library.events.enableAddButtonCheck();
}
},
"oColVis": { "oColVis": {
"sAlign": "right", "sAlign": "right",
@ -306,7 +280,7 @@ var AIRTIME = (function(AIRTIME) {
}); });
oTable.fnSetFilteringDelay(350); oTable.fnSetFilteringDelay(350);
libContentDiv.find(".dataTables_scrolling").css("max-height", tableHeight); $libContent.find(".dataTables_scrolling").css("max-height", tableHeight);
AIRTIME.library.events.setupLibraryToolbar(oTable); AIRTIME.library.events.setupLibraryToolbar(oTable);
@ -322,22 +296,58 @@ var AIRTIME = (function(AIRTIME) {
oTable.fnDraw(); oTable.fnDraw();
}); });
$('[name="pl_cb_all"]').click(function(){ $libTable.find('[name="pl_cb_all"]').click(function() {
var oTT = TableTools.fnGetInstance('library_display'); var $cbs = $libTable.find("input:checkbox"),
$trs;
if ($(this).is(":checked")) { if ($(this).is(":checked")) {
oTT.fnSelectAll(); $cbs.attr("checked", true);
//checking to enable buttons
$trs = $cbs.parents("tr");
$trs.addClass(LIB_SELECTED_CLASS);
AIRTIME.button.enableButton("lib-button-delete");
AIRTIME.library.events.enableAddButtonCheck();
} }
else { else {
oTT.fnSelectNone(); $cbs.attr("checked", false);
$trs = $cbs.parents("tr");
$trs.removeClass(LIB_SELECTED_CLASS);
AIRTIME.button.disableButton("lib-button-delete");
AIRTIME.button.disableButton("lib-button-add");
} }
}); });
//calculate dynamically width for the library search input. $libTable.find("tbody").on("click", "input[type=checkbox]", function() {
//libLength = libContentDiv.find("#library_display_length");
//libType = libContentDiv.find("#library_display_type"); var $cb = $(this),
//libFilter = libContentDiv.find("#library_display_filter"); $selectedCb,
//libFilter.find("input").width(libFilter.width() - libType.width() - libLength.width() - 80); $tr;
if ($cb.is(":checked")) {
$tr = $cb.parents("tr");
$tr.addClass(LIB_SELECTED_CLASS);
//checking to enable buttons
AIRTIME.button.enableButton("lib-button-delete");
AIRTIME.library.events.enableAddButtonCheck();
}
else {
$selectedCb = $libTable.find("tbody input:checkbox").filter(":checked");
$tr = $cb.parents("tr");
$tr.removeClass(LIB_SELECTED_CLASS);
//checking to disable buttons
if ($selectedCb.length === 0) {
AIRTIME.button.disableButton("lib-button-delete");
}
AIRTIME.library.events.enableAddButtonCheck();
}
});
checkImportStatus(); checkImportStatus();
setInterval( checkImportStatus, 5000 ); setInterval( checkImportStatus, 5000 );
@ -345,7 +355,6 @@ var AIRTIME = (function(AIRTIME) {
addQtipToSCIcons(); addQtipToSCIcons();
//begin context menu initialization. //begin context menu initialization.
$.contextMenu({ $.contextMenu({
selector: '#library_display td:not(.library_checkbox)', selector: '#library_display td:not(.library_checkbox)',

View File

@ -275,10 +275,8 @@ var AIRTIME = (function(AIRTIME){
} }
function redrawLib() { function redrawLib() {
var dt = $("#library_display").dataTable(), var dt = $("#library_display").dataTable();
oLibTT = TableTools.fnGetInstance('library_display');
oLibTT.fnSelectNone();
dt.fnStandingRedraw(); dt.fnStandingRedraw();
} }
@ -519,12 +517,11 @@ var AIRTIME = (function(AIRTIME){
fnReceive = function(event, ui) { fnReceive = function(event, ui) {
var aItems = [], var aItems = [],
aSelected, aSelected,
oLibTT = TableTools.fnGetInstance('library_display'),
i, i,
length; length;
//filter out anything that isn't an audiofile. //filter out anything that isn't an audiofile.
aSelected = oLibTT.fnGetSelectedData(); aSelected = AIRTIME.library.getSelectedData();
//if nothing is checked select the dragged item. //if nothing is checked select the dragged item.
if (aSelected.length === 0) { if (aSelected.length === 0) {
aSelected.push(ui.item.data("aData")); aSelected.push(ui.item.data("aData"));

View File

@ -1,7 +1,11 @@
var AIRTIME = (function(AIRTIME){ var AIRTIME = (function(AIRTIME){
var mod, var mod,
oSchedTable, oSchedTable,
fnServerData; SB_SELECTED_CLASS = "sb-selected",
$sbContent,
$sbTable,
$toolbar,
$lib;
if (AIRTIME.showbuilder === undefined) { if (AIRTIME.showbuilder === undefined) {
AIRTIME.showbuilder = {}; AIRTIME.showbuilder = {};
@ -42,15 +46,36 @@ var AIRTIME = (function(AIRTIME){
return val; return val;
}; };
mod.getSelectedData = function() {
var $selected = $sbTable.find("tbody").find("input:checkbox").filter(":checked").parents("tr"),
aData = [],
i, length,
$item;
for (i = 0, length = $selected.length; i < length; i++) {
$item = $($selected.get(i));
aData.push($item.data('aData'));
}
return aData.reverse();
};
mod.selectAll = function () {
$sbTable.find("input:checkbox").attr("checked", true);
};
mod.selectNone = function () {
$sbTable.find("input:checkbox").attr("checked", false);
};
mod.fnAdd = function(aMediaIds, aSchedIds) { mod.fnAdd = function(aMediaIds, aSchedIds) {
var oLibTT = TableTools.fnGetInstance('library_display');
$.post("/showbuilder/schedule-add", $.post("/showbuilder/schedule-add",
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds}, {"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
function(json){ function(json){
checkError(json); checkError(json);
oSchedTable.fnDraw(); oSchedTable.fnDraw();
oLibTT.fnSelectNone(); AIRTIME.library.selectNone();
}); });
}; };
@ -74,20 +99,35 @@ var AIRTIME = (function(AIRTIME){
}); });
}; };
fnServerData = function ( sSource, aoData, fnCallback ) { mod.fnRemoveSelectedItems = function() {
var aData = mod.getSelectedData(),
i,
length,
temp,
aItems = [];
for (i=0, length = aData.length; i < length; i++) {
temp = aData[i];
aItems.push({"id": temp.id, "instance": temp.instance, "timestamp": temp.timestamp});
}
mod.fnRemove(aItems);
};
mod.fnServerData = function ( sSource, aoData, fnCallback ) {
aoData.push( { name: "timestamp", value: AIRTIME.showbuilder.getTimestamp()} ); aoData.push( { name: "timestamp", value: AIRTIME.showbuilder.getTimestamp()} );
aoData.push( { name: "format", value: "json"} ); aoData.push( { name: "format", value: "json"} );
if (fnServerData.hasOwnProperty("start")) { if (mod.fnServerData.hasOwnProperty("start")) {
aoData.push( { name: "start", value: fnServerData.start} ); aoData.push( { name: "start", value: mod.fnServerData.start} );
} }
if (fnServerData.hasOwnProperty("end")) { if (mod.fnServerData.hasOwnProperty("end")) {
aoData.push( { name: "end", value: fnServerData.end} ); aoData.push( { name: "end", value: mod.fnServerData.end} );
} }
if (fnServerData.hasOwnProperty("ops")) { if (mod.fnServerData.hasOwnProperty("ops")) {
aoData.push( { name: "myShows", value: fnServerData.ops.myShows} ); aoData.push( { name: "myShows", value: mod.fnServerData.ops.myShows} );
aoData.push( { name: "showFilter", value: fnServerData.ops.showFilter} ); aoData.push( { name: "showFilter", value: mod.fnServerData.ops.showFilter} );
} }
$.ajax( { $.ajax( {
@ -102,32 +142,12 @@ var AIRTIME = (function(AIRTIME){
} ); } );
}; };
mod.fnServerData = fnServerData;
mod.builderDataTable = function() { mod.builderDataTable = function() {
var $sbContent = $('#show_builder'), $sbContent = $('#show_builder');
$sbTable = $sbContent.find('table'), $lib = $("#library_content"),
oTable, $sbTable = $sbContent.find('table');
fnRemoveSelectedItems,
$toolbar;
fnRemoveSelectedItems = function() { oSchedTable = $sbTable.dataTable( {
var oTT = TableTools.fnGetInstance('show_builder_table'),
aData = oTT.fnGetSelectedData(),
i,
length,
temp,
aItems = [];
for (i=0, length = aData.length; i < length; i++) {
temp = aData[i];
aItems.push({"id": temp.id, "instance": temp.instance, "timestamp": temp.timestamp});
}
AIRTIME.showbuilder.fnRemove(aItems);
};
oTable = $sbTable.dataTable( {
"aoColumns": [ "aoColumns": [
/* checkbox */ {"mDataProp": "allowed", "sTitle": "<input type='checkbox' name='sb_cb_all'>", "sWidth": "15px", "sClass": "sb-checkbox"}, /* checkbox */ {"mDataProp": "allowed", "sTitle": "<input type='checkbox' name='sb_cb_all'>", "sWidth": "15px", "sClass": "sb-checkbox"},
/* Type */ {"mDataProp": "image", "sTitle": "", "sClass": "library_image sb-image", "sWidth": "16px"}, /* Type */ {"mDataProp": "image", "sTitle": "", "sClass": "library_image sb-image", "sWidth": "16px"},
@ -163,11 +183,7 @@ var AIRTIME = (function(AIRTIME){
url: "/usersettings/set-timeline-datatable", url: "/usersettings/set-timeline-datatable",
type: "POST", type: "POST",
data: {settings : oData, format: "json"}, data: {settings : oData, format: "json"},
dataType: "json", dataType: "json"
success: function(){},
error: function (jqXHR, textStatus, errorThrown) {
var x;
}
}); });
}, },
"fnStateLoad": function (oSettings) { "fnStateLoad": function (oSettings) {
@ -181,9 +197,6 @@ var AIRTIME = (function(AIRTIME){
async: false, async: false,
success: function(json){ success: function(json){
o = json.settings; o = json.settings;
},
error: function (jqXHR, textStatus, errorThrown) {
var x;
} }
}); });
@ -378,10 +391,7 @@ var AIRTIME = (function(AIRTIME){
}, },
//remove any selected nodes before the draw. //remove any selected nodes before the draw.
"fnPreDrawCallback": function( oSettings ) { "fnPreDrawCallback": function( oSettings ) {
var oTT; mod.selectNone();
oTT = TableTools.fnGetInstance('show_builder_table');
oTT.fnSelectNone();
//disable jump to current button. //disable jump to current button.
AIRTIME.button.disableButton("sb-button-current"); AIRTIME.button.disableButton("sb-button-current");
@ -395,8 +405,6 @@ var AIRTIME = (function(AIRTIME){
markerDiv, markerDiv,
$td, $td,
$tr, $tr,
$lib = $("#library_content"),
oTable = $('#show_builder_table').dataTable(),
aData, aData,
elements, elements,
i, length, temp, i, length, temp,
@ -453,7 +461,7 @@ var AIRTIME = (function(AIRTIME){
setTimeout(function(){ setTimeout(function(){
AIRTIME.showbuilder.resetTimestamp(); AIRTIME.showbuilder.resetTimestamp();
oTable.fnDraw(); oSchedTable.fnDraw();
}, aData.refresh * 1000); //need refresh in milliseconds }, aData.refresh * 1000); //need refresh in milliseconds
break; break;
@ -491,75 +499,60 @@ var AIRTIME = (function(AIRTIME){
"iFixedColumns": 2 "iFixedColumns": 2
}, },
"oTableTools": { // R = ColReorderResize, C = ColVis
"sRowSelect": "multi", "sDom": 'R<"dt-process-rel"r><"sb-padded"<"H"C>><"dataTables_scrolling sb-padded"t>',
"aButtons": [],
"fnPreRowSelect": function ( e ) {
var node = e.currentTarget;
//don't select separating rows, or shows without privileges.
if ($(node).hasClass("sb-header")
|| $(node).hasClass("sb-footer")
|| $(node).hasClass("sb-empty")
|| $(node).hasClass("sb-not-allowed")
|| $(node).hasClass("sb-past")) {
return false;
}
return true;
},
"fnRowSelected": function ( node ) {
//seems to happen if everything is selected
if ( node === null) {
$sbTable.find("tbody input[type=checkbox]").attr("checked", true);
}
else {
$(node).find("input[type=checkbox]").attr("checked", true);
}
//checking to enable buttons
AIRTIME.button.enableButton("sb-button-delete");
},
"fnRowDeselected": function ( node ) {
var selected;
//seems to happen if everything is deselected
if ( node === null) {
$sbTable.find("input[type=checkbox]").attr("checked", false);
selected = [];
}
else {
$(node).find("input[type=checkbox]").attr("checked", false);
selected = $sbTable.find("input[type=checkbox]").filter(":checked");
}
//checking to disable buttons
if (selected.length === 0) {
AIRTIME.button.disableButton("sb-button-delete");
}
}
},
// R = ColReorderResize, C = ColVis, T = TableTools
"sDom": 'R<"dt-process-rel"r><"sb-padded"<"H"CT>><"dataTables_scrolling sb-padded"t>',
"sAjaxDataProp": "schedule", "sAjaxDataProp": "schedule",
"sAjaxSource": "/showbuilder/builder-feed" "sAjaxSource": "/showbuilder/builder-feed"
}); });
$('[name="sb_cb_all"]').click(function(){ //adding checkbox events.
var oTT = TableTools.fnGetInstance('show_builder_table'); $sbTable.find('[name="sb_cb_all"]').click(function() {
var $cbs = $sbTable.find("input:checkbox"),
$trs;
if ($(this).is(":checked")) { if ($(this).is(":checked")) {
var allowedNodes; $cbs.attr("checked", true);
//checking to enable buttons
allowedNodes = oTable.find('tr:not(:first, .sb-header, .sb-empty, .sb-footer, .sb-not-allowed, .sb-past)'); $trs = $cbs.parents("tr");
$trs.addClass(SB_SELECTED_CLASS);
allowedNodes.each(function(i, el){ AIRTIME.button.enableButton("sb-button-delete");
oTT.fnSelect(el);
});
} }
else { else {
oTT.fnSelectNone(); $cbs.attr("checked", false);
$trs = $cbs.parents("tr");
$trs.removeClass(SB_SELECTED_CLASS);
AIRTIME.button.disableButton("sb-button-delete");
}
});
$sbTable.find("tbody").on("click", "input:checkbox", function() {
var $cb = $(this),
$selectedCb,
$tr;
if ($cb.is(":checked")) {
$tr = $cb.parents("tr");
$tr.addClass(SB_SELECTED_CLASS);
//checking to enable buttons
AIRTIME.button.enableButton("sb-button-delete");
}
else {
$selectedCb = $libTable.find("tbody input:checkbox").filter(":checked");
$tr = $cb.parents("tr");
$tr.removeClass(SB_SELECTED_CLASS);
//checking to disable buttons
if ($selectedCb.length === 0) {
AIRTIME.button.disableButton("sb-button-delete");
}
} }
}); });
@ -602,10 +595,9 @@ var AIRTIME = (function(AIRTIME){
}; };
fnReceive = function(event, ui) { fnReceive = function(event, ui) {
var aItems = [], var aItems = [];
oLibTT = TableTools.fnGetInstance('library_display');
aItems = oLibTT.fnGetSelectedData(); aItems = AIRTIME.library.getSelectedData();
//if nothing is checked select the dragged item. //if nothing is checked select the dragged item.
if (aItems.length === 0) { if (aItems.length === 0) {
@ -663,9 +655,7 @@ var AIRTIME = (function(AIRTIME){
forcePlaceholderSize: true, forcePlaceholderSize: true,
distance: 10, distance: 10,
helper: function(event, item) { helper: function(event, item) {
var oTT = TableTools.fnGetInstance('show_builder_table'), var selected = mod.getSelectedData(),
selected = oTT.fnGetSelectedData(),
elements = $sbTable.find('tr:not(:first) input:checked').parents('tr'),
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"),
@ -673,8 +663,6 @@ var AIRTIME = (function(AIRTIME){
height = trfirst.height(), height = trfirst.height(),
message; message;
//elements.hide();
//if nothing is checked select the dragged item. //if nothing is checked select the dragged item.
if (selected.length === 0) { if (selected.length === 0) {
selected = [item.data("aData")]; selected = [item.data("aData")];
@ -803,12 +791,9 @@ var AIRTIME = (function(AIRTIME){
return; return;
} }
fnRemoveSelectedItems(); mod.fnRemoveSelectedItems();
}); });
//set things like a reference to the table.
AIRTIME.showbuilder.init(oTable);
//add events to cursors. //add events to cursors.
$sbTable.find("tbody").on("click", "div.marker", function(event) { $sbTable.find("tbody").on("click", "div.marker", function(event) {
var $tr = $(this).parents("tr"), var $tr = $(this).parents("tr"),
@ -930,10 +915,6 @@ var AIRTIME = (function(AIRTIME){
}); });
}; };
mod.init = function(oTable) {
oSchedTable = oTable;
};
return AIRTIME; return AIRTIME;
}(AIRTIME || {})); }(AIRTIME || {}));