-fixed formatting
This commit is contained in:
parent
96f693687b
commit
bb38512bae
|
@ -1,169 +1,161 @@
|
|||
var AIRTIME = (function(AIRTIME){
|
||||
var mod;
|
||||
|
||||
if (AIRTIME.library === undefined) {
|
||||
AIRTIME.library = {};
|
||||
}
|
||||
|
||||
mod = AIRTIME.library;
|
||||
var AIRTIME = (function(AIRTIME) {
|
||||
var mod;
|
||||
|
||||
if (AIRTIME.library === undefined) {
|
||||
AIRTIME.library = {};
|
||||
}
|
||||
|
||||
mod = AIRTIME.library;
|
||||
|
||||
mod.checkAddButton = function() {
|
||||
var selected = mod.getChosenItemsLength(),
|
||||
sortable = $('#spl_sortable'),
|
||||
check = false;
|
||||
|
||||
//make sure audioclips are selected and a playlist is currently open.
|
||||
if (selected !== 0 && sortable.length !== 0) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
if (check === true) {
|
||||
AIRTIME.button.enableButton("lib-button-add");
|
||||
}
|
||||
else {
|
||||
AIRTIME.button.disableButton("lib-button-add");
|
||||
}
|
||||
var selected = mod.getChosenItemsLength(), sortable = $('#spl_sortable'), check = false;
|
||||
|
||||
// make sure audioclips are selected and a playlist is currently open.
|
||||
if (selected !== 0 && sortable.length !== 0) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
if (check === true) {
|
||||
AIRTIME.button.enableButton("lib-button-add");
|
||||
} else {
|
||||
AIRTIME.button.disableButton("lib-button-add");
|
||||
}
|
||||
};
|
||||
|
||||
mod.fnRowCallback = function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
|
||||
var $nRow = $(nRow);
|
||||
if (aData.ftype === "audioclip") {
|
||||
$nRow.addClass("lib-audio");
|
||||
} else if (aData.ftype === "stream"){
|
||||
|
||||
mod.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
|
||||
var $nRow = $(nRow);
|
||||
if (aData.ftype === "audioclip") {
|
||||
$nRow.addClass("lib-audio");
|
||||
} else if (aData.ftype === "stream") {
|
||||
$nRow.addClass("lib-stream");
|
||||
} else if (aData.ftype === "block") {
|
||||
$nRow.addClass("lib-block");
|
||||
} else {
|
||||
$nRow.addClass("lib-pl");
|
||||
}
|
||||
|
||||
$nRow.attr("id", aData["tr_id"])
|
||||
.data("aData", aData)
|
||||
.data("screen", "playlist");
|
||||
|
||||
if (aData["bl_type"] !== undefined) {
|
||||
$nRow.attr("bl_type", aData["bl_type"]);
|
||||
}
|
||||
};
|
||||
|
||||
mod.fnDrawCallback = function() {
|
||||
|
||||
mod.redrawChosen();
|
||||
mod.checkToolBarIcons();
|
||||
|
||||
$('#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 li:first"),
|
||||
width = li.width(),
|
||||
height = li.height();
|
||||
|
||||
//dragging an element that has an unselected checkbox.
|
||||
if (mod.isChosenItem($el) === false) {
|
||||
selected++;
|
||||
}
|
||||
|
||||
if (selected === 1) {
|
||||
message = "Adding 1 Item.";
|
||||
}
|
||||
else {
|
||||
message = "Adding "+selected+" Items.";
|
||||
}
|
||||
|
||||
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',
|
||||
connectToSortable: '#spl_sortable'
|
||||
});
|
||||
};
|
||||
|
||||
mod.dblClickAdd = function(data, type) {
|
||||
var i,
|
||||
aMediaIds = [];
|
||||
|
||||
//process selected files/playlists.
|
||||
} else if (aData.ftype === "block") {
|
||||
$nRow.addClass("lib-block");
|
||||
} else {
|
||||
$nRow.addClass("lib-pl");
|
||||
}
|
||||
|
||||
$nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen",
|
||||
"playlist");
|
||||
|
||||
if (aData["bl_type"] !== undefined) {
|
||||
$nRow.attr("bl_type", aData["bl_type"]);
|
||||
}
|
||||
};
|
||||
|
||||
mod.fnDrawCallback = function() {
|
||||
|
||||
mod.redrawChosen();
|
||||
mod.checkToolBarIcons();
|
||||
|
||||
$('#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 li:first"), width = li
|
||||
.width(), height = li.height();
|
||||
|
||||
// dragging an element that has an unselected
|
||||
// checkbox.
|
||||
if (mod.isChosenItem($el) === false) {
|
||||
selected++;
|
||||
}
|
||||
|
||||
if (selected === 1) {
|
||||
message = "Adding 1 Item.";
|
||||
} else {
|
||||
message = "Adding " + selected + " Items.";
|
||||
}
|
||||
|
||||
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',
|
||||
connectToSortable : '#spl_sortable'
|
||||
});
|
||||
};
|
||||
|
||||
mod.dblClickAdd = function(data, type) {
|
||||
var i, aMediaIds = [];
|
||||
|
||||
// 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') {
|
||||
|
||||
// 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');
|
||||
}
|
||||
};
|
||||
|
||||
mod.setupLibraryToolbar = function() {
|
||||
var $toolbar = $(".lib-content .fg-toolbar:first");
|
||||
|
||||
$toolbar
|
||||
.append("<ul />")
|
||||
.find('ul')
|
||||
.append('<li class="ui-state-default lib-button-select" title="Select"><span class="ui-icon ui-icon-document-b"></span></li>')
|
||||
.append('<li class="ui-state-default ui-state-disabled lib-button-add" title="Add selected library items to the current playlist"><span class="ui-icon ui-icon-plusthick"></span></li>')
|
||||
.append('<li class="ui-state-default ui-state-disabled lib-button-delete" title="Delete selected library items"><span class="ui-icon ui-icon-trash"></span></li>');
|
||||
|
||||
//add to playlist button
|
||||
$toolbar.find('.lib-button-add')
|
||||
.click(function() {
|
||||
|
||||
if (AIRTIME.button.isDisabled('lib-button-add') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var aData = AIRTIME.library.getSelectedData(),
|
||||
i,
|
||||
temp,
|
||||
length,
|
||||
aMediaIds = [];
|
||||
|
||||
//process selected files/playlists.
|
||||
for (i = 0, length = aData.length; i < length; i++) {
|
||||
temp = aData[i];
|
||||
if (temp.ftype === "audioclip" || temp.ftype === "block" ||
|
||||
(temp.ftype === "stream" && $("#obj_type").val() === "playlist")) {
|
||||
aMediaIds.push(new Array (temp.id, temp.ftype));
|
||||
}
|
||||
}
|
||||
if (aMediaIds.length > 0) {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
|
||||
} else {
|
||||
if ($('#obj_type').val() == 'block') {
|
||||
alert('You can only add tracks to smart blocks.');
|
||||
} else if ($('#obj_type').val() == 'playlist') {
|
||||
alert('You can only add tracks, smart blocks, and webstreams to playlists.');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//delete from library.
|
||||
$toolbar.find('.lib-button-delete')
|
||||
.click(function() {
|
||||
|
||||
if (AIRTIME.button.isDisabled('lib-button-delete') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
AIRTIME.library.fnDeleteSelectedItems();
|
||||
});
|
||||
|
||||
mod.createToolbarDropDown();
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
};
|
||||
|
||||
mod.setupLibraryToolbar = function() {
|
||||
var $toolbar = $(".lib-content .fg-toolbar:first");
|
||||
|
||||
$toolbar
|
||||
.append("<ul />")
|
||||
.find('ul')
|
||||
.append(
|
||||
'<li class="ui-state-default lib-button-select" title="Select"><span class="ui-icon ui-icon-document-b"></span></li>')
|
||||
.append(
|
||||
'<li class="ui-state-default ui-state-disabled lib-button-add" title="Add selected library items to the current playlist"><span class="ui-icon ui-icon-plusthick"></span></li>')
|
||||
.append(
|
||||
'<li class="ui-state-default ui-state-disabled lib-button-delete" title="Delete selected library items"><span class="ui-icon ui-icon-trash"></span></li>');
|
||||
|
||||
// add to playlist button
|
||||
$toolbar
|
||||
.find('.lib-button-add')
|
||||
.click(function() {
|
||||
|
||||
if (AIRTIME.button.isDisabled('lib-button-add') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
var aData = AIRTIME.library.getSelectedData(), i, temp, length, aMediaIds = [];
|
||||
|
||||
// process selected files/playlists.
|
||||
for (i = 0, length = aData.length; i < length; i++) {
|
||||
temp = aData[i];
|
||||
if (temp.ftype === "audioclip"
|
||||
|| temp.ftype === "block"
|
||||
|| (temp.ftype === "stream" && $(
|
||||
"#obj_type").val() === "playlist")) {
|
||||
aMediaIds.push(new Array(temp.id,
|
||||
temp.ftype));
|
||||
}
|
||||
}
|
||||
if (aMediaIds.length > 0) {
|
||||
AIRTIME.playlist.fnAddItems(aMediaIds,
|
||||
undefined, 'after');
|
||||
} else {
|
||||
if ($('#obj_type').val() == 'block') {
|
||||
alert('You can only add tracks to smart blocks.');
|
||||
} else if ($('#obj_type').val() == 'playlist') {
|
||||
alert('You can only add tracks, smart blocks, and webstreams to playlists.');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// delete from library.
|
||||
$toolbar.find('.lib-button-delete').click(function() {
|
||||
|
||||
if (AIRTIME.button.isDisabled('lib-button-delete') === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
AIRTIME.library.fnDeleteSelectedItems();
|
||||
});
|
||||
|
||||
mod.createToolbarDropDown();
|
||||
};
|
||||
|
||||
return AIRTIME;
|
||||
|
||||
}(AIRTIME || {}));
|
||||
|
|
Loading…
Reference in New Issue