Merge branch '2.1.x' of dev.sourcefabric.org:airtime into 2.1.x

This commit is contained in:
Martin Konecny 2012-06-28 16:16:12 -04:00
commit d30f4c05bb
1 changed files with 266 additions and 268 deletions

View File

@ -1,20 +1,20 @@
var AIRTIME = (function(AIRTIME){ var AIRTIME = (function(AIRTIME){
var mod; var mod;
if (AIRTIME.schedule === undefined) { if (AIRTIME.schedule === undefined) {
AIRTIME.schedule = {}; AIRTIME.schedule = {};
} }
mod = AIRTIME.schedule; mod = AIRTIME.schedule;
return AIRTIME; return AIRTIME;
}(AIRTIME || {})); }(AIRTIME || {}));
var serverTimezoneOffset = 0; var serverTimezoneOffset = 0;
function closeDialog(event, ui) { function closeDialog(event, ui) {
$("#schedule_calendar").fullCalendar( 'refetchEvents' ); $("#schedule_calendar").fullCalendar( 'refetchEvents' );
$(this).remove(); $(this).remove();
} }
function checkShowLength(json) { function checkShowLength(json) {
@ -36,11 +36,11 @@ function confirmCancelShow(show_instance_id){
if (confirm('Cancel Current Show?')) { if (confirm('Cancel Current Show?')) {
var url = "/Schedule/cancel-current-show"; var url = "/Schedule/cancel-current-show";
$.ajax({ $.ajax({
url: url, url: url,
data: {format: "json", id: show_instance_id}, data: {format: "json", id: show_instance_id},
success: function(data){ success: function(data){
scheduleRefetchEvents(data); scheduleRefetchEvents(data);
} }
}); });
} }
} }
@ -49,11 +49,11 @@ function confirmCancelRecordedShow(show_instance_id){
if (confirm('Stop recording current show?')) { if (confirm('Stop recording current show?')) {
var url = "/Schedule/cancel-current-show"; var url = "/Schedule/cancel-current-show";
$.ajax({ $.ajax({
url: url, url: url,
data: {format: "json", id: show_instance_id}, data: {format: "json", id: show_instance_id},
success: function(data){ success: function(data){
scheduleRefetchEvents(data); scheduleRefetchEvents(data);
} }
}); });
} }
} }
@ -72,21 +72,21 @@ function uploadToSoundCloud(show_instance_id){
if(span.length == 0){ if(span.length == 0){
span = $(window.triggerElement).find(".soundcloud"); span = $(window.triggerElement).find(".soundcloud");
span.removeClass("soundcloud") span.removeClass("soundcloud")
.addClass("progress"); .addClass("progress");
}else{ }else{
span.removeClass("recording") span.removeClass("recording")
.addClass("progress"); .addClass("progress");
} }
} }
function checkCalendarSCUploadStatus(){ function checkCalendarSCUploadStatus(){
var url = '/Library/get-upload-to-soundcloud-status', var url = '/Library/get-upload-to-soundcloud-status',
span, span,
id; id;
function checkSCUploadStatusCallback(json) { function checkSCUploadStatusCallback(json) {
if (json.sc_id > 0) { if (json.sc_id > 0) {
span.removeClass("progress").addClass("soundcloud"); span.removeClass("progress").addClass("soundcloud");
@ -108,113 +108,111 @@ function checkCalendarSCUploadStatus(){
} }
function findViewportDimensions() { function findViewportDimensions() {
var viewportwidth, var viewportwidth,
viewportheight; viewportheight;
// 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
if (typeof window.innerWidth != 'undefined') { if (typeof window.innerWidth != 'undefined') {
viewportwidth = window.innerWidth, viewportheight = window.innerHeight; viewportwidth = window.innerWidth, viewportheight = window.innerHeight;
} }
// IE6 in standards compliant mode (i.e. with a valid doctype as the first // IE6 in standards compliant mode (i.e. with a valid doctype as the first
// line in the document) // line in the document)
else if (typeof document.documentElement != 'undefined' else if (typeof document.documentElement != 'undefined'
&& typeof document.documentElement.clientWidth != 'undefined' && typeof document.documentElement.clientWidth != 'undefined'
&& document.documentElement.clientWidth != 0) { && document.documentElement.clientWidth != 0) {
viewportwidth = document.documentElement.clientWidth; viewportwidth = document.documentElement.clientWidth;
viewportheight = document.documentElement.clientHeight; viewportheight = document.documentElement.clientHeight;
} }
// older versions of IE // older versions of IE
else { else {
viewportwidth = document.getElementsByTagName('body')[0].clientWidth; viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
viewportheight = document.getElementsByTagName('body')[0].clientHeight; viewportheight = document.getElementsByTagName('body')[0].clientHeight;
} }
return { return {
width: viewportwidth, width: viewportwidth,
height: viewportheight height: viewportheight
}; };
} }
function buildScheduleDialog (json) { function buildScheduleDialog (json) {
var dialog = $(json.dialog),
var dialog = $(json.dialog), viewport = findViewportDimensions(),
viewport = findViewportDimensions(), height = Math.floor(viewport.height * 0.96),
height = Math.floor(viewport.height * 0.96), width = Math.floor(viewport.width * 0.96),
width = Math.floor(viewport.width * 0.96), fnServer = AIRTIME.showbuilder.fnServerData,
fnServer = AIRTIME.showbuilder.fnServerData, //subtract padding in pixels
//subtract padding in pixels widgetWidth = width - 60,
widgetWidth = width - 60, libWidth = Math.floor(widgetWidth * 0.5),
libWidth = Math.floor(widgetWidth * 0.5), builderWidth = Math.floor(widgetWidth * 0.5);
builderWidth = Math.floor(widgetWidth * 0.5);
dialog.find("#library_content")
dialog.find("#library_content") .height(height - 115)
.height(height - 115) .width(libWidth);
.width(libWidth);
dialog.find("#show_builder")
dialog.find("#show_builder") .height(height - 115)
.height(height - 115) .width(builderWidth);
.width(builderWidth);
dialog.dialog({
dialog.dialog({ autoOpen: false,
autoOpen: false, title: json.title,
title: json.title, width: width,
width: width, height: height,
height: height, resizable: false,
resizable: false, draggable: true,
draggable: true, modal: true,
modal: true, close: closeDialog,
close: closeDialog, buttons: {"Ok": function() {
buttons: {"Ok": function() { $(this).dialog("close");
dialog.remove(); }}
$("#schedule_calendar").fullCalendar( 'refetchEvents' ); });
}}
}); //set the start end times so the builder datatables knows its time range.
fnServer.start = json.start;
//set the start end times so the builder datatables knows its time range. fnServer.end = json.end;
fnServer.start = json.start;
fnServer.end = json.end; AIRTIME.library.libraryInit();
AIRTIME.showbuilder.builderDataTable();
AIRTIME.library.libraryInit();
AIRTIME.showbuilder.builderDataTable(); //set max heights of datatables.
dialog.find(".lib-content .dataTables_scrolling")
//set max heights of datatables. .css("max-height", height - 90 - 155);
dialog.find(".lib-content .dataTables_scrolling")
.css("max-height", height - 90 - 155); dialog.find(".sb-content .dataTables_scrolling")
.css("max-height", height - 90 - 60);
dialog.find(".sb-content .dataTables_scrolling")
.css("max-height", height - 90 - 60); dialog.dialog('open');
dialog.dialog('open');
} }
function buildContentDialog (json){ function buildContentDialog (json){
var dialog = $(json.dialog), var dialog = $(json.dialog),
viewport = findViewportDimensions(), viewport = findViewportDimensions(),
height = viewport.height * 2/3, height = viewport.height * 2/3,
width = viewport.width * 4/5; width = viewport.width * 4/5;
if (json.show_error == true){ if (json.show_error == true){
alertShowErrorAndReload(); alertShowErrorAndReload();
} }
dialog.find("#show_progressbar").progressbar({ dialog.find("#show_progressbar").progressbar({
value: json.percentFilled value: json.percentFilled
}); });
dialog.dialog({ dialog.dialog({
autoOpen: false, autoOpen: false,
title: "Contents of Show \"" + json.showTitle + "\"", title: "Contents of Show \"" + json.showTitle + "\"",
width: width, width: width,
height: height, height: height,
modal: true, modal: true,
close: closeDialog, close: closeDialog,
buttons: {"Ok": function() { buttons: {"Ok": function() {
dialog.remove(); dialog.remove();
}} }}
}); });
dialog.dialog('open'); dialog.dialog('open');
} }
/** /**
@ -279,55 +277,55 @@ function alertShowErrorAndReload(){
} }
$(document).ready(function() { $(document).ready(function() {
$.ajax({ url: "/Api/calendar-init/format/json", dataType:"json", success:createFullCalendar $.ajax({ url: "/Api/calendar-init/format/json", dataType:"json", success:createFullCalendar
, error:function(jqXHR, textStatus, errorThrown){}}); , error:function(jqXHR, textStatus, errorThrown){}});
setInterval(checkCalendarSCUploadStatus, 5000); setInterval(checkCalendarSCUploadStatus, 5000);
$.contextMenu({ $.contextMenu({
selector: 'div.fc-event', selector: 'div.fc-event',
trigger: "left", trigger: "left",
ignoreRightClick: true, ignoreRightClick: true,
build: function($el, e) { build: function($el, e) {
var data, var data,
items, items,
callback; callback;
data = $el.data("event"); data = $el.data("event");
function processMenuItems(oItems) { function processMenuItems(oItems) {
//define a schedule callback. //define a schedule callback.
if (oItems.schedule !== undefined) { if (oItems.schedule !== undefined) {
callback = function() { callback = function() {
$.post(oItems.schedule.url, {format: "json", id: data.id}, function(json){ $.post(oItems.schedule.url, {format: "json", id: data.id}, function(json){
buildScheduleDialog(json); buildScheduleDialog(json);
}); });
}; };
oItems.schedule.callback = callback; oItems.schedule.callback = callback;
} }
//define a clear callback. //define a clear callback.
if (oItems.clear !== undefined) { if (oItems.clear !== undefined) {
callback = function() { callback = function() {
if (confirm("Remove all content?")) { if (confirm("Remove all content?")) {
$.post(oItems.clear.url, {format: "json", id: data.id}, function(json){ $.post(oItems.clear.url, {format: "json", id: data.id}, function(json){
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}); });
} }
}; };
oItems.clear.callback = callback; oItems.clear.callback = callback;
} }
//define an edit callback. //define an edit callback.
if (oItems.edit !== undefined) { if (oItems.edit !== undefined) {
if(oItems.edit.items !== undefined){ if(oItems.edit.items !== undefined){
var edit = oItems.edit.items; var edit = oItems.edit.items;
//edit a single instance //edit a single instance
callback = function() { callback = function() {
@ -344,55 +342,55 @@ $(document).ready(function() {
}); });
}; };
edit.all.callback = callback; edit.all.callback = callback;
}else{ }else{
callback = function() { callback = function() {
$.get(oItems.edit.url, {format: "json", id: data.id, type: oItems.edit._type}, function(json){ $.get(oItems.edit.url, {format: "json", id: data.id, type: oItems.edit._type}, function(json){
beginEditShow(json); beginEditShow(json);
}); });
}; };
oItems.edit.callback = callback; oItems.edit.callback = callback;
} }
} }
//define a content callback. //define a content callback.
if (oItems.content !== undefined) { if (oItems.content !== undefined) {
callback = function() { callback = function() {
$.get(oItems.content.url, {format: "json", id: data.id}, function(json){ $.get(oItems.content.url, {format: "json", id: data.id}, function(json){
buildContentDialog(json); buildContentDialog(json);
}); });
}; };
oItems.content.callback = callback; oItems.content.callback = callback;
} }
//define a soundcloud upload callback. //define a soundcloud upload callback.
if (oItems.soundcloud_upload !== undefined) { if (oItems.soundcloud_upload !== undefined) {
callback = function() { callback = function() {
uploadToSoundCloud(data.id); uploadToSoundCloud(data.id);
}; };
oItems.soundcloud_upload.callback = callback; oItems.soundcloud_upload.callback = callback;
} }
//define a view on soundcloud callback. //define a view on soundcloud callback.
if (oItems.soundcloud_view !== undefined) { if (oItems.soundcloud_view !== undefined) {
callback = function() { callback = function() {
window.open(oItems.soundcloud_view.url); window.open(oItems.soundcloud_view.url);
}; };
oItems.soundcloud_view.callback = callback; oItems.soundcloud_view.callback = callback;
} }
//define a cancel recorded show callback. //define a cancel recorded show callback.
if (oItems.cancel_recorded !== undefined) { if (oItems.cancel_recorded !== undefined) {
callback = function() { callback = function() {
confirmCancelRecordedShow(data.id); confirmCancelRecordedShow(data.id);
}; };
oItems.cancel_recorded.callback = callback; oItems.cancel_recorded.callback = callback;
} }
//define a view recorded callback. //define a view recorded callback.
if (oItems.view_recorded !== undefined) { if (oItems.view_recorded !== undefined) {
callback = function() { callback = function() {
@ -400,71 +398,71 @@ $(document).ready(function() {
}; };
oItems.view_recorded.callback = callback; oItems.view_recorded.callback = callback;
} }
//define a cancel callback. //define a cancel callback.
if (oItems.cancel !== undefined) { if (oItems.cancel !== undefined) {
callback = function() { callback = function() {
confirmCancelShow(data.id); confirmCancelShow(data.id);
}; };
oItems.cancel.callback = callback; oItems.cancel.callback = callback;
} }
//define a delete callback. //define a delete callback.
if (oItems.del !== undefined) { if (oItems.del !== undefined) {
//repeating show multiple delete options //repeating show multiple delete options
if (oItems.del.items !== undefined) { if (oItems.del.items !== undefined) {
var del = oItems.del.items; var del = oItems.del.items;
//delete a single instance //delete a single instance
callback = function() { callback = function() {
$.post(del.single.url, {format: "json", id: data.id}, function(json){ $.post(del.single.url, {format: "json", id: data.id}, function(json){
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}); });
}; };
del.single.callback = callback; del.single.callback = callback;
//delete this instance and all following instances. //delete this instance and all following instances.
callback = function() { callback = function() {
$.post(del.following.url, {format: "json", id: data.id}, function(json){ $.post(del.following.url, {format: "json", id: data.id}, function(json){
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}); });
}; };
del.following.callback = callback; del.following.callback = callback;
} }
//single show //single show
else { else {
callback = function() { callback = function() {
$.post(oItems.del.url, {format: "json", id: data.id}, function(json){ $.post(oItems.del.url, {format: "json", id: data.id}, function(json){
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}); });
}; };
oItems.del.callback = callback; oItems.del.callback = callback;
} }
} }
items = oItems; items = oItems;
} }
$.ajax({ $.ajax({
url: "/schedule/make-context-menu", url: "/schedule/make-context-menu",
type: "GET", type: "GET",
data: {id : data.id, format: "json"}, data: {id : data.id, format: "json"},
dataType: "json", dataType: "json",
async: false, async: false,
success: function(json){ success: function(json){
processMenuItems(json.items); processMenuItems(json.items);
} }
}); });
return { return {
items: items, items: items,
determinePosition : function($menu, x, y) { determinePosition : function($menu, x, y) {
$menu.css('display', 'block') $menu.css('display', 'block')
.position({ my: "left top", at: "right top", of: this, offset: "-20 10", collision: "fit"}) .position({ my: "left top", at: "right top", of: this, offset: "-20 10", collision: "fit"})
.css('display', 'none'); .css('display', 'none');
} }
}; };
} }