Merge branch 'ryerson-history' into 2.5.x-saas

Conflicts:
	airtime_mvc/application/views/scripts/menu.phtml
This commit is contained in:
Naomi Aro 2013-09-02 15:52:43 -04:00
commit 682a37894b
156 changed files with 38382 additions and 4637 deletions

View file

@ -488,13 +488,13 @@ $(document).ready(function() {
setCurrentUserPseudoPassword();
}
$('#current-user').live('click', function() {
$('body').on('click','#current-user', function() {
$.ajax({
url: baseUrl+'user/edit-user/format/json'
});
});
$('#cu_save_user').live('click', function() {
$('body').on('click', '#cu_save_user', function() {
$.cookie("airtime_locale", $('#cu_locale').val(), {path: '/'});
});

View file

@ -1102,16 +1102,16 @@ function closeDialogLibrary(event, ui) {
function checkImportStatus() {
$.getJSON(baseUrl+'Preference/is-import-in-progress', function(data){
var div = $('#import_status');
var $div = $('#import_status');
var table = $('#library_display').dataTable();
if (data == true){
div.show();
$div.show();
}
else{
if ($(div).is(':visible')) {
if ($div.is(':visible')) {
table.fnStandingRedraw();
}
div.hide();
$div.hide();
}
setTimeout(checkImportStatus, 5000);
});

View file

@ -0,0 +1,167 @@
var AIRTIME = (function(AIRTIME) {
var mod;
var $templateDiv;
var $templateList;
var $fileMDList;
if (AIRTIME.itemTemplate === undefined) {
AIRTIME.itemTemplate = {};
}
mod = AIRTIME.itemTemplate;
//config: name, type, filemd, required
function createTemplateLi(config) {
var templateRequired =
"<li " +
"data-name='<%= name %>' " +
"data-type='<%= type %>' " +
"data-filemd='<%= filemd %>'" +
"data-label='<%= label %>'" +
"class='<%= (filemd) ? 'field_filemd' : 'field_other' %>'" +
">" +
"<span><%= label %></span>" +
"<span><%= type %></span>" +
"</li>";
var templateOptional =
"<li " +
"data-name='<%= name %>' " +
"data-type='<%= type %>' " +
"data-filemd='<%= filemd %>'" +
"data-label='<%= label %>'" +
"class='<%= (filemd) ? 'field_filemd' : 'field_other' %>'" +
">" +
"<span><%= label %></span>" +
"<span><%= type %></span>" +
"<span class='template_item_remove'><i class='icon icon-trash'></i></span>" +
"</li>";
var template = (config.required) === true ? templateRequired : templateOptional;
template = _.template(template);
var $li = $(template(config));
return $li;
}
//taken from
//http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
function randomString(len, charSet) {
//can only use small letters to avoid DB query problems.
charSet = charSet || 'abcdefghijklmnopqrstuvwxyz';
var randomString = '';
for (var i = 0; i < len; i++) {
var randomPoz = Math.floor(Math.random() * charSet.length);
randomString += charSet.substring(randomPoz,randomPoz+1);
}
return randomString;
}
function addField(config) {
$templateList.append(createTemplateLi(config));
}
function getFieldData($el) {
return {
name: $el.data("name"),
type: $el.data("type"),
label: $el.data("label"),
isFileMd: $el.data("filemd")
};
}
mod.onReady = function() {
$templateDiv = $("#configure_item_template");
$templateList = $(".template_item_list");
$fileMDList = $(".template_file_md");
$fileMDList.on("click", "i.icon-plus", function(){
var $li = $(this).parents("li");
var config = {
name: $li.data("name"),
type: $li.data("type"),
label: $li.data("label"),
filemd: true,
required: false
};
addField(config);
$li.remove();
});
$templateList.sortable();
$templateDiv.on("click", ".template_item_remove", function() {
$(this).parents("li").remove();
});
$templateDiv.on("click", ".template_item_add button", function() {
var $div = $(this).parents("div.template_item_add"),
$input = $div.find("input"),
label = $input.val(),
name;
$input.val("");
//create a string name that will work for all languages.
name = randomString(10);
var config = {
name: name,
label: label,
type: $div.find("select").val(),
filemd: false,
required: false
};
addField(config);
});
function updateTemplate(template_id, isDefault) {
var url = baseUrl+"Playouthistorytemplate/update-template/format/json";
var data = {};
var $lis, $li;
var i, len;
var templateName;
templateName = $("#template_name").val();
$lis = $templateList.children();
for (i = 0, len = $lis.length; i < len; i++) {
$li = $($lis[i]);
data[i] = getFieldData($li);
}
$.post(url, {'id': template_id, 'name': templateName, 'fields': data, 'setDefault': isDefault}, function(json) {
var x;
});
}
$templateDiv.on("click", "#template_item_save", function(){
var template_id = $(this).data("template");
updateTemplate(template_id, false);
});
$templateDiv.on("click", "#template_set_default", function() {
var $btn = $(this),
template_id = $btn.data("template"),
url = baseUrl+"Playouthistorytemplate/set-template-default/format/json";
$btn.remove();
$.post(url, {id: template_id});
});
};
return AIRTIME;
}(AIRTIME || {}));
$(document).ready(AIRTIME.itemTemplate.onReady);

View file

@ -1,32 +1,3 @@
function getFileName(ext){
var filename = $("#his_date_start").val()+"_"+$("#his_time_start").val()+"m--"+$("#his_date_end").val()+"_"+$("#his_time_end").val()+"m"
filename = filename.replace(/:/g,"h")
if(ext == "pdf"){
filename = filename+".pdf"
}else{
filename = filename+".csv"
}
return filename;
}
function setFlashFileName( nButton, oConfig, oFlash ) {
var filename = getFileName(oConfig.sExtends)
oFlash.setFileName( filename );
if(oConfig.sExtends == "pdf"){
this.fnSetText( oFlash,
"title:"+ this.fnGetTitle(oConfig) +"\n"+
"message:"+ oConfig.sPdfMessage +"\n"+
"colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+
"orientation:"+ oConfig.sPdfOrientation +"\n"+
"size:"+ oConfig.sPdfSize +"\n"+
"--/TableToolsOpts--\n" +
this.fnGetTableData(oConfig));
}else{
this.fnSetText( oFlash,
this.fnGetTableData(oConfig));
}
}
var AIRTIME = (function(AIRTIME) {
var mod;
@ -35,167 +6,815 @@ var AIRTIME = (function(AIRTIME) {
}
mod = AIRTIME.history;
mod.historyTable = function() {
var $historyContentDiv;
var oTableTools = {
"sSwfPath": baseUrl+"js/datatables/plugin/TableTools-2.1.5/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "copy",
"fnComplete": function(nButton, oConfig, oFlash, text) {
var lines = text.split('\n').length,
len = this.s.dt.nTFoot === null ? lines-1 : lines-2,
plural = (len==1) ? "" : "s";
alert(sprintf($.i18n._('Copied %s row%s to the clipboard'), len, plural));
},
//set because only the checkbox row is not sortable.
"mColumns": "sortable"
},
{
"sExtends": "csv",
"fnClick": setFlashFileName,
//set because only the checkbox row is not sortable.
"mColumns": "sortable"
},
{
"sExtends": "pdf",
"fnClick": setFlashFileName,
"sPdfOrientation": "landscape",
//set because only the checkbox row is not sortable.
"mColumns": "sortable"
},
{
"sExtends": "print",
"sInfo" : sprintf($.i18n._("%sPrint view%sPlease use your browser's print function to print this table. Press escape when finished."), "<h6>", "</h6><p>"),
//set because only the checkbox row is not sortable.
"mColumns": "sortable"
}
]
};
var lengthMenu = [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, $.i18n._("All")]];
var sDom = 'l<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>';
var selectedLogItems = {};
var dateStartId = "#his_date_start",
timeStartId = "#his_time_start",
dateEndId = "#his_date_end",
timeEndId = "#his_time_end",
oTableAgg,
oTableItem,
oTableShow,
inShowsTab = false;
function getSelectedLogItems() {
var items = Object.keys(selectedLogItems);
return items;
}
function addSelectedLogItem($el) {
var id;
$el.addClass("his-selected");
id = $el.data("his-id");
selectedLogItems[id] = "";
}
function removeSelectedLogItem($el) {
var id;
$el.removeClass("his-selected");
id = $el.data("his-id");
delete selectedLogItems[id];
}
function emptySelectedLogItems() {
var $inputs = $historyContentDiv.find(".his_checkbox").find("input");
$inputs.prop('checked', false);
$inputs.parents("tr").removeClass("his-selected");
selectedLogItems = {};
}
function selectCurrentPage(e) {
var $ctx = $(e.currentTarget).parents("div.dataTables_wrapper"),
$inputs = $ctx.find(".his_checkbox").find("input"),
$tr,
$input;
$.each($inputs, function(index, input) {
$input = $(input);
$input.prop('checked', true);
$tr = $input.parents("tr");
addSelectedLogItem($tr);
});
}
function deselectCurrentPage(e) {
var $ctx = $(e.currentTarget).parents("div.dataTables_wrapper"),
$inputs = $ctx.find(".his_checkbox").find("input"),
$tr,
$input;
$.each($inputs, function(index, input) {
$input = $(input);
$input.prop('checked', false);
$tr = $input.parents("tr");
removeSelectedLogItem($tr);
});
}
function getFileName(ext){
var filename = $("#his_date_start").val()+"_"+$("#his_time_start").val()+"m--"+$("#his_date_end").val()+"_"+$("#his_time_end").val()+"m";
filename = filename.replace(/:/g,"h");
if (ext == "pdf"){
filename = filename+".pdf";
}
else {
filename = filename+".csv";
}
return filename;
}
function setFlashFileName( nButton, oConfig, oFlash ) {
var filename = getFileName(oConfig.sExtends);
oFlash.setFileName( filename );
if (oConfig.sExtends == "pdf") {
this.fnSetText( oFlash,
"title:"+ this.fnGetTitle(oConfig) +"\n"+
"message:"+ oConfig.sPdfMessage +"\n"+
"colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+
"orientation:"+ oConfig.sPdfOrientation +"\n"+
"size:"+ oConfig.sPdfSize +"\n"+
"--/TableToolsOpts--\n" +
this.fnGetTableData(oConfig));
}
else {
this.fnSetText(oFlash, this.fnGetTableData(oConfig));
}
}
/* This callback can be used for all history tables */
function fnServerData( sSource, aoData, fnCallback ) {
if (fnServerData.hasOwnProperty("start")) {
aoData.push( { name: "start", value: fnServerData.start} );
}
if (fnServerData.hasOwnProperty("end")) {
aoData.push( { name: "end", value: fnServerData.end} );
}
if (fnServerData.hasOwnProperty("instance")) {
aoData.push( { name: "instance_id", value: fnServerData.instance} );
}
aoData.push( { name: "format", value: "json"} );
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
function createShowAccordSection(config) {
var template,
$el;
template =
"<h3>" +
"<a href='#'>" +
"<span class='show-title'><%= name %></span>" +
"<span class='push-right'>" +
"<span class='show-date'><%= date %></span>" +
"<span class='show-time'><%= startTime %></span>" +
"-" +
"<span class='show-time'><%= endTime %></span>" +
"</span>" +
"</a>" +
"</h3>" +
"<div " +
"data-instance='<%= instance %>' " +
"></div>";
template = _.template(template);
$el = $(template(config));
return $el;
}
//$el is the div in the accordian we should create the table on.
function createShowTable($el) {
var instance = $el.data("instance");
var $table = $("<table/>", {
'cellpadding': "0",
'cellspacing': "0",
'class': "datatable",
'id': "history_table_show"
});
//assign the retrieval function the show instance id.
fnServerData.instance = instance;
$el.append($table);
$el.css("height", "auto");
oTableShow = itemHistoryTable("history_table_show");
}
function drawShowList(oShows) {
var $showList = $historyContentDiv.find("#history_show_summary"),
i,
len,
$accordSection,
show,
tmp;
$showList
.accordion( "destroy" )
.empty();
for (i = 0, len = oShows.length; i < len; i++) {
show = oShows[i];
tmp = show.starts.split(" ");
$accordSection = createShowAccordSection({
instance: show.instance_id,
name: show.name,
date: tmp[0],
startTime: tmp[1],
endTime: show.ends.split(" ").pop()
});
$showList.append($accordSection);
}
$showList.accordion({
animated: false,
create: function( event, ui ) {
var $div = $showList.find(".ui-accordion-content-active");
createShowTable($div);
},
change: function( event, ui ) {
var $div = $(ui.newContent);
$(ui.oldContent).empty();
createShowTable($div);
selectedLogItems = {};
}
//changestart: function( event, ui ) {}
});
}
function createToolbarButtons ($el) {
var $menu = $("<div class='btn-toolbar' />");
$menu.append("<div class='btn-group'>" +
"<button class='btn btn-small dropdown-toggle' data-toggle='dropdown'>" +
$.i18n._("Select")+" <span class='caret'></span>" +
"</button>" +
"<ul class='dropdown-menu'>" +
"<li class='his-select-page'><a href='#'>"+$.i18n._("Select this page")+"</a></li>" +
"<li class='his-dselect-page'><a href='#'>"+$.i18n._("Deselect this page")+"</a></li>" +
"<li class='his-dselect-all'><a href='#'>"+$.i18n._("Deselect all")+"</a></li>" +
"</ul>" +
"</div>");
$menu.append("<div class='btn-group'>" +
"<button class='btn btn-small' id='his_create'>" +
"<i class='icon-white icon-plus'></i>" +
$.i18n._("Create Entry") +
"</button>" +
"</div>");
$menu.append("<div class='btn-group'>" +
"<button class='btn btn-small' id='his_trash'>" +
"<i class='icon-white icon-trash'></i>" +
"</button>" +
"</div>");
$el.append($menu);
}
function aggregateHistoryTable() {
var oTable,
historyContentDiv = $("#history_content"),
historyTableDiv = historyContentDiv.find("#history_table"),
tableHeight = historyContentDiv.height() - 200,
fnServerData;
fnServerData = function ( sSource, aoData, fnCallback ) {
if (fnServerData.hasOwnProperty("start")) {
aoData.push( { name: "start", value: fnServerData.start} );
}
if (fnServerData.hasOwnProperty("end")) {
aoData.push( { name: "end", value: fnServerData.end} );
}
aoData.push( { name: "format", value: "json"} );
$.ajax( {
"dataType": 'json',
"type": "GET",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
$historyTableDiv = $historyContentDiv.find("#history_table_aggregate"),
columns,
fnRowCallback;
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var editUrl = baseUrl+"playouthistory/edit-file-item/id/"+aData.file_id,
$nRow = $(nRow);
$nRow.data('url-edit', editUrl);
};
oTable = historyTableDiv.dataTable( {
columns = JSON.parse(localStorage.getItem('datatables-historyfile-aoColumns'));
oTable = $historyTableDiv.dataTable( {
"aoColumns": [
{"sTitle": $.i18n._("Title"), "mDataProp": "title", "sClass": "his_title"}, /* Title */
{"sTitle": $.i18n._("Creator"), "mDataProp": "artist", "sClass": "his_artist"}, /* Creator */
{"sTitle": $.i18n._("Played"), "mDataProp": "played", "sClass": "his_artist"}, /* times played */
{"sTitle": $.i18n._("Length"), "mDataProp": "length", "sClass": "his_length library_length"}, /* Length */
{"sTitle": $.i18n._("Composer"), "mDataProp": "composer", "sClass": "his_composer"}, /* Composer */
{"sTitle": $.i18n._("Copyright"), "mDataProp": "copyright", "sClass": "his_copyright"} /* Copyright */
],
"aoColumns": columns,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": baseUrl+"Playouthistory/playout-history-feed",
"sAjaxSource": baseUrl+"playouthistory/file-history-feed",
"sAjaxDataProp": "history",
"fnServerData": fnServerData,
"fnRowCallback": fnRowCallback,
"oLanguage": datatables_dict,
"aLengthMenu": [[50, 100, 500, -1], [50, 100, 500, $.i18n._("All")]],
"iDisplayLength": 50,
"aLengthMenu": lengthMenu,
"iDisplayLength": 25,
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"bAutoWidth": true,
"sDom": 'lf<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>',
"oTableTools": {
"sSwfPath": baseUrl+"js/datatables/plugin/TableTools/swf/copy_cvs_xls_pdf.swf",
"aButtons": [
{
"sExtends": "copy",
"fnComplete": function(nButton, oConfig, oFlash, text) {
var lines = text.split('\n').length,
len = this.s.dt.nTFoot === null ? lines-1 : lines-2,
plural = (len==1) ? "" : "s";
alert(sprintf($.i18n._('Copied %s row%s to the clipboard'), len, plural));
}
},
{
"sExtends": "csv",
"fnClick": setFlashFileName
},
{
"sExtends": "pdf",
"fnClick": setFlashFileName
},
{
"sExtends": "print",
"sInfo" : sprintf($.i18n._("%sPrint view%sPlease use your browser's print function to print this table. Press escape when finished."), "<h6>", "</h6><p>")
}
]
"sDom": sDom,
"oTableTools": oTableTools
});
oTable.fnSetFilteringDelay(350);
return oTable;
}
function itemHistoryTable(id) {
var oTable,
$historyTableDiv = $historyContentDiv.find("#"+id),
$toolbar,
columns,
fnRowCallback,
booleans = {},
i, c;
columns = JSON.parse(localStorage.getItem('datatables-historyitem-aoColumns'));
for (i in columns) {
c = columns[i];
if (c["sDataType"] === "boolean") {
booleans[c["mDataProp"]] = c["sTitle"];
}
}
fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var editUrl = baseUrl+"playouthistory/edit-list-item/id/"+aData.history_id,
deleteUrl = baseUrl+"playouthistory/delete-list-item/id/"+aData.history_id,
emptyCheckBox = String.fromCharCode(parseInt(2610, 16)),
checkedCheckBox = String.fromCharCode(parseInt(2612, 16)),
b,
text,
$nRow = $(nRow);
// add checkbox
$nRow.find('td.his_checkbox').html("<input type='checkbox' name='cb_"+aData.history_id+"'>");
$nRow.data('his-id', aData.history_id);
$nRow.data('url-edit', editUrl);
$nRow.data('url-delete', deleteUrl);
for (b in booleans) {
text = aData[b] ? checkedCheckBox : emptyCheckBox;
text = text + " " + booleans[b];
$nRow.find(".his_"+b).html(text);
}
};
oTable = $historyTableDiv.dataTable( {
"aoColumns": columns,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": baseUrl+"playouthistory/item-history-feed",
"sAjaxDataProp": "history",
"fnServerData": fnServerData,
"fnRowCallback": fnRowCallback,
"oLanguage": datatables_dict,
"aLengthMenu": lengthMenu,
"iDisplayLength": 25,
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"bAutoWidth": true,
"sDom": sDom,
"oTableTools": oTableTools
});
oTable.fnSetFilteringDelay(350);
historyContentDiv.find(".dataTables_scrolling").css("max-height", tableHeight);
$toolbar = $historyTableDiv.parents(".dataTables_wrapper").find(".fg-toolbar:first");
createToolbarButtons($toolbar);
return oTable;
}
function showSummaryList() {
var url = baseUrl+"playouthistory/show-history-feed",
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId),
data = {
format: "json",
start: oRange.start,
end: oRange.end
};
$.post(url, data, function(json) {
drawShowList(json);
});
}
mod.onReady = function() {
var oBaseDatePickerSettings,
oBaseTimePickerSettings,
$hisDialogEl,
tabsInit = [
{
initialized: false,
initialize: function() {
oTableItem = itemHistoryTable("history_table_list");
},
navigate: function() {
delete fnServerData.instance;
oTableItem.fnDraw();
},
always: function() {
inShowsTab = false;
emptySelectedLogItems();
}
},
{
initialized: false,
initialize: function() {
oTableAgg = aggregateHistoryTable();
},
navigate: function() {
delete fnServerData.instance;
oTableAgg.fnDraw();
},
always: function() {
inShowsTab = false;
emptySelectedLogItems();
}
},
{
initialized: false,
initialize: function() {
},
navigate: function() {
},
always: function() {
inShowsTab = true;
showSummaryList();
emptySelectedLogItems();
}
}
];
$historyContentDiv = $("#history_content");
function redrawTables() {
oTableAgg && oTableAgg.fnDraw();
oTableItem && oTableItem.fnDraw();
oTableShow && oTableShow.fnDraw();
}
function removeHistoryDialog() {
$hisDialogEl.dialog("destroy");
$hisDialogEl.remove();
}
function initializeDialog() {
var $startPicker = $hisDialogEl.find('#his_item_starts_datetimepicker'),
$endPicker = $hisDialogEl.find('#his_item_ends_datetimepicker');
$startPicker.datetimepicker();
$endPicker.datetimepicker({
showTimeFirst: true
});
$startPicker.on('changeDate', function(e) {
$endPicker.data('datetimepicker').setLocalDate(e.localDate);
});
}
function processDialogHtml($el) {
if (inShowsTab) {
$el.find("#his_choose_instance").remove();
}
return $el
}
function makeHistoryDialog(html) {
$hisDialogEl = $(html);
$hisDialogEl = processDialogHtml($hisDialogEl);
$hisDialogEl.dialog({
title: $.i18n._("Edit History Record"),
modal: false,
open: function( event, ui ) {
initializeDialog();
},
close: function() {
removeHistoryDialog();
}
});
}
/*
* Icon hover states for search.
*/
$historyContentDiv.on("mouseenter", ".his-timerange .ui-button", function(ev) {
$(this).addClass("ui-state-hover");
});
$historyContentDiv.on("mouseleave", ".his-timerange .ui-button", function(ev) {
$(this).removeClass("ui-state-hover");
});
oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd',
//i18n_months, i18n_days_short are in common.js
monthNames: i18n_months,
dayNamesMin: i18n_days_short,
onSelect: function(sDate, oDatePicker) {
$(this).datepicker( "setDate", sDate );
}
};
oBaseTimePickerSettings = {
showPeriodLabels: false,
showCloseButton: true,
closeButtonText: $.i18n._("Done"),
showLeadingZero: false,
defaultTime: '0:00',
hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute")
};
$historyContentDiv.find(dateStartId).datepicker(oBaseDatePickerSettings);
$historyContentDiv.find(timeStartId).timepicker(oBaseTimePickerSettings);
$historyContentDiv.find(dateEndId).datepicker(oBaseDatePickerSettings);
$historyContentDiv.find(timeEndId).timepicker(oBaseTimePickerSettings);
$historyContentDiv.on("click", "#his_create", function(e) {
var url = baseUrl+"playouthistory/edit-list-item/format/json" ;
e.preventDefault();
$.get(url, function(json) {
makeHistoryDialog(json.dialog);
}, "json");
});
$('body').on("click", ".his_file_cancel, .his_item_cancel", function(e) {
removeHistoryDialog();
});
$('body').on("click", ".his_file_save", function(e) {
e.preventDefault();
var $form = $(this).parents("form");
var data = $form.serializeArray();
var url = baseUrl+"Playouthistory/update-file-item/format/json";
$.post(url, data, function(json) {
//TODO put errors on form.
if (json.error !== undefined) {
//makeHistoryDialog(json.dialog);
}
else {
removeHistoryDialog();
redrawTables();
}
}, "json");
});
$('body').on("click", ".his_item_save", function(e) {
e.preventDefault();
var $form = $(this).parents("form"),
data = $form.serializeArray(),
id = data[0].value,
createUrl = baseUrl+"Playouthistory/create-list-item/format/json",
updateUrl = baseUrl+"Playouthistory/update-list-item/format/json",
url,
$select = $hisDialogEl.find("#his_instance_select"),
instance;
url = (id === "") ? createUrl : updateUrl;
if (fnServerData.instance !== undefined) {
data.push({
name: "instance_id",
value: fnServerData.instance
});
}
else if ($select.length > 0) {
instance = $select.val();
if (instance > 0) {
data.push({
name: "instance_id",
value: instance
});
}
}
$.post(url, data, function(json) {
if (json.form !== undefined) {
var $newForm = $(json.form);
$newForm = processDialogHtml($newForm);
$hisDialogEl.html($newForm.html());
initializeDialog();
}
else {
removeHistoryDialog();
redrawTables();
}
}, "json");
});
$historyContentDiv.on("click", ".his_checkbox input", function(e) {
var checked = e.currentTarget.checked,
$tr = $(e.currentTarget).parents("tr");
if (checked) {
addSelectedLogItem($tr);
}
else {
removeSelectedLogItem($tr);
}
});
$('body').on("click", "#his_instance_retrieve", function(e) {
var startPicker = $hisDialogEl.find('#his_item_starts_datetimepicker').data('datetimepicker'),
endPicker = $hisDialogEl.find('#his_item_ends_datetimepicker').data('datetimepicker'),
url = baseUrl+"playouthistory/show-history-feed",
startDate = startPicker.getLocalDate(),
endDate = endPicker.getLocalDate(),
getEpochSeconds = AIRTIME.utilities.fnGetSecondsEpoch,
data;
data = {
start: getEpochSeconds(startDate),
end: getEpochSeconds(endDate),
format: "json"
};
$.get(url, data, function(json) {
var i,
$select = $('<select/>', {
id: 'his_instance_select'
}),
$option,
show;
if (json.length > 0) {
for (i = 0; i < json.length; i++) {
show = json[i];
$option = $('<option/>')
.text(show.name)
.attr('value', show.instance_id);
$select.append($option);
}
}
$option = $('<option/>')
.text($.i18n._("No Show"))
.attr('value', 0);
$select.append($option);
$hisDialogEl.find("#his_instance_select").replaceWith($select);
});
});
$historyContentDiv.find("#his_submit").click(function(ev){
var fn,
oRange;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
fn = fnServerData;
fn.start = oRange.start;
fn.end = oRange.end;
if (inShowsTab) {
showSummaryList();
}
else {
redrawTables();
}
});
$historyContentDiv.on("click", ".his-select-page", selectCurrentPage);
$historyContentDiv.on("click", ".his-dselect-page", deselectCurrentPage);
$historyContentDiv.on("click", ".his-dselect-all", emptySelectedLogItems);
$historyContentDiv.on("click", "#his_trash", function(ev){
var items = getSelectedLogItems(),
url = baseUrl+"playouthistory/delete-list-items";
$.post(url, {ids: items, format: "json"}, function() {
selectedLogItems = {};
redrawTables();
});
});
$historyContentDiv.find("#his-tabs").tabs({
show: function( event, ui ) {
var href = $(ui.tab).attr("href");
var index = href.split('-').pop();
var tab = tabsInit[index-1];
if (!tab.initialized) {
tab.initialize();
tab.initialized = true;
}
else {
tab.navigate();
}
tab.always();
}
});
// begin context menu initialization.
$.contextMenu({
selector: '#history_content td:not(.his_checkbox)',
trigger: "left",
ignoreRightClick: true,
build: function($el, e) {
var items = {},
callback,
$tr,
editUrl,
deleteUrl;
$tr = $el.parents("tr");
editUrl = $tr.data("url-edit");
deleteUrl = $tr.data("url-delete");
if (editUrl !== undefined) {
callback = function() {
$.post(editUrl, {format: "json"}, function(json) {
makeHistoryDialog(json.dialog);
}, "json");
};
items["edit"] = {
"name": $.i18n._("Edit"),
"icon": "edit",
"callback": callback
};
}
if (deleteUrl !== undefined) {
callback = function() {
var c = confirm("Delete this entry?");
if (c) {
$.post(deleteUrl, {format: "json"}, function(json) {
redrawTables();
});
}
};
items["del"] = {
"name": $.i18n._("Delete"),
"icon": "delete",
"callback": callback
};
}
return {
items: items
};
}
});
};
return AIRTIME;
}(AIRTIME || {}));
$(document).ready(function(){
var viewport = AIRTIME.utilities.findViewportDimensions(),
history_content = $("#history_content"),
widgetHeight = viewport.height - 185,
screenWidth = Math.floor(viewport.width - 110),
oBaseDatePickerSettings,
oBaseTimePickerSettings,
oTable,
dateStartId = "#his_date_start",
timeStartId = "#his_time_start",
dateEndId = "#his_date_end",
timeEndId = "#his_time_end";
/*
* Icon hover states for search.
*/
history_content.on("mouseenter", ".his-timerange .ui-button", function(ev) {
$(this).addClass("ui-state-hover");
});
history_content.on("mouseleave", ".his-timerange .ui-button", function(ev) {
$(this).removeClass("ui-state-hover");
});
history_content
.height(widgetHeight)
.width(screenWidth);
oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd',
//i18n_months, i18n_days_short are in common.js
monthNames: i18n_months,
dayNamesMin: i18n_days_short,
onSelect: function(sDate, oDatePicker) {
$(this).datepicker( "setDate", sDate );
}
};
oBaseTimePickerSettings = {
showPeriodLabels: false,
showCloseButton: true,
closeButtonText: $.i18n._("Done"),
showLeadingZero: false,
defaultTime: '0:00',
hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute")
};
oTable = AIRTIME.history.historyTable();
history_content.find(dateStartId).datepicker(oBaseDatePickerSettings);
history_content.find(timeStartId).timepicker(oBaseTimePickerSettings);
history_content.find(dateEndId).datepicker(oBaseDatePickerSettings);
history_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
history_content.find("#his_submit").click(function(ev){
var fn,
oRange;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
fn = oTable.fnSettings().fnServerData;
fn.start = oRange.start;
fn.end = oRange.end;
oTable.fnDraw();
});
});
$(document).ready(AIRTIME.history.onReady);

View file

@ -0,0 +1,102 @@
var AIRTIME = (function(AIRTIME) {
var mod;
var $historyTemplate;
if (AIRTIME.template === undefined) {
AIRTIME.template = {};
}
mod = AIRTIME.template;
function createItemLi(id, name, configured) {
var editUrl = baseUrl+"Playouthistorytemplate/configure-template/id/"+id;
var defaultUrl = baseUrl+"Playouthistorytemplate/set-template-default/format/json/id/"+id;
var removeUrl = baseUrl+"Playouthistorytemplate/delete-template/format/json/id/"+id;
var itemConfigured =
"<li class='template_configured' data-template='<%= id %>' data-name='<%= name %>'>" +
"<a href='<%= editUrl %>' class='template_name'><%= name %></a>" +
"<i class='icon icon-ok'></i>" +
"</li>";
var item =
"<li data-template='<%= id %>' data-name='<%= name %>'>" +
"<a href='<%= editUrl %>' class='template_name'><%= name %></a>" +
"<a href='<%= removeUrl %>' class='template_remove'><i class='icon icon-trash'></i></a>" +
"<a href='<%= defaultUrl %>' class='template_default'>Set Default</a>" +
"</li>";
var template = (configured) === true ? itemConfigured : item;
var template = _.template(template);
var $li = $(template({id: id, name: name, editUrl: editUrl, defaultUrl: defaultUrl, removeUrl: removeUrl}));
return $li;
}
mod.onReady = function() {
$historyTemplate = $("#history_template");
$historyTemplate.on("click", ".template_remove", function(ev) {
ev.preventDefault();
var $a = $(this);
var url = $a.attr("href");
$a.parents("li").remove();
$.post(url, function(){
var x;
});
});
$historyTemplate.on("click", ".template_default", function(ev) {
ev.preventDefault();
var $a = $(this);
var url = $a.attr("href");
var $oldLi, $newLi;
$oldLi = $a.parents("ul").find("li.template_configured");
$newLi = $a.parents("li");
$oldLi.replaceWith(createItemLi($oldLi.data('template'), $oldLi.data('name'), false));
$newLi.replaceWith(createItemLi($newLi.data('template'), $newLi.data('name'), true));
$.post(url, function(){
var x;
});
});
function createTemplate(type) {
var createUrl = baseUrl+"Playouthistorytemplate/create-template";
$.post(createUrl, {format: "json", type: type}, function(json) {
if (json.error !== undefined) {
alert(json.error);
return;
}
window.location.href = json.url;
});
}
$historyTemplate.on("click", "#new_item_template", function() {
createTemplate("item");
});
$historyTemplate.on("click", "#new_file_template", function() {
createTemplate("file");
});
};
return AIRTIME;
}(AIRTIME || {}));
$(document).ready(AIRTIME.template.onReady);

View file

@ -444,28 +444,28 @@ function getCurrentShow(){
* is switching from week view to day view (and vice versa)
* the icon may already be there from previous view
*/
$el.siblings().remove("span[class=small-icon now-playing]");
$el.siblings().remove("span.now-playing");
if (!$el.siblings().hasClass("small-icon now-playing")) {
if ($el.siblings().hasClass("small-icon recording")) {
/* Without removing recording icon, the now playing
* icon will overwrite it.
*/
$el.siblings().remove("span[class=small-icon recording]");
$el.siblings().remove("span.recording");
$el.before('<span class="small-icon now-playing"></span><span class="small-icon recording"></span>');
} else if ($el.siblings().hasClass("small-icon rebroadcast")) {
/* Without removing rebroadcast icon, the now playing
* icon will overwrite it.
*/
$el.siblings().remove("span[class=small-icon rebroadcast]");
$el.siblings().remove("span.rebroadcast");
$el.before('<span class="small-icon now-playing"></span><span class="small-icon rebroadcast"></span>');
} else {
$el.before('<span class="small-icon now-playing"></span>');
}
}
} else if (view_name === 'month') {
if (!$("span[class*=fc-event-title]").siblings().hasClass("small-icon now-playing")) {
if (!$("span[class*=fc-event-title]").siblings().hasClass("now-playing")) {
$("span[class*=fc-event-title]").after('<span class="small-icon now-playing"></span>');
}
}
@ -475,7 +475,7 @@ function getCurrentShow(){
id = $(this).parents("div.fc-event").data("event").id;
if (id != json.si_id) {
$(this).remove("span[small-icon now-playing]");
$(this).remove("span.now-playing");
}
});

View file

@ -35,6 +35,22 @@ var AIRTIME = (function(AIRTIME){
};
};
mod.fnGetSecondsEpoch = function(oDate) {
var iTime,
iServerOffset,
iClientOffset;
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;
}
/*
* Get the schedule range start in unix timestamp form (in seconds).
* defaults to NOW if nothing is selected.
@ -69,15 +85,7 @@ var AIRTIME = (function(AIRTIME){
//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;
return mod.fnGetSecondsEpoch(oDate);
};
/*