diff --git a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js index ea33951fc..58a80175d 100644 --- a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js +++ b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js @@ -1,182 +1,180 @@ -var AIRTIME = (function(AIRTIME){ - var mod; - - if (AIRTIME.library === undefined) { - AIRTIME.library = {}; - } - - mod = AIRTIME.library; - - mod.checkAddButton = function() { - var selected = mod.getChosenItemsLength(), - $cursor = $('tr.cursor-selected-row'), - check = false; - - //make sure library items are selected and a cursor is selected. - if (selected !== 0 && $cursor.length !== 0) { - check = true; - } - - if (check === true) { - AIRTIME.button.enableButton("lib-button-add"); - } - else { - AIRTIME.button.disableButton("lib-button-add"); - } +var AIRTIME = (function(AIRTIME) { + var mod; + + if (AIRTIME.library === undefined) { + AIRTIME.library = {}; + } + + mod = AIRTIME.library; + + mod.checkAddButton = function() { + var selected = mod.getChosenItemsLength(), $cursor = $('tr.cursor-selected-row'), check = false; + + // make sure library items are selected and a cursor is selected. + if (selected !== 0 && $cursor.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 { - $nRow.addClass("lib-pl"); - } - - $nRow.attr("id", aData["tr_id"]) - .data("aData", aData) - .data("screen", "timeline"); - }; - - mod.fnDrawCallback = function fnLibDrawCallback() { - - mod.redrawChosen(); - mod.checkToolBarIcons(); - - $('#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 = thead.find("tr:first").width(), - message; - - //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 = $('
').attr('id', 'draggingContainer') - .append('') - .find("tr") - .append('') - .find("td") - .attr("colspan", colspan) - .width(width) - .addClass("ui-state-highlight") - .append(message) - .end() - .end(); - - return container; - }, - cursor: 'pointer', - connectToSortable: '#show_builder_table' - }); - }; - - mod.dblClickAdd = function(data, type) { - var i, - length, - temp, - aMediaIds = [], - aSchedIds = [], - aData = []; - - //process selected files/playlists. - aMediaIds.push({"id": data.id, "type": type}); - - $("#show_builder_table tr.cursor-selected-row").each(function(i, el){ + $nRow.addClass("lib-pl"); + } + + $nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen", + "timeline"); + }; + + mod.fnDrawCallback = function fnLibDrawCallback() { + + mod.redrawChosen(); + mod.checkToolBarIcons(); + + $('#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 = thead.find( + "tr:first").width(), message; + + // 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 = $('
').attr('id', + 'draggingContainer').append('') + .find("tr").append('').find("td") + .attr("colspan", colspan).width(width) + .addClass("ui-state-highlight").append( + message).end().end(); + + return container; + }, + cursor : 'pointer', + connectToSortable : '#show_builder_table' + }); + }; + + mod.dblClickAdd = function(data, type) { + var i, length, temp, aMediaIds = [], aSchedIds = [], aData = []; + + // process selected files/playlists. + aMediaIds.push( { + "id" : data.id, + "type" : type + }); + + $("#show_builder_table tr.cursor-selected-row").each(function(i, el) { aData.push($(el).prev().data("aData")); }); - - //process selected schedule rows to add media after. - for (i=0, length = aData.length; i < length; i++) { + + // 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}); + aSchedIds.push( { + "id" : temp.id, + "instance" : temp.instance, + "timestamp" : temp.timestamp + }); } - - if(aSchedIds.length == 0){ + + if (aSchedIds.length == 0) { alert("Please select a cursor position on timeline."); return false; } console.log(aMediaIds); AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds); - }; - - mod.setupLibraryToolbar = function() { - var $toolbar = $(".lib-content .fg-toolbar:first"); - - $toolbar - .append("