SAAS-948 - ShowBuilder redesign editors and fixes
This commit is contained in:
parent
ba90b1f1eb
commit
59d89b0b9e
16 changed files with 2048 additions and 236 deletions
|
@ -0,0 +1,325 @@
|
|||
var AIRTIME = (function(AIRTIME) {
|
||||
var mod;
|
||||
|
||||
if (AIRTIME.library === undefined) {
|
||||
AIRTIME.library = {};
|
||||
}
|
||||
|
||||
mod = AIRTIME.library;
|
||||
|
||||
mod.checkAddButton = function() {
|
||||
var selected = mod.getChosenItemsLength(), $cursor = $('tr.sb-selected'), check = false,
|
||||
shows = $('tr.sb-header'), current = $('tr.sb-current-show'),
|
||||
// TODO: this is an ugly way of doing this... we should find a more robust way of checking which view we're in.
|
||||
btnText = (window.location.href.toLowerCase().indexOf("schedule") > -1) ? $.i18n._('Add to show') : $.i18n._('Add to next show');
|
||||
|
||||
// make sure library items are selected and a cursor is selected.
|
||||
if (selected !== 0) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
if (shows.length === 0) {
|
||||
check = false;
|
||||
}
|
||||
|
||||
if (check) {
|
||||
AIRTIME.button.enableButton("btn-group #library-plus", false);
|
||||
} else {
|
||||
AIRTIME.button.disableButton("btn-group #library-plus", false);
|
||||
}
|
||||
|
||||
if ($("#show_builder").is(":visible")) {
|
||||
if ($cursor.length !== 0) {
|
||||
btnText = $.i18n._('Add after selected items');
|
||||
} else if (current.length !== 0) {
|
||||
btnText = $.i18n._('Add to current show');
|
||||
}
|
||||
} else {
|
||||
var objType = $('#obj_type').val();
|
||||
if (objType === 'block') {
|
||||
btnText = ' ' + $.i18n._('Add to current smart block');
|
||||
} else {
|
||||
btnText = ' ' + $.i18n._('Add to current playlist');
|
||||
}
|
||||
}
|
||||
AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), ' '+ btnText);
|
||||
};
|
||||
|
||||
mod.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
|
||||
var $nRow = $(nRow);
|
||||
|
||||
if (aData.ftype === "audioclip") {
|
||||
$nRow.addClass("lib-audio");
|
||||
$image = $nRow.find('td.library_type');
|
||||
if (!isAudioSupported(aData.mime)) {
|
||||
$image.html('<span class="ui-icon ui-icon-locked"></span>');
|
||||
aData.image = '<span class="ui-icon ui-icon-locked"></span>';
|
||||
}
|
||||
} else if (aData.ftype === "stream") {
|
||||
$nRow.addClass("lib-stream");
|
||||
} else {
|
||||
$nRow.addClass("lib-pl");
|
||||
}
|
||||
|
||||
$nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen",
|
||||
"timeline");
|
||||
};
|
||||
|
||||
mod.fnDrawCallback = function fnLibDrawCallback() {
|
||||
|
||||
mod.redrawChosen();
|
||||
mod.checkToolBarIcons();
|
||||
|
||||
if ($("#show_builder").is(":visible")) {
|
||||
$('#library_display tr.lib-audio, tr.lib-pl, tr.lib-stream')
|
||||
.draggable(
|
||||
{
|
||||
helper: function () {
|
||||
|
||||
var $el = $(this), selected = mod
|
||||
.getChosenItemsLength(), container, thead = $("#show_builder_table thead"), colspan = thead
|
||||
.find("th").length, width = $el.width(), message;
|
||||
|
||||
// dragging an element that has an unselected
|
||||
// checkbox.
|
||||
if (mod.isChosenItem($el) === false) {
|
||||
selected++;
|
||||
}
|
||||
|
||||
if (selected === 1) {
|
||||
message = $.i18n._("Adding 1 Item");
|
||||
} else {
|
||||
message = sprintf($.i18n._("Adding %s Items"), selected);
|
||||
}
|
||||
|
||||
container = $('<div/>').attr('id',
|
||||
'draggingContainer').append('<tr/>')
|
||||
.find("tr").append('<td/>').find("td")
|
||||
.attr("colspan", colspan).width(width)
|
||||
.addClass("ui-state-highlight").append(
|
||||
message).end().end();
|
||||
|
||||
return container;
|
||||
},
|
||||
cursor: 'pointer',
|
||||
cursorAt: {
|
||||
top: 30,
|
||||
left: 100
|
||||
},
|
||||
connectToSortable: '#show_builder_table'
|
||||
});
|
||||
} else {
|
||||
$('#library_display tr.lib-audio, tr.lib-stream, tr.lib-pl, tr.lib-block')
|
||||
.draggable(
|
||||
{
|
||||
helper: function () {
|
||||
|
||||
var $el = $(this), selected = mod
|
||||
.getChosenAudioFilesLength(), container, message, li = $("#side_playlist ul[id='spl_sortable'] li:first"),
|
||||
width = li.width(), height = 55;
|
||||
if (width > 798) width = 798;
|
||||
|
||||
// dragging an element that has an unselected
|
||||
// checkbox.
|
||||
if (mod.isChosenItem($el) === false) {
|
||||
selected++;
|
||||
}
|
||||
|
||||
if (selected === 1) {
|
||||
message = $.i18n._("Adding 1 Item");
|
||||
} else {
|
||||
message = sprintf($.i18n._("Adding %s Items"), selected);
|
||||
}
|
||||
|
||||
container = $('<div class="helper"/>').append(
|
||||
"<li/>").find("li").addClass(
|
||||
"ui-state-default").append("<div/>")
|
||||
.find("div").addClass(
|
||||
"list-item-container").append(
|
||||
message).end().width(width)
|
||||
.height(height).end();
|
||||
|
||||
return container;
|
||||
},
|
||||
cursor: 'pointer',
|
||||
cursorAt: {
|
||||
top: 30,
|
||||
left: 100
|
||||
},
|
||||
connectToSortable: '#spl_sortable'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
mod.dblClickAdd = function(data, type) {
|
||||
var i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
|
||||
|
||||
if ($("#show_builder").is(":visible")) {
|
||||
// process selected files/playlists.
|
||||
aMediaIds.push({
|
||||
"id": data.id,
|
||||
"type": type
|
||||
});
|
||||
|
||||
$("#show_builder_table tr.sb-selected").each(function (i, el) {
|
||||
aData.push($(el).data("aData"));
|
||||
});
|
||||
|
||||
// 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
|
||||
});
|
||||
}
|
||||
|
||||
if (aSchedIds.length == 0) {
|
||||
if (!addToCurrentOrNext(aSchedIds)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
|
||||
} else {
|
||||
// process selected files/playlists.
|
||||
aMediaIds.push(new Array(data.id, data.ftype));
|
||||
|
||||
// check if a playlist/block is open before adding items
|
||||
if ($('input[id="obj_type"]').val() == 'playlist'
|
||||
|| $('input[id="obj_type"]').val() == 'block') {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function addToCurrentOrNext(arr) {
|
||||
var el;
|
||||
// Add to the end of the current show by getting the footer
|
||||
el = $(".sb-footer.sb-current-show");
|
||||
var data = el.prev().data("aData");
|
||||
|
||||
if (data === undefined) {
|
||||
alert($.i18n._("Cannot schedule outside a show."));
|
||||
return false;
|
||||
}
|
||||
|
||||
arr.push({
|
||||
"id" : data.id,
|
||||
"instance" : data.instance,
|
||||
"timestamp" : data.timestamp
|
||||
});
|
||||
|
||||
if (!isInView(el)) {
|
||||
$('.dataTables_scrolling.sb-padded').animate({
|
||||
scrollTop: el.offset().top
|
||||
}, 0);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
mod.setupLibraryToolbar = function() {
|
||||
var $toolbar = $(".lib-content .fg-toolbar:first");
|
||||
|
||||
mod.createToolbarButtons();
|
||||
|
||||
$toolbar.append($menu);
|
||||
// add to timeline button
|
||||
$toolbar
|
||||
.find('.icon-plus').parent()
|
||||
.click(
|
||||
function() {
|
||||
|
||||
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
|
||||
|
||||
// process selected files/playlists.
|
||||
for (i = 0, length = selected.length; i < length; i++) {
|
||||
data = selected[i];
|
||||
aMediaIds.push( {
|
||||
"id" : data.id,
|
||||
"type" : data.ftype
|
||||
});
|
||||
}
|
||||
|
||||
$("#show_builder_table tr.sb-selected")
|
||||
.each(function(i, el) {
|
||||
aData.push($(el).data("aData"));
|
||||
});
|
||||
|
||||
// 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
|
||||
});
|
||||
}
|
||||
|
||||
if (aSchedIds.length == 0) {
|
||||
addToCurrentOrNext(aSchedIds);
|
||||
}
|
||||
|
||||
AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
|
||||
});
|
||||
|
||||
// delete from library.
|
||||
$toolbar.find('.icon-trash').parent().click(function() {
|
||||
|
||||
if (AIRTIME.button.isDisabled('icon-trash') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
AIRTIME.library.fnDeleteSelectedItems();
|
||||
});
|
||||
|
||||
$toolbar.find('#sb-new').click(function() {
|
||||
if (AIRTIME.button.isDisabled('btn-group #sb-new') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var selection = $(".media_type_selector.selected").attr("selection_id");
|
||||
console.log(selection);
|
||||
|
||||
if (selection == 2) {
|
||||
AIRTIME.playlist.fnNew();
|
||||
} else if (selection == 3) {
|
||||
AIRTIME.playlist.fnNewBlock();
|
||||
} else if (selection == 4) {
|
||||
AIRTIME.playlist.fnWsNew();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$toolbar.find('#sb-edit').click(function() {
|
||||
if (AIRTIME.button.isDisabled('btn-group #sb-edit') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var data = $(".lib-selected:first").data("aData");
|
||||
|
||||
if (data.ftype === "audioclip") {
|
||||
$.get(baseUrl + "library/edit-file-md/id/" + data.id, {format: "json"}, function(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();
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
|
@ -131,10 +131,20 @@ var AIRTIME = (function(AIRTIME) {
|
|||
"<span id='lib-plus-text'></span>" +
|
||||
"</button>" +
|
||||
"</div>")
|
||||
.append("<div class='btn-group'>" +
|
||||
.append("<div class='btn-group' title=" + $.i18n._('Delete') + ">" +
|
||||
"<button class='btn btn-small' id='sb-trash'>" +
|
||||
"<i class='icon-white icon-trash'></i>" +
|
||||
"</button>" +
|
||||
"</div>")
|
||||
.append("<div class='btn-group' title=" + $.i18n._('Edit') + ">" +
|
||||
"<button class='btn btn-small' id='sb-edit'>" +
|
||||
"<i class='icon-white icon-pencil'></i>" +
|
||||
"</button>" +
|
||||
"</div>")
|
||||
.append("<div class='btn-group' title=" + $.i18n._('New') + ">" +
|
||||
"<button class='btn btn-small' id='sb-new'>" +
|
||||
"<i class='icon-white icon-plus'></i>" +
|
||||
"</button>" +
|
||||
"</div>");
|
||||
};
|
||||
|
||||
|
@ -143,7 +153,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
$('#sb-dselect-page').click(function(){mod.deselectCurrentPage();});
|
||||
$('#sb-dselect-all').click(function(){mod.selectNone();});
|
||||
};
|
||||
|
||||
|
||||
mod.checkDeleteButton = function() {
|
||||
var selected = mod.getChosenItemsLength(),
|
||||
check = false;
|
||||
|
@ -151,7 +161,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
if (selected !== 0) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
|
||||
if (check === true) {
|
||||
AIRTIME.button.enableButton("btn-group #sb-trash", false);
|
||||
}
|
||||
|
@ -159,11 +169,44 @@ var AIRTIME = (function(AIRTIME) {
|
|||
AIRTIME.button.disableButton("btn-group #sb-trash", false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
mod.checkEditButton = function() {
|
||||
var selected = mod.getChosenItemsLength(),
|
||||
check = false;
|
||||
|
||||
if (selected === 1) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
if (check === true) {
|
||||
AIRTIME.button.enableButton("btn-group #sb-edit", false);
|
||||
}
|
||||
else {
|
||||
AIRTIME.button.disableButton("btn-group #sb-edit", false);
|
||||
}
|
||||
};
|
||||
|
||||
mod.checkNewButton = function() {
|
||||
var selected = $(".media_type_selector.selected").attr("selection_id"),
|
||||
check = false;
|
||||
|
||||
if (selected != 1) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
if (check === true) {
|
||||
AIRTIME.button.enableButton("btn-group #sb-new", false);
|
||||
}
|
||||
else {
|
||||
AIRTIME.button.disableButton("btn-group #sb-new", false);
|
||||
}
|
||||
};
|
||||
|
||||
mod.checkToolBarIcons = function() {
|
||||
|
||||
AIRTIME.library.checkAddButton();
|
||||
AIRTIME.library.checkDeleteButton();
|
||||
AIRTIME.library.checkDeleteButton();
|
||||
AIRTIME.library.checkEditButton();
|
||||
AIRTIME.library.checkNewButton();
|
||||
};
|
||||
|
||||
mod.getSelectedData = function() {
|
||||
|
@ -301,8 +344,6 @@ var AIRTIME = (function(AIRTIME) {
|
|||
|
||||
//Prevent the user from spamming the delete button while the AJAX request is in progress
|
||||
AIRTIME.button.disableButton("btn-group #sb-trash", false);
|
||||
//Hack to immediately show the "Processing" div in DataTables to give the user some sort of feedback.
|
||||
$(".dataTables_processing").css('visibility','visible');
|
||||
|
||||
$.post(baseUrl+"library/delete",
|
||||
{"format": "json", "media": aMedia},
|
||||
|
@ -560,7 +601,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
oData.iCreate = parseInt(oData.iCreate, 10);
|
||||
},
|
||||
|
||||
"sAjaxSource": baseUrl+"Library/contents-feed-test",
|
||||
"sAjaxSource": baseUrl+"Library/contents-feed",
|
||||
"sAjaxDataProp": "files",
|
||||
|
||||
"fnServerData": function ( sSource, aoData, fnCallback ) {
|
||||
|
@ -648,7 +689,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
"oLanguage": datatables_dict,
|
||||
|
||||
// R = ColReorder, C = ColVis
|
||||
"sDom": 'Rl<"#library_display_type">f<"dt-process-rel"r><"H"<"library_toolbar"C>><"dataTables_scrolling"t><"F"ip>',
|
||||
"sDom": 'R<"#library_display_type"><"dt-process-rel"r><"H"<"library_toolbar"Cf>><"dataTables_scrolling"t><"F"ilp>>',
|
||||
|
||||
"oColVis": {
|
||||
"sAlign": "right",
|
||||
|
|
|
@ -164,7 +164,7 @@ var AIRTIME = (function(AIRTIME) {
|
|||
mod.checkToolBarIcons = function() {
|
||||
|
||||
AIRTIME.library.checkAddButton();
|
||||
AIRTIME.library.checkDeleteButton();
|
||||
AIRTIME.library.checkDeleteButton();
|
||||
};
|
||||
|
||||
mod.getSelectedData = function() {
|
||||
|
|
1462
airtime_mvc/public/js/airtime/library/spl-test.js
Normal file
1462
airtime_mvc/public/js/airtime/library/spl-test.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -316,7 +316,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
|
||||
mod.fnAdd = function(aMediaIds, aSchedIds) {
|
||||
mod.disableUI();
|
||||
|
||||
|
||||
$.post(baseUrl+"showbuilder/schedule-add",
|
||||
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
|
||||
mod.fnItemCallback
|
||||
|
|
|
@ -305,13 +305,6 @@ var AIRTIME = (function(AIRTIME){
|
|||
|
||||
mod.fnAdd = function(aMediaIds, aSchedIds) {
|
||||
mod.disableUI();
|
||||
for (var i in aSchedIds) {
|
||||
if ($("#"+aSchedIds[i].id).hasClass("sb-past")) {
|
||||
alert($.i18n._("Cannot add media before currently playing track."));
|
||||
mod.enableUI();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$.post(baseUrl+"showbuilder/schedule-add",
|
||||
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
|
||||
|
@ -381,7 +374,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
"url": sSource,
|
||||
"data": aoData,
|
||||
"success": function(json) {
|
||||
mod.updateCalendarStatusIcon(json)
|
||||
mod.updateCalendarStatusIcon(json);
|
||||
mod.setTimestamp(json.timestamp);
|
||||
mod.setShowInstances(json.instances);
|
||||
mod.getSelectedCursors();
|
||||
|
@ -402,7 +395,7 @@ var AIRTIME = (function(AIRTIME){
|
|||
|
||||
mod.builderDataTable = function() {
|
||||
$sbContent = $('#show_builder');
|
||||
$lib = $("#library_content"),
|
||||
$lib = $("#library_content");
|
||||
$sbTable = $sbContent.find('table');
|
||||
var isInitialized = false;
|
||||
|
||||
|
|
|
@ -144,8 +144,27 @@ AIRTIME = (function(AIRTIME) {
|
|||
}
|
||||
|
||||
mod.onReady = function() {
|
||||
// Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a)
|
||||
var acceptedTypes = ["audio/ogg",
|
||||
"application/ogg",
|
||||
"audio/vorbis",
|
||||
"audio/mp3",
|
||||
"audio/mpeg",
|
||||
"audio/mpeg3",
|
||||
"audio/x-aac",
|
||||
"audio/aac",
|
||||
"audio/aacp",
|
||||
"audio/mp4",
|
||||
"audio/x-flac",
|
||||
"audio/wav",
|
||||
"audio/x-wav",
|
||||
"audio/mp2",
|
||||
"audio/mp1",
|
||||
"audio/x-ms-wma",
|
||||
"audio/basic"];
|
||||
|
||||
Dropzone.options.uploadForm = {
|
||||
acceptedFiles: acceptedTypes.join(),
|
||||
init: function () {
|
||||
this.on("sending", function (file, xhr, data) {
|
||||
data.append("csrf_token", $("#csrf").val());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue