Merge branch 'saas-dev' into saas-showbuilder-fade-editor-restyling

This commit is contained in:
Albert Santoni 2015-09-04 11:21:00 -04:00
commit 1db1af3f2e
134 changed files with 119858 additions and 113185 deletions

View file

@ -71,7 +71,7 @@ function getDatatablesStrings(overrideDict) {
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 entries"),
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total entries)"),
"sInfoPostFix": $.i18n._(""),
"sInfoThousands": $.i18n._("),"),
"sInfoThousands": $.i18n._(","),
"sLengthMenu": $.i18n._("Show _MENU_"),
"sLoadingRecords": $.i18n._("Loading..."),
//"sProcessing": $.i18n._("Processing..."),
@ -212,6 +212,41 @@ function validateTimeRange() {
};
}
// validate uploaded images
function validateImage(img, el) {
// remove any existing error messages
if ($("#img-err")) { $("#img-err").remove(); }
if (img.size > 2048000) { // 2MB - pull this from somewhere instead?
// hack way of inserting an error message
var err = $.i18n._("Selected file is too large");
el.parent().after(
"<ul id='img-err' class='errors'>" +
"<li>" + err + "</li>" +
"</ul>");
return false;
} else if (validateMimeType(img.type) < 0) {
var err = $.i18n._("File format is not supported");
el.parent().after(
"<ul id='img-err' class='errors'>" +
"<li>" + err + "</li>" +
"</ul>");
return false;
}
return true;
}
// validate image mime type
function validateMimeType(mime) {
var extensions = [
'image/jpeg',
'image/png',
'image/gif'
// BMP?
];
return $.inArray(mime, extensions);
}
function pad(number, length) {
return sprintf("%'0"+length+"d", number);
}

View file

