Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-02-29 19:23:46 -05:00
commit b37a58aea4
25 changed files with 1197 additions and 990 deletions

View File

@ -55,7 +55,9 @@ class LibraryController extends Zend_Controller_Action
$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/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/library/library.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/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/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']);

View File

@ -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/add-show.css?'.$CC_CONFIG['airtime_version']);
$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']);
//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); Application_Model_Schedule::createNewFormSections($this->view);
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
@ -78,10 +101,12 @@ class ScheduleController extends Zend_Controller_Action
$userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userInfo = Zend_Auth::getInstance()->getStorage()->read();
$user = new Application_Model_User($userInfo->id); $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; $editable = true;
else }
else {
$editable = false; $editable = false;
}
$this->view->events = Application_Model_Show::getFullCalendarEvents($start, $end, $editable); $this->view->events = Application_Model_Show::getFullCalendarEvents($start, $end, $editable);
} }
@ -105,9 +130,9 @@ class ScheduleController extends Zend_Controller_Action
$error = $showInstance->moveShow($deltaDay, $deltaMin); $error = $showInstance->moveShow($deltaDay, $deltaMin);
} }
if(isset($error)) if (isset($error)) {
$this->view->error = $error; $this->view->error = $error;
}
} }
public function resizeShowAction() public function resizeShowAction()
@ -200,7 +225,7 @@ class ScheduleController extends Zend_Controller_Action
&& !$instance->isRebroadcast()) { && !$instance->isRebroadcast()) {
$menu["schedule"] = array("name"=> "Add / Remove Content", $menu["schedule"] = array("name"=> "Add / Remove Content",
"url" => "/showbuilder/index/"); "url" => "/showbuilder/builder-dialog/");
$menu["clear"] = array("name"=> "Remove All Content", "icon" => "delete", $menu["clear"] = array("name"=> "Remove All Content", "icon" => "delete",
"url" => "/schedule/clear-show"); "url" => "/schedule/clear-show");

View File

@ -9,6 +9,7 @@ class ShowbuilderController extends Zend_Controller_Action
$ajaxContext->addActionContext('schedule-move', 'json') $ajaxContext->addActionContext('schedule-move', 'json')
->addActionContext('schedule-add', 'json') ->addActionContext('schedule-add', 'json')
->addActionContext('schedule-remove', 'json') ->addActionContext('schedule-remove', 'json')
->addActionContext('builder-dialog', 'json')
->addActionContext('builder-feed', 'json') ->addActionContext('builder-feed', 'json')
->initContext(); ->initContext();
} }
@ -53,11 +54,40 @@ class ShowbuilderController extends Zend_Controller_Action
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds"); $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/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/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/jquery.ui.timepicker.css');
$this->view->headLink()->appendStylesheet($baseUrl.'/css/showbuilder.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() { public function builderFeedAction() {
$request = $this->getRequest(); $request = $this->getRequest();

View File

@ -1508,10 +1508,9 @@ class Application_Model_Show {
if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) { if ($editable && (strtotime($today_timestamp) < strtotime($show["starts"]))) {
$options["editable"] = true; $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; return $events;
@ -1521,10 +1520,6 @@ class Application_Model_Show {
{ {
$event = array(); $event = array();
if($show["rebroadcast"]) {
$event["disableResizing"] = true;
}
$startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC")); $startDateTime = new DateTime($show["starts"], new DateTimeZone("UTC"));
$startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get())); $startDateTime->setTimezone(new DateTimeZone(date_default_timezone_get()));
@ -1538,7 +1533,6 @@ class Application_Model_Show {
$event["end"] = $endDateTime->format("Y-m-d H:i:s"); $event["end"] = $endDateTime->format("Y-m-d H:i:s");
$event["endUnix"] = $endDateTime->format("U"); $event["endUnix"] = $endDateTime->format("U");
$event["allDay"] = false; $event["allDay"] = false;
//$event["description"] = $show["description"];
$event["showId"] = intval($show["show_id"]); $event["showId"] = intval($show["show_id"]);
$event["record"] = intval($show["record"]); $event["record"] = intval($show["record"]);
$event["rebroadcast"] = intval($show["rebroadcast"]); $event["rebroadcast"] = intval($show["rebroadcast"]);
@ -1547,10 +1541,9 @@ class Application_Model_Show {
if (!is_null($show["file_id"])){ if (!is_null($show["file_id"])){
$file = Application_Model_StoredFile::Recall($show["file_id"]); $file = Application_Model_StoredFile::Recall($show["file_id"]);
$soundcloud_id = $file->getSoundCloudId(); $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 //event colouring
if ($show["color"] != "") { if ($show["color"] != "") {

View File

@ -1 +0,0 @@
<br /><br /><center>View script for controller <b>Library</b> and script/action name <b>delete</b></center>

View File

@ -1,8 +0,0 @@
<?php // libraryTablePartial.phtml ?>
<tr id="<?php echo substr($this->ftype, 0, 2) ?>_<?php echo $this->id ?>">
<td><?php echo $this->track_title ?></td>
<td><?php echo $this->artist_name ?></td>
<td><?php echo $this->album_title ?></td>
<td><?php echo $this->track_number ?></td>
<td><?php echo $this->length ?></td>
</tr>

View File

@ -1 +0,0 @@
<br /><br /><center>View script for controller <b>Library</b> and script/action name <b>search</b></center>

View File

@ -1,3 +0,0 @@
<?php
echo $this->partialLoop('library/libraryTablePartial.phtml', $this->files);

View File

@ -4,11 +4,11 @@ if (count($items)) : ?>
<?php $i = 0; ?> <?php $i = 0; ?>
<?php foreach($items as $item) : ?> <?php foreach($items as $item) : ?>
<li class="ui-state-default" id="spl_<?php echo $item["id"] ?>" unqid="<?php echo $item["CcFiles"]["gunid"]."_".$i; ?>"> <li class="ui-state-default" id="spl_<?php echo $item["id"] ?>" unqid="<?php echo $item["CcFiles"]["gunid"]."_".$item["id"]; ?>">
<div class="list-item-container"> <div class="list-item-container">
<a href="javascript:void(0);" class="big_play" <a href="javascript:void(0);" class="big_play"
onclick="audioPreview('<?php echo $item["CcFiles"]["gunid"].".".pathinfo($item["CcFiles"]["filepath"], PATHINFO_EXTENSION);?>', onclick="audioPreview('<?php echo $item["CcFiles"]["gunid"].".".pathinfo($item["CcFiles"]["filepath"], PATHINFO_EXTENSION);?>',
'spl_<?php echo $i ?>')"><span class="ui-icon ui-icon-play"></span></a> 'spl_<?php echo $item["id"] ?>')"><span class="ui-icon ui-icon-play"></span></a>
<div class="text-row top"> <div class="text-row top">
<span class="spl_playlength"><?php echo $item["cliplength"] ?></span> <span class="spl_playlength"><?php echo $item["cliplength"] ?></span>

View File

@ -0,0 +1,9 @@
<div class="wrapper">
<div id="library_content" class="tabs ui-widget ui-widget-content block-shadow alpha-block padded">
<div id="import_status" style="display:none">File import in progress...</div>
<table id="library_display" cellpadding="0" cellspacing="0" class="datatable"></table>
</div>
<div id="show_builder" class="ui-widget ui-widget-content block-shadow omega-block padded">
<table id="show_builder_table" cellpadding="0" cellspacing="0" class="datatable"></table>
</div>
</div>

View File

@ -30,7 +30,7 @@ button.ColVis_Button::-moz-focus-inner {
div.ColVis_collectionBackground { div.ColVis_collectionBackground {
background-color: black; background-color: black;
z-index: 996; z-index: 1003;
} }
div.ColVis_collection { div.ColVis_collection {
@ -39,7 +39,7 @@ div.ColVis_collection {
background-color: #999; background-color: #999;
padding: 3px; padding: 3px;
border: 1px solid #ccc; border: 1px solid #ccc;
z-index: 998; z-index: 1005;
} }
div.ColVis_collection button.ColVis_Button { div.ColVis_collection button.ColVis_Button {
@ -51,7 +51,7 @@ div.ColVis_collection button.ColVis_Button {
div.ColVis_catcher { div.ColVis_catcher {
position: absolute; position: absolute;
z-index: 997; z-index: 1004;
} }
.disabled { .disabled {

View File

@ -79,3 +79,8 @@
.library_year { .library_year {
text-align: center; text-align: center;
} }
.library_sr,
.library_bitrate {
text-align: right;
}

View File

@ -457,7 +457,5 @@ div.helper li {
} }
li.spl_empty { li.spl_empty {
text-align: center;
height: 56px; height: 56px;
border:2px dashed black;
} }

View File

@ -35,3 +35,12 @@ tr.cursor-selected-row .marker {
.sb-over { .sb-over {
background-color:#ff3030; background-color:#ff3030;
} }
.ui-dialog .wrapper {
margin: 0;
padding: 10px 0 0 0;
}
.ui-dialog .ui-buttonset {
margin-right: 0 !important;
}

View File

@ -601,6 +601,7 @@ dl.inline-list dd {
} }
.dataTables_info { .dataTables_info {
float: left;
padding: 8px 0 0 8px; padding: 8px 0 0 8px;
font-size:12px; font-size:12px;
color:#555555; color:#555555;
@ -608,6 +609,7 @@ dl.inline-list dd {
} }
.dataTables_paginate { .dataTables_paginate {
float: right;
padding: 8px 0 8px 8px; padding: 8px 0 8px 8px;
} }
.dataTables_paginate .ui-button { .dataTables_paginate .ui-button {
@ -618,7 +620,7 @@ dl.inline-list dd {
} }
.dataTables_filter input { .dataTables_filter input {
background: url("images/search_auto_bg.png") no-repeat scroll 0 0 #DDDDDD; background: url("images/search_auto_bg.png") no-repeat scroll 0 0 #DDDDDD;
width: 60%; width: 55%;
border: 1px solid #5B5B5B; border: 1px solid #5B5B5B;
margin-left: -8px; margin-left: -8px;
padding: 4px 3px 4px 25px; padding: 4px 3px 4px 25px;

View File

@ -0,0 +1,29 @@
var AIRTIME = (function(AIRTIME){
var mod,
DEFAULT_CLASS = 'ui-button ui-state-default',
DISABLED_CLASS = 'ui-state-disabled';
if (AIRTIME.button === undefined) {
AIRTIME.button = {};
}
mod = AIRTIME.button;
mod.enableButton = function(c) {
var button = $("."+c).find("button");
if (button.hasClass(DISABLED_CLASS)) {
button.removeClass(DISABLED_CLASS);
}
};
mod.disableButton = function(c) {
var button = $("."+c).find("button");
if (!button.hasClass(DISABLED_CLASS)) {
button.addClass(DISABLED_CLASS);
}
};
return AIRTIME;
}(AIRTIME || {}));

View File

@ -8,6 +8,24 @@ var AIRTIME = (function(AIRTIME){
AIRTIME.library.events = {}; AIRTIME.library.events = {};
mod = AIRTIME.library.events; mod = AIRTIME.library.events;
mod.enableAddButtonCheck = function() {
var selected = $('#library_display tr[id ^= "au"] input[type=checkbox]').filter(":checked"),
sortable = $('#spl_sortable'),
check = false;
//make sure audioclips are selected and a playlist is currently open.
if (selected.length !== 0 && sortable.length !== 0) {
check = true;
}
if (check === true) {
AIRTIME.button.enableButton("library_group_add");
}
else {
AIRTIME.button.disableButton("library_group_add");
}
};
mod.fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { mod.fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var $nRow = $(nRow); var $nRow = $(nRow);
@ -63,7 +81,6 @@ var AIRTIME = (function(AIRTIME){
*/ */
mod.setupLibraryToolbar = function( oLibTable ) { mod.setupLibraryToolbar = function( oLibTable ) {
var aButtons, var aButtons,
fnResetCol,
fnAddSelectedItems; fnAddSelectedItems;
fnAddSelectedItems = function() { fnAddSelectedItems = function() {
@ -89,8 +106,8 @@ var AIRTIME = (function(AIRTIME){
//[1] = id //[1] = id
//[2] = enabled //[2] = enabled
//[3] = click event //[3] = click event
aButtons = [["Delete", "library_group_delete", true, AIRTIME.library.fnDeleteSelectedItems], aButtons = [["Delete", "library_group_delete", false, AIRTIME.library.fnDeleteSelectedItems],
["Add", "library_group_add", true, fnAddSelectedItems]]; ["Add", "library_group_add", false, fnAddSelectedItems]];
addToolBarButtonsLibrary(aButtons); addToolBarButtonsLibrary(aButtons);
}; };

View File

@ -8,6 +8,24 @@ var AIRTIME = (function(AIRTIME){
AIRTIME.library.events = {}; AIRTIME.library.events = {};
mod = AIRTIME.library.events; mod = AIRTIME.library.events;
mod.enableAddButtonCheck = function() {
var selected = $('#library_display tr input[type=checkbox]').filter(":checked"),
cursor = $('tr.cursor-selected-row'),
check = false;
//make sure library items are selected and a cursor is selected.
if (selected.length !== 0 && cursor.length !== 0) {
check = true;
}
if (check === true) {
AIRTIME.button.enableButton("library_group_add");
}
else {
AIRTIME.button.disableButton("library_group_add");
}
};
mod.fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { mod.fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var $nRow = $(nRow); var $nRow = $(nRow);
@ -21,7 +39,6 @@ var AIRTIME = (function(AIRTIME){
$('#library_display tr:not(:first)').draggable({ $('#library_display tr:not(:first)').draggable({
helper: function(){ helper: function(){
var selected = $('#library_display tr:not(:first) input:checked').parents('tr'), var selected = $('#library_display tr:not(:first) input:checked').parents('tr'),
aItems = [],
container, container,
thead = $("#show_builder_table thead"), thead = $("#show_builder_table thead"),
colspan = thead.find("th").length, colspan = thead.find("th").length,
@ -34,10 +51,10 @@ var AIRTIME = (function(AIRTIME){
} }
if (selected.length === 1) { if (selected.length === 1) {
message = "Moving "+selected.length+" Item." message = "Moving "+selected.length+" Item.";
} }
else { else {
message = "Moving "+selected.length+" Items." message = "Moving "+selected.length+" Items.";
} }
container = $('<div/>').attr('id', 'draggingContainer') container = $('<div/>').attr('id', 'draggingContainer')
@ -61,8 +78,6 @@ var AIRTIME = (function(AIRTIME){
mod.setupLibraryToolbar = function(oLibTable) { mod.setupLibraryToolbar = function(oLibTable) {
var aButtons, var aButtons,
fnTest,
fnResetCol,
fnAddSelectedItems, fnAddSelectedItems,
fnAddSelectedItems = function() { fnAddSelectedItems = function() {
@ -93,12 +108,13 @@ var AIRTIME = (function(AIRTIME){
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds); AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
}; };
//[0] = button text //[0] = button text
//[1] = id //[1] = id
//[2] = enabled //[2] = enabled
//[3] = click event //[3] = click event
aButtons = [["Delete", "library_group_delete", true, AIRTIME.library.fnDeleteSelectedItems], aButtons = [["Delete", "library_group_delete", false, AIRTIME.library.fnDeleteSelectedItems],
["Add", "library_group_add", true, fnAddSelectedItems]]; ["Add", "library_group_add", false, fnAddSelectedItems]];
addToolBarButtonsLibrary(aButtons); addToolBarButtonsLibrary(aButtons);
}; };

View File

@ -1,5 +1,6 @@
var AIRTIME = (function(AIRTIME){ var AIRTIME = (function(AIRTIME){
var mod; var mod,
libraryInit;
if (AIRTIME.library === undefined) { if (AIRTIME.library === undefined) {
AIRTIME.library = {}; AIRTIME.library = {};
@ -13,6 +14,10 @@ var AIRTIME = (function(AIRTIME){
$.post("/library/delete", $.post("/library/delete",
{"format": "json", "media": aMedia}, {"format": "json", "media": aMedia},
function(json){ function(json){
if (json.message !== undefined) {
alert(json.message);
}
oLibTT.fnSelectNone(); oLibTT.fnSelectNone();
oLibTable.fnDraw(); oLibTable.fnDraw();
}); });
@ -36,183 +41,7 @@ var AIRTIME = (function(AIRTIME){
AIRTIME.library.fnDeleteItems(aMedia); AIRTIME.library.fnDeleteItems(aMedia);
}; };
return AIRTIME; libraryInit = function() {
}(AIRTIME || {}));
function addToolBarButtonsLibrary(aButtons) {
var i,
length = aButtons.length,
libToolBar,
html,
buttonClass = '',
DEFAULT_CLASS = 'ui-button ui-state-default',
DISABLED_CLASS = 'ui-state-disabled';
libToolBar = $(".library_toolbar");
for ( i=0; i < length; i+=1 ) {
buttonClass = '';
//add disabled class if not enabled.
if (aButtons[i][2] === false) {
buttonClass+=DISABLED_CLASS;
}
html = '<div id="'+aButtons[i][1]+'" class="ColVis TableTools"><button class="'+DEFAULT_CLASS+' '+buttonClass+'"><span>'+aButtons[i][0]+'</span></button></div>';
libToolBar.append(html);
libToolBar.find("#"+aButtons[i][1]).click(aButtons[i][3]);
}
}
function enableGroupBtn(btnId, func) {
btnId = '#' + btnId;
if ($(btnId).hasClass('ui-state-disabled')) {
$(btnId).removeClass('ui-state-disabled');
}
}
function disableGroupBtn(btnId) {
btnId = '#' + btnId;
if (!$(btnId).hasClass('ui-state-disabled')) {
$(btnId).addClass('ui-state-disabled');
}
}
function checkImportStatus(){
$.getJSON('/Preference/is-import-in-progress', function(data){
var div = $('#import_status');
if (data == true){
div.show();
}
else{
div.hide();
}
});
}
function addProgressIcon(id) {
var tr = $("#au_"+id),
span;
span = tr.find("td.library_title").find("span");
if (span.length > 0){
span.removeClass()
.addClass("small-icon progress");
}
else{
tr.find("td.library_title")
.append('<span class="small-icon progress"></span>');
}
}
function checkSCUploadStatus(){
var url = '/Library/get-upload-to-soundcloud-status';
$("span[class*=progress]").each(function(){
var span, id;
span = $(this);
id = span.parent().parent().data("aData").id;
$.post(url, {format: "json", id: id, type:"file"}, function(json){
if (json.sc_id > 0) {
span.removeClass("progress")
.addClass("soundcloud");
}
else if (json.sc_id == "-3") {
span.removeClass("progress")
.addClass("sc-error");
}
});
});
}
function addQtipToSCIcons(){
$(".progress, .soundcloud, .sc-error").live('mouseover', function(){
var id = $(this).parent().parent().data("aData").id;
if ($(this).hasClass("progress")){
$(this).qtip({
content: {
text: "Uploading in progress..."
},
position:{
adjust: {
resize: true,
method: "flip flip"
},
at: "right center",
my: "left top",
viewport: $(window)
},
show: {
ready: true // Needed to make it show on first mouseover event
}
});
}
else if($(this).hasClass("soundcloud")){
$(this).qtip({
content: {
text: "Retreiving data from the server...",
ajax: {
url: "/Library/get-upload-to-soundcloud-status",
type: "post",
data: ({format: "json", id : id, type: "file"}),
success: function(json, status){
this.set('content.text', "The soundcloud id for this file is: "+json.sc_id);
}
}
},
position:{
adjust: {
resize: true,
method: "flip flip"
},
at: "right center",
my: "left top",
viewport: $(window)
},
show: {
ready: true // Needed to make it show on first mouseover event
}
});
}else if($(this).hasClass("sc-error")){
$(this).qtip({
content: {
text: "Retreiving data from the server...",
ajax: {
url: "/Library/get-upload-to-soundcloud-status",
type: "post",
data: ({format: "json", id : id, type: "file"}),
success: function(json, status){
this.set('content.text', "There was error while uploading to soundcloud.<br>"+"Error code: "+json.error_code+
"<br>"+"Error msg: "+json.error_msg+"<br>");
}
}
},
position:{
adjust: {
resize: true,
method: "flip flip"
},
at: "right center",
my: "left top",
viewport: $(window)
},
show: {
ready: true // Needed to make it show on first mouseover event
}
});
}
});
}
$(document).ready(function() {
var oTable; var oTable;
oTable = $('#library_display').dataTable( { oTable = $('#library_display').dataTable( {
@ -234,8 +63,8 @@ $(document).ready(function() {
/* BPM */ {"sTitle": "BPM", "mDataProp": "bpm", "bSearchable": false, "bVisible": false, "sClass": "library_bpm"}, /* BPM */ {"sTitle": "BPM", "mDataProp": "bpm", "bSearchable": false, "bVisible": false, "sClass": "library_bpm"},
/* Composer */ {"sTitle": "Composer", "mDataProp": "composer", "bSearchable": false, "bVisible": false, "sClass": "library_composer"}, /* 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"}, /* 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"}, /* Bit Rate */ {"sTitle": "Bit Rate", "mDataProp": "bit_rate", "bSearchable": false, "bVisible": false, "sClass": "library_bitrate", "sWidth": "80px"},
/* Sameple Rate */ {"sTitle": "Sample Rate", "mDataProp": "sample_rate", "bSearchable": false, "bVisible": false, "sClass": "library_sr"}, /* 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"}, /* 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"}, /* 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"}, /* Label */ {"sTitle": "Label", "mDataProp": "label", "bSearchable": false, "bVisible": false, "sClass": "library_label"},
@ -400,24 +229,40 @@ $(document).ready(function() {
"sRowSelect": "multi", "sRowSelect": "multi",
"aButtons": [], "aButtons": [],
"fnRowSelected": function ( node ) { "fnRowSelected": function ( node ) {
var selected;
//seems to happen if everything is selected //seems to happen if everything is selected
if ( node === null) { if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", true); selected = oTable.find("input[type=checkbox]");
selected.attr("checked", true);
} }
else { else {
$(node).find("input[type=checkbox]").attr("checked", true); $(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 ) { "fnRowDeselected": function ( node ) {
var selected;
//seems to happen if everything is deselected //seems to happen if everything is deselected
if ( node === null) { if ( node === null) {
oTable.find("input[type=checkbox]").attr("checked", false); oTable.find("input[type=checkbox]").attr("checked", false);
selected = [];
} }
else { else {
$(node).find("input[type=checkbox]").attr("checked", false); $(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();
} }
}, },
@ -472,7 +317,7 @@ $(document).ready(function() {
ignoreRightClick: true, ignoreRightClick: true,
build: function($el, e) { build: function($el, e) {
var x, request, data, screen, items, callback, $tr; var data, screen, items, callback, $tr;
$tr = $el.parent(); $tr = $el.parent();
data = $tr.data("aData"); data = $tr.data("aData");
@ -527,7 +372,7 @@ $(document).ready(function() {
media.push({"id": data.id, "type": data.ftype}); media.push({"id": data.id, "type": data.ftype});
$.post(oItems.del.url, {format: "json", media: media }, function(json){ $.post(oItems.del.url, {format: "json", media: media }, function(json){
var oTable, tr; var oTable;
if (json.message) { if (json.message) {
alert(json.message); alert(json.message);
@ -595,4 +440,184 @@ $(document).ready(function() {
}; };
} }
}); });
};
mod.libraryInit = libraryInit;
return AIRTIME;
}(AIRTIME || {}));
function addToolBarButtonsLibrary(aButtons) {
var i,
length = aButtons.length,
libToolBar = $(".library_toolbar"),
html,
buttonClass = '',
DEFAULT_CLASS = 'ui-button ui-state-default',
DISABLED_CLASS = 'ui-state-disabled',
fn;
for ( i = 0; i < length; i += 1 ) {
buttonClass = '';
//add disabled class if not enabled.
if (aButtons[i][2] === false) {
buttonClass += DISABLED_CLASS;
}
html = '<div class="ColVis TableTools '+aButtons[i][1]+'"><button class="'+DEFAULT_CLASS+' '+buttonClass+'"><span>'+aButtons[i][0]+'</span></button></div>';
libToolBar.append(html);
//create a closure to preserve the state of i.
(function(index){
libToolBar.find("."+aButtons[index][1]).click(function(){
fn = function() {
var $button = $(this).find("button");
//only call the passed function if the button is enabled.
if (!$button.hasClass(DISABLED_CLASS)) {
aButtons[index][3]();
}
};
fn.call(this);
}); });
}(i));
}
}
function checkImportStatus(){
$.getJSON('/Preference/is-import-in-progress', function(data){
var div = $('#import_status');
if (data == true){
div.show();
}
else{
div.hide();
}
});
}
function addProgressIcon(id) {
var tr = $("#au_"+id),
span;
span = tr.find("td.library_title").find("span");
if (span.length > 0){
span.removeClass()
.addClass("small-icon progress");
}
else{
tr.find("td.library_title")
.append('<span class="small-icon progress"></span>');
}
}
function checkSCUploadStatus(){
var url = '/Library/get-upload-to-soundcloud-status';
$("span[class*=progress]").each(function(){
var span, id;
span = $(this);
id = span.parent().parent().data("aData").id;
$.post(url, {format: "json", id: id, type:"file"}, function(json){
if (json.sc_id > 0) {
span.removeClass("progress")
.addClass("soundcloud");
}
else if (json.sc_id == "-3") {
span.removeClass("progress")
.addClass("sc-error");
}
});
});
}
function addQtipToSCIcons(){
$(".progress, .soundcloud, .sc-error").live('mouseover', function(){
var id = $(this).parent().parent().data("aData").id;
if ($(this).hasClass("progress")){
$(this).qtip({
content: {
text: "Uploading in progress..."
},
position:{
adjust: {
resize: true,
method: "flip flip"
},
at: "right center",
my: "left top",
viewport: $(window)
},
show: {
ready: true // Needed to make it show on first mouseover event
}
});
}
else if($(this).hasClass("soundcloud")){
$(this).qtip({
content: {
text: "Retreiving data from the server...",
ajax: {
url: "/Library/get-upload-to-soundcloud-status",
type: "post",
data: ({format: "json", id : id, type: "file"}),
success: function(json, status){
this.set('content.text', "The soundcloud id for this file is: "+json.sc_id);
}
}
},
position:{
adjust: {
resize: true,
method: "flip flip"
},
at: "right center",
my: "left top",
viewport: $(window)
},
show: {
ready: true // Needed to make it show on first mouseover event
}
});
}else if($(this).hasClass("sc-error")){
$(this).qtip({
content: {
text: "Retreiving data from the server...",
ajax: {
url: "/Library/get-upload-to-soundcloud-status",
type: "post",
data: ({format: "json", id : id, type: "file"}),
success: function(json, status){
this.set('content.text', "There was error while uploading to soundcloud.<br>"+"Error code: "+json.error_code+
"<br>"+"Error msg: "+json.error_msg+"<br>");
}
}
},
position:{
adjust: {
resize: true,
method: "flip flip"
},
at: "right center",
my: "left top",
viewport: $(window)
},
show: {
ready: true // Needed to make it show on first mouseover event
}
});
}
});
}

View File

@ -0,0 +1 @@
$(document).ready(AIRTIME.library.libraryInit);

View File

@ -67,20 +67,9 @@ function uploadToSoundCloud(show_instance_id){
} }
} }
function buildContentDialog (json){ function findViewportDimensions() {
var dialog = $(json.dialog), var viewportwidth,
viewportwidth, viewportheight;
viewportheight,
height,
width;
if (json.show_error == true){
alertShowErrorAndReload();
}
dialog.find("#show_progressbar").progressbar({
value: json.percentFilled
});
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use // the more standards compliant browsers (mozilla/netscape/opera/IE7) use
// window.innerWidth and window.innerHeight // window.innerWidth and window.innerHeight
@ -101,8 +90,56 @@ function buildContentDialog (json){
viewportheight = document.getElementsByTagName('body')[0].clientHeight; viewportheight = document.getElementsByTagName('body')[0].clientHeight;
} }
height = viewportheight * 2/3; return {
width = viewportwidth * 4/5; 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({ dialog.dialog({
autoOpen: false, autoOpen: false,
@ -201,8 +238,12 @@ $(document).ready(function() {
if (oItems.schedule !== undefined) { if (oItems.schedule !== undefined) {
callback = function() { 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; oItems.schedule.callback = callback;
} }

View File

@ -1,6 +1,7 @@
var AIRTIME = (function(AIRTIME){ var AIRTIME = (function(AIRTIME){
var mod, var mod,
oSchedTable; oSchedTable,
fnServerData;
if (AIRTIME.showbuilder === undefined) { if (AIRTIME.showbuilder === undefined) {
AIRTIME.showbuilder = {}; 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 ) { fnServerData = function ( sSource, aoData, fnCallback ) {
aoData.push( { name: "format", value: "json"} ); aoData.push( { name: "format", value: "json"} );
@ -173,9 +69,12 @@ $(document).ready(function() {
} ); } );
}; };
oRange = fnGetScheduleRange(); mod.fnServerData = fnServerData;
fnServerData.start = oRange.start;
fnServerData.end = oRange.end; mod.builderDataTable = function() {
var tableDiv = $('#show_builder_table'),
oTable,
fnRemoveSelectedItems;
fnRemoveSelectedItems = function() { fnRemoveSelectedItems = function() {
var oTT = TableTools.fnGetInstance('show_builder_table'), var oTT = TableTools.fnGetInstance('show_builder_table'),
@ -273,7 +172,7 @@ $(document).ready(function() {
oData.iCreate = parseInt(oData.iCreate, 10); oData.iCreate = parseInt(oData.iCreate, 10);
}, },
"fnServerData": fnServerData, "fnServerData": AIRTIME.showbuilder.fnServerData,
"fnRowCallback": function ( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { "fnRowCallback": function ( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var i, var i,
sSeparatorHTML, sSeparatorHTML,
@ -419,16 +318,26 @@ $(document).ready(function() {
else { else {
$(node).find("input[type=checkbox]").attr("checked", true); $(node).find("input[type=checkbox]").attr("checked", true);
} }
//checking to enable buttons
AIRTIME.button.enableButton("sb_delete");
}, },
"fnRowDeselected": function ( node ) { "fnRowDeselected": function ( node ) {
var selected;
//seems to happen if everything is deselected //seems to happen if everything is deselected
if ( node === null) { if ( node === null) {
var oTable = $("#show_builder_table").dataTable(); tableDiv.find("input[type=checkbox]").attr("checked", false);
oTable.find("input[type=checkbox]").attr("checked", false); selected = [];
} }
else { else {
$(node).find("input[type=checkbox]").attr("checked", false); $(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");
} }
} }
}, },
@ -457,35 +366,6 @@ $(document).ready(function() {
} }
}); });
$("#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 sortableConf = (function(){
var origTrs, var origTrs,
aItemData = [], aItemData = [],
@ -521,9 +401,7 @@ $(document).ready(function() {
fnReceive = function(event, ui) { fnReceive = function(event, ui) {
var aItems = [], var aItems = [],
oLibTT = TableTools.fnGetInstance('library_display'), oLibTT = TableTools.fnGetInstance('library_display');
i,
length;
aItems = oLibTT.fnGetSelectedData(); aItems = oLibTT.fnGetSelectedData();
@ -579,7 +457,7 @@ $(document).ready(function() {
tableDiv.sortable(sortableConf); tableDiv.sortable(sortableConf);
$("#show_builder .fg-toolbar") $("#show_builder .fg-toolbar")
.append('<div class="ColVis TableTools"><button class="ui-button ui-state-default"><span>Delete</span></button></div>') .append('<div class="ColVis TableTools sb_delete"><button class="ui-button ui-state-default ui-state-disabled"><span>Delete</span></button></div>')
.click(fnRemoveSelectedItems); .click(fnRemoveSelectedItems);
//set things like a reference to the table. //set things like a reference to the table.
@ -587,16 +465,28 @@ $(document).ready(function() {
//add event to cursors. //add event to cursors.
tableDiv.find("tbody").on("click", "div.marker", function(event){ tableDiv.find("tbody").on("click", "div.marker", function(event){
var tr = $(this).parents("tr"); var tr = $(this).parents("tr"),
cursorSelClass = "cursor-selected-row";
if (tr.hasClass("cursor-selected-row")) { if (tr.hasClass(cursorSelClass)) {
tr.removeClass("cursor-selected-row"); tr.removeClass(cursorSelClass);
} }
else { else {
tr.addClass("cursor-selected-row"); tr.addClass(cursorSelClass);
} }
//check if add button can still be enabled.
AIRTIME.library.events.enableAddButtonCheck();
return false; return false;
}); });
}); };
mod.init = function(oTable) {
oSchedTable = oTable;
};
return AIRTIME;
}(AIRTIME || {}));

View File

@ -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();
});