diff --git a/airtime_mvc/application/controllers/LibraryController.php b/airtime_mvc/application/controllers/LibraryController.php
index 772b83a4d..64d411086 100644
--- a/airtime_mvc/application/controllers/LibraryController.php
+++ b/airtime_mvc/application/controllers/LibraryController.php
@@ -57,6 +57,7 @@ class LibraryController extends Zend_Controller_Action
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/main_library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php
index 86678e8ba..a97471759 100644
--- a/airtime_mvc/application/controllers/ScheduleController.php
+++ b/airtime_mvc/application/controllers/ScheduleController.php
@@ -59,6 +59,29 @@ class ScheduleController extends Zend_Controller_Action
$this->view->headLink()->appendStylesheet($baseUrl.'/css/add-show.css?'.$CC_CONFIG['airtime_version']);
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);
+ //Start Show builder JS/CSS requirements
+ $this->view->headScript()->appendFile($baseUrl.'/js/contextmenu/jquery.contextMenu.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/datatables/js/jquery.dataTables.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.pluginAPI.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/datatables/plugin/dataTables.fnSetFilteringDelay.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.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($this->view->baseUrl('/js/airtime/library/events/library_showbuilder.js?'.$CC_CONFIG['airtime_version']),'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/airtime/library/library.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
+
+ $this->view->headLink()->appendStylesheet($baseUrl.'/css/media_library.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/ColReorder.css?'.$CC_CONFIG['airtime_version']);
+ $this->view->headLink()->appendStylesheet($baseUrl.'/css/TableTools.css?'.$CC_CONFIG['airtime_version']);
+ $this->view->headLink()->appendStylesheet($baseUrl.'/css/showbuilder.css?'.$CC_CONFIG['airtime_version']);
+ //End Show builder JS/CSS requirements
+
Application_Model_Schedule::createNewFormSections($this->view);
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
@@ -78,10 +101,12 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
- if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER)))
+ if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
$editable = true;
- else
+ }
+ else {
$editable = false;
+ }
$this->view->events = Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
}
@@ -95,19 +120,19 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id);
- if($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
- try{
+ if ($user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER))) {
+ try {
$showInstance = new Application_Model_ShowInstance($showInstanceId);
- }catch(Exception $e){
+ } catch (Exception $e){
$this->view->show_error = true;
return false;
}
$error = $showInstance->moveShow($deltaDay, $deltaMin);
}
- if(isset($error))
+ if (isset($error)) {
$this->view->error = $error;
-
+ }
}
public function resizeShowAction()
@@ -200,7 +225,7 @@ class ScheduleController extends Zend_Controller_Action
&& !$instance->isRebroadcast()) {
$menu["schedule"] = array("name"=> "Add / Remove Content",
- "url" => "/showbuilder/index/");
+ "url" => "/showbuilder/builder-dialog/");
$menu["clear"] = array("name"=> "Remove All Content", "icon" => "delete",
"url" => "/schedule/clear-show");
diff --git a/airtime_mvc/application/controllers/ShowbuilderController.php b/airtime_mvc/application/controllers/ShowbuilderController.php
index ef8177f7c..1a9082988 100644
--- a/airtime_mvc/application/controllers/ShowbuilderController.php
+++ b/airtime_mvc/application/controllers/ShowbuilderController.php
@@ -9,6 +9,7 @@ class ShowbuilderController extends Zend_Controller_Action
$ajaxContext->addActionContext('schedule-move', 'json')
->addActionContext('schedule-add', 'json')
->addActionContext('schedule-remove', 'json')
+ ->addActionContext('builder-dialog', 'json')
->addActionContext('builder-feed', 'json')
->initContext();
}
@@ -53,11 +54,40 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js','text/javascript');
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/builder.js','text/javascript');
+ $this->view->headScript()->appendFile($baseUrl.'/js/airtime/showbuilder/main_builder.js','text/javascript');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/showbuilder.css');
}
+ public function builderDialogAction() {
+
+ $request = $this->getRequest();
+ $id = $request->getParam("id");
+
+ $instance = CcShowInstancesQuery::create()->findPK($id);
+
+ if (is_null($instance)) {
+ $this->view->error = "show does not exist";
+ return;
+ }
+
+ $start = $instance->getDbStarts(null);
+ $start->setTimezone(new DateTimeZone(date_default_timezone_get()));
+ $end = $instance->getDbEnds(null);
+ $end->setTimezone(new DateTimeZone(date_default_timezone_get()));
+
+ $show_name = $instance->getCcShow()->getDbName();
+ $start_time = $start->format("Y-m-d H:i:s");
+ $end_time = $end->format("Y-m-d H:i:s");
+
+ $this->view->title = "{$show_name}: {$start_time} - {$end_time}";
+ $this->view->start = $instance->getDbStarts("U");
+ $this->view->end = $instance->getDbEnds("U");
+
+ $this->view->dialog = $this->view->render('showbuilder/builderDialog.phtml');
+ }
+
public function builderFeedAction() {
$request = $this->getRequest();
diff --git a/airtime_mvc/application/models/Show.php b/airtime_mvc/application/models/Show.php
index ec4cdbcfe..d9d91cf52 100644
--- a/airtime_mvc/application/models/Show.php
+++ b/airtime_mvc/application/models/Show.php
@@ -1491,7 +1491,7 @@ class Application_Model_Show {
$events = array();
$interval = $start->diff($end);
- $days = $interval->format('%a');
+ $days = $interval->format('%a');
$shows = Application_Model_Show::getShows($start, $end);
@@ -1508,10 +1508,9 @@ class Application_Model_Show {
if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) {
$options["editable"] = true;
- $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
- } else {
- $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
}
+
+ $events[] = Application_Model_Show::makeFullCalendarEvent($show, $options);
}
return $events;
@@ -1521,10 +1520,6 @@ class Application_Model_Show {
{
$event = array();
- if($show["rebroadcast"]) {
- $event["disableResizing"] = true;
- }
-
$startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC"));
$startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
@@ -1538,29 +1533,27 @@ class Application_Model_Show {
$event["end"] = $endDateTime->format("Y-m-d H:i:s");
$event["endUnix"] = $endDateTime->format("U");
$event["allDay"] = false;
- //$event["description"] = $show["description"];
$event["showId"] = intval($show["show_id"]);
$event["record"] = intval($show["record"]);
$event["rebroadcast"] = intval($show["rebroadcast"]);
// get soundcloud_id
- if(!is_null($show["file_id"])){
+ if (!is_null($show["file_id"])){
$file = Application_Model_StoredFile::Recall($show["file_id"]);
$soundcloud_id = $file->getSoundCloudId();
- }else{
- $soundcloud_id = null;
}
- $event["soundcloud_id"] = (is_null($soundcloud_id) ? -1 : $soundcloud_id);
+
+ $event["soundcloud_id"] = isset($soundcloud_id) ? $soundcloud_id : -1;
//event colouring
- if($show["color"] != "") {
+ if ($show["color"] != "") {
$event["textColor"] = "#".$show["color"];
}
- if($show["background_color"] != "") {
+ if ($show["background_color"] != "") {
$event["color"] = "#".$show["background_color"];
}
- foreach($options as $key=>$value) {
+ foreach ($options as $key => $value) {
$event[$key] = $value;
}
diff --git a/airtime_mvc/application/views/scripts/showbuilder/builderDialog.phtml b/airtime_mvc/application/views/scripts/showbuilder/builderDialog.phtml
new file mode 100644
index 000000000..8c8bee2b5
--- /dev/null
+++ b/airtime_mvc/application/views/scripts/showbuilder/builderDialog.phtml
@@ -0,0 +1,9 @@
+
+
+
File import in progress...
+
+
+
+
\ No newline at end of file
diff --git a/airtime_mvc/public/css/datatables/css/ColVis.css b/airtime_mvc/public/css/datatables/css/ColVis.css
index 95987b876..f4be403c1 100644
--- a/airtime_mvc/public/css/datatables/css/ColVis.css
+++ b/airtime_mvc/public/css/datatables/css/ColVis.css
@@ -30,7 +30,7 @@ button.ColVis_Button::-moz-focus-inner {
div.ColVis_collectionBackground {
background-color: black;
- z-index: 996;
+ z-index: 1003;
}
div.ColVis_collection {
@@ -39,7 +39,7 @@ div.ColVis_collection {
background-color: #999;
padding: 3px;
border: 1px solid #ccc;
- z-index: 998;
+ z-index: 1005;
}
div.ColVis_collection button.ColVis_Button {
@@ -51,7 +51,7 @@ div.ColVis_collection button.ColVis_Button {
div.ColVis_catcher {
position: absolute;
- z-index: 997;
+ z-index: 1004;
}
.disabled {
diff --git a/airtime_mvc/public/css/showbuilder.css b/airtime_mvc/public/css/showbuilder.css
index 9854c67b4..eefd5bf57 100644
--- a/airtime_mvc/public/css/showbuilder.css
+++ b/airtime_mvc/public/css/showbuilder.css
@@ -34,4 +34,13 @@ tr.cursor-selected-row .marker {
.sb-over {
background-color:#ff3030;
+}
+
+.ui-dialog .wrapper {
+ margin: 0;
+ padding: 10px 0 0 0;
+}
+
+.ui-dialog .ui-buttonset {
+ margin-right: 0 !important;
}
\ No newline at end of file
diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css
index 9845cd260..5215c675e 100644
--- a/airtime_mvc/public/css/styles.css
+++ b/airtime_mvc/public/css/styles.css
@@ -601,6 +601,7 @@ dl.inline-list dd {
}
.dataTables_info {
+ float: left;
padding: 8px 0 0 8px;
font-size:12px;
color:#555555;
@@ -608,6 +609,7 @@ dl.inline-list dd {
}
.dataTables_paginate {
+ float: right;
padding: 8px 0 8px 8px;
}
.dataTables_paginate .ui-button {
@@ -618,7 +620,7 @@ dl.inline-list dd {
}
.dataTables_filter input {
background: url("images/search_auto_bg.png") no-repeat scroll 0 0 #DDDDDD;
- width: 60%;
+ width: 55%;
border: 1px solid #5B5B5B;
margin-left: -8px;
padding: 4px 3px 4px 25px;
diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js
index 97ceea6b1..42aa267ef 100644
--- a/airtime_mvc/public/js/airtime/library/library.js
+++ b/airtime_mvc/public/js/airtime/library/library.js
@@ -1,5 +1,6 @@
var AIRTIME = (function(AIRTIME){
- var mod;
+ var mod,
+ libraryInit;
if (AIRTIME.library === undefined) {
AIRTIME.library = {};
@@ -40,6 +41,408 @@ var AIRTIME = (function(AIRTIME){
AIRTIME.library.fnDeleteItems(aMedia);
};
+ libraryInit = function() {
+ var oTable;
+
+ oTable = $('#library_display').dataTable( {
+
+ "aoColumns": [
+ /* Checkbox */ {"sTitle": "", "mDataProp": "checkbox", "bSortable": false, "bSearchable": false, "sWidth": "25px", "sClass": "library_checkbox"},
+ /* Type */ {"sTitle": "", "mDataProp": "image", "bSearchable": false, "sWidth": "25px", "sClass": "library_type", "iDataSort": 2},
+ /* ftype */ {"sTitle": "", "mDataProp": "ftype", "bSearchable": false, "bVisible": false},
+ /* Title */ {"sTitle": "Title", "mDataProp": "track_title", "sClass": "library_title"},
+ /* Creator */ {"sTitle": "Creator", "mDataProp": "artist_name", "sClass": "library_creator"},
+ /* Album */ {"sTitle": "Album", "mDataProp": "album_title", "sClass": "library_album"},
+ /* Genre */ {"sTitle": "Genre", "mDataProp": "genre", "sClass": "library_genre"},
+ /* Year */ {"sTitle": "Year", "mDataProp": "year", "sClass": "library_year", "sWidth": "60px"},
+ /* Length */ {"sTitle": "Length", "mDataProp": "length", "sClass": "library_length", "sWidth": "80px"},
+ /* Upload Time */ {"sTitle": "Uploaded", "mDataProp": "utime", "sClass": "library_upload_time"},
+ /* Last Modified */ {"sTitle": "Last Modified", "mDataProp": "mtime", "bVisible": false, "sClass": "library_modified_time"},
+ /* Track Number */ {"sTitle": "Track", "mDataProp": "track_number", "bSearchable": false, "bVisible": false, "sClass": "library_track"},
+ /* Mood */ {"sTitle": "Mood", "mDataProp": "mood", "bSearchable": false, "bVisible": false, "sClass": "library_mood"},
+ /* BPM */ {"sTitle": "BPM", "mDataProp": "bpm", "bSearchable": false, "bVisible": false, "sClass": "library_bpm"},
+ /* Composer */ {"sTitle": "Composer", "mDataProp": "composer", "bSearchable": false, "bVisible": false, "sClass": "library_composer"},
+ /* Website */ {"sTitle": "Website", "mDataProp": "info_url", "bSearchable": false, "bVisible": false, "sClass": "library_url"},
+ /* Bit Rate */ {"sTitle": "Bit Rate", "mDataProp": "bit_rate", "bSearchable": false, "bVisible": false, "sClass": "library_bitrate", "sWidth": "80px"},
+ /* Sample Rate */ {"sTitle": "Sample", "mDataProp": "sample_rate", "bSearchable": false, "bVisible": false, "sClass": "library_sr", "sWidth": "80px"},
+ /* ISRC Number */ {"sTitle": "ISRC", "mDataProp": "isrc_number", "bSearchable": false, "bVisible": false, "sClass": "library_isrc"},
+ /* Encoded */ {"sTitle": "Encoded", "mDataProp": "encoded_by", "bSearchable": false, "bVisible": false, "sClass": "library_encoded"},
+ /* Label */ {"sTitle": "Label", "mDataProp": "label", "bSearchable": false, "bVisible": false, "sClass": "library_label"},
+ /* Copyright */ {"sTitle": "Copyright", "mDataProp": "copyright", "bSearchable": false, "bVisible": false, "sClass": "library_copyright"},
+ /* Mime */ {"sTitle": "Mime", "mDataProp": "mime", "bSearchable": false, "bVisible": false, "sClass": "library_mime"},
+ /* Language */ {"sTitle": "Language", "mDataProp": "language", "bSearchable": false, "bVisible": false, "sClass": "library_language"}
+ ],
+
+ "bProcessing": true,
+ "bServerSide": true,
+
+ "bStateSave": true,
+ "fnStateSaveParams": function (oSettings, oData) {
+ //remove oData components we don't want to save.
+ delete oData.oSearch;
+ delete oData.aoSearchCols;
+ },
+ "fnStateSave": function (oSettings, oData) {
+
+ $.ajax({
+ url: "/usersettings/set-library-datatable",
+ type: "POST",
+ data: {settings : oData, format: "json"},
+ dataType: "json",
+ success: function(){},
+ error: function (jqXHR, textStatus, errorThrown) {
+ var x;
+ }
+ });
+ },
+ "fnStateLoad": function (oSettings) {
+ var o;
+
+ $.ajax({
+ url: "/usersettings/get-library-datatable",
+ type: "GET",
+ data: {format: "json"},
+ dataType: "json",
+ async: false,
+ success: function(json){
+ o = json.settings;
+ },
+ error: function (jqXHR, textStatus, errorThrown) {
+ var x;
+ }
+ });
+
+ return o;
+ },
+ "fnStateLoadParams": function (oSettings, oData) {
+ var i,
+ length,
+ a = oData.abVisCols;
+
+ //putting serialized data back into the correct js type to make
+ //sure everything works properly.
+ for (i = 0, length = a.length; i < length; i++) {
+ a[i] = (a[i] === "true") ? true : false;
+ }
+
+ a = oData.ColReorder;
+ for (i = 0, length = a.length; i < length; i++) {
+ a[i] = parseInt(a[i], 10);
+ }
+
+ oData.iEnd = parseInt(oData.iEnd, 10);
+ oData.iLength = parseInt(oData.iLength, 10);
+ oData.iStart = parseInt(oData.iStart, 10);
+ oData.iCreate = parseInt(oData.iCreate, 10);
+ },
+
+ "sAjaxSource": "/Library/contents",
+ "fnServerData": function ( sSource, aoData, fnCallback ) {
+ var type;
+
+ aoData.push( { name: "format", value: "json"} );
+
+ //push whether to search files/playlists or all.
+ type = $("#library_display_type").find("select").val();
+ type = (type === undefined) ? 0 : type;
+ aoData.push( { name: "type", value: type} );
+
+ $.ajax( {
+ "dataType": 'json',
+ "type": "GET",
+ "url": sSource,
+ "data": aoData,
+ "success": fnCallback
+ } );
+ },
+ "fnRowCallback": AIRTIME.library.events.fnRowCallback,
+ "fnCreatedRow": function( nRow, aData, iDataIndex ) {
+
+ //call the context menu so we can prevent the event from propagating.
+ $(nRow).find('td:not(.library_checkbox)').click(function(e){
+
+ $(this).contextMenu({x: e.pageX, y: e.pageY});
+
+ return false;
+ });
+
+ //add a tool tip to appear when the user clicks on the type icon.
+ $(nRow).find("td:not(:first, td>img)").qtip({
+ content: {
+ text: "Loading...",
+ title: {
+ text: aData.track_title
+ },
+ ajax: {
+ url: "/Library/get-file-meta-data",
+ type: "get",
+ data: ({format: "html", id : aData.id, type: aData.ftype}),
+ success: function(data, status) {
+ this.set('content.text', data);
+ }
+ }
+ },
+ position: {
+ target: 'event',
+ adjust: {
+ resize: true,
+ method: "flip flip"
+ },
+ my: 'left center',
+ at: 'right center',
+ viewport: $(window), // Keep the tooltip on-screen at all times
+ effect: false // Disable positioning animation
+ },
+ style: {
+ classes: "ui-tooltip-dark"
+ },
+ show: 'mousedown',
+ events: {
+ show: function(event, api) {
+ // Only show the tooltip if it was a right-click
+ if(event.originalEvent.button !== 2) {
+ event.preventDefault();
+ }
+ }
+ },
+ hide: 'mouseout'
+
+ });
+ },
+ "fnDrawCallback": AIRTIME.library.events.fnDrawCallback,
+ "fnHeaderCallback": function(nHead) {
+ $(nHead).find("input[type=checkbox]").attr("checked", false);
+ },
+
+ "aaSorting": [[3, 'asc']],
+ "sPaginationType": "full_numbers",
+ "bJQueryUI": true,
+ "bAutoWidth": false,
+ "oLanguage": {
+ "sSearch": ""
+ },
+
+ // R = ColReorder, C = ColVis, T = TableTools
+ "sDom": 'Rl<"#library_display_type">fr<"H"T<"library_toolbar"C>>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("library_group_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("library_group_delete");
+ }
+ AIRTIME.library.events.enableAddButtonCheck();
+ }
+ },
+
+ "oColVis": {
+ "buttonText": "Show/Hide Columns",
+ "sAlign": "right",
+ "aiExclude": [0, 1, 2],
+ "sSize": "css"
+ },
+
+ "oColReorder": {
+ "iFixedColumns": 2
+ }
+
+ });
+ oTable.fnSetFilteringDelay(350);
+
+ AIRTIME.library.events.setupLibraryToolbar(oTable);
+
+ $("#library_display_type")
+ .addClass("dataTables_type")
+ .append('')
+ .find("select")
+ .append('')
+ .append('')
+ .append('')
+ .end()
+ .change(function(ev){
+ oTable.fnDraw();
+ });
+
+ $('[name="pl_cb_all"]').click(function(){
+ var oTT = TableTools.fnGetInstance('library_display');
+
+ if ($(this).is(":checked")) {
+ oTT.fnSelectAll();
+ }
+ else {
+ oTT.fnSelectNone();
+ }
+ });
+
+ checkImportStatus();
+ setInterval( checkImportStatus, 5000 );
+ setInterval( checkSCUploadStatus, 5000 );
+
+ addQtipToSCIcons();
+
+ $.contextMenu({
+ selector: '#library_display td:not(.library_checkbox)',
+ trigger: "left",
+ ignoreRightClick: true,
+
+ build: function($el, e) {
+ var data, screen, items, callback, $tr;
+
+ $tr = $el.parent();
+ data = $tr.data("aData");
+ screen = $tr.data("screen");
+
+ function processMenuItems(oItems) {
+
+ //define an add to playlist callback.
+ if (oItems.pl_add !== undefined) {
+
+ callback = function() {
+ AIRTIME.playlist.fnAddItems([data.id], undefined, 'after');
+ };
+
+ oItems.pl_add.callback = callback;
+ }
+
+ //define an edit callback.
+ if (oItems.edit !== undefined) {
+
+ if (data.ftype === "audioclip") {
+ callback = function() {
+ document.location.href = oItems.edit.url;
+ };
+ }
+ else {
+ callback = function() {
+ AIRTIME.playlist.fnEdit(data.id);
+ };
+ }
+ oItems.edit.callback = callback;
+ }
+
+ //define a delete callback.
+ if (oItems.del !== undefined) {
+
+ //delete through the playlist controller, will reset
+ //playlist screen if this is the currently edited playlist.
+ if (data.ftype === "playlist" && screen === "playlist") {
+ callback = function() {
+
+ if (confirm('Are you sure you want to delete the selected item?')) {
+ AIRTIME.playlist.fnDelete(data.id);
+ }
+ };
+ }
+ else {
+ callback = function() {
+ var media = [];
+
+ if (confirm('Are you sure you want to delete the selected item?')) {
+
+ media.push({"id": data.id, "type": data.ftype});
+ $.post(oItems.del.url, {format: "json", media: media }, function(json){
+ var oTable;
+
+ if (json.message) {
+ alert(json.message);
+ }
+
+ oTable = $("#library_display").dataTable();
+ oTable.fnDeleteRow( $tr[0] );
+ });
+ }
+ };
+ }
+
+ oItems.del.callback = callback;
+ }
+
+ //define a download callback.
+ if (oItems.download !== undefined) {
+
+ callback = function() {
+ document.location.href = oItems.download.url;
+ };
+ oItems.download.callback = callback;
+ }
+ //add callbacks for Soundcloud menu items.
+ if (oItems.soundcloud !== undefined) {
+ var soundcloud = oItems.soundcloud.items;
+
+ //define an upload to soundcloud callback.
+ if (soundcloud.upload !== undefined) {
+
+ callback = function() {
+ $.post(soundcloud.upload.url, function(){
+ addProgressIcon(data.id);
+ });
+ };
+ soundcloud.upload.callback = callback;
+ }
+
+ //define a view on soundcloud callback
+ if (soundcloud.view !== undefined) {
+
+ callback = function() {
+ window.open(soundcloud.view.url);
+ };
+ soundcloud.view.callback = callback;
+ }
+ }
+
+ items = oItems;
+ }
+
+ request = $.ajax({
+ url: "/library/context-menu",
+ type: "GET",
+ data: {id : data.id, type: data.ftype, format: "json", "screen": screen},
+ dataType: "json",
+ async: false,
+ success: function(json){
+ processMenuItems(json.items);
+ }
+ });
+
+ return {
+ items: items
+ };
+ }
+ });
+ };
+ mod.libraryInit = libraryInit;
+
return AIRTIME;
}(AIRTIME || {}));
@@ -217,405 +620,4 @@ function addQtipToSCIcons(){
});
}
});
-}
-
-$(document).ready(function() {
- var oTable;
-
- oTable = $('#library_display').dataTable( {
-
- "aoColumns": [
- /* Checkbox */ {"sTitle": "", "mDataProp": "checkbox", "bSortable": false, "bSearchable": false, "sWidth": "25px", "sClass": "library_checkbox"},
- /* Type */ {"sTitle": "", "mDataProp": "image", "bSearchable": false, "sWidth": "25px", "sClass": "library_type", "iDataSort": 2},
- /* ftype */ {"sTitle": "", "mDataProp": "ftype", "bSearchable": false, "bVisible": false},
- /* Title */ {"sTitle": "Title", "mDataProp": "track_title", "sClass": "library_title"},
- /* Creator */ {"sTitle": "Creator", "mDataProp": "artist_name", "sClass": "library_creator"},
- /* Album */ {"sTitle": "Album", "mDataProp": "album_title", "sClass": "library_album"},
- /* Genre */ {"sTitle": "Genre", "mDataProp": "genre", "sClass": "library_genre"},
- /* Year */ {"sTitle": "Year", "mDataProp": "year", "sClass": "library_year", "sWidth": "60px"},
- /* Length */ {"sTitle": "Length", "mDataProp": "length", "sClass": "library_length", "sWidth": "80px"},
- /* Upload Time */ {"sTitle": "Uploaded", "mDataProp": "utime", "sClass": "library_upload_time"},
- /* Last Modified */ {"sTitle": "Last Modified", "mDataProp": "mtime", "bVisible": false, "sClass": "library_modified_time"},
- /* Track Number */ {"sTitle": "Track", "mDataProp": "track_number", "bSearchable": false, "bVisible": false, "sClass": "library_track"},
- /* Mood */ {"sTitle": "Mood", "mDataProp": "mood", "bSearchable": false, "bVisible": false, "sClass": "library_mood"},
- /* BPM */ {"sTitle": "BPM", "mDataProp": "bpm", "bSearchable": false, "bVisible": false, "sClass": "library_bpm"},
- /* Composer */ {"sTitle": "Composer", "mDataProp": "composer", "bSearchable": false, "bVisible": false, "sClass": "library_composer"},
- /* Website */ {"sTitle": "Website", "mDataProp": "info_url", "bSearchable": false, "bVisible": false, "sClass": "library_url"},
- /* Bit Rate */ {"sTitle": "Bit Rate", "mDataProp": "bit_rate", "bSearchable": false, "bVisible": false, "sClass": "library_bitrate", "sWidth": "80px"},
- /* Sample Rate */ {"sTitle": "Sample", "mDataProp": "sample_rate", "bSearchable": false, "bVisible": false, "sClass": "library_sr", "sWidth": "80px"},
- /* ISRC Number */ {"sTitle": "ISRC", "mDataProp": "isrc_number", "bSearchable": false, "bVisible": false, "sClass": "library_isrc"},
- /* Encoded */ {"sTitle": "Encoded", "mDataProp": "encoded_by", "bSearchable": false, "bVisible": false, "sClass": "library_encoded"},
- /* Label */ {"sTitle": "Label", "mDataProp": "label", "bSearchable": false, "bVisible": false, "sClass": "library_label"},
- /* Copyright */ {"sTitle": "Copyright", "mDataProp": "copyright", "bSearchable": false, "bVisible": false, "sClass": "library_copyright"},
- /* Mime */ {"sTitle": "Mime", "mDataProp": "mime", "bSearchable": false, "bVisible": false, "sClass": "library_mime"},
- /* Language */ {"sTitle": "Language", "mDataProp": "language", "bSearchable": false, "bVisible": false, "sClass": "library_language"}
- ],
-
- "bProcessing": true,
- "bServerSide": true,
-
- "bStateSave": true,
- "fnStateSaveParams": function (oSettings, oData) {
- //remove oData components we don't want to save.
- delete oData.oSearch;
- delete oData.aoSearchCols;
- },
- "fnStateSave": function (oSettings, oData) {
-
- $.ajax({
- url: "/usersettings/set-library-datatable",
- type: "POST",
- data: {settings : oData, format: "json"},
- dataType: "json",
- success: function(){},
- error: function (jqXHR, textStatus, errorThrown) {
- var x;
- }
- });
- },
- "fnStateLoad": function (oSettings) {
- var o;
-
- $.ajax({
- url: "/usersettings/get-library-datatable",
- type: "GET",
- data: {format: "json"},
- dataType: "json",
- async: false,
- success: function(json){
- o = json.settings;
- },
- error: function (jqXHR, textStatus, errorThrown) {
- var x;
- }
- });
-
- return o;
- },
- "fnStateLoadParams": function (oSettings, oData) {
- var i,
- length,
- a = oData.abVisCols;
-
- //putting serialized data back into the correct js type to make
- //sure everything works properly.
- for (i = 0, length = a.length; i < length; i++) {
- a[i] = (a[i] === "true") ? true : false;
- }
-
- a = oData.ColReorder;
- for (i = 0, length = a.length; i < length; i++) {
- a[i] = parseInt(a[i], 10);
- }
-
- oData.iEnd = parseInt(oData.iEnd, 10);
- oData.iLength = parseInt(oData.iLength, 10);
- oData.iStart = parseInt(oData.iStart, 10);
- oData.iCreate = parseInt(oData.iCreate, 10);
- },
-
- "sAjaxSource": "/Library/contents",
- "fnServerData": function ( sSource, aoData, fnCallback ) {
- var type;
-
- aoData.push( { name: "format", value: "json"} );
-
- //push whether to search files/playlists or all.
- type = $("#library_display_type").find("select").val();
- type = (type === undefined) ? 0 : type;
- aoData.push( { name: "type", value: type} );
-
- $.ajax( {
- "dataType": 'json',
- "type": "GET",
- "url": sSource,
- "data": aoData,
- "success": fnCallback
- } );
- },
- "fnRowCallback": AIRTIME.library.events.fnRowCallback,
- "fnCreatedRow": function( nRow, aData, iDataIndex ) {
-
- //call the context menu so we can prevent the event from propagating.
- $(nRow).find('td:not(.library_checkbox)').click(function(e){
-
- $(this).contextMenu({x: e.pageX, y: e.pageY});
-
- return false;
- });
-
- //add a tool tip to appear when the user clicks on the type icon.
- $(nRow).find("td:not(:first, td>img)").qtip({
- content: {
- text: "Loading...",
- title: {
- text: aData.track_title
- },
- ajax: {
- url: "/Library/get-file-meta-data",
- type: "get",
- data: ({format: "html", id : aData.id, type: aData.ftype}),
- success: function(data, status) {
- this.set('content.text', data);
- }
- }
- },
- position: {
- target: 'event',
- adjust: {
- resize: true,
- method: "flip flip"
- },
- my: 'left center',
- at: 'right center',
- viewport: $(window), // Keep the tooltip on-screen at all times
- effect: false // Disable positioning animation
- },
- style: {
- classes: "ui-tooltip-dark"
- },
- show: 'mousedown',
- events: {
- show: function(event, api) {
- // Only show the tooltip if it was a right-click
- if(event.originalEvent.button !== 2) {
- event.preventDefault();
- }
- }
- },
- hide: 'mouseout'
-
- });
- },
- "fnDrawCallback": AIRTIME.library.events.fnDrawCallback,
- "fnHeaderCallback": function(nHead) {
- $(nHead).find("input[type=checkbox]").attr("checked", false);
- },
-
- "aaSorting": [[3, 'asc']],
- "sPaginationType": "full_numbers",
- "bJQueryUI": true,
- "bAutoWidth": false,
- "oLanguage": {
- "sSearch": ""
- },
-
- // R = ColReorder, C = ColVis, T = TableTools
- "sDom": 'Rl<"#library_display_type">fr<"H"T<"library_toolbar"C>>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("library_group_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("library_group_delete");
- }
- AIRTIME.library.events.enableAddButtonCheck();
- }
- },
-
- "oColVis": {
- "buttonText": "Show/Hide Columns",
- "sAlign": "right",
- "aiExclude": [0, 1, 2],
- "sSize": "css"
- },
-
- "oColReorder": {
- "iFixedColumns": 2
- }
-
- });
- oTable.fnSetFilteringDelay(350);
-
- AIRTIME.library.events.setupLibraryToolbar(oTable);
-
- $("#library_display_type")
- .addClass("dataTables_type")
- .append('')
- .find("select")
- .append('')
- .append('')
- .append('')
- .end()
- .change(function(ev){
- oTable.fnDraw();
- });
-
- $('[name="pl_cb_all"]').click(function(){
- var oTT = TableTools.fnGetInstance('library_display');
-
- if ($(this).is(":checked")) {
- oTT.fnSelectAll();
- }
- else {
- oTT.fnSelectNone();
- }
- });
-
- checkImportStatus();
- setInterval( checkImportStatus, 5000 );
- setInterval( checkSCUploadStatus, 5000 );
-
- addQtipToSCIcons();
-
- $.contextMenu({
- selector: '#library_display td:not(.library_checkbox)',
- trigger: "left",
- ignoreRightClick: true,
-
- build: function($el, e) {
- var data, screen, items, callback, $tr;
-
- $tr = $el.parent();
- data = $tr.data("aData");
- screen = $tr.data("screen");
-
- function processMenuItems(oItems) {
-
- //define an add to playlist callback.
- if (oItems.pl_add !== undefined) {
-
- callback = function() {
- AIRTIME.playlist.fnAddItems([data.id], undefined, 'after');
- };
-
- oItems.pl_add.callback = callback;
- }
-
- //define an edit callback.
- if (oItems.edit !== undefined) {
-
- if (data.ftype === "audioclip") {
- callback = function() {
- document.location.href = oItems.edit.url;
- };
- }
- else {
- callback = function() {
- AIRTIME.playlist.fnEdit(data.id);
- };
- }
- oItems.edit.callback = callback;
- }
-
- //define a delete callback.
- if (oItems.del !== undefined) {
-
- //delete through the playlist controller, will reset
- //playlist screen if this is the currently edited playlist.
- if (data.ftype === "playlist" && screen === "playlist") {
- callback = function() {
-
- if (confirm('Are you sure you want to delete the selected item?')) {
- AIRTIME.playlist.fnDelete(data.id);
- }
- };
- }
- else {
- callback = function() {
- var media = [];
-
- if (confirm('Are you sure you want to delete the selected item?')) {
-
- media.push({"id": data.id, "type": data.ftype});
- $.post(oItems.del.url, {format: "json", media: media }, function(json){
- var oTable;
-
- if (json.message) {
- alert(json.message);
- }
-
- oTable = $("#library_display").dataTable();
- oTable.fnDeleteRow( $tr[0] );
- });
- }
- };
- }
-
- oItems.del.callback = callback;
- }
-
- //define a download callback.
- if (oItems.download !== undefined) {
-
- callback = function() {
- document.location.href = oItems.download.url;
- };
- oItems.download.callback = callback;
- }
- //add callbacks for Soundcloud menu items.
- if (oItems.soundcloud !== undefined) {
- var soundcloud = oItems.soundcloud.items;
-
- //define an upload to soundcloud callback.
- if (soundcloud.upload !== undefined) {
-
- callback = function() {
- $.post(soundcloud.upload.url, function(){
- addProgressIcon(data.id);
- });
- };
- soundcloud.upload.callback = callback;
- }
-
- //define a view on soundcloud callback
- if (soundcloud.view !== undefined) {
-
- callback = function() {
- window.open(soundcloud.view.url);
- };
- soundcloud.view.callback = callback;
- }
- }
-
- items = oItems;
- }
-
- request = $.ajax({
- url: "/library/context-menu",
- type: "GET",
- data: {id : data.id, type: data.ftype, format: "json", "screen": screen},
- dataType: "json",
- async: false,
- success: function(json){
- processMenuItems(json.items);
- }
- });
-
- return {
- items: items
- };
- }
- });
-});
+}
\ No newline at end of file
diff --git a/airtime_mvc/public/js/airtime/library/main_library.js b/airtime_mvc/public/js/airtime/library/main_library.js
new file mode 100644
index 000000000..d50811e7e
--- /dev/null
+++ b/airtime_mvc/public/js/airtime/library/main_library.js
@@ -0,0 +1 @@
+$(document).ready(AIRTIME.library.libraryInit);
\ No newline at end of file
diff --git a/airtime_mvc/public/js/airtime/schedule/schedule.js b/airtime_mvc/public/js/airtime/schedule/schedule.js
index 8cd072b2c..e93be7df3 100644
--- a/airtime_mvc/public/js/airtime/schedule/schedule.js
+++ b/airtime_mvc/public/js/airtime/schedule/schedule.js
@@ -67,21 +67,10 @@ function uploadToSoundCloud(show_instance_id){
}
}
-function buildContentDialog (json){
- var dialog = $(json.dialog),
- viewportwidth,
- viewportheight,
- height,
- width;
+function findViewportDimensions() {
+ var viewportwidth,
+ viewportheight;
- if (json.show_error == true){
- alertShowErrorAndReload();
- }
-
- dialog.find("#show_progressbar").progressbar({
- value: json.percentFilled
- });
-
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use
// window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') {
@@ -101,9 +90,57 @@ function buildContentDialog (json){
viewportheight = document.getElementsByTagName('body')[0].clientHeight;
}
- height = viewportheight * 2/3;
- width = viewportwidth * 4/5;
+ return {
+ width: viewportwidth,
+ height: viewportheight
+ };
+}
+
+function buildScheduleDialog (json) {
+ var dialog = $(json.dialog),
+ viewport = findViewportDimensions(),
+ height = viewport.height * 0.96,
+ width = viewport.width * 0.96,
+ fnServer = AIRTIME.showbuilder.fnServerData;
+
+ dialog.dialog({
+ autoOpen: false,
+ title: json.title,
+ width: width,
+ height: height,
+ modal: true,
+ close: closeDialog,
+ buttons: {"Ok": function() {
+ dialog.remove();
+ $("#schedule_calendar").fullCalendar( 'refetchEvents' );
+ }}
+ });
+
+ //set the start end times so the builder datatables knows its time range.
+ fnServer.start = json.start;
+ fnServer.end = json.end;
+
+ AIRTIME.library.libraryInit();
+ AIRTIME.showbuilder.builderDataTable();
+
+ dialog.dialog('open');
+}
+
+function buildContentDialog (json){
+ var dialog = $(json.dialog),
+ viewport = findViewportDimensions(),
+ height = viewport.height * 2/3,
+ width = viewport.width * 4/5;
+
+ if (json.show_error == true){
+ alertShowErrorAndReload();
+ }
+
+ dialog.find("#show_progressbar").progressbar({
+ value: json.percentFilled
+ });
+
dialog.dialog({
autoOpen: false,
title: 'Show Contents',
@@ -201,8 +238,12 @@ $(document).ready(function() {
if (oItems.schedule !== undefined) {
callback = function() {
- document.location = oItems.schedule.url + "from/" + data.startUnix + "/to/" + data.endUnix;
- };
+
+ $.post(oItems.schedule.url, {format: "json", id: data.id}, function(json){
+ buildScheduleDialog(json);
+ });
+ };
+
oItems.schedule.callback = callback;
}
diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js
index b8000fc0c..146e596bb 100644
--- a/airtime_mvc/public/js/airtime/showbuilder/builder.js
+++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js
@@ -1,6 +1,7 @@
var AIRTIME = (function(AIRTIME){
var mod,
- oSchedTable;
+ oSchedTable,
+ fnServerData;
if (AIRTIME.showbuilder === undefined) {
AIRTIME.showbuilder = {};
@@ -45,111 +46,6 @@ var AIRTIME = (function(AIRTIME){
});
};
- mod.init = function(oTable) {
- oSchedTable = oTable;
- };
-
- return AIRTIME;
-
-}(AIRTIME || {}));
-
-
-$(document).ready(function() {
- var tableDiv = $('#show_builder_table'),
- oTable,
- oBaseDatePickerSettings,
- oBaseTimePickerSettings,
- fnAddSelectedItems,
- fnRemoveSelectedItems,
- oRange,
- fnServerData;
-
- oBaseDatePickerSettings = {
- dateFormat: 'yy-mm-dd',
- onSelect: function(sDate, oDatePicker) {
- var oDate,
- dInput;
-
- dInput = $(this);
- oDate = dInput.datepicker( "setDate", sDate );
- }
- };
-
- oBaseTimePickerSettings = {
- showPeriodLabels: false,
- showCloseButton: true,
- showLeadingZero: false,
- defaultTime: '0:00'
- };
-
- /*
- * Get the schedule range start in unix timestamp form (in seconds).
- * defaults to NOW if nothing is selected.
- *
- * @param String sDatePickerId
- *
- * @param String sTimePickerId
- *
- * @return Number iTime
- */
- function fnGetTimestamp(sDatePickerId, sTimePickerId) {
- var date,
- time,
- iTime,
- iServerOffset,
- iClientOffset;
-
- if ($(sDatePickerId).val() === "") {
- return 0;
- }
-
- date = $(sDatePickerId).val();
- time = $(sTimePickerId).val();
-
- date = date.split("-");
- time = time.split(":");
-
- //0 based month in js.
- oDate = new Date(date[0], date[1]-1, date[2], time[0], time[1]);
-
- iTime = oDate.getTime(); //value is in millisec.
- iTime = Math.round(iTime / 1000);
- iServerOffset = serverTimezoneOffset;
- iClientOffset = oDate.getTimezoneOffset() * -60;//function returns minutes
-
- //adjust for the fact the the Date object is in client time.
- iTime = iTime + iClientOffset + iServerOffset;
-
- return iTime;
- }
- /*
- * Returns an object containing a unix timestamp in seconds for the start/end range
- *
- * @return Object {"start", "end", "range"}
- */
- function fnGetScheduleRange() {
- var iStart,
- iEnd,
- iRange,
- DEFAULT_RANGE = 60*60*24;
-
- iStart = fnGetTimestamp("#sb_date_start", "#sb_time_start");
- iEnd = fnGetTimestamp("#sb_date_end", "#sb_time_end");
-
- iRange = iEnd - iStart;
-
- if (iRange === 0 || iEnd < iStart) {
- iEnd = iStart + DEFAULT_RANGE;
- iRange = DEFAULT_RANGE;
- }
-
- return {
- start: iStart,
- end: iEnd,
- range: iRange
- };
- }
-
fnServerData = function ( sSource, aoData, fnCallback ) {
aoData.push( { name: "format", value: "json"} );
@@ -173,442 +69,424 @@ $(document).ready(function() {
} );
};
- oRange = fnGetScheduleRange();
- fnServerData.start = oRange.start;
- fnServerData.end = oRange.end;
-
- fnRemoveSelectedItems = function() {
- var oTT = TableTools.fnGetInstance('show_builder_table'),
- aData = oTT.fnGetSelectedData(),
- i,
- length,
- temp,
- aItems = [];
+ mod.fnServerData = fnServerData;
- 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 = tableDiv.dataTable( {
- "aoColumns": [
- /* checkbox */ {"mDataProp": "allowed", "sTitle": "", "sWidth": "15px"},
- /* starts */{"mDataProp": "starts", "sTitle": "Start"},
- /* ends */{"mDataProp": "ends", "sTitle": "End"},
- /* runtime */{"mDataProp": "runtime", "sTitle": "Duration", "sClass": "library_length"},
- /* title */{"mDataProp": "title", "sTitle": "Title"},
- /* creator */{"mDataProp": "creator", "sTitle": "Creator"},
- /* album */{"mDataProp": "album", "sTitle": "Album"},
- /* cue in */{"mDataProp": "cuein", "sTitle": "Cue In", "bVisible": false},
- /* cue out */{"mDataProp": "cueout", "sTitle": "Cue Out", "bVisible": false},
- /* fade in */{"mDataProp": "fadein", "sTitle": "Fade In", "bVisible": false},
- /* fade out */{"mDataProp": "fadeout", "sTitle": "Fade Out", "bVisible": false}
- ],
-
- "bJQueryUI": true,
- "bSort": false,
- "bFilter": false,
- "bProcessing": true,
- "bServerSide": true,
- "bInfo": false,
- "bAutoWidth": false,
-
- "bStateSave": true,
- "fnStateSaveParams": function (oSettings, oData) {
- //remove oData components we don't want to save.
- delete oData.oSearch;
- delete oData.aoSearchCols;
- },
- "fnStateSave": function (oSettings, oData) {
-
- $.ajax({
- url: "/usersettings/set-timeline-datatable",
- type: "POST",
- data: {settings : oData, format: "json"},
- dataType: "json",
- success: function(){},
- error: function (jqXHR, textStatus, errorThrown) {
- var x;
- }
- });
- },
- "fnStateLoad": function (oSettings) {
- var o;
+ mod.builderDataTable = function() {
+ var tableDiv = $('#show_builder_table'),
+ oTable,
+ fnRemoveSelectedItems;
- $.ajax({
- url: "/usersettings/get-timeline-datatable",
- type: "GET",
- data: {format: "json"},
- dataType: "json",
- async: false,
- success: function(json){
- o = json.settings;
- },
- error: function (jqXHR, textStatus, errorThrown) {
- var x;
- }
- });
-
- return o;
- },
- "fnStateLoadParams": function (oSettings, oData) {
- var i,
+ fnRemoveSelectedItems = function() {
+ var oTT = TableTools.fnGetInstance('show_builder_table'),
+ aData = oTT.fnGetSelectedData(),
+ i,
length,
- a = oData.abVisCols;
+ temp,
+ aItems = [];
- //putting serialized data back into the correct js type to make
- //sure everything works properly.
- for (i = 0, length = a.length; i < length; i++) {
- a[i] = (a[i] === "true") ? true : false;
- }
+ 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 = tableDiv.dataTable( {
+ "aoColumns": [
+ /* checkbox */ {"mDataProp": "allowed", "sTitle": "", "sWidth": "15px"},
+ /* starts */{"mDataProp": "starts", "sTitle": "Start"},
+ /* ends */{"mDataProp": "ends", "sTitle": "End"},
+ /* runtime */{"mDataProp": "runtime", "sTitle": "Duration", "sClass": "library_length"},
+ /* title */{"mDataProp": "title", "sTitle": "Title"},
+ /* creator */{"mDataProp": "creator", "sTitle": "Creator"},
+ /* album */{"mDataProp": "album", "sTitle": "Album"},
+ /* cue in */{"mDataProp": "cuein", "sTitle": "Cue In", "bVisible": false},
+ /* cue out */{"mDataProp": "cueout", "sTitle": "Cue Out", "bVisible": false},
+ /* fade in */{"mDataProp": "fadein", "sTitle": "Fade In", "bVisible": false},
+ /* fade out */{"mDataProp": "fadeout", "sTitle": "Fade Out", "bVisible": false}
+ ],
- a = oData.ColReorder;
- for (i = 0, length = a.length; i < length; i++) {
- a[i] = parseInt(a[i], 10);
- }
-
- oData.iCreate = parseInt(oData.iCreate, 10);
- },
-
- "fnServerData": fnServerData,
- "fnRowCallback": function ( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
- var i,
- sSeparatorHTML,
- fnPrepareSeparatorRow,
- node,
- cl="";
+ "bJQueryUI": true,
+ "bSort": false,
+ "bFilter": false,
+ "bProcessing": true,
+ "bServerSide": true,
+ "bInfo": false,
+ "bAutoWidth": false,
- //save some info for reordering purposes.
- $(nRow).data({"aData": aData});
+ "bStateSave": true,
+ "fnStateSaveParams": function (oSettings, oData) {
+ //remove oData components we don't want to save.
+ delete oData.oSearch;
+ delete oData.aoSearchCols;
+ },
+ "fnStateSave": function (oSettings, oData) {
+
+ $.ajax({
+ url: "/usersettings/set-timeline-datatable",
+ type: "POST",
+ data: {settings : oData, format: "json"},
+ dataType: "json",
+ success: function(){},
+ error: function (jqXHR, textStatus, errorThrown) {
+ var x;
+ }
+ });
+ },
+ "fnStateLoad": function (oSettings) {
+ var o;
+
+ $.ajax({
+ url: "/usersettings/get-timeline-datatable",
+ type: "GET",
+ data: {format: "json"},
+ dataType: "json",
+ async: false,
+ success: function(json){
+ o = json.settings;
+ },
+ error: function (jqXHR, textStatus, errorThrown) {
+ var x;
+ }
+ });
+
+ return o;
+ },
+ "fnStateLoadParams": function (oSettings, oData) {
+ var i,
+ length,
+ a = oData.abVisCols;
- if (aData.allowed !== true) {
- $(nRow).addClass("sb-not-allowed");
- }
- else {
- $(nRow).addClass("sb-allowed");
- }
-
- //status used to colour tracks.
- if (aData.status === 1) {
- $(nRow).addClass("sb-boundry");
- }
- else if (aData.status === 2) {
- $(nRow).addClass("sb-over");
- }
-
- fnPrepareSeparatorRow = function(sRowContent, sClass, iNodeIndex) {
+ //putting serialized data back into the correct js type to make
+ //sure everything works properly.
+ for (i = 0, length = a.length; i < length; i++) {
+ a[i] = (a[i] === "true") ? true : false;
+ }
+
+ a = oData.ColReorder;
+ for (i = 0, length = a.length; i < length; i++) {
+ a[i] = parseInt(a[i], 10);
+ }
+
+ oData.iCreate = parseInt(oData.iCreate, 10);
+ },
+
+ "fnServerData": AIRTIME.showbuilder.fnServerData,
+ "fnRowCallback": function ( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
+ var i,
+ sSeparatorHTML,
+ fnPrepareSeparatorRow,
+ node,
+ cl="";
- node = nRow.children[iNodeIndex];
- node.innerHTML = sRowContent;
- node.setAttribute('colspan',100);
- for (i = iNodeIndex + 1; i < nRow.children.length; i = i+1) {
- node = nRow.children[i];
- node.innerHTML = "";
- node.setAttribute("style", "display : none");
+ //save some info for reordering purposes.
+ $(nRow).data({"aData": aData});
+
+ if (aData.allowed !== true) {
+ $(nRow).addClass("sb-not-allowed");
+ }
+ else {
+ $(nRow).addClass("sb-allowed");
}
- $(nRow).addClass(sClass);
+ //status used to colour tracks.
+ if (aData.status === 1) {
+ $(nRow).addClass("sb-boundry");
+ }
+ else if (aData.status === 2) {
+ $(nRow).addClass("sb-over");
+ }
+
+ fnPrepareSeparatorRow = function(sRowContent, sClass, iNodeIndex) {
+
+ node = nRow.children[iNodeIndex];
+ node.innerHTML = sRowContent;
+ node.setAttribute('colspan',100);
+ for (i = iNodeIndex + 1; i < nRow.children.length; i = i+1) {
+ node = nRow.children[i];
+ node.innerHTML = "";
+ node.setAttribute("style", "display : none");
+ }
+
+ $(nRow).addClass(sClass);
+ };
+
+ if (aData.header === true) {
+ cl = 'sb-header';
+
+ sSeparatorHTML = ''+aData.title+''+aData.starts+''+aData.ends+'';
+ fnPrepareSeparatorRow(sSeparatorHTML, cl, 0);
+ }
+ else if (aData.footer === true) {
+ node = nRow.children[0];
+ cl = 'sb-footer';
+
+ //check the show's content status.
+ if (aData.runtime > 0) {
+ node.innerHTML = '';
+ cl = cl + ' ui-state-highlight';
+ }
+ else {
+ node.innerHTML = '';
+ cl = cl + ' ui-state-error';
+ }
+
+ sSeparatorHTML = ''+aData.fRuntime+'';
+ fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
+ }
+ else if (aData.empty === true) {
+
+ sSeparatorHTML = 'Show Empty';
+ cl = cl + " sb-empty odd";
+
+ fnPrepareSeparatorRow(sSeparatorHTML, cl, 0);
+ }
+ else {
+
+ node = nRow.children[0];
+ if (aData.allowed === true) {
+ node.innerHTML = '';
+ }
+ else {
+ node.innerHTML = '';
+ }
+ }
+ },
+ "fnDrawCallback": function(oSettings, json) {
+ var wrapperDiv,
+ markerDiv,
+ td;
+
+ //create cursor arrows.
+ tableDiv.find("tr:not(:first, .sb-footer, .sb-empty, .sb-not-allowed)").each(function(i, el) {
+ td = $(el).find("td:first");
+ if (td.hasClass("dataTables_empty")) {
+ return false;
+ }
+
+ wrapperDiv = $("", {
+ "class": "innerWrapper",
+ "css": {
+ "height": td.height()
+ }
+ });
+ markerDiv = $("", {
+ "class": "marker"
+ });
+
+ td.append(markerDiv).wrapInner(wrapperDiv);
+ });
+ },
+ "fnHeaderCallback": function(nHead) {
+ $(nHead).find("input[type=checkbox]").attr("checked", false);
+ },
+ //remove any selected nodes before the draw.
+ "fnPreDrawCallback": function( oSettings ) {
+ var oTT = TableTools.fnGetInstance('show_builder_table');
+ oTT.fnSelectNone();
+ },
+
+ "oColVis": {
+ "aiExclude": [ 0, 1 ]
+ },
+
+ "oColReorder": {
+ "iFixedColumns": 2
+ },
+
+ "oTableTools": {
+ "sRowSelect": "multi",
+ "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")) {
+ return false;
+ }
+ return true;
+ },
+ "fnRowSelected": function ( node ) {
+
+ //seems to happen if everything is selected
+ if ( node === null) {
+ oTable.find("input[type=checkbox]").attr("checked", true);
+ }
+ else {
+ $(node).find("input[type=checkbox]").attr("checked", true);
+ }
+
+ //checking to enable buttons
+ AIRTIME.button.enableButton("sb_delete");
+ },
+ "fnRowDeselected": function ( node ) {
+ var selected;
+
+ //seems to happen if everything is deselected
+ if ( node === null) {
+ tableDiv.find("input[type=checkbox]").attr("checked", false);
+ selected = [];
+ }
+ else {
+ $(node).find("input[type=checkbox]").attr("checked", false);
+ selected = tableDiv.find("input[type=checkbox]").filter(":checked");
+ }
+
+ //checking to disable buttons
+ if (selected.length === 0) {
+ AIRTIME.button.disableButton("sb_delete");
+ }
+ }
+ },
+
+ // R = ColReorderResize, C = ColVis, T = TableTools
+ "sDom": 'Rr<"H"CT>t<"F">',
+
+ "sAjaxDataProp": "schedule",
+ "sAjaxSource": "/showbuilder/builder-feed"
+ });
+
+ $('[name="sb_cb_all"]').click(function(){
+ var oTT = TableTools.fnGetInstance('show_builder_table');
+
+ if ($(this).is(":checked")) {
+ var allowedNodes;
+
+ allowedNodes = oTable.find('tr:not(:first, .sb-header, .sb-empty, .sb-footer, .sb-not-allowed)');
+
+ allowedNodes.each(function(i, el){
+ oTT.fnSelect(el);
+ });
+ }
+ else {
+ oTT.fnSelectNone();
+ }
+ });
+
+ var sortableConf = (function(){
+ var origTrs,
+ aItemData = [],
+ oPrevData,
+ fnAdd,
+ fnMove,
+ fnReceive,
+ fnUpdate,
+ i,
+ html;
+
+ fnAdd = function() {
+ var aMediaIds = [],
+ aSchedIds = [];
+
+ for(i = 0; i < aItemData.length; i++) {
+ aMediaIds.push({"id": aItemData[i].id, "type": aItemData[i].ftype});
+ }
+ aSchedIds.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
+
+ AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
};
- if (aData.header === true) {
- cl = 'sb-header';
+ fnMove = function() {
+ var aSelect = [],
+ aAfter = [];
+
+ aSelect.push({"id": aItemData[0].id, "instance": aItemData[0].instance, "timestamp": aItemData[0].timestamp});
+ aAfter.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
+
+ AIRTIME.showbuilder.fnMove(aSelect, aAfter);
+ };
+
+ fnReceive = function(event, ui) {
+ var aItems = [],
+ oLibTT = TableTools.fnGetInstance('library_display');
+
+ aItems = oLibTT.fnGetSelectedData();
- sSeparatorHTML = ''+aData.title+''+aData.starts+''+aData.ends+'';
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 0);
- }
- else if (aData.footer === true) {
- node = nRow.children[0];
- cl = 'sb-footer';
+ //if nothing is checked select the dragged item.
+ if (aItems.length === 0) {
+ aItems.push(ui.item.data("aData"));
+ }
+
+ origTrs = aItems;
+ html = ui.helper.html();
+ };
+
+ fnUpdate = function(event, ui) {
+ var prev = ui.item.prev();
- //check the show's content status.
- if (aData.runtime > 0) {
- node.innerHTML = '';
- cl = cl + ' ui-state-highlight';
- }
- else {
- node.innerHTML = '';
- cl = cl + ' ui-state-error';
+ //can't add items outside of shows.
+ if (!prev.hasClass("sb-allowed")) {
+ alert("Cannot schedule outside a show.");
+ ui.item.remove();
+ return;
}
+
+ aItemData = [];
+ oPrevData = prev.data("aData");
+
+ //item was dragged in
+ if (origTrs !== undefined) {
- sSeparatorHTML = ''+aData.fRuntime+'';
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
- }
- else if (aData.empty === true) {
-
- sSeparatorHTML = 'Show Empty';
- cl = cl + " sb-empty odd";
-
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 0);
- }
- else {
-
- node = nRow.children[0];
- if (aData.allowed === true) {
- node.innerHTML = '';
+ $("#show_builder_table tr.ui-draggable")
+ .empty()
+ .after(html);
+
+ aItemData = origTrs;
+ origTrs = undefined;
+ fnAdd();
}
+ //item was reordered.
else {
- node.innerHTML = '';
+ aItemData.push(ui.item.data("aData"));
+ fnMove();
}
+ };
+
+ return {
+ placeholder: "placeholder show-builder-placeholder ui-state-highlight",
+ forcePlaceholderSize: true,
+ items: 'tr:not(:first, :last, .sb-header, .sb-footer, .sb-not-allowed)',
+ receive: fnReceive,
+ update: fnUpdate
+ };
+ }());
+
+ tableDiv.sortable(sortableConf);
+
+ $("#show_builder .fg-toolbar")
+ .append('')
+ .click(fnRemoveSelectedItems);
+
+ //set things like a reference to the table.
+ AIRTIME.showbuilder.init(oTable);
+
+ //add event to cursors.
+ tableDiv.find("tbody").on("click", "div.marker", function(event){
+ var tr = $(this).parents("tr"),
+ cursorSelClass = "cursor-selected-row";
+
+ if (tr.hasClass(cursorSelClass)) {
+ tr.removeClass(cursorSelClass);
}
- },
- "fnDrawCallback": function(oSettings, json) {
- var wrapperDiv,
- markerDiv,
- td;
-
- //create cursor arrows.
- tableDiv.find("tr:not(:first, .sb-footer, .sb-empty, .sb-not-allowed)").each(function(i, el) {
- td = $(el).find("td:first");
- if (td.hasClass("dataTables_empty")) {
- return false;
- }
-
- wrapperDiv = $("", {
- "class": "innerWrapper",
- "css": {
- "height": td.height()
- }
- });
- markerDiv = $("", {
- "class": "marker"
- });
-
- td.append(markerDiv).wrapInner(wrapperDiv);
- });
- },
- "fnHeaderCallback": function(nHead) {
- $(nHead).find("input[type=checkbox]").attr("checked", false);
- },
- //remove any selected nodes before the draw.
- "fnPreDrawCallback": function( oSettings ) {
- var oTT = TableTools.fnGetInstance('show_builder_table');
- oTT.fnSelectNone();
- },
-
- "oColVis": {
- "aiExclude": [ 0, 1 ]
- },
-
- "oColReorder": {
- "iFixedColumns": 2
- },
-
- "oTableTools": {
- "sRowSelect": "multi",
- "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")) {
- return false;
- }
- return true;
- },
- "fnRowSelected": function ( node ) {
-
- //seems to happen if everything is selected
- if ( node === null) {
- oTable.find("input[type=checkbox]").attr("checked", true);
- }
- else {
- $(node).find("input[type=checkbox]").attr("checked", true);
- }
-
- //checking to enable buttons
- AIRTIME.button.enableButton("sb_delete");
- },
- "fnRowDeselected": function ( node ) {
- var selected;
-
- //seems to happen if everything is deselected
- if ( node === null) {
- tableDiv.find("input[type=checkbox]").attr("checked", false);
- selected = [];
- }
- else {
- $(node).find("input[type=checkbox]").attr("checked", false);
- selected = tableDiv.find("input[type=checkbox]").filter(":checked");
- }
-
- //checking to disable buttons
- if (selected.length === 0) {
- AIRTIME.button.disableButton("sb_delete");
- }
- }
- },
-
- // R = ColReorderResize, C = ColVis, T = TableTools
- "sDom": 'Rr<"H"CT>t<"F">',
-
- "sAjaxDataProp": "schedule",
- "sAjaxSource": "/showbuilder/builder-feed"
- });
-
- $('[name="sb_cb_all"]').click(function(){
- var oTT = TableTools.fnGetInstance('show_builder_table');
-
- if ($(this).is(":checked")) {
- var allowedNodes;
-
- allowedNodes = oTable.find('tr:not(:first, .sb-header, .sb-empty, .sb-footer, .sb-not-allowed)');
-
- allowedNodes.each(function(i, el){
- oTT.fnSelect(el);
- });
- }
- else {
- oTT.fnSelectNone();
- }
- });
-
- $("#sb_date_start").datepicker(oBaseDatePickerSettings);
- $("#sb_time_start").timepicker(oBaseTimePickerSettings);
- $("#sb_date_end").datepicker(oBaseDatePickerSettings);
- $("#sb_time_end").timepicker(oBaseTimePickerSettings);
-
- $("#sb_submit").click(function(ev){
- var fn,
- oRange,
- op;
-
- oRange = fnGetScheduleRange();
-
- fn = oTable.fnSettings().fnServerData;
- fn.start = oRange.start;
- fn.end = oRange.end;
-
- op = $("div.sb-advanced-options");
- if (op.is(":visible")) {
-
- if (fn.ops === undefined) {
- fn.ops = {};
- }
- fn.ops.showFilter = op.find("#sb_show_filter").val();
- fn.ops.myShows = op.find("#sb_my_shows").is(":checked") ? 1 : 0;
- }
-
- oTable.fnDraw();
- });
-
- var sortableConf = (function(){
- var origTrs,
- aItemData = [],
- oPrevData,
- fnAdd,
- fnMove,
- fnReceive,
- fnUpdate,
- i,
- html;
-
- fnAdd = function() {
- var aMediaIds = [],
- aSchedIds = [];
-
- for(i = 0; i < aItemData.length; i++) {
- aMediaIds.push({"id": aItemData[i].id, "type": aItemData[i].ftype});
- }
- aSchedIds.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
-
- AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
- };
-
- fnMove = function() {
- var aSelect = [],
- aAfter = [];
-
- aSelect.push({"id": aItemData[0].id, "instance": aItemData[0].instance, "timestamp": aItemData[0].timestamp});
- aAfter.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
-
- AIRTIME.showbuilder.fnMove(aSelect, aAfter);
- };
-
- fnReceive = function(event, ui) {
- var aItems = [],
- oLibTT = TableTools.fnGetInstance('library_display');
-
- aItems = oLibTT.fnGetSelectedData();
-
- //if nothing is checked select the dragged item.
- if (aItems.length === 0) {
- aItems.push(ui.item.data("aData"));
- }
-
- origTrs = aItems;
- html = ui.helper.html();
- };
-
- fnUpdate = function(event, ui) {
- var prev = ui.item.prev();
-
- //can't add items outside of shows.
- if (!prev.hasClass("sb-allowed")) {
- alert("Cannot schedule outside a show.");
- ui.item.remove();
- return;
- }
-
- aItemData = [];
- oPrevData = prev.data("aData");
-
- //item was dragged in
- if (origTrs !== undefined) {
-
- $("#show_builder_table tr.ui-draggable")
- .empty()
- .after(html);
-
- aItemData = origTrs;
- origTrs = undefined;
- fnAdd();
- }
- //item was reordered.
else {
- aItemData.push(ui.item.data("aData"));
- fnMove();
+ tr.addClass(cursorSelClass);
}
- };
+
+ //check if add button can still be enabled.
+ AIRTIME.library.events.enableAddButtonCheck();
+
+ return false;
+ });
- return {
- placeholder: "placeholder show-builder-placeholder ui-state-highlight",
- forcePlaceholderSize: true,
- items: 'tr:not(:first, :last, .sb-header, .sb-footer, .sb-not-allowed)',
- receive: fnReceive,
- update: fnUpdate
- };
- }());
+ };
- tableDiv.sortable(sortableConf);
+ mod.init = function(oTable) {
+ oSchedTable = oTable;
+ };
- $("#show_builder .fg-toolbar")
- .append('')
- .click(fnRemoveSelectedItems);
+ return AIRTIME;
- //set things like a reference to the table.
- AIRTIME.showbuilder.init(oTable);
-
- //add event to cursors.
- tableDiv.find("tbody").on("click", "div.marker", function(event){
- var tr = $(this).parents("tr"),
- cursorSelClass = "cursor-selected-row";
-
- if (tr.hasClass(cursorSelClass)) {
- tr.removeClass(cursorSelClass);
- }
- else {
- tr.addClass(cursorSelClass);
- }
-
- //check if add button can still be enabled.
- AIRTIME.library.events.enableAddButtonCheck();
-
- return false;
- });
-
-});
+}(AIRTIME || {}));
\ No newline at end of file
diff --git a/airtime_mvc/public/js/airtime/showbuilder/main_builder.js b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js
new file mode 100644
index 000000000..e1cc1f1c0
--- /dev/null
+++ b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js
@@ -0,0 +1,128 @@
+$(document).ready(function(){
+
+ var oBaseDatePickerSettings,
+ oBaseTimePickerSettings,
+ oRange;
+
+ oBaseDatePickerSettings = {
+ dateFormat: 'yy-mm-dd',
+ onSelect: function(sDate, oDatePicker) {
+ var oDate,
+ dInput;
+
+ dInput = $(this);
+ oDate = dInput.datepicker( "setDate", sDate );
+ }
+ };
+
+ oBaseTimePickerSettings = {
+ showPeriodLabels: false,
+ showCloseButton: true,
+ showLeadingZero: false,
+ defaultTime: '0:00'
+ };
+
+ /*
+ * Get the schedule range start in unix timestamp form (in seconds).
+ * defaults to NOW if nothing is selected.
+ *
+ * @param String sDatePickerId
+ *
+ * @param String sTimePickerId
+ *
+ * @return Number iTime
+ */
+ function fnGetTimestamp(sDatePickerId, sTimePickerId) {
+ var date,
+ time,
+ iTime,
+ iServerOffset,
+ iClientOffset;
+
+ if ($(sDatePickerId).val() === "") {
+ return 0;
+ }
+
+ date = $(sDatePickerId).val();
+ time = $(sTimePickerId).val();
+
+ date = date.split("-");
+ time = time.split(":");
+
+ //0 based month in js.
+ oDate = new Date(date[0], date[1]-1, date[2], time[0], time[1]);
+
+ iTime = oDate.getTime(); //value is in millisec.
+ iTime = Math.round(iTime / 1000);
+ iServerOffset = serverTimezoneOffset;
+ iClientOffset = oDate.getTimezoneOffset() * -60;//function returns minutes
+
+ //adjust for the fact the the Date object is in client time.
+ iTime = iTime + iClientOffset + iServerOffset;
+
+ return iTime;
+ }
+ /*
+ * Returns an object containing a unix timestamp in seconds for the start/end range
+ *
+ * @return Object {"start", "end", "range"}
+ */
+ function fnGetScheduleRange() {
+ var iStart,
+ iEnd,
+ iRange,
+ DEFAULT_RANGE = 60*60*24;
+
+ iStart = fnGetTimestamp("#sb_date_start", "#sb_time_start");
+ iEnd = fnGetTimestamp("#sb_date_end", "#sb_time_end");
+
+ iRange = iEnd - iStart;
+
+ if (iRange === 0 || iEnd < iStart) {
+ iEnd = iStart + DEFAULT_RANGE;
+ iRange = DEFAULT_RANGE;
+ }
+
+ return {
+ start: iStart,
+ end: iEnd,
+ range: iRange
+ };
+ }
+
+ $("#sb_date_start").datepicker(oBaseDatePickerSettings);
+ $("#sb_time_start").timepicker(oBaseTimePickerSettings);
+ $("#sb_date_end").datepicker(oBaseDatePickerSettings);
+ $("#sb_time_end").timepicker(oBaseTimePickerSettings);
+
+ $("#sb_submit").click(function(ev){
+ var fn,
+ oRange,
+ op,
+ oTable = $('#show_builder_table').dataTable();
+
+ oRange = fnGetScheduleRange();
+
+ fn = oTable.fnSettings().fnServerData;
+ fn.start = oRange.start;
+ fn.end = oRange.end;
+
+ op = $("div.sb-advanced-options");
+ if (op.is(":visible")) {
+
+ if (fn.ops === undefined) {
+ fn.ops = {};
+ }
+ fn.ops.showFilter = op.find("#sb_show_filter").val();
+ fn.ops.myShows = op.find("#sb_my_shows").is(":checked") ? 1 : 0;
+ }
+
+ oTable.fnDraw();
+ });
+
+ oRange = fnGetScheduleRange();
+ AIRTIME.showbuilder.fnServerData.start = oRange.start;
+ AIRTIME.showbuilder.fnServerData.end = oRange.end;
+
+ AIRTIME.showbuilder.builderDataTable();
+});
\ No newline at end of file