@ -77,52 +77,30 @@ var AIRTIME = (function(AIRTIME) {
cb.append("<input id='super-checkbox' type='checkbox'>");
}
var libEmpty = $('#library_empty');
if (emptyRow.length > 0) {
emptyRow.hide();
var opts = {},
mediaType = parseInt($('.media_type_selector.selected').attr('data-selection-id')),
var mediaType = parseInt($('.media_type_selector.selected').attr('data-selection-id')),
img = $('#library_empty_image');
// TODO: once the new manual pages are added, change links!
if (mediaType > 1) {
opts.subtext = $.i18n._("Click 'New' to create one now.");
opts.href = "http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters/library/";
} else {
opts.subtext = $.i18n._("Click 'Upload' to add some now.");
opts.href = "http://sourcefabric.booktype.pro/airtime-pro-for-broadcasters/add-media/";
}
switch(mediaType) {
case 1:
opts.media = $.i18n._('tracks');
opts.icon = 'icon-music';
break;
case 2:
opts.media = $.i18n._('playlists');
opts.icon = 'icon-list';
break;
case 3:
opts.media = $.i18n._('smart blocks');
opts.icon = 'icon-time';
break;
case 4:
opts.media = $.i18n._('webstreams');
opts.icon = 'icon-random';
break;
}
// Remove all classes for when we change between empty media types
img.removeClass(function() {
return $( this ).attr( "class" );
});
img.addClass("icon-white " + opts.icon);
$('#library_empty_text').html(
$.i18n._("You haven't added any ") + opts.media + "."
+ "<br/>" + opts.subtext
+ "<br/><a href='" + opts.href + "'>" + $.i18n._("Learn about ") + opts.media + "</a>"
);
$('#library_empty').show();
// TODO: once the new manual pages are added, change links!
$.getJSON( "ajax/library_placeholders.json", function( data ) {
var opts = data[mediaType];
img.addClass("icon-white " + opts.icon);
$('#library_empty_text').html(
$.i18n._("You haven't added any " + opts.media + ".")
+ "<br/>" + $.i18n._(opts.subtext)
+ "<br/><a target='_blank' href='" + opts.href + "'>" + $.i18n._("Learn about " + opts.media) + "</a>"
);
libEmpty.show();
AIRTIME.library.onResize();
});
} else {
$('#library_empty').hide();
libEmpty.hide();
}
if ($("#show_builder_table").is(":visible")) {
@ -281,120 +259,133 @@ var AIRTIME = (function(AIRTIME) {
mod.createToolbarButtons();
mod.moveSearchBarToHeader();
$toolbar.append($menu);
// add to timeline button
$toolbar
.find('#library-plus')
.click(
function() {
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
return;
}
if (localStorage.getItem('user-type') != 'G') {
$toolbar.append($menu);
// add to timeline button
$toolbar
.find('#library-plus')
.click(
function () {
var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
return;
}
if ($("#show_builder_table").is(":visible")) {
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push( {
"id" : data.id,
"type" : data.ftype
});
}
var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
// process selected files/playlists.
$("#show_builder_table tr.sb-selected").each(function(i, el) {
aData.push($(el).data("aData"));
if ($("#show_builder_table").is(":visible")) {
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push({
"id": data.id,
"type": data.ftype
});
}
// process selected schedule rows to add media
// after.
for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i];
aSchedIds.push( {
"id" : temp.id,
"instance" : temp.instance,
"timestamp" : temp.timestamp
});
}
// process selected files/playlists.
$("#show_builder_table tr.sb-selected").each(function (i, el) {
aData.push($(el).data("aData"));
});
if (aSchedIds.length == 0) {
if (!addToCurrentOrNext(aSchedIds)) {
return;
}
}
// process selected schedule rows to add media
// after.
for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i];
aSchedIds.push({
"id": temp.id,
"instance": temp.instance,
"timestamp": temp.timestamp
});
}
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
} else {
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push([data.id, data.ftype]);
}
// check if a playlist/block is open before adding items
if ($('.active-tab .obj_type').val() == 'playlist'
|| $('.active-tab .obj_type').val() == 'block') {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
if (aSchedIds.length == 0) {
if (!addToCurrentOrNext(aSchedIds)) {
return;
}
}
});
// delete from library.
$toolbar.find('.icon-trash').parent().click(function() {
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
} else {
for (i = 0, length = selected.length; i < length; i++) {
data = selected[i];
aMediaIds.push([data.id, data.ftype]);
}
if (AIRTIME.button.isDisabled('icon-trash') === true) {
return;
}
// check if a playlist/block is open before adding items
if ($('.active-tab .obj_type').val() == 'playlist'
|| $('.active-tab .obj_type').val() == 'block') {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
}
}
});
AIRTIME.library.fnDeleteSelectedItems();
});
// delete from library.
$toolbar.find('.icon-trash').parent().click(function () {
if (AIRTIME.button.isDisabled('icon-trash') === true) {
return;
}
$toolbar.find('#sb-new').click(function() {
if (AIRTIME.button.isDisabled('btn-group #sb-new') === true) {
return;
}
AIRTIME.library.fnDeleteSelectedItems();
});
var selection = $(".media_type_selector.selected").attr("data-selection-id");
$toolbar.find('#sb-new').click(function () {
if (AIRTIME.button.isDisabled('btn-group #sb-new') === true) {
return;
}
if (selection == 2) {
AIRTIME.playlist.fnNew();
} else if (selection == 3) {
AIRTIME.playlist.fnNewBlock();
} else if (selection == 4) {
AIRTIME.playlist.fnWsNew();
}
});
var selection = $(".media_type_selector.selected").attr("data-selection-id");
$toolbar.find('#sb-edit').click(function() {
if (AIRTIME.button.isDisabled('btn-group #sb-edit') === true) {
return;
}
var selected = $(".lib-selected");
selected.each(function(i, el) {
var data = $(el).data("aData");
if (data.ftype === "audioclip") {
$.get(baseUrl + "library/edit-file-md/id/" + data.id, {format: "json"}, function(json){
AIRTIME.playlist.fileMdEdit(json);
//buildEditMetadataDialog(json);
});
} else if (data.ftype === "playlist" || data.ftype === "block") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl+'playlist/edit');
AIRTIME.playlist.validatePlaylistElements();
} else if (data.ftype === "stream") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'webstream/edit');
if (selection == 2) {
AIRTIME.playlist.fnNew();
} else if (selection == 3) {
AIRTIME.playlist.fnNewBlock();
} else if (selection == 4) {
AIRTIME.playlist.fnWsNew();
}
});
});
mod.createToolbarDropDown();
$toolbar.find('#sb-edit').click(function () {
if (AIRTIME.button.isDisabled('btn-group #sb-edit') === true) {
return;
}
var selected = $(".lib-selected");
selected.each(function (i, el) {
var data = $(el).data("aData");
if (data.ftype === "audioclip") {
$.get(baseUrl + "library/edit-file-md/id/" + data.id, {format: "json"}, function (json) {
AIRTIME.playlist.fileMdEdit(json);
//buildEditMetadataDialog(json);
});
} else if (data.ftype === "playlist" || data.ftype === "block") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'playlist/edit');
AIRTIME.playlist.validatePlaylistElements();
} else if (data.ftype === "stream") {
AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'webstream/edit');
}
});
});
mod.createToolbarDropDown();
}
};
mod.onResize = function() {
var libEmpty = $('#library_empty'), wrapper = $('#library_display_wrapper').find('.dataTables_scrolling');
libEmpty.css('left', wrapper.offset().left + (wrapper.width() / 2) - (libEmpty.width() / 2) - $(window).scrollLeft());
libEmpty.css('top', wrapper.offset().top + (wrapper.height() / 2) - (libEmpty.height() / 2) + 19 - $(window).scrollTop());
};
return AIRTIME;
}(AIRTIME || {}));
$(window).resize(AIRTIME.library.onResize);
$(window).scroll(AIRTIME.library.onResize);
$(document).ready(function() {
$('#content').scroll(AIRTIME.library.onResize);
});

