diff --git a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js index 6ade8636f..dd98a2dac 100644 --- a/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js +++ b/airtime_mvc/public/js/airtime/library/events/library_playlistbuilder.js @@ -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 = $('
') - .append("") - .find("li") - .addClass("ui-state-default") - .append("") - .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 = $('').append( + "").find("li").addClass( + "ui-state-default").append("") + .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("