View file

@ -558,6 +558,19 @@ var AIRTIME = (function(AIRTIME) {
}
function handleAjaxError(r) {
// If the request was denied due to permissioning
if (r.status === 403) {
// Hide the processing div
$("#library_display_wrapper").find(".dt-process-rel").hide();
$.getJSON( "ajax/library_placeholders.json", function( data ) {
$('#library_empty_text').text($.i18n._(data.unauthorized));
}) ;
$('#library_empty').show();
}
}
oTable = $libTable.dataTable( {
// put hidden columns at the top to insure they can never be visible
@ -614,22 +627,24 @@ var AIRTIME = (function(AIRTIME) {
},
"fnStateSave": function (oSettings, oData) {
localStorage.setItem('datatables-library', JSON.stringify(oData));
/*
$.ajax({
url: baseUrl+"usersettings/set-library-datatable",
type: "POST",
data: {settings : oData, format: "json"},
dataType: "json"
});
*/
// Sadly, this is necessary because we need to unscramble the colReorder map on the backend
$.ajax({
url: baseUrl + "usersettings/set-library-datatable",
type: "POST",
data: {settings: oData, format: "json"},
dataType: "json"
});
colReorderMap = oData.ColReorder;
},
"fnStateLoad": function fnLibStateLoad(oSettings) {
var settings = localStorage.getItem('datatables-library');
var settings = JSON.parse(localStorage.getItem('datatables-library'));
// Hacky; always set the visibility of the last column (actions buttons) to true
if (settings && settings.abVisCols) settings.abVisCols[settings.abVisCols.length - 1] = true;
try {
return JSON.parse(settings);
return settings;
} catch (e) {
return null;
}
@ -677,7 +692,6 @@ var AIRTIME = (function(AIRTIME) {
*/
var advSearchFields = $("div#advanced_search").children(':visible');
var advSearchValid = validateAdvancedSearch(advSearchFields);
advSearchFields.val("TEST");
var type;
aoData.push( { name: "format", value: "json"} );
aoData.push( { name: "advSearch", value: advSearchValid} );
@ -687,15 +701,30 @@ var AIRTIME = (function(AIRTIME) {
type = (type === undefined) ? 1 : type;
aoData.push( { name: "type", value: type} );
getUsabilityHint();
//getUsabilityHint();
$.ajax( {
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
} );
"success": fnCallback,
"error": handleAjaxError
}).done(function(data) {
if (data.iTotalRecords > data.iTotalDisplayRecords) {
$('#filter_message').text(
$.i18n._("Filtering out ") + (data.iTotalRecords - data.iTotalDisplayRecords)
+ $.i18n._(" of ") + data.iTotalRecords
+ $.i18n._(" records")
);
$('#library_empty').hide();
$('#library_display').find('tr:has(td.dataTables_empty)').show();
} else {
$('#filter_message').text("");
}
$('#library_content').find('.dataTables_filter input[type="text"]')
.css('padding-right', $('#advanced-options').find('button').outerWidth());
});
},
"fnRowCallback": AIRTIME.library.fnRowCallback,
"fnCreatedRow": function( nRow, aData, iDataIndex ) {

View file

@ -185,7 +185,7 @@ $(document).ready(function () {
"bFilter": false,
"bSort": false,
//"sDom": '<"H">frtip<"F"l>',
"sDom": 'frt<"F"lip>',
"sDom": '<"dataTables_scrolling"frt><"F"lip>',
"bPaginate": true,
"sPaginationType": "full_numbers",
"oLanguage": getDatatablesStrings({

View file

@ -421,17 +421,19 @@ var AIRTIME = (function(AIRTIME){
$('.zend_form + .spl-no-margin > div:has(*:visible):last').css('margin-left', 0);
}
function getId() {
return parseInt($pl.find(".obj_id").val(), 10);
function getId(pl) {
pl = (pl === undefined) ? $pl : pl;
return parseInt(pl.find(".obj_id").val(), 10);
}
mod.getModified = function() {
return parseInt($pl.find(".obj_lastMod").val(), 10);
}
mod.getModified = function(pl) {
pl = (pl === undefined) ? $pl : pl;
return parseInt(pl.find(".obj_lastMod").val(), 10);
};
mod.setModified = function(modified) {
$pl.find(".obj_lastMod").val(modified);
}
};
function setTitleLabel(title) {
$pl.find(".title_obj_name").text(title);
@ -569,6 +571,10 @@ var AIRTIME = (function(AIRTIME){
if (pane.get(0) == curr.get(0)) { // Closing the current tab, otherwise we don't need to switch tabs
AIRTIME.showbuilder.switchTab(toPane, toTab);
}
// If we close a tab that was causing tabs to wrap to the next row, we need to resize to change the
// margin for the tab nav
AIRTIME.playlist.onResize();
}
mod.closeTab = function(id) {
@ -1004,7 +1010,7 @@ var AIRTIME = (function(AIRTIME){
});
});
$pl.on("click", "#save_button", function(event) {
$pl.find("#save_button").unbind().on("click", function(event) {
/* Smart blocks: get name, description, and criteria
* Playlists: get name, description
*/
@ -1211,8 +1217,8 @@ var AIRTIME = (function(AIRTIME){
var url, id, lastMod, type, pl = (tabId === undefined) ? $pl : $('#pl-tab-content-' + tabId);
stopAudioPreview();
id = (plid === undefined) ? getId() : plid;
lastMod = mod.getModified();
id = (plid === undefined) ? getId(pl) : plid;
lastMod = mod.getModified(pl);
type = pl.find('.obj_type').val();
url = baseUrl+'playlist/delete';
@ -1268,7 +1274,6 @@ var AIRTIME = (function(AIRTIME){
};
mod.playlistResponse = function(json){
console.log(json);
if (json.error !== undefined ||
(json.result !== undefined && json.result != 0)) {
if (json.error) {
@ -1284,12 +1289,12 @@ var AIRTIME = (function(AIRTIME){
}
mod.enableUI();
}
};
mod.replaceForm = function(json){
$pl.find('.editor_pane_wrapper').html(json.html);
openPlaylist(json);
}
};
function playlistRequest(sUrl, oData) {
@ -1561,6 +1566,7 @@ var AIRTIME = (function(AIRTIME){
mod.setAsActive = function() {
$pl = $(".active-tab");
$.post(baseUrl + "playlist/change-playlist", {"id": getId(), "type": $pl.find('.obj_type').val()});
};
mod.init = function() {

View file

@ -10,7 +10,7 @@ $(document).ready(function() {
width = width * .91;
$("#listenerstat_content").find("#flot_placeholder").width(width);
$("#listenerstat_content").find("#legend").width(width);
getDataAndPlot();
listenerstat_content.find("#his_submit").click(function(){
@ -21,7 +21,17 @@ $(document).ready(function() {
});
});
function getDataAndPlot(startTimestamp, endTimestamp){
/**
* Toggle a spinner overlay so the user knows the page is processing
*/
function toggleOverlay() {
$('#flot_placeholder').toggleClass('processing');
}
function getDataAndPlot(startTimestamp, endTimestamp) {
// Turn on the processing overlay
toggleOverlay();
// get data
$.get(baseUrl+'Listenerstat/get-data', {start: startTimestamp, end: endTimestamp}, function(data){
out = new Object();
@ -37,6 +47,8 @@ function getDataAndPlot(startTimestamp, endTimestamp){
out[mpName] = plotData;
});
plot(out);
// Turn off the processing overlay
toggleOverlay();
})
}

View file

@ -11,18 +11,30 @@ function setSmartBlockEvents() {
var div = $('dd[id="sp_criteria-element"]').children('div:visible:last');
div.find('.db-logic-label').text('and').show();
div = div.next().show();
if (div.length == 0) {
div = $('dd[id="sp_criteria-element"]').children('div:first');
div.children().removeAttr('disabled');
div.show();
div.children().removeAttr('disabled');
div = div.next();
if (div.length === 0) {
$(this).hide();
appendAddButton();
appendModAddButton();
removeButtonCheck();
} else {
div.find('.db-logic-label').text('and').show();
div = div.next().show();
div.children().removeAttr('disabled');
div = div.next();
if (div.length === 0) {
$(this).hide();
}
appendAddButton();
appendModAddButton();
removeButtonCheck();
}
appendAddButton();
appendModAddButton();
removeButtonCheck();
});
/********** ADD MODIFIER ROW **********/
@ -512,7 +524,9 @@ function callback(json, type) {
form.find('.success').show();
}
form.find('.smart-block-form').removeClass("closed");
removeButtonCheck();
form.find('.smart-block-form').removeClass("closed");
} else {
if (json.result == "0") {
$('.active-tab #sp-success-saved').text($.i18n._('Smart block saved')).show();
@ -524,6 +538,7 @@ function callback(json, type) {
}
else {
AIRTIME.playlist.playlistResponse(json);
removeButtonCheck();
}
form.find('.smart-block-form').removeClass("closed");
}
@ -551,6 +566,7 @@ function appendAddButton() {
}
function removeButtonCheck() {
/*
var rows = $('.active-tab dd[id="sp_criteria-element"]').children('div'),
enabled = rows.find('select[name^="sp_criteria_field"]:enabled'),
rmv_button = enabled.siblings('a[id^="criteria_remove"]');
@ -560,7 +576,7 @@ function removeButtonCheck() {
} else {
rmv_button.removeAttr('disabled');
rmv_button.show();
}
}*/
}
function enableLoadingIcon() {

View file

@ -33,10 +33,10 @@ function setSystemFromEmailReadonly() {
var enableSystemEmails = $("#enableSystemEmail");
var systemFromEmail = $("#systemEmail");
if ($(enableSystemEmails).is(':checked')) {
systemFromEmail.removeAttr("readonly");
systemFromEmail.removeAttr("readonly");
} else {
systemFromEmail.attr("readonly", "readonly");
}
}
}
function setMailServerInputReadonly() {
@ -114,14 +114,15 @@ function setMsAuthenticationFieldsReadonly(ele) {
}
function removeLogo() {
$.post(baseUrl+'Preference/remove-logo', function(json){});
location.reload();
$.post(baseUrl+'preference/remove-logo', function(json){});
// Reload without resubmitting the form
location.href = location.href.replace(location.hash,"");
}
function deleteAllFiles() {
var resp = confirm($.i18n._("Are you sure you want to delete all the tracks in your library?"))
if (resp) {
$.post(baseUrl+'Preference/delete-all-files', function(json){});
$.post(baseUrl+'preference/delete-all-files', function(json){});
location.reload();
}
}
@ -153,6 +154,36 @@ $(document).ready(function() {
});
});*/
// when an image is uploaded, preview it to the user
var logo = $("#stationLogo"),
preview = $("#logo-img");
logo.change(function(e) {
if (this.files && this.files[0]) {
preview.show();
var reader = new FileReader(); // browser compatibility?
reader.onload = function (e) {
console.log("Reader loaded");
preview.attr('src', e.target.result);
};
// check image size so we don't crash the page trying to render
if (validateImage(this.files[0], logo)) {
// read the image data as though it were a data URI
reader.readAsDataURL(this.files[0]);
} else {
// remove the file element data
$(this).val('').replaceWith($(this).clone(true));
preview.hide();
}
} else {
preview.hide();
}
});
if (preview.attr('src').indexOf('images/') > -1) {
$("#logo-remove-btn").hide();
}
showErrorSections();
setMailServerInputReadonly();

View file

@ -678,41 +678,6 @@ function setAddShowEvents(form) {
}
});
// validate on upload
function validateImage(img, el) {
// remove any existing error messages
if ($("#img-err")) { $("#img-err").remove(); }
if (img.size > 2048000) { // 2MB - pull this from somewhere instead?
// hack way of inserting an error message
var err = $.i18n._("Selected file is too large");
el.parent().after(
"<ul id='img-err' class='errors'>" +
"<li>" + err + "</li>" +
"</ul>");
return false;
} else if (validateMimeType(img.type) < 0) {
var err = $.i18n._("File format is not supported");
el.parent().after(
"<ul id='img-err' class='errors'>" +
"<li>" + err + "</li>" +
"</ul>");
return false;
}
return true;
}
// Duplicate of the function in ShowImageController
function validateMimeType(mime) {
var extensions = [
'image/jpeg',
'image/png',
'image/gif'
// BMP?
];
return $.inArray(mime, extensions);
}
form.find("#add_show_logo_current_remove").click(function() {
if (confirm($.i18n._('Are you sure you want to delete the current logo?'))) {
var showId = $("#add_show_id").attr("value");

View file

@ -43,10 +43,16 @@ function rowClickCallback(row_id){
}});
}
function removeUserCallback(row_id, nRow){
$.ajax({ url: baseUrl+'User/remove-user/id/'+ row_id +'/format/json', dataType:"text", success:function(data){
var o = $('#users_datatable').dataTable().fnDeleteRow(nRow);
}});
function removeUserCallback(row_id, nRow) {
if (confirm($.i18n._("Are you sure you want to delete this user?"))) {
$.ajax({
url: baseUrl + 'User/remove-user/id/' + row_id + '/format/json',
dataType: "text",
success: function (data) {
var o = $('#users_datatable').dataTable().fnDeleteRow(nRow);
}
});
}
}
function rowCallback( nRow, aData, iDisplayIndex ){