-
+
\ No newline at end of file
diff --git a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml
index 9ad40d990..017c2e656 100644
--- a/airtime_mvc/application/views/scripts/playlist/smart-block.phtml
+++ b/airtime_mvc/application/views/scripts/playlist/smart-block.phtml
@@ -4,86 +4,67 @@ if (isset($this->obj)) {
$count = count($contents);
}
?>
-
+
+
+
+
+
-
-
-
+
-
-
- form; ?>
-
-
-
-
- 00
-
-
- 00
-
-
+ form; ?>
+
+
+
+
+
+
+ 00
+
+
+ 00
+
+
+
-
-
-
-
- contents = $contents;
- echo $this->render('playlist/update.phtml') ?>
-
+
+ contents = $contents;
+ echo $this->render('playlist/update.phtml') ?>
+
+
diff --git a/airtime_mvc/application/views/scripts/show-builder/index.phtml b/airtime_mvc/application/views/scripts/show-builder/index.phtml
deleted file mode 100644
index 4ad028ef2..000000000
--- a/airtime_mvc/application/views/scripts/show-builder/index.phtml
+++ /dev/null
@@ -1,41 +0,0 @@
-quotaLimitReached) { ?>
-csrf ?>
-
-
-
-
-
-csrf ?>
-
-
-
-
-
-dialog ?>
diff --git a/airtime_mvc/application/views/scripts/showbuilder/index.phtml b/airtime_mvc/application/views/scripts/showbuilder/index.phtml
index 0473ec1bf..4ad028ef2 100644
--- a/airtime_mvc/application/views/scripts/showbuilder/index.phtml
+++ b/airtime_mvc/application/views/scripts/showbuilder/index.phtml
@@ -1,23 +1,41 @@
-disableLib): ?>
-
showLib): ?>
- style="display:none"
-
->
- render('library/library.phtml') ?>
-
-
+quotaLimitReached) { ?>
+csrf ?>
+
+
+
+
-
-
- disableLib && !$this->showLib):?>
-
-
-
-
- sb_form; ?>
+csrf ?>
+
+
-lang_tz_popup_form; ?>
+
+
+dialog ?>
diff --git a/airtime_mvc/application/views/scripts/webstream/_webstream.phtml b/airtime_mvc/application/views/scripts/webstream/_webstream.phtml
deleted file mode 100644
index 0d4288668..000000000
--- a/airtime_mvc/application/views/scripts/webstream/_webstream.phtml
+++ /dev/null
@@ -1,47 +0,0 @@
-obj)) : ?>
-
-
obj->getLastModified('U'); ?>"/>
-
-
-
-
-
-
-
obj->getDefaultLength(); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/airtime_mvc/application/views/scripts/webstream/webstream.phtml b/airtime_mvc/application/views/scripts/webstream/webstream.phtml
index 484a8a638..0d4288668 100644
--- a/airtime_mvc/application/views/scripts/webstream/webstream.phtml
+++ b/airtime_mvc/application/views/scripts/webstream/webstream.phtml
@@ -1,26 +1,3 @@
-
-
-
obj)) : ?>
obj->getLastModified('U'); ?>"/>
@@ -35,17 +12,13 @@
obj->getDefaultLength(); ?>
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -60,6 +33,15 @@
+
+
diff --git a/airtime_mvc/public/js/airtime/library/_library.js b/airtime_mvc/public/js/airtime/library/_library.js
deleted file mode 100644
index a4f8d6b63..000000000
--- a/airtime_mvc/public/js/airtime/library/_library.js
+++ /dev/null
@@ -1,1392 +0,0 @@
-var AIRTIME = (function(AIRTIME) {
- var mod,
- libraryInit,
- oTable,
- $libContent,
- $libTable,
- LIB_SELECTED_CLASS = "lib-selected",
- chosenItems = {},
- visibleChosenItems = {},
- $previouslySelected,
- flagForDeselection = false;
-
-
- // we need to know whether the criteria value is string or
- // numeric in order to provide a single textbox or range textboxes
- // in the advanced search
- // s => string
- // n => numberic
- var libraryColumnTypes = {
- 0 : "",
- "album_title" : "s",
- "artist_name" : "s",
- "bit_rate" : "n",
- "bpm" : "n",
- "comments" : "s",
- "composer" : "s",
- "conductor" : "s",
- "copyright" : "s",
- "cuein" : "n",
- "cueout" : "n",
- "utime" : "n",
- "mtime" : "n",
- "lptime" : "n",
- "disc_number" : "n",
- "encoded_by" : "s",
- "genre" : "s",
- "isrc_number" : "s",
- "label" : "s",
- "language" : "s",
- "length" : "n",
- "lyricist" : "s",
- "mime" : "s",
- "mood" : "s",
- "name" : "s",
- "orchestra" : "s",
- "rating" : "n",
- "sample_rate" : "n",
- "track_title" : "s",
- "track_num" : "n",
- "year" : "n",
- "owner_id" : "s",
- "info_url" : "s",
- "replay_gain" : "n"
- };
-
- if (AIRTIME.library === undefined) {
- AIRTIME.library = {};
- }
- mod = AIRTIME.library;
-
- mod.getChosenItemsLength = function(){
- var cItem,
- selected,
- $trs;
-
- // Get visible items and check if any chosenItems are visible
- $trs = $libTable.find("tr");
- $trs.each(function(i){
- for (cItem in chosenItems) {
- if (cItem === $(this).attr("id")) {
- visibleChosenItems[cItem] = $(this).data('aData');
- }
- }
- });
-
- selected = Object.keys(visibleChosenItems).length;
- visibleChosenItems = {};
- return selected;
- };
-
- mod.getChosenAudioFilesLength = function(){
- // var files = Object.keys(chosenItems),
- var files,
- $trs,
- cItem,
- i, length,
- count = 0,
- reAudio=/^(au|st|pl|bl)/ ;
-
- // Get visible items and check if any chosenItems are visible
- $trs = $libTable.find("tr");
- $trs.each(function(i){
- for (cItem in chosenItems) {
- if (cItem === $(this).attr("id")) {
- visibleChosenItems[cItem] = $(this).data('aData');
- }
- }
- });
-
- files = Object.keys(visibleChosenItems);
-
- for (i = 0, length = files.length; i < length; i++) {
-
- if (files[i].search(reAudio) !== -1) {
- count++;
- }
- }
- visibleChosenItems = {};
- return count;
- };
-
- mod.changeAddButtonText = function($button, btnText) {
- $button.text(btnText);
- };
-
- mod.createToolbarButtons = function () {
- $menu = $("
");
- $menu
- .append("
" +
- "" +
- " " +
- "" + $.i18n._('New') + " " +
- " " +
- "
")
- .append("
" +
- "" +
- " " +
- "" + $.i18n._('Edit') + " " +
- " " +
- "
")
-
- .append("
" +
- "" +
- " " +
- " " +
- " " +
- "
")
- .append("
" +
- "" +
- " " +
- "" + $.i18n._('Delete') + " " +
- " " +
- "
")
- .append("
" +
- "" +
- $.i18n._("Select") + " " +
- " " +
- "" +
- "
"
- );
- };
-
- mod.moveSearchBarToHeader = function() {
- $("#library_display_filter").appendTo("#library_content > .panel-header");
- $("#advanced_search").click(function(e) {
- e.stopPropagation();
- });
- };
-
- mod.createToolbarDropDown = function() {
- $('#sb-select-page').click(function(){mod.selectCurrentPage();});
- $('#sb-dselect-page').click(function(){mod.deselectCurrentPage();});
- $('#sb-dselect-all').click(function(){mod.selectNone();});
- };
-
- mod.checkDeleteButton = function() {
- var selected = mod.getChosenItemsLength(),
- check = false;
-
- if (selected !== 0) {
- check = true;
- }
-
- if (check === true) {
- AIRTIME.button.enableButton("btn-group #sb-trash", false);
- }
- else {
- 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.checkEditButton();
- AIRTIME.library.checkNewButton();
- };
-
- mod.getSelectedData = function() {
- var id,
- data = [],
- cItem,
- $trs;
-
- $.fn.reverse = [].reverse;
-
- // Get visible items and check if any chosenItems are visible
- $trs = $libTable.find("tr").reverse();
- $trs.each(function(i){
- for (cItem in chosenItems) {
- if (cItem === $(this).attr("id")) {
- visibleChosenItems[cItem] = $(this).data('aData');
- }
- }
- });
-
- for (id in visibleChosenItems) {
- if (visibleChosenItems.hasOwnProperty(id)) {
- data.push(visibleChosenItems[id]);
- }
- }
- visibleChosenItems = {};
- return data;
- };
-
- mod.redrawChosen = function() {
- var ids = Object.keys(chosenItems),
- i, length,
- $el;
-
- for (i = 0, length = ids.length; i < length; i++) {
- $el = $libTable.find("#"+ids[i]);
-
- if ($el.length !== 0) {
- mod.highlightItem($el);
- mod.checkItem($el);
- }
- }
- };
-
- mod.isChosenItem = function($el) {
- var id = $el.attr("id"),
- item = chosenItems[id];
-
- return item !== undefined;
- };
-
- mod.addToChosen = function($el) {
- var id = $el.attr("id");
-
- chosenItems[id] = $el.data('aData');
- };
-
- mod.removeFromChosen = function($el) {
- var id = $el.attr("id");
-
- // used to not keep dragged items selected.
- if (!$el.hasClass(LIB_SELECTED_CLASS)) {
- delete chosenItems[id];
- }
- };
-
- mod.checkItem = function($el) {
- $el.find(".library_checkbox > input").prop('checked', true);
- $("#super-checkbox").prop("checked", true);
- };
-
- mod.uncheckItem = function($el) {
- $el.find(".library_checkbox > input").prop('checked', false);
- if ($("." + LIB_SELECTED_CLASS.length == 0)) {
- $("#super-checkbox").prop("checked", false);
- }
- };
-
- mod.highlightItem = function($el) {
- $el.addClass(LIB_SELECTED_CLASS);
- };
-
- mod.unHighlightItem = function($el) {
- $el.removeClass(LIB_SELECTED_CLASS);
- };
-
- mod.selectItem = function($el) {
- mod.highlightItem($el);
- mod.addToChosen($el);
-
- mod.checkToolBarIcons();
- };
-
- mod.deselectItem = function($el) {
- mod.unHighlightItem($el);
- mod.removeFromChosen($el);
- mod.checkToolBarIcons();
- };
-
- /*
- * selects all items which the user can currently see. (behaviour taken from
- * gmail)
- *
- * by default the items are selected in reverse order so we need to reverse
- * it back
- */
- mod.selectCurrentPage = function() {
- $.fn.reverse = [].reverse;
- var $trs = $libTable.find("tbody").find("tr").reverse();
-
- $trs.each(function(i, el){
- mod.selectItem($(el));
- mod.checkItem($(el));
- });
-
- mod.checkToolBarIcons();
-
- };
-
- /*
- * deselects all items that the user can currently see. (behaviour taken
- * from gmail)
- */
- mod.deselectCurrentPage = function() {
- var $trs = $libTable.find("tr");
-
- $trs.each(function(i, el){
- mod.deselectItem($(el));
- mod.uncheckItem($(el));
- });
-
- mod.checkToolBarIcons();
- };
-
- mod.selectNone = function() {
- var $trs = $libTable.find("tr");
- $trs.each(function(i, el){
- mod.deselectItem($(el));
- mod.uncheckItem($(el));
- });
- $previouslySelected = undefined;
-
- chosenItems = {};
-
- mod.checkToolBarIcons();
- };
-
- mod.fnRedraw = function() {
- oTable.fnStandingRedraw();
- };
-
- mod.fnDeleteItems = function(aMedia) {
- //Prevent the user from spamming the delete button while the AJAX request is in progress
- AIRTIME.button.disableButton("btn-group #sb-trash", false);
- var openTabObjectIds = $(".obj_id"),
- mediaIds = [];
- for (var i in aMedia) {
- mediaIds.push(parseInt(aMedia[i].id));
- }
-
- openTabObjectIds.each(function(i, el) {
- var v = parseInt($(el).val());
- if ($.inArray(v, mediaIds) > -1) {
- AIRTIME.playlist.closeTab($(el).closest(".pl-content").attr("tab-id"));
- }
- });
-
- $.post(baseUrl+"library/delete",
- {"format": "json", "media": aMedia},
- function(json){
- if (json.message !== undefined) {
- alert(json.message);
- }
-
- chosenItems = {};
- oTable.fnStandingRedraw();
-
- //Re-enable the delete button
- AIRTIME.button.enableButton("btn-group #sb-trash", false);
- });
- };
-
- mod.fnDeleteSelectedItems = function() {
- if (confirm($.i18n._('Are you sure you want to delete the selected item(s)?'))) {
- var aData = AIRTIME.library.getSelectedData(),
- item,
- temp,
- aMedia = [],
- currentObjId = $(".side_playlist.active-tab").find(".obj_id").val(),
- currentObjType = $(".side_playlist.active-tab").find(".obj_type").val(),
- closeObj = false;
-
- // process selected files/playlists.
- for (item in aData) {
- temp = aData[item];
- if (temp !== null && temp.hasOwnProperty('id') ) {
- aMedia.push({"id": temp.id, "type": temp.ftype});
- if ( (temp.id == currentObjId && temp.ftype === currentObjType) ||
- temp.id == currentObjId && temp.ftype === "stream" && currentObjType === "webstream") {
- closeObj = true;
- }
- }
- }
-
- AIRTIME.library.fnDeleteItems(aMedia);
-
- // close the object (playlist/block/webstream)
- // on the right side if it was just deleted
- // from the library
- if (closeObj) {
- $.post(baseUrl+"playlist/close-playlist",
- {"format": "json", "type": currentObjType},
- function(json) {
- $("#editor_pane_wrapper").empty().append(json.html);
- });
- }
- }
- };
-
-
- libraryInit = function() {
-
- $libContent = $("#library_content");
-
- /*
- * Icon hover states in the toolbar.
- */
- $libContent.on("mouseenter", ".fg-toolbar ul li", function(ev) {
- $el = $(this);
-
- if (!$el.hasClass("ui-state-disabled")) {
- $el.addClass("ui-state-hover");
- }
- });
- $libContent.on("mouseleave", ".fg-toolbar ul li", function(ev) {
- $el = $(this);
-
- if (!$el.hasClass("ui-state-disabled")) {
- $el.removeClass("ui-state-hover");
- }
- });
-
- var colReorderMap = new Array();
-
- $libTable = $libContent.find("table");
-
- function getTableHeight() {
- return $libContent.height() - 175;
- }
-
- function setColumnFilter(oTable){
- // TODO : remove this dirty hack once js is refactored
- if (!oTable.fnSettings()) { return ; }
- var aoCols = oTable.fnSettings().aoColumns;
- var colsForAdvancedSearch = new Array();
- var advanceSearchDiv = $("div#advanced_search");
- advanceSearchDiv.empty();
- $.each(aoCols, function(i,ele){
- if (ele.bSearchable) {
- var currentColId = ele._ColReorder_iOrigCol;
-
- var inputClass = 'filter_column filter_number_text';
- var labelStyle = "style='margin-right:35px;'";
- if (libraryColumnTypes[ele.mDataProp] != "s") {
- inputClass = 'filterColumn filter_number_range';
- labelStyle = "";
- }
-
- if (ele.bVisible) {
- advanceSearchDiv.append(
- "
" +
- "
"+ele.sTitle+" " +
- "
" +
- "
");
- } else {
- advanceSearchDiv.append(
- "
" +
- "
"+ele.sTitle+" " +
- "
" +
- "
");
- }
-
- if (libraryColumnTypes[ele.mDataProp] == "s") {
- var obj = { sSelector: "#"+ele.mDataProp }
- } else {
- var obj = { sSelector: "#"+ele.mDataProp, type: "number-range" }
- }
- colsForAdvancedSearch.push(obj);
- } else {
- colsForAdvancedSearch.push(null);
- }
- });
-
- oTable.columnFilter({
- aoColumns: colsForAdvancedSearch,
- bUseColVis: true,
- sPlaceHolder: "head:before"
- }
- );
- }
-
- function setFilterElement(iColumn, bVisible){
- var actualId = colReorderMap[iColumn];
- var selector = "div#advanced_search_col_"+actualId;
- var $el = $(selector);
-
- if (bVisible) {
- $el.show();
- } else {
- $el.hide();
- }
- }
-
- function getLibraryDatatableStrings() {
- //Set up the datatables string translation table with different strings depending on
- //whether you're viewing files, playlists, smart blocks, etc.
- var type = parseInt($(".media_type_selector.selected").attr("selection_id"));
- type = (type === undefined) ? 1 : type;
-
- //FIXME: The code that calls this function doesn't work as intended because you can't
- // change the oLanguage property of a datatable dynamically. :(
-
- switch (type) {
- /*
- case 0:
- return getDatatablesStrings({
- "sEmptyTable": $.i18n._("No files found"),
- });
- break;
- case 1:
- return getDatatablesStrings({
- "sEmptyTable": $.i18n._("No playlists found"),
- });
- break;
- case 2:
- return getDatatablesStrings({
- "sEmptyTable": $.i18n._("No smart blocks found"),
- });
- break;*/
- default:
- return getDatatablesStrings({
- "sEmptyTable": $.i18n._(""),
- "sZeroRecords": $.i18n._("No matching results found.")
- });
- break;
- };
-
- }
-
-
- oTable = $libTable.dataTable( {
-
- // put hidden columns at the top to insure they can never be visible
- // on the table through column reordering.
-
- //IMPORTANT: WHEN ADDING A NEW COLUMN PLEASE CONSULT WITH THE WIKI
- // https://wiki.sourcefabric.org/display/CC/Adding+a+new+library+datatable+column
- "aoColumns": [
- /* ftype */ { "sTitle" : "" , "mDataProp" : "ftype" , "bSearchable" : false , "bVisible" : false },
- /* Checkbox */ { "sTitle" : "" , "mDataProp" : "checkbox" , "bSortable" : false , "bSearchable" : false , "sWidth" : "16px" , "sClass" : "library_checkbox" },
- /* Type */ { "sTitle" : "" , "mDataProp" : "image" , "bSortable" : false , "bSearchable" : false , "sWidth" : "16px" , "sClass" : "library_type" , "iDataSort" : 0 },
- /* Is Scheduled */ { "sTitle" : $.i18n._("Scheduled") , "mDataProp" : "is_scheduled" , "bVisible" : false , "bSearchable" : false , "sWidth" : "90px" , "sClass" : "library_is_scheduled" },
- ///* Is Playlist */ { "sTitle" : $.i18n._("Playlist / Block") , "mDataProp" : "is_playlist" , "bSearchable" : false , "sWidth" : "110px" , "sClass" : "library_is_playlist"} ,
- /* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "track_title" , "sClass" : "library_title" , "sWidth" : "170px" },
- /* Creator */ { "sTitle" : $.i18n._("Creator") , "mDataProp" : "artist_name" , "sClass" : "library_creator" , "sWidth" : "160px" },
- /* Album */ { "sTitle" : $.i18n._("Album") , "mDataProp" : "album_title" , "sClass" : "library_album" , "sWidth" : "150px" },
- /* Bit Rate */ { "sTitle" : $.i18n._("Bit Rate") , "mDataProp" : "bit_rate" , "bVisible" : false , "sClass" : "library_bitrate" , "sWidth" : "80px" },
- /* BPM */ { "sTitle" : $.i18n._("BPM") , "mDataProp" : "bpm" , "bVisible" : false , "sClass" : "library_bpm" , "sWidth" : "50px" },
- /* Composer */ { "sTitle" : $.i18n._("Composer") , "mDataProp" : "composer" , "bVisible" : false , "sClass" : "library_composer" , "sWidth" : "150px" },
- /* Conductor */ { "sTitle" : $.i18n._("Conductor") , "mDataProp" : "conductor" , "bVisible" : false , "sClass" : "library_conductor" , "sWidth" : "125px" },
- /* Copyright */ { "sTitle" : $.i18n._("Copyright") , "mDataProp" : "copyright" , "bVisible" : false , "sClass" : "library_copyright" , "sWidth" : "125px" },
- /* Cue In */ { "sTitle" : $.i18n._("Cue In") , "mDataProp" : "cuein" , "bVisible" : false , "sClass" : "library_length" , "sWidth" : "80px" },
- /* Cue Out */ { "sTitle" : $.i18n._("Cue Out") , "mDataProp" : "cueout" , "bVisible" : false , "sClass" : "library_length" , "sWidth" : "80px" },
- /* Encoded */ { "sTitle" : $.i18n._("Encoded By") , "mDataProp" : "encoded_by" , "bVisible" : false , "sClass" : "library_encoded" , "sWidth" : "150px" },
- /* Genre */ { "sTitle" : $.i18n._("Genre") , "mDataProp" : "genre" , "bVisible" : false , "sClass" : "library_genre" , "sWidth" : "100px" },
- /* ISRC Number */ { "sTitle" : $.i18n._("ISRC") , "mDataProp" : "isrc_number" , "bVisible" : false , "sClass" : "library_isrc" , "sWidth" : "150px" },
- /* Label */ { "sTitle" : $.i18n._("Label") , "mDataProp" : "label" , "bVisible" : false , "sClass" : "library_label" , "sWidth" : "125px" },
- /* Language */ { "sTitle" : $.i18n._("Language") , "mDataProp" : "language" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" },
- /* Last Modified */ { "sTitle" : $.i18n._("Last Modified") , "mDataProp" : "mtime" , "bVisible" : false , "sClass" : "library_modified_time" , "sWidth" : "155px" },
- /* Last Played */ { "sTitle" : $.i18n._("Last Played") , "mDataProp" : "lptime" , "bVisible" : false , "sClass" : "library_modified_time" , "sWidth" : "155px" },
- /* Length */ { "sTitle" : $.i18n._("Length") , "mDataProp" : "length" , "sClass" : "library_length" , "sWidth" : "80px" },
- /* Mime */ { "sTitle" : $.i18n._("Mime") , "mDataProp" : "mime" , "bVisible" : false , "sClass" : "library_mime" , "sWidth" : "80px" },
- /* Mood */ { "sTitle" : $.i18n._("Mood") , "mDataProp" : "mood" , "bVisible" : false , "sClass" : "library_mood" , "sWidth" : "70px" },
- /* Owner */ { "sTitle" : $.i18n._("Owner") , "mDataProp" : "owner_id" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" },
- /* Replay Gain */ { "sTitle" : $.i18n._("Replay Gain") , "mDataProp" : "replay_gain" , "bVisible" : false , "sClass" : "library_replay_gain" , "sWidth" : "125px" },
- /* Sample Rate */ { "sTitle" : $.i18n._("Sample Rate") , "mDataProp" : "sample_rate" , "bVisible" : false , "sClass" : "library_sr" , "sWidth" : "125px" },
- /* Track Number */ { "sTitle" : $.i18n._("Track Number") , "mDataProp" : "track_number" , "bVisible" : false , "sClass" : "library_track" , "sWidth" : "125px" },
- /* Upload Time */ { "sTitle" : $.i18n._("Uploaded") , "mDataProp" : "utime" , "bVisible" : false , "sClass" : "library_upload_time" , "sWidth" : "155px" },
- /* Website */ { "sTitle" : $.i18n._("Website") , "mDataProp" : "info_url" , "bVisible" : false , "sClass" : "library_url" , "sWidth" : "150px" },
- /* Year */ { "sTitle" : $.i18n._("Year") , "mDataProp" : "year" , "bVisible" : false , "sClass" : "library_year" , "sWidth" : "60px" },
- /* Context Menu */ { "sTitle" : "" , "mData" : null , "bSortable" : false , "sClass" : "library_actions" , "bSearchable" : false , "sWidth" : "16px" }
- ],
-
- "bProcessing": true,
- "bServerSide": true,
-
- "aLengthMenu": [5, 10, 15, 20, 25, 50, 100],
-
- "bStateSave": true,
- "fnStateSaveParams": function (oSettings, oData) {
- // remove oData components we don't want to save.
- delete oData.oSearch;
- delete oData.aoSearchCols;
- },
- "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"
- });
- */
-
- colReorderMap = oData.ColReorder;
- },
- "fnStateLoad": function fnLibStateLoad(oSettings) {
- var settings = localStorage.getItem('datatables-library');
-
- try {
- return JSON.parse(settings);
- } catch (e) {
- return null;
- }
- },
- "fnStateLoadParams": function (oSettings, oData) {
- var i,
- length,
- a = oData.abVisCols;
-
- if (a) {
- // putting serialized data back into the correct js type to make
- // sure everything works properly.
- for (i = 0, length = a.length; i < length; i++) {
- if (typeof(a[i]) === "string") {
- a[i] = (a[i] === "true");
- }
- }
- }
-
- a = oData.ColReorder;
- if (a) {
- for (i = 0, length = a.length; i < length; i++) {
- if (typeof(a[i]) === "string") {
- a[i] = parseInt(a[i], 10);
- }
- }
- }
-
- oData.iEnd = parseInt(oData.iEnd, 10);
- oData.iLength = parseInt(oData.iLength, 10);
- oData.iStart = parseInt(oData.iStart, 10);
- oData.iCreate = parseInt(oData.iCreate, 10);
- },
-
- "sAjaxSource": baseUrl+"Library/contents-feed",
- "sAjaxDataProp": "files",
-
- "fnServerData": function ( sSource, aoData, fnCallback ) {
- /*
- * The real validation check is done in
- * dataTables.columnFilter.js We also need to check it here
- * because datatable is redrawn everytime an action is performed
- * in the Library page. In order for datatable to redraw the
- * advanced search fields MUST all be valid.
- */
- var advSearchFields = $("div#advanced_search").children(':visible');
- var advSearchValid = validateAdvancedSearch(advSearchFields);
- var type;
- aoData.push( { name: "format", value: "json"} );
- aoData.push( { name: "advSearch", value: advSearchValid} );
-
- // push whether to search files/playlists or all.
- type = $(".media_type_selector.selected").attr("selection_id");
- type = (type === undefined) ? 1 : type;
- aoData.push( { name: "type", value: type} );
-
- getUsabilityHint();
-
- $.ajax( {
- "dataType": 'json',
- "type": "POST",
- "url": sSource,
- "data": aoData,
- "success": fnCallback
- } );
- },
- "fnRowCallback": AIRTIME.library.fnRowCallback,
- "fnCreatedRow": function( nRow, aData, iDataIndex ) {
- // add checkbox
- $(nRow).find('td.library_checkbox').html("
");
-
- $(nRow).find('td.library_actions')
- .text("...")
- .on('click', function(e) {
- $(this).contextMenu({x: $(e.target).offset().left, y: $(e.target).offset().top})
- }).html("
...
");
-
- // add audio preview image/button
- if (aData.ftype === "audioclip") {
- $(nRow).find('td.library_type').html('
');
- } else if (aData.ftype === "playlist") {
- $(nRow).find('td.library_type').html('
');
- } else if (aData.ftype === "block") {
- $(nRow).find('td.library_type').html('
');
- } else if (aData.ftype === "stream") {
- $(nRow).find('td.library_type').html('
');
- }
-
- if (aData.is_scheduled) {
- $(nRow).find("td.library_is_scheduled").html('
');
- } else if (!aData.is_scheduled) {
- $(nRow).find("td.library_is_scheduled").html('');
- }
- if (aData.is_playlist) {
- $(nRow).find("td.library_is_playlist").html('
');
- } else if (!aData.is_playlist) {
- $(nRow).find("td.library_is_playlist").html('');
- }
-
- // add the play function to the library_type td
- $(nRow).find('td.library_type').click(function(){
- if (aData.ftype === 'playlist' && aData.length !== '0.0'){
- open_playlist_preview(aData.audioFile, 0);
- } else if (aData.ftype === 'audioclip') {
- if (isAudioSupported(aData.mime)) {
- open_audio_preview(aData.ftype, aData.id);
- }
- } else if (aData.ftype == 'stream') {
- if (isAudioSupported(aData.mime)) {
- open_audio_preview(aData.ftype, aData.id);
- }
- } else if (aData.ftype == 'block' && aData.bl_type == 'static') {
- open_block_preview(aData.audioFile, 0);
- }
- return false;
- });
- },
- // remove any selected nodes before the draw.
- "fnPreDrawCallback": function( oSettings ) {
-
- // make sure any dragging helpers are removed or else they'll be
- // stranded on the screen.
- $("#draggingContainer").remove();
- },
- "fnDrawCallback": AIRTIME.library.fnDrawCallback,
-
- "aaSorting": [[5, 'asc']],
- "sPaginationType": "full_numbers",
- "bJQueryUI": true,
- "bAutoWidth": false,
- "oLanguage": getLibraryDatatableStrings(),
-
- // R = ColReorder, C = ColVis
- "sDom": 'Rf<"dt-process-rel"r><"H"<"library_toolbar"C>><"dataTables_scrolling"t><"F"ilp>>',
-
- "oColVis": {
- "sAlign": "right",
- "aiExclude": [0, 1, 2, 31],
- "sSize": "css",
- "fnStateChange": setFilterElement,
- "buttonText": $.i18n._("Columns")
- },
-
- "oColReorder": {
- "iFixedColumnsRight": 1,
- "iFixedColumns": 3
- },
-
- "bScrollCollapse": false
-
- });
-
- setColumnFilter(oTable);
- oTable.fnSetFilteringDelay(350);
-
- var simpleSearchText;
-
- $libContent.on("click", "legend", function(){
- $simpleSearch = $libContent.find("#library_display_filter label");
- var $fs = $(this).parents("fieldset"),
- searchHeight,
- tableHeight = getTableHeight(),
- height;
-
- if ($fs.hasClass("closed")) {
- $fs.removeClass("closed");
- searchHeight = $fs.height();
-
- //keep value of simple search for when user switches back to it
- simpleSearchText = $simpleSearch.find('input').val();
-
- // clear the simple search text field and reset datatable
- $(".dataTables_filter input").val("").keyup();
-
- $simpleSearch.addClass("sp-invisible");
- }
- else {
- // clear the advanced search fields
- var divs = $("div#advanced_search").children(':visible');
- $.each(divs, function(i, div){
- fields = $(div).children().find('input');
- $.each(fields, function(i, field){
- if ($(field).val() !== "") {
- $(field).val("");
- // we need to reset the results when removing
- // an advanced search field
- $(field).keyup();
- }
- });
- });
-
- //reset datatable with previous simple search results (if any)
- $(".dataTables_filter input").val(simpleSearchText).keyup();
-
- $simpleSearch.removeClass("sp-invisible");
- $fs.addClass("closed");
- }
- });
-
- AIRTIME.library.setupLibraryToolbar(oTable);
-
- $libTable.find("tbody").on("dblclick", "tr", function(ev) {
- var data = $(this).data("aData");
- AIRTIME.library.dblClickAdd(data, data.ftype);
- });
-
- $libTable.find("tbody").on("mousedown", "tr > td.library_checkbox", function(ev) {
- var $tr = $(this).parent(),
- // Get the ID of the selected row
- $rowId = $tr.attr("id");
-
- if (!$tr.hasClass(LIB_SELECTED_CLASS)) {
- if (ev.shiftKey && $previouslySelected !== undefined) {
- if ($previouslySelected.attr("id") == $rowId) {
- return;
- }
-
- // If the selected row comes before the previously selected row,
- // we want to select previous rows, otherwise we select next
- if ($previouslySelected.prevAll("#" + $rowId).length !== 0) {
- $previouslySelected.prevUntil($tr).each(function (i, el) {
- mod.selectItem($(el));
- mod.checkItem($(el));
- });
- } else {
- $previouslySelected.nextUntil($tr).each(function (i, el) {
- mod.selectItem($(el));
- mod.checkItem($(el));
- });
- }
- }
- mod.selectItem($tr);
- mod.checkItem($tr);
- } else {
- flagForDeselection = true;
- }
-
- // Remember this row so we can properly multiselect
- $previouslySelected = $tr;
- });
-
- $libTable.find("tbody").on("mousedown", "tr > td:not(.library_checkbox)", function(ev) {
- var $tr = $(this).parent(),
- // Get the ID of the selected row
- $rowId = $tr.attr("id");
-
- if (ev.shiftKey && $previouslySelected !== undefined) {
- if ($previouslySelected.attr("id") == $rowId) {
- return;
- }
-
- // If the selected row comes before the previously selected row,
- // we want to select previous rows, otherwise we select next
- if ($previouslySelected.prevAll("#" + $rowId).length !== 0) {
- $previouslySelected.prevUntil($tr).each(function (i, el) {
- mod.selectItem($(el));
- mod.checkItem($(el));
- });
- } else {
- $previouslySelected.nextUntil($tr).each(function (i, el) {
- mod.selectItem($(el));
- mod.checkItem($(el));
- });
- }
- } else if (!ev.ctrlKey) {
- AIRTIME.library.selectNone();
- }
-
- mod.selectItem($tr);
- mod.checkItem($tr);
-
- // Remember this row so we can properly multiselect
- $previouslySelected = $tr;
- });
-
- $libTable.find("tbody").on("click", "tr", function() {
- var tr = $(this);
-
- if (flagForDeselection) {
- flagForDeselection = false;
- mod.deselectItem(tr);
- mod.uncheckItem(tr);
- } else {
- mod.checkItem(tr);
- }
- });
-
- $libTable.find("thead").on("click", "th > input[type='checkbox']", function() {
- if ($(this).is(":checked")) {
- AIRTIME.library.selectCurrentPage();
- $(this).prop("checked", true);
- } else {
- AIRTIME.library.selectNone();
- $(this).prop("checked", false);
- }
- });
-
- $('#sb-actions').on("click", function(e) {
- $("#library_display tr:has(td)").contextMenu({x: $(e.target).offset().left, y: $(e.target).offset().top});
- });
-
- // begin context menu initialization.
- AIRTIME.library.ctxMenu = $.contextMenu({
- selector: '#library_display tr:has(td)',
- //trigger: "left",
- trigger: "custom",
-
- build: function($el, e) {
- var data, screen, items, callback, $tr;
-
- $tr = $el;
- data = $tr.data("aData");
- screen = $tr.data("screen");
-
- function processMenuItems(oItems) {
-
- // define an add to playlist callback.
- if (oItems.pl_add !== undefined) {
- var aItems = [];
-
- callback = function() {
- aItems.push(new Array(data.id, data.ftype));
- AIRTIME.playlist.fnAddItems(aItems, undefined, 'after');
- };
-
- oItems.pl_add.callback = callback;
- }
-
- // define an edit callback.
- if (oItems.edit !== undefined) {
- if (data.ftype === "audioclip") {
- callback = function() {
- $.get(oItems.edit.url, {format: "json"}, function(json){
- AIRTIME.playlist.fileMdEdit(json);
- });
- };
- } else if (data.ftype === "playlist" || data.ftype === "block") {
- callback = function() {
- AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl+'new-playlist/edit');
- AIRTIME.playlist.validatePlaylistElements();
- };
- } else if (data.ftype === "stream") {
- callback = function() {
- AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'new-webstream/edit');
- }
- } else {
- throw new Exception($.i18n._("Unknown type: ") + data.ftype);
- }
- oItems.edit.callback = callback;
- }
-
- // define a play callback.
- if (oItems.play !== undefined) {
-
- if (oItems.play.mime !== undefined) {
- if (!isAudioSupported(oItems.play.mime)) {
- oItems.play.disabled = true;
- }
- }
-
- callback = function() {
- if (data.ftype === 'playlist' && data.length !== '0.0'){
- playlistIndex = $(this).parent().attr('id').substring(3); // remove
- // the
- // pl_
- open_playlist_preview(playlistIndex, 0);
- } else if (data.ftype === 'audioclip' || data.ftype === 'stream') {
- open_audio_preview(data.ftype, data.id);
- } else if (data.ftype === 'block') {
- blockIndex = $(this).parent().attr('id').substring(3); // remove
- // the
- // pl_
- open_block_preview(blockIndex, 0);
- }
- };
- oItems.play.callback = callback;
- }
-
- // define a delete callback.
- if (oItems.del !== undefined) {
-
- // delete through the playlist controller, will reset
- // playlist screen if this is the currently edited
- // playlist.
- if ((data.ftype === "playlist" || data.ftype === "block") && screen === "playlist") {
- callback = function() {
- aMedia = [];
- aMedia.push({"id": data.id, "type": data.ftype});
- if (confirm($.i18n._('Are you sure you want to delete the selected item?'))) {
- AIRTIME.library.fnDeleteItems(aMedia);
- }
- };
- }
- else {
- callback = function() {
- var media = [];
-
- if (confirm($.i18n._('Are you sure you want to delete the selected item?'))) {
-
- media.push({"id": data.id, "type": data.ftype});
- $.post(oItems.del.url, {format: "json", media: media }, function(json){
- var oTable;
-
- if (json.message) {
- alert(json.message);
- }
-
- oTable = $("#library_display").dataTable();
- oTable.fnDeleteRow( $tr[0] );
- });
- }
- };
- }
-
- oItems.del.callback = callback;
- }
-
- // define a download callback.
- if (oItems.download !== undefined) {
-
- callback = function() {
- document.location.href = oItems.download.url;
- };
- oItems.download.callback = callback;
- }
- // add callbacks for Soundcloud menu items.
- if (oItems.soundcloud !== undefined) {
- var soundcloud = oItems.soundcloud.items;
-
- // define an upload to soundcloud callback.
- if (soundcloud.upload !== undefined) {
-
- callback = function() {
- alert($.i18n._("Your track is being uploaded and will " +
- "appear on SoundCloud in a couple of minutes"));
- $.post(soundcloud.upload.url, function(){});
- };
- soundcloud.upload.callback = callback;
- }
-
- // define an upload to soundcloud callback.
- if (soundcloud.remove !== undefined) {
-
- callback = function() {
- alert($.i18n._("Your track is being deleted from SoundCloud"));
- $.post(soundcloud.remove.url, function(){});
- };
- soundcloud.remove.callback = callback;
- }
-
- // define a view on soundcloud callback
- if (soundcloud.view !== undefined) {
-
- callback = function() {
- window.open(soundcloud.view.url);
- };
- soundcloud.view.callback = callback;
- }
- }
- // add callbacks for duplicate menu items.
- if (oItems.duplicate !== undefined) {
- var url = oItems.duplicate.url;
- callback = function() {
- $.post(url, {format: "json", id: data.id }, function(json){
- oTable.fnStandingRedraw();
- });
- };
- oItems.duplicate.callback = callback;
- }
- // remove 'Add to smart block' option if the current
- // block is dynamic
- if ($('input:radio[name=sp_type]:checked').val() === "1") {
- delete oItems.pl_add;
- }
- items = oItems;
- }
-
- request = $.ajax({
- url: baseUrl+"library/context-menu",
- type: "GET",
- data: {id : data.id, type: data.ftype, format: "json", "screen": screen},
- dataType: "json",
- async: false,
- success: function(json){
- processMenuItems(json.items);
- }
- });
-
- return {
- items: items
- };
- }
- });
- };
-
- mod.libraryInit = libraryInit;
-
- return AIRTIME;
-
-}(AIRTIME || {}));
-
-function buildEditMetadataDialog (json){
- var dialog = $(json.dialog);
-
- dialog.dialog({
- autoOpen: false,
- title: $.i18n._("Edit Metadata"),
- width: 460,
- height: 660,
- modal: true,
- close: closeDialogLibrary
- });
-
- dialog.dialog('open');
-}
-
-function closeDialogLibrary(event, ui) {
- $(this).remove();
-}
-
-/*
- * This function is called from dataTables.columnFilter.js
- */
-function validateAdvancedSearch(divs) {
- var valid,
- allValid = true,
- fieldName,
- fields,
- searchTerm = Array(),
- searchTermType,
- regExpr,
- timeRegEx = "\\d{2}[:]([0-5]){1}([0-9]){1}[:]([0-5]){1}([0-9]){1}([.]\\d{1,6})?",
- dateRegEx = "\\d{4}[-]\\d{2}[-]\\d{2}?",
- integerRegEx = "^\\d+$",
- numericRegEx = "^\\d+[.]?\\d*$";
-
- searchTerm[0] = "";
- searchTerm[1] = "";
- $.each(divs, function(i, div){
- fieldName = $(div).children('div').attr('id');
- fields = $(div).children().find('input');
- searchTermType = validationTypes[fieldName];
- valid = true;
-
- $.each(fields, function(i, field){
- searchTerm[i] = $(field).val();
-
- if (searchTerm[i] !== "") {
-
- if (searchTermType === "l") {
- regExpr = new RegExp("^" +timeRegEx+ "$");
- } else if (searchTermType === "t") {
- var pieces = searchTerm[i].split(" ");
- if (pieces.length === 2) {
- regExpr = new RegExp("^" +dateRegEx+ " " +timeRegEx+ "$");
- } else if (pieces.length === 1) {
- regExpr = new RegExp("^" +dateRegEx+ "$");
- }
- } else if (searchTermType === "i") {
- regExpr = new RegExp(integerRegEx);
- } else if (searchTermType === "n") {
- regExpr = new RegExp(numericRegEx);
- if (searchTerm[i].charAt(0) === "-") {
- searchTerm[i] = searchTerm[i].substr(1);
- }
- }
-
- // string fields do not need validation
- if (searchTermType !== "s") {
- valid = regExpr.test(searchTerm[i]);
- if (!valid) allValid = false;
- }
-
- addRemoveValidationIcons(valid, $(field), searchTermType);
-
- /*
- * Empty fields should not have valid/invalid indicator Range values
- * are considered valid even if only the 'From' value is provided.
- * Therefore, if the 'To' value is empty but the 'From' value is not
- * empty we need to keep the validation icon on screen.
- */
- } else if (searchTerm[0] === "" && searchTerm[1] !== "" ||
- searchTerm[0] === "" && searchTerm[1] === ""){
- if ($(field).closest('div').prev().hasClass('checked-icon') ||
- $(field).closest('div').prev().hasClass('not-available-icon')) {
- $(field).closest('div').prev().remove();
- }
- }
-
- if (!valid) {
- return false;
- }
- });
- });
-
- return allValid;
-}
-
-function addRemoveValidationIcons(valid, field, searchTermType) {
- var title = '';
- if (searchTermType === 'i') {
- title = $.i18n._('Input must be a positive number');
- } else if (searchTermType === 'n') {
- title = $.i18n._('Input must be a number');
- } else if (searchTermType === 't') {
- title = $.i18n._('Input must be in the format: yyyy-mm-dd');
- } else if (searchTermType === 'l') {
- title = $.i18n._('Input must be in the format: hh:mm:ss.t');
- }
-
- var validIndicator = "
",
- invalidIndicator = "
";
-
- if (valid) {
- if (!field.closest('div').prev().hasClass('checked-icon')) {
- // remove invalid icon before adding valid icon
- if (field.closest('div').prev().hasClass('not-available-icon')) {
- field.closest('div').prev().remove();
- }
- field.closest('div').before(validIndicator);
- }
- } else {
- if (!field.closest('div').prev().hasClass('not-available-icon')) {
- // remove valid icon before adding invalid icon
- if (field.closest('div').prev().hasClass('checked-icon')) {
- field.closest('div').prev().remove();
- }
- field.closest('div').before(invalidIndicator);
- }
- }
-}
-
-function resizeAdvancedSearch() {
- var s = $("#advanced_search");
- s.css("max-height", $(window).height() / 4);
- s.css("overflow", "auto");
-}
-
-/*
- * Validation types: s => string i => integer n => numeric (positive/negative,
- * whole/decimals) t => timestamp l => length
- */
-var validationTypes = {
- "album_title" : "s",
- "artist_name" : "s",
- "bit_rate" : "i",
- "bpm" : "i",
- "comments" : "s",
- "composer" : "s",
- "conductor" : "s",
- "copyright" : "s",
- "cuein" : "l",
- "cueout" : "l",
- "encoded_by" : "s",
- "utime" : "t",
- "mtime" : "t",
- "lptime" : "t",
- "disc_number" : "i",
- "genre" : "s",
- "isrc_number" : "s",
- "label" : "s",
- "language" : "s",
- "length" : "l",
- "lyricist" : "s",
- "mood" : "s",
- "mime" : "s",
- "name" : "s",
- "orchestra" : "s",
- "owner_id" : "s",
- "rating" : "i",
- "replay_gain" : "n",
- "sample_rate" : "n",
- "track_title" : "s",
- "track_number" : "i",
- "info_url" : "s",
- "year" : "i"
-};
-
-$(document).ready(function() {
- $('.active-tab .md-save').live("click", function() {
- var file_id = $('#file_id').val(),
- data = $(".active-tab #edit-md-dialog form").serializeArray();
- $.post(baseUrl+'library/edit-file-md', {format: "json", id: file_id, data: data}, function() {
- //$("#edit-md-dialog").dialog().remove();
-
- // don't redraw the library table if we are on calendar page
- // we would be on calendar if viewing recorded file metadata
- if ($("#schedule_calendar").length === 0) {
- oTable.fnStandingRedraw();
- }
- });
-
- AIRTIME.playlist.closeTab();
- });
-
- $('#edit-md-dialog').live("keyup", function(event) {
- if (event.keyCode === 13) {
- $('#editmdsave').click();
- }
- });
-
- if (location.hash === "") {
- $("a[href$='#files']").parent().addClass("selected");
- }
- $("a[href$='"+location.hash+"']").parent().addClass("selected");
-
- // Slightly hacky way of triggering the click event when it's outside of the anchor text
- $(".media_type_selector").on("click", function() {
- // Need get(0) here so we don't create a stack overflow by recurring the click on the parent
- $(this).find("a").get(0).click();
- });
-
- $(window).on('hashchange', function() {
- // If we click Dashboard from one of the media views, do nothing
- if (!location.hash) {
- return;
- }
- AIRTIME.library.selectNone();
- $(".media_type_selector").each(function () {
- $(this).removeClass("selected");
- });
- $("a[href$='"+location.hash+"']").parent().addClass("selected");
- oTable.fnDraw();
- });
-
- /* Overridden by hashchange function
-
- $(".media_type_selector").on("click", function() {
- if (!$(this).hasClass("selected")) {
- AIRTIME.library.selectNone();
- $(".media_type_selector").each(function () {
- $(this).removeClass("selected");
- });
- $(this).addClass("selected");
- oTable.fnDraw();
- }
- });
- */
-
- $("#advanced-options").on("click", function() {
- resizeAdvancedSearch();
- });
-
- $(window).resize(function() {
- resizeAdvancedSearch();
- });
-});
-
diff --git a/airtime_mvc/public/js/airtime/library/_spl.js b/airtime_mvc/public/js/airtime/library/_spl.js
deleted file mode 100644
index 2d3f6f729..000000000
--- a/airtime_mvc/public/js/airtime/library/_spl.js
+++ /dev/null
@@ -1,1576 +0,0 @@
-//--------------------------------------------------------------------------------------------------------------------------------
-// Playlist Functions
-//--------------------------------------------------------------------------------------------------------------------------------
-
-var AIRTIME = (function(AIRTIME){
-
- if (AIRTIME.playlist === undefined) {
- AIRTIME.playlist = {};
- }
-
- var mod = AIRTIME.playlist,
- viewport,
- $lib,
- $pl,
- $togglePl = $("
"+$.i18n._("Open Media Builder")+" "),
- widgetHeight,
- resizeTimeout,
- width,
- $tabCount = 0,
- $openTabs = {};
-
- function isTimeValid(time) {
- //var regExpr = new RegExp("^\\d{2}[:]\\d{2}[:]\\d{2}([.]\\d{1,6})?$");
- var regExpr = new RegExp("^\\d{2}[:]([0-5]){1}([0-9]){1}[:]([0-5]){1}([0-9]){1}([.]\\d{1})?$");
-
- return regExpr.test(time);
- }
-
- function isFadeValid(fade) {
- var regExpr = new RegExp("^\\d{1}(\\d{1})?([.]\\d{1})?$");
-
- return regExpr.test(fade);
- }
-
- function playlistError(json) {
- alert(json.error);
- //closeTab();
- //openPlaylist(json);
- }
-
- function stopAudioPreview() {
- // stop any preview playing
- $('#jquery_jplayer_1').jPlayer('stop');
- }
-
- function highlightActive(el) {
-
- $(el).addClass("ui-state-active");
- }
-
- function unHighlightActive(el) {
-
- $(el).removeClass("ui-state-active");
- }
-
- function showError(el, error) {
- $(el).parent().next()
- .empty()
- .append(error)
- .show();
- }
-
- function hideError(el) {
- $(el).parent().next()
- .empty()
- .hide();
- }
-
- function changeCueIn(event) {
- event.stopPropagation();
- var span = $(this),
- id = span.parent().attr("id").split("_").pop(),
- url = baseUrl+"new-playlist/set-cue",
- cueIn = $.trim(span.text()),
- li = span.parents("li"),
- unqid = li.attr("unqid"),
- lastMod = getModified(),
- type = $pl.find('.obj_type').val();
-
- if (!isTimeValid(cueIn)){
- showError(span, $.i18n._("please put in a time '00:00:00 (.0)'"));
- return;
- }
- $.post(url,
- {format: "json", cueIn: cueIn, id: id, modified: lastMod, type: type},
- function(json){
-
- if (json.error !== undefined){
- playlistError(json);
- return;
- }
- if (json.cue_error !== undefined) {
- showError(span, json.cue_error);
- return;
- }
-
- setPlaylistContent(json);
-
- li = $('.side_playlist.active-tab li[unqid='+unqid+']');
- li.find(".cue-edit").toggle();
- highlightActive(li);
- highlightActive(li.find('.spl_cue'));
- });
- }
-
- function changeCueOut(event) {
- event.stopPropagation();
- var span = $(this),
- id = span.parent().attr("id").split("_").pop(),
- url = baseUrl+"new-playlist/set-cue",
- cueOut = $.trim(span.text()),
- li = span.parents("li"),
- unqid = li.attr("unqid"),
- lastMod = getModified(),
- type = $pl.find('.obj_type').val();
-
- if (!isTimeValid(cueOut)){
- showError(span, $.i18n._("please put in a time '00:00:00 (.0)'"));
- return;
- }
-
- $.post(url,
- {format: "json", cueOut: cueOut, id: id, modified: lastMod, type: type},
- function(json){
-
- if (json.error !== undefined){
- playlistError(json);
- return;
- }
- if (json.cue_error !== undefined) {
- showError(span, json.cue_error);
- return;
- }
-
- setPlaylistContent(json);
-
- li = $('.side_playlist.active-tab li[unqid='+unqid+']');
- li.find(".cue-edit").toggle();
- highlightActive(li);
- highlightActive(li.find('.spl_cue'));
- });
- }
-
- /* used from waveform pop-up */
- function changeCues($el, id, cueIn, cueOut) {
-
- var url = baseUrl+"new-playlist/set-cue",
- lastMod = getModified(),
- type = $pl.find('.obj_type').val(),
- li,
- span;
-
- if (!isTimeValid(cueIn)){
- $el.find('.cue-in-error').val($.i18n._("please put in a time '00:00:00 (.0)'")).show();
- return;
- }
- else {
- $el.find('.cue-in-error').hide();
- }
-
- if (!isTimeValid(cueOut)){
- $el.find('.cue-out-error').val($.i18n._("please put in a time '00:00:00 (.0)'")).show();
- return;
- }
- else {
- $el.find('.cue-out-error').hide();
- }
-
- $.post(url,
- {format: "json", cueIn: cueIn, cueOut: cueOut, id: id, modified: lastMod, type: type},
- function(json){
-
- $el.dialog('destroy');
- $el.remove();
-
- if (json.error !== undefined){
- playlistError(json);
- return;
- }
- if (json.cue_error !== undefined) {
-
- li = $('.side_playlist.active-tab li[unqid='+id+']');
-
- if (json.code === 0) {
-
- span = $('#spl_cue_in_'+id).find('span');
- showError(span, json.cue_error);
- span = $('#spl_cue_out_'+id).find('span');
- showError(span, json.cue_error);
- }
- else if (json.code === 1) {
-
- span = $('#spl_cue_in_'+id).find('span');
- showError(span, json.cue_error);
- }
- else if (json.code === 2) {
-
- span = $('#spl_cue_out_'+id).find('span');
- showError(span, json.cue_error);
- }
-
- return;
- }
-
- setPlaylistContent(json);
-
- li = $('.side_playlist.active-tab li[unqid='+id+']');
- li.find(".cue-edit").toggle();
- highlightActive(li);
- highlightActive(li.find('.spl_cue'));
- });
- }
-
- /* used from waveform pop-up */
- function changeCrossfade($el, id1, id2, fadeIn, fadeOut, offset, id) {
-
- var url = baseUrl+"new-playlist/set-crossfade",
- lastMod = getModified(),
- type = $pl.find('.obj_type').val();
-
- $.post(url,
- {format: "json", fadeIn: fadeIn, fadeOut: fadeOut, id1: id1, id2: id2, offset: offset, modified: lastMod, type: type},
- function(json){
-
- $el.dialog('destroy');
- $el.remove();
-
- if (json.error !== undefined){
- playlistError(json);
- return;
- }
-
- setPlaylistContent(json);
-
- $li = $pl.find('li[unqid='+id+']');
- $li.find('.crossfade').toggle();
- highlightActive($li.find('.spl_fade_control'));
- });
- }
-
- function changeFadeIn(event) {
- event.preventDefault();
-
- var span = $(this),
- id = span.parent().attr("id").split("_").pop(),
- url = baseUrl+"new-playlist/set-fade",
- fadeIn = $.trim(span.text()),
- li = span.parents("li"),
- unqid = li.attr("unqid"),
- lastMod = getModified(),
- type = $pl.find('.obj_type').val();
-
- if (!isFadeValid(fadeIn)){
- showError(span, $.i18n._("please put in a time in seconds '00 (.0)'"));
- return;
- }
-
- $.post(url,
- {format: "json", fadeIn: fadeIn, id: id, modified: lastMod, type: type},
- function(json){
-
- if (json.error !== undefined){
- playlistError(json);
- return;
- }
- if (json.fade_error !== undefined) {
- showError(span, json.fade_error);
- return;
- }
-
- setPlaylistContent(json);
-
- li = $pl.find('li[unqid='+unqid+']');
- li.find('.crossfade').toggle();
- highlightActive(li.find('.spl_fade_control'));
- });
- }
-
- function changeFadeOut(event) {
- event.stopPropagation();
-
- var span = $(this),
- id = span.parent().attr("id").split("_").pop(),
- url = baseUrl+"new-playlist/set-fade",
- fadeOut = $.trim(span.text()),
- li = span.parents("li"),
- unqid = li.attr("unqid"),
- lastMod = getModified(),
- type = $pl.find('.obj_type').val();
-
- if (!isFadeValid(fadeOut)){
- showError(span, $.i18n._("please put in a time in seconds '00 (.0)'"));
- return;
- }
-
- $.post(url,
- {format: "json", fadeOut: fadeOut, id: id, modified: lastMod, type: type},
- function(json){
-
- if (json.error !== undefined){
- playlistError(json);
- return;
- }
- if (json.fade_error !== undefined) {
- showError(span, json.fade_error);
- return;
- }
-
- setPlaylistContent(json);
-
- li = $pl.find('li[unqid='+unqid+']');
- li.find('.crossfade').toggle();
- highlightActive(li.find('.spl_fade_control'));
- });
- }
-
- function submitOnEnter(event) {
- //enter was pressed
- if(event.keyCode === 13) {
- event.preventDefault();
- $(this).blur();
- }
- }
-
- function openFadeEditor(event) {
- var li;
-
- event.stopPropagation();
-
- li = $(this).parents("li");
- li.find(".crossfade").toggle();
-
- if ($(this).hasClass("ui-state-active")) {
- unHighlightActive(this);
- }
- else {
- highlightActive(this);
- }
- }
-
- function openCueEditor(event) {
- var li, icon;
-
- event.stopPropagation();
-
- icon = $(this);
- li = $(this).parents("li");
- li.find(".cue-edit").toggle();
-
- if (li.hasClass("ui-state-active")) {
- unHighlightActive(li);
- unHighlightActive(icon);
- }
- else {
- highlightActive(li);
- highlightActive(icon);
- }
- }
-
- function editName() {
- var nameElement = $(this);
- //remove any newlines if user somehow snuck them in (easy to do if dragging/dropping text)
- nameElement.text(nameElement.text().replace("\n", ""));
-
- var name = $pl.find(".playlist_name_display").text();
- $(".nav.nav-tabs .active a > span.tab-name").text(name);
- }
-
- function redrawLib() {
- var dt = $lib.find("#library_display").dataTable();
-
- dt.fnStandingRedraw();
- AIRTIME.library.redrawChosen();
- }
-
- function setPlaylistContent(json) {
- var $html = $(json.html);
-
- $('#spl_name > a')
- .empty()
- .append(json.name);
- $pl.find('.obj_length')
- .empty()
- .append(json.length);
- $('#fieldset-metadate_change textarea')
- .empty()
- .val(json.description);
-
- $pl.find('.spl_sortable').off('focusout keydown');
- $pl.find('.spl_sortable')
- .empty()
- .append($html);
- setCueEvents();
- setFadeEvents();
- setModified(json.modified);
- AIRTIME.playlist.validatePlaylistElements();
- redrawLib();
- }
-
- function setFadeIcon(){
- var contents = $pl.find(".spl_sortable");
- var show = contents.is(":visible");
- var empty = $pl.find(".spl_empty");
-
- if (!show || empty.length > 0) {
- $pl.find("#spl_crossfade").hide();
- } else {
- //get list of playlist contents
- var list = contents.children();
-
- //if first and last items are blocks, hide the fade icon
- var first = list.first();
- var last = list.last();
- if (first.find(':first-child').children().attr('blockid') !== undefined &&
- last.find(':first-child').children().attr('blockid') !== undefined) {
- $pl.find("#spl_crossfade").hide();
- } else {
- $pl.find("#spl_crossfade").show();
- }
- }
- }
-
- function getId() {
- return parseInt($pl.find(".obj_id").val(), 10);
- }
-
- function getModified() {
- return parseInt($pl.find(".obj_lastMod").val(), 10);
- }
-
- function setModified(modified) {
- $pl.find(".obj_lastMod").val(modified);
- }
-
- /*
- * Should all be moved to builder.js eventually
- */
- function buildNewTab(json) {
- AIRTIME.library.selectNone();
-
- var tabId = $openTabs[json.type + json.id];
- if (tabId !== undefined) {
- AIRTIME.showbuilder.switchTab($("#pl-tab-content-" + tabId), $("#pl-tab-" + tabId));
- return undefined;
- }
- $tabCount++;
-
- var wrapper = "
",
- t = $("#show_builder").append(wrapper).find("#pl-tab-content-" + $tabCount),
- pane = $(".editor_pane_wrapper:last"),
- name = json.type == "md" ? // file
- pane.append(json.html).find("#track_title").val() + $.i18n._(" - Metadata Editor")
- : pane.append(json.html).find(".playlist_name_display").text(),
- tab =
- "
" +
- " " +
- " " +
- " " +
- " ",
- tabs = $(".nav.nav-tabs");
-
- if (json.id) {
- $openTabs[json.type + json.id] = $tabCount;
- }
-
- $(".nav.nav-tabs li").removeClass("active");
- tabs.append(tab);
- tabs.find("#pl-tab-" + $tabCount + " span.tab-name").text(name);
-
- var newTab = $("#pl-tab-" + $tabCount);
- AIRTIME.showbuilder.switchTab(t, newTab);
-
- return {wrapper: pane, tab: newTab, pane: t};
- }
-
- function openFileMdEditor(json) {
- var newTab = buildNewTab(json);
- if (newTab === undefined) {
- return;
- }
- newTab.tab.on("click", function() {
- if (!$(this).hasClass('active')) {
- AIRTIME.showbuilder.switchTab(newTab.pane, newTab.tab);
- }
- });
- newTab.wrapper.find(".md-cancel").on("click", function() {
- closeTab();
- });
- initialEvents();
- }
-
- function openPlaylist(json) {
- var newTab = buildNewTab(json);
- if (newTab === undefined) {
- return;
- }
- newTab.tab.on("click", function() {
- if (!$(this).hasClass('active')) {
- AIRTIME.showbuilder.switchTab(newTab.pane, newTab.tab);
- $.post(baseUrl+'new-playlist/edit',
- {format: "json", id: newTab.pane.find(".obj_id").val(), type: newTab.pane.find(".obj_type").val()});
- }
- });
- AIRTIME.playlist.init();
-
- // functions in smart_blockbuilder.js
- setupUI();
- appendAddButton();
- appendModAddButton();
- removeButtonCheck();
- }
-
- function openPlaylistPanel() {
- viewport = AIRTIME.utilities.findViewportDimensions();
- var screenWidth = Math.floor(viewport.width - 40);
- widgetHeight = viewport.height - 185;
-
- $pl.show().width(Math.floor(screenWidth * 0.44));
- $pl.height(widgetHeight);
- $("#pl_edit").hide();
- }
-
- function closeTab(id) {
- var curr = $(".active-tab"),
- pane = id ? $(".pl-content[tab-id='" + id + "']") : curr,
- tab = id ? $(".nav.nav-tabs [tab-id='" + id + "']") : $(".nav.nav-tabs .active"),
- toPane = pane.next().length > 0 ? pane.next() : pane.prev(),
- toTab = tab.next().length > 0 ? tab.next() : tab.prev(),
- objId = pane.find(".obj_id").val(),
- pl = id ? pane : $pl;
- delete $openTabs[tab.attr("tab-type") + objId]; // Remove the closed tab from our open tabs array
-
- // Remove the relevant DOM elements (the tab and the tab content)
- tab.remove();
- pl.remove();
-
- if (pane.get(0) == curr.get(0)) { // Closing the current tab, otherwise we don't need to switch tabs
- AIRTIME.showbuilder.switchTab(toPane, toTab);
- }
- }
-
- mod.closeTab = function(id) {
- closeTab(id);
- };
-
- //Purpose of this function is to iterate over all playlist elements
- //and verify whether they can be previewed by the browser or not. If not
- //then the playlist element is greyed out
- mod.validatePlaylistElements = function(){
- $.each($("div .big_play"), function(index, value){
- if ($(value).attr('blockId') === undefined) {
- var mime = $(value).attr("data-mime-type");
- //If mime is undefined it is likely because the file was
- //deleted from the library. This case is handled in mod.onReady()
- if (mime !== undefined) {
- if (isAudioSupported(mime)) {
- $(value).bind("click", openAudioPreview);
- } else {
- $(value).attr("class", "big_play_disabled dark_class");
- $(value).qtip({
- content: $.i18n._("Your browser does not support playing this file type: ")+ mime,
- show: 'mouseover',
- hide: {
- delay: 500,
- fixed: true
- },
- style: {
- border: {
- width: 0,
- radius: 4
- },
- classes: "ui-tooltip-dark ui-tooltip-rounded"
- },
- position: {
- my: "left bottom",
- at: "right center"
- }
- })
- }
- }
- } else {
- if ($(value).attr('blocktype') === 'dynamic') {
- $(value).attr("class", "big_play_disabled dark_class");
- $(value).qtip({
- content: $.i18n._('Dynamic block is not previewable'),
- show: 'mouseover',
- hide: {
- delay: 500,
- fixed: true
- },
- style: {
- border: {
- width: 0,
- radius: 4
- },
- classes: "ui-tooltip-dark ui-tooltip-rounded"
- },
- position: {
- my: "left bottom",
- at: "right center"
- }
- })
- } else {
- $(value).bind("click", openAudioPreview);
- }
- }
- });
- };
-
- //sets events dynamically for playlist entries (each row in the playlist)
- function setPlaylistEntryEvents() {
- $pl.delegate(".spl_sortable .ui-icon-closethick",
- {"click": function(ev){
- var id;
- id = parseInt($(this).attr("id").split("_").pop(), 10);
- AIRTIME.playlist.fnDeleteItems([id]);
- }});
-
- $pl.delegate(".spl_fade_control",
- {"click": openFadeEditor});
-
- $pl.delegate(".spl_cue",
- {"click": openCueEditor});
-
- $pl.delegate(".spl_block_expand",
- {"click": function(ev){
- var id = parseInt($(this).attr("id").split("_").pop(), 10);
- var blockId = parseInt($(this).attr("blockId"), 10);
- if ($(this).hasClass('close')) {
- var sUrl = baseUrl+"new-playlist/get-block-info";
- mod.disableUI();
- $.post(sUrl, {format:"json", id:blockId}, function(data){
- $html = "";
- var isStatic = data.isStatic;
- delete data.type;
- if (isStatic) {
- $.each(data, function(index, ele){
- if (ele.track_title !== undefined) {
- if (ele.creator === null) {
- ele.creator = "";
- }
- if (ele.track_title === null) {
- ele.track_title = "";
- }
- $html += "
" +
- ""+ele.track_title+" - " +
- ""+ele.creator+" " +
- ""+ele.length+" " +
- " ";
- }
- })
- } else {
- for (var key in data.crit){
- $.each(data.crit[key], function(index, ele){
- var extra = (ele['extra']==null)?"":"- "+ele['extra'];
- $html += "
" +
- ""+ele['display_name']+" " +
- ""+ele['display_modifier']+" " +
- ""+ele['value']+" " +
- ""+extra+" " +
- " ";
- });
- }
- $html += "
"+$.i18n._("Limit to: ")+data.limit.value+" "+data.limit.display_modifier+" ";
- }
- $pl.find("#block_"+id+"_info").html($html).show();
- mod.enableUI();
- });
- $(this).removeClass('close');
- } else {
- $pl.find("#block_"+id+"_info").html("").hide();
- $(this).addClass('close');
- }
- }});
- }
-
- //sets events dynamically for the cue editor.
- function setCueEvents() {
- var temp = $('.active-tab .spl_sortable');
- temp.on("focusout", ".spl_cue_in span", changeCueIn);
- temp.on("keydown", ".spl_cue_in span", submitOnEnter);
-
- temp.on("focusout", ".spl_cue_out span", changeCueOut);
- temp.on("keydown", ".spl_cue_out span", submitOnEnter);
-
- //remove show waveform buttons since web audio api is not supported.
- if (!(window.AudioContext || window.webkitAudioContext)) {
- temp.find('.pl-waveform-cues-btn')
- .parent()
- .html($.i18n._("Waveform features are available in a browser supporting the Web Audio API"));
- }
- }
-
- //sets events dynamically for the fade editor.
- function setFadeEvents() {
- var temp = $('.active-tab .spl_sortable');
- temp.on("focusout", ".spl_fade_in span", changeFadeIn);
- temp.on("keydown", ".spl_fade_in span", submitOnEnter);
-
- temp.on("focusout", ".spl_fade_out span", changeFadeOut);
- temp.on("keydown", ".spl_fade_out span", submitOnEnter);
-
- //remove show waveform buttons since web audio api is not supported.
- if (!(window.AudioContext || window.webkitAudioContext)) {
- temp.find('.pl-waveform-fades-btn')
- .parent()
- .html($.i18n._("Waveform features are available in a browser supporting the Web Audio API"));
- }
- }
-
- function initialEvents() {
- var cachedDescription;
-
- //main playlist fades events
- $pl.on("click", "#spl_crossfade", function() {
- var lastMod = getModified(),
- type = $pl.find('.obj_type').val();
-
- if ($(this).hasClass("ui-state-active")) {
- $(this).removeClass("ui-state-active");
- $pl.find("#crossfade_main").hide();
- }
- else {
- $(this).addClass("ui-state-active");
-
- var url = baseUrl+'new-playlist/get-playlist-fades';
- $.post(url,
- {format: "json", modified: lastMod, type: type},
- function(json){
- if (json.error !== undefined){
- playlistError(json);
- }
- else {
- var fadeIn = $pl.find("span.spl_main_fade_in");
- var fadeOut = $pl.find("span.spl_main_fade_out");
- if (json.fadeIn == null) {
- fadeIn.parent().prev().hide();
- fadeIn.hide();
- } else {
- fadeIn.parent().prev().show();
- fadeIn.show();
- fadeIn.empty().append(json.fadeIn);
- }
- if (json.fadeOut == null) {
- fadeOut.parent().prev().hide();
- fadeOut.hide();
- } else {
- fadeOut.parent().prev().show();
- fadeOut.show();
- fadeOut.empty().append(json.fadeOut);
- }
- if (json.fadeIn != null || json.fadeOut != null) {
- $pl.find("#crossfade_main").show();
- }
- }
- });
- }
- });
-
- $pl.on("blur", "span.spl_main_fade_in", function(event){
- event.stopPropagation();
-
- var url = baseUrl+"new-playlist/set-playlist-fades",
- span = $(this),
- fadeIn = $.trim(span.text()),
- lastMod = getModified(),
- type = $pl.find('.obj_type').val();
-
- if (!isFadeValid(fadeIn)){
- showError(span, $.i18n._("please put in a time in seconds '00 (.0)'"));
- return;
- }
-
- $.post(url,
- {format: "json", fadeIn: fadeIn, modified: lastMod, type: type},
- function(json){
- hideError(span);
- if (json.modified !== undefined) {
- setModified(json.modified);
- }
- });
- });
-
- $pl.on("blur", "span.spl_main_fade_out", function(event){
- event.stopPropagation();
-
- var url = baseUrl+"new-playlist/set-playlist-fades",
- span = $(this),
- fadeOut = $.trim(span.text()),
- lastMod = getModified(),
- type = $pl.find('.obj_type').val();
-
- if (!isFadeValid(fadeOut)){
- showError(span, $.i18n._("please put in a time in seconds '00 (.0)'"));
- return;
- }
-
- $.post(url,
- {format: "json", fadeOut: fadeOut, modified: lastMod, type: type},
- function(json){
- hideError(span);
- if (json.modified !== undefined) {
- setModified(json.modified);
- }
- });
- });
-
- $pl.on("keydown", "span.spl_main_fade_in, span.spl_main_fade_out", submitOnEnter);
-
- $pl.on("click", "#crossfade_main > .ui-icon-closethick", function(){
- $pl.find("#spl_crossfade").removeClass("ui-state-active");
- $pl.find("#crossfade_main").hide();
- });
- //end main playlist fades.
-
- //edit playlist name event
- $pl.on("keydown", ".playlist_name_display", submitOnEnter);
- $pl.on("blur", ".playlist_name_display", editName);
-
- //edit playlist description events
- $pl.on("click", "legend", function(){
- var $fs = $(this).parents("fieldset");
-
- if ($fs.hasClass("closed")) {
- cachedDescription = $fs.find("textarea").val();
- $fs.removeClass("closed");
- }
- else {
- $fs.addClass("closed");
- }
- });
-
-
- $pl.on("click", 'button[id="playlist_shuffle_button"]', function(){
- obj_id = $pl.find('.obj_id').val();
- url = baseUrl+"new-playlist/shuffle";
- enableLoadingIcon();
- $.post(url, {format: "json", obj_id: obj_id}, function(json){
-
- if (json.error !== undefined) {
- alert(json.error);
- }
- if (json.html !== undefined) {
- closeTab();
- openPlaylist(json);
- }
- if (json.result == "0") {
- $pl.find('.success').text($.i18n._('Playlist shuffled'));
- $pl.find('.success').show();
- }
- disableLoadingIcon();
- setTimeout(removeSuccessMsg, 5000);
- });
- });
-
- $pl.find("#webstream_save").on("click", function(){
- //get all fields and POST to server
- //description
- //stream url
- //default_length
- //playlist name
- var id = $pl.find(".obj_id").attr("value");
- var description = $pl.find("#description").val();
- var streamurl = $pl.find("#streamurl-element input").val();
- var length = $pl.find("#streamlength-element input").val();
- var name = $pl.find(".playlist_name_display").text();
-
- //hide any previous errors (if any)
- $(".side_playlist.active-tab .errors").empty().hide();
-
- var url = baseUrl+'new-webstream/save';
- $.post(url,
- {format: "json", id:id, description: description, url:streamurl, length: length, name: name},
- function(json){
- if (json.analysis){
- for (var s in json.analysis){
- var field = json.analysis[s];
-
- if (!field[0]) {
- var elemId = "#"+s+"-error";
- var $div = $(".side_playlist.active-tab " + elemId).text(field[1]).show();
- }
- }
- } else {
- var $status = $(".side_playlist.active-tab .status");
- $status.html(json.statusMessage);
- $status.show();
- setTimeout(function(){$status.fadeOut("slow", function(){$status.empty()})}, 5000);
-
- var $ws_id = $(".active-tab .obj_id");
- $ws_id.attr("value", json.streamId);
-
- var $ws_id = $("#ws_delete");
- $ws_id.show();
-
-
- var length = $(".side_playlist.active-tab .ws_length");
- length.text(json.length);
-
- //redraw the library to show the new webstream
- redrawLib();
- }
-
- });
-
-
- });
-
- $pl.find("#webstream_cancel, #cancel_button").on("click", function() {
- var tabId = $pl.attr("tab-id");
- $("li[tab-id=" + tabId + "] .lib_pl_close").click();
- });
-
- $lib.on("click", "#pl_edit", function() {
- openPlaylistPanel();
- $.ajax({
- url : baseUrl+"usersettings/set-library-screen-settings",
- type : "POST",
- data : {
- settings : {
- playlist : true
- },
- format : "json"
- },
- dataType : "json"
- });
- });
-
- // Unbind so each tab is only handled by its own close button
- $(".lib_pl_close").unbind().click(function(e) {
- e.preventDefault();
- e.stopPropagation();
-
- $(this).unbind("click"); // Prevent repeated clicks in quick succession from closing multiple tabs
-
- var tabId = $(this).closest("li").attr("tab-id");
- //AIRTIME.showbuilder.switchTab($("#pl-tab-content-" + tabId), $("#pl-tab-" + tabId));
- //$pl.hide();
-
- // We need to update the text on the add button
- AIRTIME.library.checkAddButton();
- // We also need to run the draw callback to update how dragged items are drawn
- AIRTIME.library.fnDrawCallback();
-
- var name = $pl.find('.playlist_name_display').text().trim();
-
- if ((name == "Untitled Playlist"
- || name == "Untitled Smart Block")
- && $pl.find(".spl_sortable .spl_empty").length == 1) {
- mod.fnDelete(undefined, tabId);
- } else {
- closeTab(tabId);
- }
-
- $.ajax( {
- url : baseUrl+"usersettings/set-library-screen-settings",
- type : "POST",
- data : {
- settings : {
- playlist : false
- },
- format : "json"
- },
- dataType : "json"
- });
- });
-
- $pl.on("click", "#save_button", function(event) {
- /* Smart blocks: get name, description, and criteria
- * Playlists: get name, description
- */
- var criteria = $pl.find('form').serializeArray(),
- block_name = $pl.find('.playlist_name_display').text(),
- block_desc = $pl.find('textarea[name="description"]').val(),
- save_action = baseUrl+'new-playlist/save',
- obj_id = $pl.find(".obj_id").val(),
- obj_type = $pl.find('.obj_type').val(),
- lastMod = getModified(),
- dt = $('table[id="library_display"]').dataTable();
- enableLoadingIcon();
- $.post(save_action,
- {format: "json", data: criteria, name: block_name, description: block_desc, obj_id: obj_id, type: obj_type, modified: lastMod},
- function(json){
- if (json.error !== undefined) {
- alert(json.error);
- }
- if (json.html !== undefined) {
- closeTab();
- openPlaylist(json);
- }
- setModified(json.modified);
- if (obj_type == "block") {
- callback(json, "save");
- } else {
- $('.success').text($.i18n._('Playlist saved'));
- $('.success').show();
- setTimeout(removeSuccessMsg, 5000);
- dt.fnStandingRedraw();
- }
- setFadeIcon();
- disableLoadingIcon();
- }
- );
- });
-
- $pl.find("#pl-bl-clear-content").unbind().on("click", function(event) {
- var sUrl = baseUrl+"new-playlist/empty-content",
- oData = {};
- playlistRequest(sUrl, oData);
- });
- }
-
- function setUpPlaylist() {
- var sortableConf;
-
- sortableConf = (function(){
- var aReceiveItems,
- html,
- fnReceive,
- fnUpdate;
-
- fnReceive = function(event, ui) {
- var aItems = [],
- aSelected,
- i,
- length;
-
- AIRTIME.library.addToChosen(ui.item);
-
- //filter out anything that isn't an audiofile.
- aSelected = AIRTIME.library.getSelectedData();
-
- for (i = 0, length = aSelected.length; i < length; i++) {
- aItems.push(new Array(aSelected[i].id, aSelected[i].ftype));
- }
-
- aReceiveItems = aItems;
- html = ui.helper.html();
-
- AIRTIME.library.removeFromChosen(ui.item);
- };
-
- fnUpdate = function(event, ui) {
- var prev,
- aItems = [],
- iAfter,
- sAddType;
-
- prev = ui.item.prev();
- if (prev.hasClass("spl_empty") || prev.length === 0) {
- iAfter = undefined;
- sAddType = 'before';
- }
- else {
- iAfter = parseInt(prev.attr("id").split("_").pop(), 10);
- sAddType = 'after';
- }
-
- //item was dragged in from library datatable
- if (aReceiveItems !== undefined) {
-
- $pl.find("tr.ui-draggable")
- .after(html)
- .empty();
-
- aItems = aReceiveItems;
- aReceiveItems = undefined;
-
- AIRTIME.playlist.fnAddItems(aItems, iAfter, sAddType);
- }
- //item was reordered.
- else {
- aItems.push(parseInt(ui.item.attr("id").split("_").pop(), 10));
- AIRTIME.playlist.fnMoveItems(aItems, iAfter);
- }
- };
-
- return {
- items: 'li',
- //hack taken from
- //http://stackoverflow.com/questions/2150002/jquery-ui-sortable-how-can-i-change-the-appearance-of-the-placeholder-object
- placeholder: {
- element: function(currentItem) {
- return $('
')[0];
- },
- update: function(container, p) {
- return;
- }
- },
- forcePlaceholderSize: true,
- //handle: 'div.list-item-container',
- start: function(event, ui) {
- ui.placeholder.height(56);
- },
- axis: "y",
- containment: "document",
- receive: fnReceive,
- update: fnUpdate
- };
- }());
-
- $pl.find(".spl_sortable").sortable(sortableConf);
- AIRTIME.playlist.validatePlaylistElements();
- }
-
- mod.fnNew = function() {
- var url = baseUrl+'new-playlist/new';
-
- stopAudioPreview();
-
- $.post(url,
- {format: "json", type: 'playlist'},
- function(json){
- openPlaylist(json);
- redrawLib();
- });
- };
-
- mod.fnWsNew = function() {
- var url = baseUrl+'new-webstream/new';
-
- stopAudioPreview();
-
- $.post(url,
- {format: "json"},
- function(json){
- openPlaylist(json);
- redrawLib();
- });
- };
-
-
- mod.fnNewBlock = function() {
- var url = baseUrl+'new-playlist/new';
-
- stopAudioPreview();
-
- $.post(url,
- {format: "json", type: 'block'},
- function(json){
- openPlaylist(json);
- redrawLib();
- });
- };
-
- mod.fileMdEdit = function(json) {
- openFileMdEditor(json);
- };
-
- mod.fnEdit = function(id, type, url) {
- //openPlaylistPanel();
- stopAudioPreview();
-
- $.post(url,
- {format: "json", id: id, type: type},
- function(json){
- openPlaylist(json);
- redrawLib();
- });
- };
-
-
- mod.fnDelete = function(plid, tabId) {
- var url, id, lastMod, type, pl = (tabId === undefined) ? $pl : $('#pl-tab-content-' + tabId);
-
- stopAudioPreview();
- id = (plid === undefined) ? getId() : plid;
- lastMod = getModified();
- type = pl.find('.obj_type').val();
- url = baseUrl+'new-playlist/delete';
-
- $.post(url,
- {format: "json", ids: id, modified: lastMod, type: type},
- function(json) {
- closeTab(tabId);
- redrawLib();
- });
- };
-
- mod.fnWsDelete = function(wsid) {
- var url, id, lastMod;
-
- stopAudioPreview();
- id = (wsid === undefined) ? getId() : wsid;
- lastMod = getModified();
- type = $pl.find('.obj_type').val();
- url = baseUrl+'new-webstream/delete';
-
- $.post(url,
- {format: "json", ids: id, modified: lastMod, type: type},
- function(json){
- openPlaylist(json);
- redrawLib();
- });
- };
-
- mod.disableUI = function() {
-
- $lib.block({
- message: "",
- theme: true,
- applyPlatformOpacityRules: false
- });
-
- $pl.block({
- message: "",
- theme: true,
- applyPlatformOpacityRules: false
- });
- };
-
- mod.fnOpenPlaylist = function(json) {
- openPlaylist(json);
- };
-
- mod.enableUI = function() {
- $lib.unblock();
- $pl.unblock();
-
- setupUI();
- };
-
- function playlistResponse(json){
- if (json.error !== undefined) {
- playlistError(json);
- }
- else {
- setPlaylistContent(json);
- setFadeIcon();
- }
-
- mod.enableUI();
- }
-
- function playlistRequest(sUrl, oData) {
- var lastMod,
- obj_type = $pl.find('.obj_type').val();
-
- mod.disableUI();
-
- lastMod = getModified();
-
- oData["modified"] = lastMod;
- oData["obj_type"] = obj_type;
- oData["format"] = "json";
-
- $.post(
- sUrl,
- oData,
- playlistResponse
- );
- }
-
- mod.fnAddItems = function(aItems, iAfter, sAddType) {
- AIRTIME.library.selectNone();
- var sUrl = baseUrl+"new-playlist/add-items";
- oData = {"aItems": aItems, "afterItem": iAfter, "type": sAddType};
- playlistRequest(sUrl, oData);
- };
-
- mod.fnMoveItems = function(aIds, iAfter) {
- var sUrl = baseUrl+"new-playlist/move-items",
- oData = {"ids": aIds, "afterItem": iAfter};
-
- playlistRequest(sUrl, oData);
- };
-
- mod.fnDeleteItems = function(aItems) {
- var sUrl = baseUrl+"new-playlist/delete-items",
- oData = {"ids": aItems};
-
- playlistRequest(sUrl, oData);
- };
-
- mod.showFadesWaveform = function(e) {
- var $el = $(e.target),
- $parent = $el.parents("dl"),
- $li = $el.parents("li"),
- $fadeOut = $parent.find(".spl_fade_out"),
- $fadeIn = $parent.find(".spl_fade_in"),
- $html = $($("#tmpl-pl-fades").html()),
- tracks = [],
- dim = AIRTIME.utilities.findViewportDimensions(),
- playlistEditor,
- id1, id2,
- id = $li.attr("unqid");
-
-
- function removeDialog() {
- playlistEditor.stop();
-
- $html.dialog("destroy");
- $html.remove();
- }
-
- if ($fadeOut.length > 0) {
-
- tracks.push({
- src: $fadeOut.data("fadeout"),
- cuein: $fadeOut.data("cuein"),
- cueout: $fadeOut.data("cueout"),
- fades: [{
- shape: $fadeOut.data("type"),
- type: "FadeOut",
- end: $fadeOut.data("cueout") - $fadeOut.data("cuein"),
- start: $fadeOut.data("cueout") - $fadeOut.data("cuein") - $fadeOut.data("length")
- }],
- states: {
- 'fadein': false,
- 'shift': false
- }
- });
-
- id1 = $fadeOut.data("item");
- }
-
- if ($fadeIn.length > 0) {
-
- tracks.push({
- src: $fadeIn.data("fadein"),
- start: $fadeIn.data("offset"),
- cuein: $fadeIn.data("cuein"),
- cueout: $fadeIn.data("cueout"),
- fades: [{
- shape: $fadeIn.data("type"),
- type: "FadeIn",
- end: $fadeIn.data("length"),
- start: 0
- }],
- states: {
- 'fadeout': false,
- 'shift': false
- }
- });
-
- id2 = $fadeIn.data("item");
- }
-
- //set the first track to not be moveable (might only be one track depending on what follows)
- //tracks[0].states["shift"] = false;
-
- $html.dialog({
- modal: true,
- title: $.i18n._("Fade Editor"),
- show: 'clip',
- hide: 'clip',
- width: dim.width - 100,
- height: 350,
- buttons: [
- {text: $.i18n._("Cancel"), class: "btn btn-small", click: removeDialog},
- {text: $.i18n._("Save"), class: "btn btn-small btn-inverse", click: function() {
- var json = playlistEditor.getJson(),
- offset,
- fadeIn, fadeOut,
- fade;
-
- playlistEditor.stop();
-
- if (json.length === 0)
- {
- id1 = undefined;
- id2 = undefined;
- }
- else if (json.length === 1) {
-
- fade = json[0]["fades"][0];
-
- if (fade["type"] === "FadeOut") {
- fadeOut = fade["end"] - fade["start"];
- id2 = undefined; //incase of track decode error.
- }
- else {
- fadeIn = fade["end"] - fade["start"];
- id1 = undefined; //incase of track decode error.
- }
- }
- else {
-
- offset = json[0]["end"] - json[1]["start"];
-
- fade = json[0]["fades"][0];
- fadeOut = fade["end"] - fade["start"];
-
- fade = json[1]["fades"][0];
- fadeIn = fade["end"] - fade["start"];
- }
-
- fadeIn = (fadeIn === undefined) ? undefined : fadeIn.toFixed(1);
- fadeOut = (fadeOut === undefined) ? undefined : fadeOut.toFixed(1);
-
- changeCrossfade($html, id1, id2, fadeIn, fadeOut, offset, id);
- }}
- ],
- open: function (event, ui) {
-
- var config = new Config({
- resolution: 15000,
- state: "cursor",
- mono: true,
- timescale: true,
- waveHeight: 80,
- container: $html[0],
- UITheme: "jQueryUI",
- timeFormat: 'hh:mm:ss.u'
- });
-
- playlistEditor = new PlaylistEditor();
- playlistEditor.setConfig(config);
- playlistEditor.init(tracks);
- },
- close: removeDialog,
- resizeStop: function(event, ui) {
- playlistEditor.resize();
- }
- });
- };
-
- mod.showCuesWaveform = function(e) {
- var $el = $(e.target),
- $li = $el.parents("li"),
- id = $li.attr("unqid"),
- $parent = $el.parent(),
- uri = $parent.data("uri"),
- $html = $($("#tmpl-pl-cues").html()),
- cueIn = $li.find('.spl_cue_in').data("cueIn"),
- cueOut = $li.find('.spl_cue_out').data("cueOut"),
- cueInSec = $li.find('.spl_cue_in').data("cueSec"),
- cueOutSec = $li.find('.spl_cue_out').data("cueSec"),
- tracks = [{
- src: uri,
- selected: {
- start: cueInSec,
- end: cueOutSec
- }
- }],
- dim = AIRTIME.utilities.findViewportDimensions(),
- playlistEditor;
-
- function removeDialog() {
- playlistEditor.stop();
-
- $html.dialog("destroy");
- $html.remove();
- }
-
- $html.find('.editor-cue-in').html(cueIn);
- $html.find('.editor-cue-out').html(cueOut);
-
- $html.on("click", ".set-cue-in", function(e) {
- var cueIn = $html.find('.audio_start').val();
-
- $html.find('.editor-cue-in').html(cueIn);
- });
-
- $html.on("click", ".set-cue-out", function(e) {
- var cueOut = $html.find('.audio_end').val();
-
- $html.find('.editor-cue-out').html(cueOut);
- });
-
- $html.dialog({
- modal: true,
- title: $.i18n._("Cue Editor"),
- show: 'clip',
- hide: 'clip',
- width: dim.width - 100,
- height: 325,
- buttons: [
- {text: $.i18n._("Cancel"), class: "btn btn-small", click: removeDialog},
- {text: $.i18n._("Save"), class: "btn btn-small btn-inverse", click: function() {
- var cueIn = $html.find('.editor-cue-in').html(),
- cueOut = $html.find('.editor-cue-out').html();
-
- playlistEditor.stop();
-
- changeCues($html, id, cueIn, cueOut);
- }}
- ],
- open: function (event, ui) {
-
- var config = new Config({
- resolution: 15000,
- mono: true,
- timescale: true,
- waveHeight: 80,
- container: $html[0],
- UITheme: "jQueryUI",
- timeFormat: 'hh:mm:ss.u'
- });
-
- playlistEditor = new PlaylistEditor();
- playlistEditor.setConfig(config);
- playlistEditor.init(tracks);
- },
- close: removeDialog,
- resizeStop: function(event, ui) {
- playlistEditor.resize();
- }
- });
- };
-
- mod.setAsActive = function() {
- $pl = $(".active-tab");
- };
-
- mod.init = function() {
- AIRTIME.playlist.setAsActive();
-
- //$pl.delegate("#spl_delete", {"click": function(ev){
- // AIRTIME.playlist.fnDelete();
- //}});
- //
- //$pl.delegate("#ws_delete", {"click": function(ev){
- // AIRTIME.playlist.fnWsDelete();
- //}});
-
- $pl.delegate(".pl-waveform-cues-btn", {"click": function(ev){
- AIRTIME.playlist.showCuesWaveform(ev);
- }});
-
- $pl.delegate(".pl-waveform-fades-btn", {"click": function(ev){
- AIRTIME.playlist.showFadesWaveform(ev);
- }});
-
- setPlaylistEntryEvents();
- setCueEvents();
- setFadeEvents();
- setFadeIcon();
-
- initialEvents();
- setUpPlaylist();
-
- $pl.find(".ui-icon-alert").qtip({
- content: {
- text: sprintf($.i18n._("%s is unsure about the status of this file. This can happen when the file is on a remote drive that is unaccessible or the file is in a directory that isn't 'watched' anymore."), PRODUCT_NAME)
- },
- position: {
- adjust: {
- resize: true,
- method: "flip flip"
- },
- at: "right center",
- my: "left top",
- viewport: $(window)
- },
- style: {
- classes: "ui-tooltip-dark"
- },
- show: 'mouseover',
- hide: 'mouseout'
- });
- };
-
- mod.onReady = function() {
- $lib = $("#library_content");
-
- $('#new-playlist').live('click', function(){AIRTIME.playlist.fnNew();});
- $('#new-smart-block').live('click', function(){AIRTIME.playlist.fnNewBlock();});
- $('#new-webstream').live('click', function(){AIRTIME.playlist.fnWsNew();});
-
- AIRTIME.playlist.init();
- };
-
- mod.onResize = function() {
- var h = $(".panel-header .nav").height();
- $(".pl-content").css("margin-top", h + 5); // 8px extra for padding
- $("#show_builder_table_wrapper").css("top", h + 5);
- };
-
- return AIRTIME;
-
-}(AIRTIME || {}));
-
-
-$(document).ready(AIRTIME.playlist.onReady);
-$(window).resize(AIRTIME.playlist.onResize);
diff --git a/airtime_mvc/public/js/airtime/library/events/_library_showbuilder.js b/airtime_mvc/public/js/airtime/library/events/_library_showbuilder.js
deleted file mode 100644
index 4b5a7a718..000000000
--- a/airtime_mvc/public/js/airtime/library/events/_library_showbuilder.js
+++ /dev/null
@@ -1,350 +0,0 @@
-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_table").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 = $('.active-tab .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('
');
- aData.image = '
';
- }
- } 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();
-
- var cb = $('th.library_checkbox');
- if (cb.find("input").length == 0) {
- cb.append("
");
- }
-
- if ($("#show_builder_table").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 = $('
').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',
- //cursorAt: {
- // top: 30,
- // right: 10
- //},
- distance: 25, // min-distance for dragging
- 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,
- width = $(this).width(), height = 55;
-
- // 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 = $('
').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',
- //cursorAt: {
- // top: 30,
- // right: 10
- //},
- distance: 25, // min-distance for dragging
- connectToSortable: '.active-tab .spl_sortable'
- });
- }
- };
-
- mod.dblClickAdd = function(data, type) {
- var i, length, temp, aMediaIds = [], aSchedIds = [], aData = [];
-
- if ($("#show_builder_table").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 ($('.active-tab .obj_type').val() == 'playlist'
- || $('.active-tab .obj_type').val() == 'block') {
- AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
- }
- }
- };
-
- function addToCurrentOrNext(arr) {
- var el;
- // Add to the end of the current or next show by getting the footer
- el = $(".sb-footer.sb-future:first");
- var data = el.prev().data("aData");
-
- if (data === undefined) {
- alert($.i18n._("Cannot schedule outside a show.\nTry creating a show first."));
- 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();
- 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;
- }
-
- var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], 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 files/playlists.
- $("#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 {
- 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');
- }
- }
- });
-
- // 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");
-
- 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 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+'new-playlist/edit');
- AIRTIME.playlist.validatePlaylistElements();
- } else if (data.ftype === "stream") {
- AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'new-webstream/edit');
- }
- });
- });
-
- mod.createToolbarDropDown();
- };
-
- return AIRTIME;
-
-}(AIRTIME || {}));
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 8dcfd651b..9c17fa001 100644
--- a/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js
+++ b/airtime_mvc/public/js/airtime/library/events/library_showbuilder.js
@@ -11,7 +11,7 @@ var AIRTIME = (function(AIRTIME) {
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.
- cursorText = (window.location.href.toLowerCase().indexOf("schedule") > -1) ? $.i18n._('Add to show') : $.i18n._('Add to next show');
+ 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) {
@@ -22,18 +22,27 @@ var AIRTIME = (function(AIRTIME) {
check = false;
}
- if (check === true) {
+ if (check) {
AIRTIME.button.enableButton("btn-group #library-plus", false);
} else {
AIRTIME.button.disableButton("btn-group #library-plus", false);
}
- if ($cursor.length !== 0) {
- cursorText = $.i18n._('Add before selected items');
- } else if (current.length !== 0) {
- cursorText = $.i18n._('Add to current show');
+ if ($("#show_builder_table").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 = $('.active-tab .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'), ' '+ cursorText);
+ AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), btnText);
};
mod.fnRowCallback = function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
@@ -53,7 +62,7 @@ var AIRTIME = (function(AIRTIME) {
}
$nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen",
- "timeline");
+ "timeline");
};
mod.fnDrawCallback = function fnLibDrawCallback() {
@@ -61,15 +70,20 @@ var AIRTIME = (function(AIRTIME) {
mod.redrawChosen();
mod.checkToolBarIcons();
- $('#library_display tr.lib-audio, tr.lib-pl, tr.lib-stream')
- .draggable(
+ var cb = $('th.library_checkbox');
+ if (cb.find("input").length == 0) {
+ cb.append("
");
+ }
+
+ if ($("#show_builder_table").is(":visible")) {
+ $('#library_display tr.lib-audio, tr.lib-pl, tr.lib-stream')
+ .draggable(
{
- helper : function() {
+ 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;
+ .getChosenItemsLength(), container, thead = $("#show_builder_table thead"), colspan = thead
+ .find("th").length, width = $el.width(), message;
// dragging an element that has an unselected
// checkbox.
@@ -84,73 +98,123 @@ var AIRTIME = (function(AIRTIME) {
}
container = $('
').attr('id',
- 'draggingContainer').append('
')
- .find("tr").append('
').find("td")
- .attr("colspan", colspan).width(width)
- .addClass("ui-state-highlight").append(
- message).end().end();
+ 'draggingContainer').append('
')
+ .find("tr").append('
').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'
+ cursor: 'pointer',
+ //cursorAt: {
+ // top: 30,
+ // right: 10
+ //},
+ distance: 25, // min-distance for dragging
+ 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,
+ width = $(this).width(), height = 55;
+
+ // 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 = $('
').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',
+ //cursorAt: {
+ // top: 30,
+ // right: 10
+ //},
+ distance: 25, // min-distance for dragging
+ connectToSortable: '.active-tab .spl_sortable'
+ });
+ }
};
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.sb-selected").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++) {
- temp = aData[i];
- aSchedIds.push( {
- "id" : temp.id,
- "instance" : temp.instance,
- "timestamp" : temp.timestamp
+ if ($("#show_builder_table").is(":visible")) {
+ // process selected files/playlists.
+ aMediaIds.push({
+ "id": data.id,
+ "type": type
});
- }
- if (aSchedIds.length == 0) {
- if (!addToCurrentOrNext(aSchedIds)) {
- return;
+ $("#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 ($('.active-tab .obj_type').val() == 'playlist'
+ || $('.active-tab .obj_type').val() == 'block') {
+ AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after');
}
}
-
- AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
};
function addToCurrentOrNext(arr) {
var el;
- // Get the show instance id of the first non-data row (id = 0)
- // The second last row in the table with that instance id is the
- // last schedule item for the first show. (This is important for
- // the Now Playing screen if multiple shows are in view).
- el = $("[si_id="+$("#0").attr("si_id")+"]");
- var temp = el.eq(-2).data("aData");
+ // Add to the end of the current or next show by getting the footer
+ el = $(".sb-footer.sb-future:first");
+ var data = el.prev().data("aData");
- if (temp === undefined) {
- alert($.i18n._("Cannot schedule outside a show."));
+ if (data === undefined) {
+ alert($.i18n._("Cannot schedule outside a show.\nTry creating a show first."));
return false;
}
arr.push({
- "id" : temp.id,
- "instance" : temp.instance,
- "timestamp" : temp.timestamp
+ "id" : data.id,
+ "instance" : data.instance,
+ "timestamp" : data.timestamp
});
if (!isInView(el)) {
@@ -159,57 +223,72 @@ var AIRTIME = (function(AIRTIME) {
}, 0);
}
- return arr;
+ return true;
}
mod.setupLibraryToolbar = function() {
var $toolbar = $(".lib-content .fg-toolbar:first");
mod.createToolbarButtons();
+ mod.moveSearchBarToHeader();
$toolbar.append($menu);
// add to timeline button
$toolbar
- .find('.icon-plus').parent()
+ .find('#library-plus')
.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).prev().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);
+ var selected = AIRTIME.library.getSelectedData(), data, i, length, temp, aMediaIds = [], aSchedIds = [], 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 files/playlists.
+ $("#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 {
+ 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');
+ }
}
-
- AIRTIME.showbuilder.fnAdd(aMediaIds, aSchedIds);
});
// delete from library.
@@ -222,6 +301,47 @@ var AIRTIME = (function(AIRTIME) {
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");
+
+ 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 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();
};
diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js
index cfa4fe1ec..e80f763de 100644
--- a/airtime_mvc/public/js/airtime/library/library.js
+++ b/airtime_mvc/public/js/airtime/library/library.js
@@ -7,7 +7,8 @@ var AIRTIME = (function(AIRTIME) {
LIB_SELECTED_CLASS = "lib-selected",
chosenItems = {},
visibleChosenItems = {},
- $previouslySelected;
+ $previouslySelected,
+ flagForDeselection = false;
// we need to know whether the criteria value is string or
@@ -51,33 +52,32 @@ var AIRTIME = (function(AIRTIME) {
"info_url" : "s",
"replay_gain" : "n"
};
-
+
if (AIRTIME.library === undefined) {
AIRTIME.library = {};
}
mod = AIRTIME.library;
-
+
mod.getChosenItemsLength = function(){
var cItem,
selected,
$trs;
-
// Get visible items and check if any chosenItems are visible
- $trs = $libTable.find("tbody input:checkbox").parents("tr");
+ $trs = $libTable.find("tr");
$trs.each(function(i){
for (cItem in chosenItems) {
if (cItem === $(this).attr("id")) {
visibleChosenItems[cItem] = $(this).data('aData');
}
- }
+ }
});
-
+
selected = Object.keys(visibleChosenItems).length;
visibleChosenItems = {};
return selected;
};
-
+
mod.getChosenAudioFilesLength = function(){
// var files = Object.keys(chosenItems),
var files,
@@ -86,21 +86,21 @@ var AIRTIME = (function(AIRTIME) {
i, length,
count = 0,
reAudio=/^(au|st|pl|bl)/ ;
-
+
// Get visible items and check if any chosenItems are visible
- $trs = $libTable.find("tbody input:checkbox").parents("tr");
+ $trs = $libTable.find("tr");
$trs.each(function(i){
for (cItem in chosenItems) {
if (cItem === $(this).attr("id")) {
visibleChosenItems[cItem] = $(this).data('aData');
}
- }
+ }
});
-
+
files = Object.keys(visibleChosenItems);
-
+
for (i = 0, length = files.length; i < length; i++) {
-
+
if (files[i].search(reAudio) !== -1) {
count++;
}
@@ -108,43 +108,64 @@ var AIRTIME = (function(AIRTIME) {
visibleChosenItems = {};
return count;
};
-
+
mod.changeAddButtonText = function($button, btnText) {
$button.text(btnText);
};
-
- mod.createToolbarButtons = function() {
+
+ mod.createToolbarButtons = function () {
$menu = $("
");
$menu
+ .append("
" +
+ "" +
+ " " +
+ "" + $.i18n._('New') + " " +
+ " " +
+ "
")
+ .append("
" +
+ "" +
+ " " +
+ "" + $.i18n._('Edit') + " " +
+ " " +
+ "
")
+
.append("
" +
- "" +
- $.i18n._("Select")+" " +
- " " +
- "" +
- "
")
+ "
" +
+ " " +
+ " " +
+ " " +
+ "
")
+ .append("
" +
+ "" +
+ " " +
+ "" + $.i18n._('Delete') + " " +
+ " " +
+ "
")
.append("
" +
- "" +
- " " +
- " " +
- " " +
- "
")
- .append("
" +
- "" +
- " " +
- " " +
- "
");
+ "
" +
+ $.i18n._("Select") + " " +
+ " " +
+ "" +
+ "
");
};
-
+
+ mod.moveSearchBarToHeader = function() {
+ $("#library_display_filter").appendTo("#library_content > .panel-header");
+ $("#advanced_search").click(function(e) {
+ e.stopPropagation();
+ });
+ };
+
mod.createToolbarDropDown = function() {
$('#sb-select-page').click(function(){mod.selectCurrentPage();});
$('#sb-dselect-page').click(function(){mod.deselectCurrentPage();});
$('#sb-dselect-all').click(function(){mod.selectNone();});
};
-
+
mod.checkDeleteButton = function() {
var selected = mod.getChosenItemsLength(),
check = false;
@@ -152,7 +173,7 @@ var AIRTIME = (function(AIRTIME) {
if (selected !== 0) {
check = true;
}
-
+
if (check === true) {
AIRTIME.button.enableButton("btn-group #sb-trash", false);
}
@@ -160,31 +181,64 @@ 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.checkEditButton();
+ AIRTIME.library.checkNewButton();
};
-
+
mod.getSelectedData = function() {
var id,
data = [],
cItem,
$trs;
-
+
$.fn.reverse = [].reverse;
-
+
// Get visible items and check if any chosenItems are visible
- $trs = $libTable.find("tbody input:checkbox").parents("tr").reverse();
+ $trs = $libTable.find("tr").reverse();
$trs.each(function(i){
for (cItem in chosenItems) {
if (cItem === $(this).attr("id")) {
visibleChosenItems[cItem] = $(this).data('aData');
}
- }
+ }
});
-
+
for (id in visibleChosenItems) {
if (visibleChosenItems.hasOwnProperty(id)) {
data.push(visibleChosenItems[id]);
@@ -193,73 +247,79 @@ var AIRTIME = (function(AIRTIME) {
visibleChosenItems = {};
return data;
};
-
+
mod.redrawChosen = function() {
var ids = Object.keys(chosenItems),
i, length,
$el;
-
+
for (i = 0, length = ids.length; i < length; i++) {
$el = $libTable.find("#"+ids[i]);
-
+
if ($el.length !== 0) {
mod.highlightItem($el);
+ mod.checkItem($el);
}
}
};
-
+
mod.isChosenItem = function($el) {
var id = $el.attr("id"),
item = chosenItems[id];
- return item !== undefined ? true : false;
+ return item !== undefined;
};
-
+
mod.addToChosen = function($el) {
var id = $el.attr("id");
-
+
chosenItems[id] = $el.data('aData');
};
-
+
mod.removeFromChosen = function($el) {
var id = $el.attr("id");
-
+
// used to not keep dragged items selected.
if (!$el.hasClass(LIB_SELECTED_CLASS)) {
delete chosenItems[id];
- }
+ }
};
-
+
+ mod.checkItem = function($el) {
+ $el.find(".library_checkbox > input").prop('checked', true);
+ $("#super-checkbox").prop("checked", true);
+ };
+
+ mod.uncheckItem = function($el) {
+ $el.find(".library_checkbox > input").prop('checked', false);
+ if ($("." + LIB_SELECTED_CLASS.length == 0)) {
+ $("#super-checkbox").prop("checked", false);
+ }
+ };
+
mod.highlightItem = function($el) {
- var $input = $el.find("input");
-
- $input.attr("checked", true);
$el.addClass(LIB_SELECTED_CLASS);
};
-
+
mod.unHighlightItem = function($el) {
- var $input = $el.find("input");
-
- $input.attr("checked", false);
$el.removeClass(LIB_SELECTED_CLASS);
};
-
+
mod.selectItem = function($el) {
-
mod.highlightItem($el);
mod.addToChosen($el);
-
+ // Remember this row so we can properly multiselect
+ $previouslySelected = $el;
+
mod.checkToolBarIcons();
};
-
+
mod.deselectItem = function($el) {
-
mod.unHighlightItem($el);
mod.removeFromChosen($el);
-
mod.checkToolBarIcons();
};
-
+
/*
* selects all items which the user can currently see. (behaviour taken from
* gmail)
@@ -269,63 +329,67 @@ var AIRTIME = (function(AIRTIME) {
*/
mod.selectCurrentPage = function() {
$.fn.reverse = [].reverse;
- var $inputs = $libTable.find("tbody input:checkbox"),
- $trs = $inputs.parents("tr").reverse();
-
- $inputs.attr("checked", true);
- $trs.addClass(LIB_SELECTED_CLASS);
+ var $trs = $libTable.find("tbody").find("tr").reverse();
$trs.each(function(i, el){
- $el = $(this);
- mod.addToChosen($el);
+ mod.selectItem($(el));
+ mod.checkItem($(el));
});
mod.checkToolBarIcons();
-
+
};
-
+
/*
* deselects all items that the user can currently see. (behaviour taken
* from gmail)
*/
mod.deselectCurrentPage = function() {
- var $inputs = $libTable.find("tbody input:checkbox"),
- $trs = $inputs.parents("tr"),
- id;
-
- $inputs.attr("checked", false);
- $trs.removeClass(LIB_SELECTED_CLASS);
-
+ var $trs = $libTable.find("tr");
+
$trs.each(function(i, el){
- $el = $(this);
- id = $el.attr("id");
- delete chosenItems[id];
+ mod.deselectItem($(el));
+ mod.uncheckItem($(el));
});
-
- mod.checkToolBarIcons();
- };
-
- mod.selectNone = function() {
- var $inputs = $libTable.find("tbody input:checkbox"),
- $trs = $inputs.parents("tr");
-
- $inputs.attr("checked", false);
- $trs.removeClass(LIB_SELECTED_CLASS);
-
- chosenItems = {};
-
+
mod.checkToolBarIcons();
};
-
- mod.fnDeleteItems = function(aMedia) {
+ mod.selectNone = function() {
+ var $trs = $libTable.find("tr");
+ $trs.each(function(i, el){
+ mod.deselectItem($(el));
+ mod.uncheckItem($(el));
+ });
+ $previouslySelected = undefined;
+
+ chosenItems = {};
+
+ mod.checkToolBarIcons();
+ };
+
+ mod.fnRedraw = function() {
+ oTable.fnStandingRedraw();
+ };
+
+ mod.fnDeleteItems = function(aMedia) {
//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');
+ var openTabObjectIds = $(".obj_id"),
+ mediaIds = [];
+ for (var i in aMedia) {
+ mediaIds.push(parseInt(aMedia[i].id));
+ }
- $.post(baseUrl+"library/delete",
- {"format": "json", "media": aMedia},
+ openTabObjectIds.each(function(i, el) {
+ var v = parseInt($(el).val());
+ if ($.inArray(v, mediaIds) > -1) {
+ AIRTIME.playlist.closeTab($(el).closest(".pl-content").attr("tab-id"));
+ }
+ });
+
+ $.post(baseUrl+"library/delete",
+ {"format": "json", "media": aMedia},
function(json){
if (json.message !== undefined) {
alert(json.message);
@@ -338,15 +402,15 @@ var AIRTIME = (function(AIRTIME) {
AIRTIME.button.enableButton("btn-group #sb-trash", false);
});
};
-
+
mod.fnDeleteSelectedItems = function() {
if (confirm($.i18n._('Are you sure you want to delete the selected item(s)?'))) {
var aData = AIRTIME.library.getSelectedData(),
item,
temp,
aMedia = [],
- currentObjId = $(".side_playlist").find(".obj_id").val(),
- currentObjType = $(".side_playlist").find(".obj_type").val(),
+ currentObjId = $(".side_playlist.active-tab").find(".obj_id").val(),
+ currentObjType = $(".side_playlist.active-tab").find(".obj_type").val(),
closeObj = false;
// process selected files/playlists.
@@ -355,7 +419,7 @@ var AIRTIME = (function(AIRTIME) {
if (temp !== null && temp.hasOwnProperty('id') ) {
aMedia.push({"id": temp.id, "type": temp.ftype});
if ( (temp.id == currentObjId && temp.ftype === currentObjType) ||
- temp.id == currentObjId && temp.ftype === "stream" && currentObjType === "webstream") {
+ temp.id == currentObjId && temp.ftype === "stream" && currentObjType === "webstream") {
closeObj = true;
}
}
@@ -370,42 +434,42 @@ var AIRTIME = (function(AIRTIME) {
$.post(baseUrl+"playlist/close-playlist",
{"format": "json", "type": currentObjType},
function(json) {
- $(".side_playlist").empty().append(json.html);
+ $("#editor_pane_wrapper").empty().append(json.html);
});
}
}
};
-
+
libraryInit = function() {
-
+
$libContent = $("#library_content");
-
+
/*
* Icon hover states in the toolbar.
*/
$libContent.on("mouseenter", ".fg-toolbar ul li", function(ev) {
$el = $(this);
-
+
if (!$el.hasClass("ui-state-disabled")) {
$el.addClass("ui-state-hover");
- }
+ }
});
$libContent.on("mouseleave", ".fg-toolbar ul li", function(ev) {
$el = $(this);
-
+
if (!$el.hasClass("ui-state-disabled")) {
$el.removeClass("ui-state-hover");
- }
+ }
});
-
+
var colReorderMap = new Array();
-
+
$libTable = $libContent.find("table");
-
+
function getTableHeight() {
- return $libContent.height() - 175;
+ return $libContent.height() - 175;
}
-
+
function setColumnFilter(oTable){
// TODO : remove this dirty hack once js is refactored
if (!oTable.fnSettings()) { return ; }
@@ -416,28 +480,28 @@ var AIRTIME = (function(AIRTIME) {
$.each(aoCols, function(i,ele){
if (ele.bSearchable) {
var currentColId = ele._ColReorder_iOrigCol;
-
- var inputClass = 'filter_column filter_number_text';
+
+ var inputClass = 'filter_column filter_number_text';
var labelStyle = "style='margin-right:35px;'";
if (libraryColumnTypes[ele.mDataProp] != "s") {
inputClass = 'filterColumn filter_number_range';
labelStyle = "";
}
-
+
if (ele.bVisible) {
advanceSearchDiv.append(
"
" +
- "
"+ele.sTitle+" : " +
- "
" +
+ "
"+ele.sTitle+" " +
+ "
" +
"
");
} else {
advanceSearchDiv.append(
"
" +
- "
"+ele.sTitle+" " +
- "
" +
+ "
"+ele.sTitle+" " +
+ "
" +
"
");
}
-
+
if (libraryColumnTypes[ele.mDataProp] == "s") {
var obj = { sSelector: "#"+ele.mDataProp }
} else {
@@ -448,82 +512,111 @@ var AIRTIME = (function(AIRTIME) {
colsForAdvancedSearch.push(null);
}
});
-
+
oTable.columnFilter({
- aoColumns: colsForAdvancedSearch,
- bUseColVis: true,
- sPlaceHolder: "head:before"
+ aoColumns: colsForAdvancedSearch,
+ bUseColVis: true,
+ sPlaceHolder: "head:before"
}
);
}
-
+
function setFilterElement(iColumn, bVisible){
var actualId = colReorderMap[iColumn];
var selector = "div#advanced_search_col_"+actualId;
var $el = $(selector);
-
+
if (bVisible) {
$el.show();
} else {
$el.hide();
}
-
- //resize to prevent double scroll bars.
- var $fs = $el.parents("fieldset"),
- tableHeight = getTableHeight(),
- searchHeight = $fs.height();
-
- $libContent.find(".dataTables_scrolling").css("max-height", tableHeight - searchHeight);
}
-
+
+ function getLibraryDatatableStrings() {
+ //Set up the datatables string translation table with different strings depending on
+ //whether you're viewing files, playlists, smart blocks, etc.
+ var type = parseInt($(".media_type_selector.selected").attr("selection_id"));
+ type = (type === undefined) ? 1 : type;
+
+ //FIXME: The code that calls this function doesn't work as intended because you can't
+ // change the oLanguage property of a datatable dynamically. :(
+
+ switch (type) {
+ /*
+ case 0:
+ return getDatatablesStrings({
+ "sEmptyTable": $.i18n._("No files found"),
+ });
+ break;
+ case 1:
+ return getDatatablesStrings({
+ "sEmptyTable": $.i18n._("No playlists found"),
+ });
+ break;
+ case 2:
+ return getDatatablesStrings({
+ "sEmptyTable": $.i18n._("No smart blocks found"),
+ });
+ break;*/
+ default:
+ return getDatatablesStrings({
+ "sEmptyTable": $.i18n._(""),
+ "sZeroRecords": $.i18n._("No matching results found.")
+ });
+ break;
+ };
+
+ }
+
oTable = $libTable.dataTable( {
-
+
// put hidden columns at the top to insure they can never be visible
// on the table through column reordering.
-
+
//IMPORTANT: WHEN ADDING A NEW COLUMN PLEASE CONSULT WITH THE WIKI
// https://wiki.sourcefabric.org/display/CC/Adding+a+new+library+datatable+column
"aoColumns": [
- /* ftype */ { "sTitle" : "" , "mDataProp" : "ftype" , "bSearchable" : false , "bVisible" : false } ,
- /* Checkbox */ { "sTitle" : "" , "mDataProp" : "checkbox" , "bSortable" : false , "bSearchable" : false , "sWidth" : "25px" , "sClass" : "library_checkbox" } ,
- /* Type */ { "sTitle" : "" , "mDataProp" : "image" , "bSearchable" : false , "sWidth" : "25px" , "sClass" : "library_type" , "iDataSort" : 0 } ,
- /* Is Scheduled */ { "sTitle" : $.i18n._("Scheduled") , "mDataProp" : "is_scheduled" , "bSearchable" : false , "sWidth" : "90px" , "sClass" : "library_is_scheduled"} ,
- /* Is Playlist */ { "sTitle" : $.i18n._("Playlist / Block") , "mDataProp" : "is_playlist" , "bSearchable" : false , "sWidth" : "110px" , "sClass" : "library_is_playlist"} ,
- /* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "track_title" , "sClass" : "library_title" , "sWidth" : "170px" } ,
- /* Creator */ { "sTitle" : $.i18n._("Creator") , "mDataProp" : "artist_name" , "sClass" : "library_creator" , "sWidth" : "160px" } ,
- /* Album */ { "sTitle" : $.i18n._("Album") , "mDataProp" : "album_title" , "sClass" : "library_album" , "sWidth" : "150px" } ,
- /* Bit Rate */ { "sTitle" : $.i18n._("Bit Rate") , "mDataProp" : "bit_rate" , "bVisible" : false , "sClass" : "library_bitrate" , "sWidth" : "80px" },
- /* BPM */ { "sTitle" : $.i18n._("BPM") , "mDataProp" : "bpm" , "bVisible" : false , "sClass" : "library_bpm" , "sWidth" : "50px" },
- /* Composer */ { "sTitle" : $.i18n._("Composer") , "mDataProp" : "composer" , "bVisible" : false , "sClass" : "library_composer" , "sWidth" : "150px" },
- /* Conductor */ { "sTitle" : $.i18n._("Conductor") , "mDataProp" : "conductor" , "bVisible" : false , "sClass" : "library_conductor" , "sWidth" : "125px" },
- /* Copyright */ { "sTitle" : $.i18n._("Copyright") , "mDataProp" : "copyright" , "bVisible" : false , "sClass" : "library_copyright" , "sWidth" : "125px" },
- /* Cue In */ { "sTitle" : $.i18n._("Cue In") , "mDataProp" : "cuein" , "bVisible" : false , "sClass" : "library_length" , "sWidth" : "80px" },
- /* Cue Out */ { "sTitle" : $.i18n._("Cue Out") , "mDataProp" : "cueout" , "bVisible" : false , "sClass" : "library_length" , "sWidth" : "80px" },
- /* Encoded */ { "sTitle" : $.i18n._("Encoded By") , "mDataProp" : "encoded_by" , "bVisible" : false , "sClass" : "library_encoded" , "sWidth" : "150px" },
- /* Genre */ { "sTitle" : $.i18n._("Genre") , "mDataProp" : "genre" , "bVisible" : false , "sClass" : "library_genre" , "sWidth" : "100px" },
- /* ISRC Number */ { "sTitle" : $.i18n._("ISRC") , "mDataProp" : "isrc_number" , "bVisible" : false , "sClass" : "library_isrc" , "sWidth" : "150px" },
- /* Label */ { "sTitle" : $.i18n._("Label") , "mDataProp" : "label" , "bVisible" : false , "sClass" : "library_label" , "sWidth" : "125px" },
- /* Language */ { "sTitle" : $.i18n._("Language") , "mDataProp" : "language" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" },
- /* Last Modified */ { "sTitle" : $.i18n._("Last Modified") , "mDataProp" : "mtime" , "bVisible" : false , "sClass" : "library_modified_time" , "sWidth" : "125px" },
- /* Last Played */ { "sTitle" : $.i18n._("Last Played") , "mDataProp" : "lptime" , "bVisible" : false , "sClass" : "library_modified_time" , "sWidth" : "125px" },
- /* Length */ { "sTitle" : $.i18n._("Length") , "mDataProp" : "length" , "sClass" : "library_length" , "sWidth" : "80px" } ,
- /* Mime */ { "sTitle" : $.i18n._("Mime") , "mDataProp" : "mime" , "bVisible" : false , "sClass" : "library_mime" , "sWidth" : "80px" },
- /* Mood */ { "sTitle" : $.i18n._("Mood") , "mDataProp" : "mood" , "bVisible" : false , "sClass" : "library_mood" , "sWidth" : "70px" },
- /* Owner */ { "sTitle" : $.i18n._("Owner") , "mDataProp" : "owner_id" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" },
- /* Replay Gain */ { "sTitle" : $.i18n._("Replay Gain") , "mDataProp" : "replay_gain" , "bVisible" : false , "sClass" : "library_replay_gain" , "sWidth" : "80px" },
- /* Sample Rate */ { "sTitle" : $.i18n._("Sample Rate") , "mDataProp" : "sample_rate" , "bVisible" : false , "sClass" : "library_sr" , "sWidth" : "80px" },
- /* Track Number */ { "sTitle" : $.i18n._("Track Number") , "mDataProp" : "track_number" , "bVisible" : false , "sClass" : "library_track" , "sWidth" : "65px" },
- /* Upload Time */ { "sTitle" : $.i18n._("Uploaded") , "mDataProp" : "utime" , "sClass" : "library_upload_time" , "sWidth" : "125px" } ,
- /* Website */ { "sTitle" : $.i18n._("Website") , "mDataProp" : "info_url" , "bVisible" : false , "sClass" : "library_url" , "sWidth" : "150px" },
- /* Year */ { "sTitle" : $.i18n._("Year") , "mDataProp" : "year" , "bVisible" : false , "sClass" : "library_year" , "sWidth" : "60px" }
- ],
-
-
+ /* ftype */ { "sTitle" : "" , "mDataProp" : "ftype" , "bSearchable" : false , "bVisible" : false },
+ /* Checkbox */ { "sTitle" : "" , "mDataProp" : "checkbox" , "bSortable" : false , "bSearchable" : false , "sWidth" : "16px" , "sClass" : "library_checkbox" },
+ /* Type */ { "sTitle" : "" , "mDataProp" : "image" , "bSortable" : false , "bSearchable" : false , "sWidth" : "16px" , "sClass" : "library_type" , "iDataSort" : 0 },
+ /* Is Scheduled */ { "sTitle" : $.i18n._("Scheduled") , "mDataProp" : "is_scheduled" , "bVisible" : false , "bSearchable" : false , "sWidth" : "90px" , "sClass" : "library_is_scheduled" },
+ ///* Is Playlist */ { "sTitle" : $.i18n._("Playlist / Block") , "mDataProp" : "is_playlist" , "bSearchable" : false , "sWidth" : "110px" , "sClass" : "library_is_playlist"} ,
+ /* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "track_title" , "sClass" : "library_title" , "sWidth" : "170px" },
+ /* Creator */ { "sTitle" : $.i18n._("Creator") , "mDataProp" : "artist_name" , "sClass" : "library_creator" , "sWidth" : "160px" },
+ /* Album */ { "sTitle" : $.i18n._("Album") , "mDataProp" : "album_title" , "sClass" : "library_album" , "sWidth" : "150px" },
+ /* Bit Rate */ { "sTitle" : $.i18n._("Bit Rate") , "mDataProp" : "bit_rate" , "bVisible" : false , "sClass" : "library_bitrate" , "sWidth" : "80px" },
+ /* BPM */ { "sTitle" : $.i18n._("BPM") , "mDataProp" : "bpm" , "bVisible" : false , "sClass" : "library_bpm" , "sWidth" : "50px" },
+ /* Composer */ { "sTitle" : $.i18n._("Composer") , "mDataProp" : "composer" , "bVisible" : false , "sClass" : "library_composer" , "sWidth" : "150px" },
+ /* Conductor */ { "sTitle" : $.i18n._("Conductor") , "mDataProp" : "conductor" , "bVisible" : false , "sClass" : "library_conductor" , "sWidth" : "125px" },
+ /* Copyright */ { "sTitle" : $.i18n._("Copyright") , "mDataProp" : "copyright" , "bVisible" : false , "sClass" : "library_copyright" , "sWidth" : "125px" },
+ /* Cue In */ { "sTitle" : $.i18n._("Cue In") , "mDataProp" : "cuein" , "bVisible" : false , "sClass" : "library_length" , "sWidth" : "80px" },
+ /* Cue Out */ { "sTitle" : $.i18n._("Cue Out") , "mDataProp" : "cueout" , "bVisible" : false , "sClass" : "library_length" , "sWidth" : "80px" },
+ /* Encoded */ { "sTitle" : $.i18n._("Encoded By") , "mDataProp" : "encoded_by" , "bVisible" : false , "sClass" : "library_encoded" , "sWidth" : "150px" },
+ /* Genre */ { "sTitle" : $.i18n._("Genre") , "mDataProp" : "genre" , "bVisible" : false , "sClass" : "library_genre" , "sWidth" : "100px" },
+ /* ISRC Number */ { "sTitle" : $.i18n._("ISRC") , "mDataProp" : "isrc_number" , "bVisible" : false , "sClass" : "library_isrc" , "sWidth" : "150px" },
+ /* Label */ { "sTitle" : $.i18n._("Label") , "mDataProp" : "label" , "bVisible" : false , "sClass" : "library_label" , "sWidth" : "125px" },
+ /* Language */ { "sTitle" : $.i18n._("Language") , "mDataProp" : "language" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" },
+ /* Last Modified */ { "sTitle" : $.i18n._("Last Modified") , "mDataProp" : "mtime" , "bVisible" : false , "sClass" : "library_modified_time" , "sWidth" : "155px" },
+ /* Last Played */ { "sTitle" : $.i18n._("Last Played") , "mDataProp" : "lptime" , "bVisible" : false , "sClass" : "library_modified_time" , "sWidth" : "155px" },
+ /* Length */ { "sTitle" : $.i18n._("Length") , "mDataProp" : "length" , "sClass" : "library_length" , "sWidth" : "80px" },
+ /* Mime */ { "sTitle" : $.i18n._("Mime") , "mDataProp" : "mime" , "bVisible" : false , "sClass" : "library_mime" , "sWidth" : "80px" },
+ /* Mood */ { "sTitle" : $.i18n._("Mood") , "mDataProp" : "mood" , "bVisible" : false , "sClass" : "library_mood" , "sWidth" : "70px" },
+ /* Owner */ { "sTitle" : $.i18n._("Owner") , "mDataProp" : "owner_id" , "bVisible" : false , "sClass" : "library_language" , "sWidth" : "125px" },
+ /* Replay Gain */ { "sTitle" : $.i18n._("Replay Gain") , "mDataProp" : "replay_gain" , "bVisible" : false , "sClass" : "library_replay_gain" , "sWidth" : "125px" },
+ /* Sample Rate */ { "sTitle" : $.i18n._("Sample Rate") , "mDataProp" : "sample_rate" , "bVisible" : false , "sClass" : "library_sr" , "sWidth" : "125px" },
+ /* Track Number */ { "sTitle" : $.i18n._("Track Number") , "mDataProp" : "track_number" , "bVisible" : false , "sClass" : "library_track" , "sWidth" : "125px" },
+ /* Upload Time */ { "sTitle" : $.i18n._("Uploaded") , "mDataProp" : "utime" , "bVisible" : false , "sClass" : "library_upload_time" , "sWidth" : "155px" },
+ /* Website */ { "sTitle" : $.i18n._("Website") , "mDataProp" : "info_url" , "bVisible" : false , "sClass" : "library_url" , "sWidth" : "150px" },
+ /* Year */ { "sTitle" : $.i18n._("Year") , "mDataProp" : "year" , "bVisible" : false , "sClass" : "library_year" , "sWidth" : "60px" },
+ /* Context Menu */ { "sTitle" : "" , "mData" : null , "bSortable" : false , "sClass" : "library_actions" , "bSearchable" : false , "sWidth" : "16px" }
+ ],
+
"bProcessing": true,
"bServerSide": true,
-
- "aLengthMenu": [[5, 10, 15, 20, 25, 50, 100], [5, 10, 15, 20, 25, 50, 100]],
-
+
+ "aLengthMenu": [5, 10, 15, 20, 25, 50, 100],
+
"bStateSave": true,
"fnStateSaveParams": function (oSettings, oData) {
// remove oData components we don't want to save.
@@ -533,19 +626,19 @@ 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"
- });
- */
+ $.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');
-
+
try {
return JSON.parse(settings);
} catch (e) {
@@ -556,17 +649,17 @@ var AIRTIME = (function(AIRTIME) {
var i,
length,
a = oData.abVisCols;
-
+
if (a) {
// putting serialized data back into the correct js type to make
// sure everything works properly.
for (i = 0, length = a.length; i < length; i++) {
if (typeof(a[i]) === "string") {
- a[i] = (a[i] === "true") ? true : false;
- }
+ a[i] = (a[i] === "true");
+ }
}
}
-
+
a = oData.ColReorder;
if (a) {
for (i = 0, length = a.length; i < length; i++) {
@@ -575,16 +668,16 @@ var AIRTIME = (function(AIRTIME) {
}
}
}
-
+
oData.iEnd = parseInt(oData.iEnd, 10);
oData.iLength = parseInt(oData.iLength, 10);
oData.iStart = parseInt(oData.iStart, 10);
oData.iCreate = parseInt(oData.iCreate, 10);
},
-
+
"sAjaxSource": baseUrl+"Library/contents-feed",
"sAjaxDataProp": "files",
-
+
"fnServerData": function ( sSource, aoData, fnCallback ) {
/*
* The real validation check is done in
@@ -598,10 +691,10 @@ var AIRTIME = (function(AIRTIME) {
var type;
aoData.push( { name: "format", value: "json"} );
aoData.push( { name: "advSearch", value: advSearchValid} );
-
+
// push whether to search files/playlists or all.
- type = $("#library_display_type").find("select").val();
- type = (type === undefined) ? 0 : type;
+ type = $(".media_type_selector.selected").attr("selection_id");
+ type = (type === undefined) ? 1 : type;
aoData.push( { name: "type", value: type} );
getUsabilityHint();
@@ -619,6 +712,12 @@ var AIRTIME = (function(AIRTIME) {
// add checkbox
$(nRow).find('td.library_checkbox').html("
");
+ $(nRow).find('td.library_actions')
+ .text("...")
+ .on('click', function(e) {
+ $(this).contextMenu({x: $(e.target).offset().left, y: $(e.target).offset().top})
+ }).html("
...
");
+
// add audio preview image/button
if (aData.ftype === "audioclip") {
$(nRow).find('td.library_type').html('
');
@@ -658,137 +757,40 @@ var AIRTIME = (function(AIRTIME) {
}
return false;
});
-
- alreadyclicked=false;
- // call the context menu so we can prevent the event from
- // propagating.
- $(nRow).find('td:not(.library_checkbox, .library_type)').click(function(e){
- var el=$(this);
- if (alreadyclicked)
- {
- alreadyclicked=false; // reset
- clearTimeout(alreadyclickedTimeout); // prevent this
- // from
- // happening
- // do what needs to happen on double click.
-
- $tr = $(el).parent();
- data = $tr.data("aData");
- AIRTIME.library.dblClickAdd(data, data.ftype);
- }
- else
- {
- alreadyclicked=true;
- alreadyclickedTimeout=setTimeout(function(){
- alreadyclicked=false; // reset when it happens
- // do what needs to happen on single click.
- // use el instead of $(this) because $(this) is
- // no longer the element
- el.contextMenu({x: e.pageX, y: e.pageY});
- },300); // <-- dblclick tolerance here
- }
- return false;
- });
-
- /*$(nRow).find(".media-item-in-use").qtip({
- content: {
- text: aData.status_msg
- },
- hide: {
- delay: 500,
- fixed: true
- },
- style: {
- border: {
- width: 0,
- radius: 4
- },
- classes: "ui-tooltip-dark ui-tooltip-rounded"
- },
- position: {
- my: "left bottom",
- at: "right center"
- },
- });*/
-
- // add a tool tip to appear when the user clicks on the type
- // icon.
- $(nRow).find("td:not(.library_checkbox, .library_type)").qtip({
- content: {
- text: function(event, api) {
- $.get(baseUrl+"library/get-file-metadata",
- ({format: "html", id : aData.id, type: aData.ftype}),
- function (html) {
- api.set('content.text', html);
- }, "html")
- .fail(function (xhr, status, error) {
- api.set('content.text', status + ': ' + error)
- });
- return 'Loading...';
- },
- title: {
- text: aData.track_title
- }
- },
- position: {
- target: 'event',
- adjust: {
- resize: true,
- method: "flip flip"
- },
- my: 'left center',
- at: 'right center',
- viewport: $(window), // Keep the tooltip on-screen at
- // all times
- effect: false // Disable positioning animation
- },
- style: {
- classes: "ui-tooltip-dark file-md-long"
- },
- show: 'mousedown',
- events: {
- show: function(event, api) {
- // Only show the tooltip if it was a right-click
- if(event.originalEvent.button !== 2) {
- event.preventDefault();
- }
- }
- },
- hide: {event:'mouseout', delay: 50, fixed:true}
- });
},
- // remove any selected nodes before the draw.
+ // remove any selected nodes before the draw.
"fnPreDrawCallback": function( oSettings ) {
-
+
// make sure any dragging helpers are removed or else they'll be
// stranded on the screen.
$("#draggingContainer").remove();
},
"fnDrawCallback": AIRTIME.library.fnDrawCallback,
-
+
"aaSorting": [[5, 'asc']],
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"bAutoWidth": false,
- "oLanguage": getDatatablesStrings({
- "sZeroRecords": $.i18n._("No matching records found."),
- }),
-
+ "oLanguage": getLibraryDatatableStrings(),
+
// R = ColReorder, C = ColVis
- "sDom": 'Rl<"#library_display_type">f<"dt-process-rel"r><"H"<"library_toolbar"C>><"dataTables_scrolling"t><"F"ip>',
-
+ "sDom": 'Rf<"dt-process-rel"r><"H"<"library_toolbar"C>><"dataTables_scrolling"t><"F"ilp>>',
+
"oColVis": {
"sAlign": "right",
- "aiExclude": [0, 1, 2],
+ "aiExclude": [0, 1, 2, 31],
"sSize": "css",
"fnStateChange": setFilterElement,
- "buttonText": $.i18n._("Show / hide columns")
+ "buttonText": $.i18n._("Columns")
},
-
+
"oColReorder": {
+ "iFixedColumnsRight": 1,
"iFixedColumns": 3
- }
-
+ },
+
+ "bScrollCollapse": false
+
});
setColumnFilter(oTable);
@@ -799,9 +801,9 @@ var AIRTIME = (function(AIRTIME) {
$libContent.on("click", "legend", function(){
$simpleSearch = $libContent.find("#library_display_filter label");
var $fs = $(this).parents("fieldset"),
- searchHeight,
- tableHeight = getTableHeight(),
- height;
+ searchHeight,
+ tableHeight = getTableHeight(),
+ height;
if ($fs.hasClass("closed")) {
$fs.removeClass("closed");
@@ -814,10 +816,6 @@ var AIRTIME = (function(AIRTIME) {
$(".dataTables_filter input").val("").keyup();
$simpleSearch.addClass("sp-invisible");
-
- //resize the library table to avoid a double scroll bar. CC-4504
- height = tableHeight - searchHeight;
- $libContent.find(".dataTables_scrolling").css("max-height", height);
}
else {
// clear the advanced search fields
@@ -833,115 +831,165 @@ var AIRTIME = (function(AIRTIME) {
}
});
});
-
+
//reset datatable with previous simple search results (if any)
$(".dataTables_filter input").val(simpleSearchText).keyup();
$simpleSearch.removeClass("sp-invisible");
$fs.addClass("closed");
-
- //resize the library table to avoid a double scroll bar. CC-4504
- $libContent.find(".dataTables_scrolling").css("max-height", tableHeight);
}
});
-
- var tableHeight = getTableHeight();
- $libContent.find(".dataTables_scrolling").css("max-height", tableHeight);
-
- AIRTIME.library.setupLibraryToolbar(oTable);
-
- $("#library_display_type")
- .addClass("dataTables_type")
- .append('
')
- .find("select")
- .append('
'+$.i18n._("All")+' ')
- .append('
'+$.i18n._("Files")+' ')
- .append('
'+$.i18n._("Playlists")+' ')
- .append('
'+$.i18n._("Smart Blocks")+' ')
- .append('
'+$.i18n._("Web Streams")+' ')
- .end()
- .change(function(ev){
- oTable.fnDraw();
- });
-
- $libTable.find("tbody").on("click", "input[type=checkbox]", function(ev) {
- var $cb = $(this),
- $tr = $cb.parents("tr"),
- // Get the ID of the selected row
+ AIRTIME.library.setupLibraryToolbar(oTable);
+
+ $libTable.find("tbody").on("dblclick", "tr", function(ev) {
+ var data = $(this).data("aData");
+ AIRTIME.library.dblClickAdd(data, data.ftype);
+ });
+
+ $libTable.find("tbody").on("mousedown", "tr > td.library_checkbox", function(ev) {
+ var $tr = $(this).parent(),
+ // Get the ID of the selected row
$rowId = $tr.attr("id");
- if ($cb.is(":checked")) {
+ if (!$tr.hasClass(LIB_SELECTED_CLASS)) {
if (ev.shiftKey && $previouslySelected !== undefined) {
+ if ($previouslySelected.attr("id") == $rowId) {
+ return;
+ }
+
// If the selected row comes before the previously selected row,
// we want to select previous rows, otherwise we select next
- if ($previouslySelected.prevAll("#"+$rowId).length !== 0) {
- $previouslySelected.prevUntil($tr).each(function(i, el){
+ if ($previouslySelected.prevAll("#" + $rowId).length !== 0) {
+ $previouslySelected.prevUntil($tr).each(function (i, el) {
mod.selectItem($(el));
+ mod.checkItem($(el));
});
} else {
- $previouslySelected.nextUntil($tr).each(function(i, el){
+ $previouslySelected.nextUntil($tr).each(function (i, el) {
mod.selectItem($(el));
+ mod.checkItem($(el));
});
}
}
+ mod.selectItem($tr);
+ mod.checkItem($tr);
+ } else {
+ flagForDeselection = true;
+ }
+ });
+
+ $libTable.find("tbody").on("mousedown", "tr > td:not(.library_checkbox)", function(ev) {
+ var $tr = $(this).parent(),
+ // Get the ID of the selected row
+ $rowId = $tr.attr("id");
+
+ if (!$tr.hasClass(LIB_SELECTED_CLASS)) {
+ if (ev.shiftKey && $previouslySelected !== undefined) {
+ if ($previouslySelected.attr("id") == $rowId) {
+ return;
+ }
+
+ // If the selected row comes before the previously selected row,
+ // we want to select previous rows, otherwise we select next
+ if ($previouslySelected.prevAll("#" + $rowId).length !== 0) {
+ $previouslySelected.prevUntil($tr).each(function (i, el) {
+ mod.selectItem($(el));
+ mod.checkItem($(el));
+ });
+ } else {
+ $previouslySelected.nextUntil($tr).each(function (i, el) {
+ mod.selectItem($(el));
+ mod.checkItem($(el));
+ });
+ }
+ } else if (!ev.ctrlKey) {
+ mod.selectNone();
+ }
mod.selectItem($tr);
- // Remember this row so we can properly multiselect
- $previouslySelected = $tr;
+ mod.checkItem($tr);
}
- else {
- mod.deselectItem($tr);
- }
-
});
-
+
+ $libTable.find("tbody").on("click", "tr > td.library_checkbox", function() {
+ var tr = $(this).parent();
+
+ if (flagForDeselection) {
+ flagForDeselection = false;
+ mod.deselectItem(tr);
+ mod.uncheckItem(tr);
+ } else {
+ mod.checkItem(tr);
+ }
+ });
+
+ $libTable.find("tbody").on("click", "tr > td:not(.library_checkbox)", function(e) {
+ var tr = $(this).parent();
+ if (!(e.shiftKey || e.ctrlKey)) {
+ mod.selectNone();
+ mod.selectItem(tr);
+ }
+ mod.checkItem(tr);
+ });
+
+ $libTable.find("thead").on("click", "th > input[type='checkbox']", function() {
+ if ($(this).is(":checked")) {
+ AIRTIME.library.selectCurrentPage();
+ $(this).prop("checked", true);
+ } else {
+ AIRTIME.library.selectNone();
+ $(this).prop("checked", false);
+ }
+ });
+
+ $('#sb-actions').on("click", function(e) {
+ $("#library_display tr:has(td)").contextMenu({x: $(e.target).offset().left, y: $(e.target).offset().top});
+ });
+
// begin context menu initialization.
- $.contextMenu({
- selector: '#library_display td:not(.library_checkbox)',
- trigger: "left",
- ignoreRightClick: true,
-
+ AIRTIME.library.ctxMenu = $.contextMenu({
+ selector: '#library_display tr:has(td)',
+ //trigger: "left",
+ trigger: "custom",
+
build: function($el, e) {
var data, screen, items, callback, $tr;
-
- $tr = $el.parent();
+
+ $tr = $el;
data = $tr.data("aData");
screen = $tr.data("screen");
-
+
function processMenuItems(oItems) {
-
+
// define an add to playlist callback.
if (oItems.pl_add !== undefined) {
var aItems = [];
-
+
callback = function() {
aItems.push(new Array(data.id, data.ftype));
AIRTIME.playlist.fnAddItems(aItems, undefined, 'after');
};
-
+
oItems.pl_add.callback = callback;
}
-
+
// define an edit callback.
if (oItems.edit !== undefined) {
-
if (data.ftype === "audioclip") {
callback = function() {
$.get(oItems.edit.url, {format: "json"}, function(json){
- buildEditMetadataDialog(json);
+ AIRTIME.playlist.fileMdEdit(json);
});
};
} else if (data.ftype === "playlist" || data.ftype === "block") {
callback = function() {
- var url = baseUrl+'Playlist/edit';
- AIRTIME.playlist.fnEdit(data.id, data.ftype, url);
+ AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl+'playlist/edit');
AIRTIME.playlist.validatePlaylistElements();
};
} else if (data.ftype === "stream") {
callback = function() {
- var url = baseUrl+'Webstream/edit';
- AIRTIME.playlist.fnEdit(data.id, data.ftype, url);
+ AIRTIME.playlist.fnEdit(data.id, data.ftype, baseUrl + 'webstream/edit');
}
} else {
throw new Exception($.i18n._("Unknown type: ") + data.ftype);
@@ -959,26 +1007,22 @@ var AIRTIME = (function(AIRTIME) {
}
callback = function() {
- if (data.ftype === 'playlist' && data.length !== '0.0'){
- playlistIndex = $(this).parent().attr('id').substring(3); // remove
- // the
- // pl_
+ if (data.ftype === 'playlist' && data.length !== '0.0'){
+ playlistIndex = $(this).parent().attr('id').substring(3); // remove the pl_
open_playlist_preview(playlistIndex, 0);
} else if (data.ftype === 'audioclip' || data.ftype === 'stream') {
open_audio_preview(data.ftype, data.id);
} else if (data.ftype === 'block') {
- blockIndex = $(this).parent().attr('id').substring(3); // remove
- // the
- // pl_
+ blockIndex = $(this).parent().attr('id').substring(3); // remove the pl_
open_block_preview(blockIndex, 0);
}
};
oItems.play.callback = callback;
}
-
+
// define a delete callback.
if (oItems.del !== undefined) {
-
+
// delete through the playlist controller, will reset
// playlist screen if this is the currently edited
// playlist.
@@ -994,30 +1038,30 @@ var AIRTIME = (function(AIRTIME) {
else {
callback = function() {
var media = [];
-
+
if (confirm($.i18n._('Are you sure you want to delete the selected item?'))) {
-
+
media.push({"id": data.id, "type": data.ftype});
$.post(oItems.del.url, {format: "json", media: media }, function(json){
var oTable;
-
+
if (json.message) {
alert(json.message);
}
-
+
oTable = $("#library_display").dataTable();
oTable.fnDeleteRow( $tr[0] );
});
}
};
}
-
+
oItems.del.callback = callback;
}
-
+
// define a download callback.
if (oItems.download !== undefined) {
-
+
callback = function() {
document.location.href = oItems.download.url;
};
@@ -1032,7 +1076,7 @@ var AIRTIME = (function(AIRTIME) {
callback = function() {
alert($.i18n._("Your track is being uploaded and will " +
- "appear on SoundCloud in a couple of minutes"));
+ "appear on SoundCloud in a couple of minutes"));
$.post(soundcloud.upload.url, function(){});
};
soundcloud.upload.callback = callback;
@@ -1074,33 +1118,34 @@ var AIRTIME = (function(AIRTIME) {
}
items = oItems;
}
-
+
request = $.ajax({
- url: baseUrl+"library/context-menu",
- type: "GET",
- data: {id : data.id, type: data.ftype, format: "json", "screen": screen},
- dataType: "json",
- async: false,
- success: function(json){
- processMenuItems(json.items);
- }
+ url: baseUrl+"library/context-menu",
+ type: "GET",
+ data: {id : data.id, type: data.ftype, format: "json", "screen": screen},
+ dataType: "json",
+ async: false,
+ success: function(json){
+ processMenuItems(json.items);
+ }
});
-
+
return {
items: items
};
}
});
};
+
mod.libraryInit = libraryInit;
-
+
return AIRTIME;
-
+
}(AIRTIME || {}));
function buildEditMetadataDialog (json){
var dialog = $(json.dialog);
-
+
dialog.dialog({
autoOpen: false,
title: $.i18n._("Edit Metadata"),
@@ -1117,39 +1162,6 @@ function closeDialogLibrary(event, ui) {
$(this).remove();
}
-function checkImportStatus() {
- $.getJSON(baseUrl+'Preference/is-import-in-progress', function(data){
- var $div = $('#import_status');
- var table = $('#library_display').dataTable();
- if (data == true){
- $div.show();
- }
- else{
- if ($div.is(':visible')) {
- table.fnStandingRedraw();
- }
- $div.hide();
- }
- setTimeout(checkImportStatus, 5000);
- });
-}
-
-function addProgressIcon(id) {
- var tr = $("#au_"+id),
- span;
-
- span = tr.find("td.library_title").find("span");
-
- if (span.length > 0){
- span.removeClass()
- .addClass("small-icon progress");
- }
- else{
- tr.find("td.library_title")
- .append('
');
- }
-}
-
/*
* This function is called from dataTables.columnFilter.js
*/
@@ -1169,16 +1181,16 @@ function validateAdvancedSearch(divs) {
searchTerm[0] = "";
searchTerm[1] = "";
$.each(divs, function(i, div){
- fieldName = $(div).children(':nth-child(2)').attr('id');
+ fieldName = $(div).children('div').attr('id');
fields = $(div).children().find('input');
searchTermType = validationTypes[fieldName];
valid = true;
-
+
$.each(fields, function(i, field){
searchTerm[i] = $(field).val();
if (searchTerm[i] !== "") {
-
+
if (searchTermType === "l") {
regExpr = new RegExp("^" +timeRegEx+ "$");
} else if (searchTermType === "t") {
@@ -1196,29 +1208,29 @@ function validateAdvancedSearch(divs) {
searchTerm[i] = searchTerm[i].substr(1);
}
}
-
+
// string fields do not need validation
if (searchTermType !== "s") {
valid = regExpr.test(searchTerm[i]);
if (!valid) allValid = false;
}
-
+
addRemoveValidationIcons(valid, $(field), searchTermType);
-
- /*
- * Empty fields should not have valid/invalid indicator Range values
- * are considered valid even if only the 'From' value is provided.
- * Therefore, if the 'To' value is empty but the 'From' value is not
- * empty we need to keep the validation icon on screen.
- */
+
+ /*
+ * Empty fields should not have valid/invalid indicator Range values
+ * are considered valid even if only the 'From' value is provided.
+ * Therefore, if the 'To' value is empty but the 'From' value is not
+ * empty we need to keep the validation icon on screen.
+ */
} else if (searchTerm[0] === "" && searchTerm[1] !== "" ||
- searchTerm[0] === "" && searchTerm[1] === ""){
- if ($(field).closest('div').children(':last-child').hasClass('checked-icon') ||
- $(field).closest('div').children(':last-child').hasClass('not-available-icon')) {
- $(field).closest('div').children(':last-child').remove();
+ searchTerm[0] === "" && searchTerm[1] === ""){
+ if ($(field).closest('div').prev().hasClass('checked-icon') ||
+ $(field).closest('div').prev().hasClass('not-available-icon')) {
+ $(field).closest('div').prev().remove();
}
}
-
+
if (!valid) {
return false;
}
@@ -1239,29 +1251,35 @@ function addRemoveValidationIcons(valid, field, searchTermType) {
} else if (searchTermType === 'l') {
title = $.i18n._('Input must be in the format: hh:mm:ss.t');
}
-
+
var validIndicator = "
",
invalidIndicator = "
";
-
+
if (valid) {
- if (!field.closest('div').children(':last-child').hasClass('checked-icon')) {
+ if (!field.closest('div').prev().hasClass('checked-icon')) {
// remove invalid icon before adding valid icon
- if (field.closest('div').children(':last-child').hasClass('not-available-icon')) {
- field.closest('div').children(':last-child').remove();
+ if (field.closest('div').prev().hasClass('not-available-icon')) {
+ field.closest('div').prev().remove();
}
- field.closest('div').append(validIndicator);
+ field.closest('div').before(validIndicator);
}
} else {
- if (!field.closest('div').children(':last-child').hasClass('not-available-icon')) {
+ if (!field.closest('div').prev().hasClass('not-available-icon')) {
// remove valid icon before adding invalid icon
- if (field.closest('div').children(':last-child').hasClass('checked-icon')) {
- field.closest('div').children(':last-child').remove();
+ if (field.closest('div').prev().hasClass('checked-icon')) {
+ field.closest('div').prev().remove();
}
- field.closest('div').append(invalidIndicator);
+ field.closest('div').before(invalidIndicator);
}
}
}
+function resizeAdvancedSearch() {
+ var s = $("#advanced_search");
+ s.css("max-height", $(window).height() / 4);
+ s.css("overflow", "auto");
+}
+
/*
* Validation types: s => string i => integer n => numeric (positive/negative,
* whole/decimals) t => timestamp l => length
@@ -1303,11 +1321,11 @@ var validationTypes = {
};
$(document).ready(function() {
- $('#editmdsave').live("click", function() {
+ $('.active-tab .md-save').live("click", function() {
var file_id = $('#file_id').val(),
- data = $("#edit-md-dialog form").serializeArray();
+ data = $(".active-tab #edit-md-dialog form").serializeArray();
$.post(baseUrl+'library/edit-file-md', {format: "json", id: file_id, data: data}, function() {
- $("#edit-md-dialog").dialog().remove();
+ //$("#edit-md-dialog").dialog().remove();
// don't redraw the library table if we are on calendar page
// we would be on calendar if viewing recorded file metadata
@@ -1315,10 +1333,8 @@ $(document).ready(function() {
oTable.fnStandingRedraw();
}
});
- });
-
- $('#editmdcancel').live("click", function() {
- $("#edit-md-dialog").dialog().remove();
+
+ AIRTIME.playlist.closeTab();
});
$('#edit-md-dialog').live("keyup", function(event) {
@@ -1326,5 +1342,51 @@ $(document).ready(function() {
$('#editmdsave').click();
}
});
+
+ if (location.hash === "") {
+ $("a[href$='#files']").parent().addClass("selected");
+ }
+ $("a[href$='"+location.hash+"']").parent().addClass("selected");
+
+ // Slightly hacky way of triggering the click event when it's outside of the anchor text
+ $(".media_type_selector").on("click", function() {
+ // Need get(0) here so we don't create a stack overflow by recurring the click on the parent
+ $(this).find("a").get(0).click();
+ });
+
+ $(window).on('hashchange', function() {
+ // If we click Dashboard from one of the media views, do nothing
+ if (!location.hash) {
+ return;
+ }
+ AIRTIME.library.selectNone();
+ $(".media_type_selector").each(function () {
+ $(this).removeClass("selected");
+ });
+ $("a[href$='"+location.hash+"']").parent().addClass("selected");
+ oTable.fnDraw();
+ });
+
+ /* Overridden by hashchange function
+
+ $(".media_type_selector").on("click", function() {
+ if (!$(this).hasClass("selected")) {
+ AIRTIME.library.selectNone();
+ $(".media_type_selector").each(function () {
+ $(this).removeClass("selected");
+ });
+ $(this).addClass("selected");
+ oTable.fnDraw();
+ }
+ });
+ */
+
+ $("#advanced-options").on("click", function() {
+ resizeAdvancedSearch();
+ });
+
+ $(window).resize(function() {
+ resizeAdvancedSearch();
+ });
});
diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js
index f312fd43b..1251de505 100644
--- a/airtime_mvc/public/js/airtime/library/spl.js
+++ b/airtime_mvc/public/js/airtime/library/spl.js
@@ -3,11 +3,11 @@
//--------------------------------------------------------------------------------------------------------------------------------
var AIRTIME = (function(AIRTIME){
-
+
if (AIRTIME.playlist === undefined) {
AIRTIME.playlist = {};
}
-
+
var mod = AIRTIME.playlist,
viewport,
$lib,
@@ -15,31 +15,34 @@ var AIRTIME = (function(AIRTIME){
$togglePl = $("
"+$.i18n._("Open Media Builder")+" "),
widgetHeight,
resizeTimeout,
- width;
-
+ width,
+ $tabCount = 0,
+ $openTabs = {};
+
function isTimeValid(time) {
//var regExpr = new RegExp("^\\d{2}[:]\\d{2}[:]\\d{2}([.]\\d{1,6})?$");
var regExpr = new RegExp("^\\d{2}[:]([0-5]){1}([0-9]){1}[:]([0-5]){1}([0-9]){1}([.]\\d{1})?$");
-
+
return regExpr.test(time);
}
-
+
function isFadeValid(fade) {
var regExpr = new RegExp("^\\d{1}(\\d{1})?([.]\\d{1})?$");
return regExpr.test(fade);
}
-
+
function playlistError(json) {
alert(json.error);
- openPlaylist(json);
+ //closeTab();
+ //openPlaylist(json);
}
-
+
function stopAudioPreview() {
// stop any preview playing
$('#jquery_jplayer_1').jPlayer('stop');
}
-
+
function highlightActive(el) {
$(el).addClass("ui-state-active");
@@ -67,19 +70,19 @@ var AIRTIME = (function(AIRTIME){
event.stopPropagation();
var span = $(this),
id = span.parent().attr("id").split("_").pop(),
- url = baseUrl+"Playlist/set-cue",
+ url = baseUrl+"playlist/set-cue",
cueIn = $.trim(span.text()),
li = span.parents("li"),
unqid = li.attr("unqid"),
lastMod = getModified(),
- type = $('.obj_type').val();
-
+ type = $pl.find('.obj_type').val();
+
if (!isTimeValid(cueIn)){
showError(span, $.i18n._("please put in a time '00:00:00 (.0)'"));
return;
}
- $.post(url,
- {format: "json", cueIn: cueIn, id: id, modified: lastMod, type: type},
+ $.post(url,
+ {format: "json", cueIn: cueIn, id: id, modified: lastMod, type: type},
function(json){
if (json.error !== undefined){
@@ -93,7 +96,7 @@ var AIRTIME = (function(AIRTIME){
setPlaylistContent(json);
- li = $('.side_playlist li[unqid='+unqid+']');
+ li = $('.side_playlist.active-tab li[unqid='+unqid+']');
li.find(".cue-edit").toggle();
highlightActive(li);
highlightActive(li.find('.spl_cue'));
@@ -104,20 +107,20 @@ var AIRTIME = (function(AIRTIME){
event.stopPropagation();
var span = $(this),
id = span.parent().attr("id").split("_").pop(),
- url = baseUrl+"Playlist/set-cue",
+ url = baseUrl+"playlist/set-cue",
cueOut = $.trim(span.text()),
li = span.parents("li"),
unqid = li.attr("unqid"),
lastMod = getModified(),
- type = $('.obj_type').val();
+ type = $pl.find('.obj_type').val();
if (!isTimeValid(cueOut)){
showError(span, $.i18n._("please put in a time '00:00:00 (.0)'"));
return;
}
-
- $.post(url,
- {format: "json", cueOut: cueOut, id: id, modified: lastMod, type: type},
+
+ $.post(url,
+ {format: "json", cueOut: cueOut, id: id, modified: lastMod, type: type},
function(json){
if (json.error !== undefined){
@@ -131,22 +134,22 @@ var AIRTIME = (function(AIRTIME){
setPlaylistContent(json);
- li = $('.side_playlist li[unqid='+unqid+']');
+ li = $('.side_playlist.active-tab li[unqid='+unqid+']');
li.find(".cue-edit").toggle();
highlightActive(li);
highlightActive(li.find('.spl_cue'));
});
}
-
+
/* used from waveform pop-up */
function changeCues($el, id, cueIn, cueOut) {
-
- var url = baseUrl+"Playlist/set-cue",
+
+ var url = baseUrl+"playlist/set-cue",
lastMod = getModified(),
- type = $('.obj_type').val(),
+ type = $pl.find('.obj_type').val(),
li,
span;
-
+
if (!isTimeValid(cueIn)){
$el.find('.cue-in-error').val($.i18n._("please put in a time '00:00:00 (.0)'")).show();
return;
@@ -154,7 +157,7 @@ var AIRTIME = (function(AIRTIME){
else {
$el.find('.cue-in-error').hide();
}
-
+
if (!isTimeValid(cueOut)){
$el.find('.cue-out-error').val($.i18n._("please put in a time '00:00:00 (.0)'")).show();
return;
@@ -162,11 +165,11 @@ var AIRTIME = (function(AIRTIME){
else {
$el.find('.cue-out-error').hide();
}
-
- $.post(url,
- {format: "json", cueIn: cueIn, cueOut: cueOut, id: id, modified: lastMod, type: type},
+
+ $.post(url,
+ {format: "json", cueIn: cueIn, cueOut: cueOut, id: id, modified: lastMod, type: type},
function(json){
-
+
$el.dialog('destroy');
$el.remove();
@@ -175,50 +178,50 @@ var AIRTIME = (function(AIRTIME){
return;
}
if (json.cue_error !== undefined) {
-
- li = $('.side_playlist li[unqid='+id+']');
-
+
+ li = $('.side_playlist.active-tab li[unqid='+id+']');
+
if (json.code === 0) {
-
+
span = $('#spl_cue_in_'+id).find('span');
showError(span, json.cue_error);
span = $('#spl_cue_out_'+id).find('span');
showError(span, json.cue_error);
}
else if (json.code === 1) {
-
+
span = $('#spl_cue_in_'+id).find('span');
showError(span, json.cue_error);
}
else if (json.code === 2) {
-
+
span = $('#spl_cue_out_'+id).find('span');
showError(span, json.cue_error);
}
-
+
return;
}
setPlaylistContent(json);
- li = $('.side_playlist li[unqid='+id+']');
+ li = $('.side_playlist.active-tab li[unqid='+id+']');
li.find(".cue-edit").toggle();
highlightActive(li);
highlightActive(li.find('.spl_cue'));
});
}
-
+
/* used from waveform pop-up */
function changeCrossfade($el, id1, id2, fadeIn, fadeOut, offset, id) {
-
- var url = baseUrl+"Playlist/set-crossfade",
+
+ var url = baseUrl+"playlist/set-crossfade",
lastMod = getModified(),
- type = $('.obj_type').val();
-
- $.post(url,
- {format: "json", fadeIn: fadeIn, fadeOut: fadeOut, id1: id1, id2: id2, offset: offset, modified: lastMod, type: type},
+ type = $pl.find('.obj_type').val();
+
+ $.post(url,
+ {format: "json", fadeIn: fadeIn, fadeOut: fadeOut, id1: id1, id2: id2, offset: offset, modified: lastMod, type: type},
function(json){
-
+
$el.dialog('destroy');
$el.remove();
@@ -226,10 +229,10 @@ var AIRTIME = (function(AIRTIME){
playlistError(json);
return;
}
-
+
setPlaylistContent(json);
- $li = $('.side_playlist li[unqid='+id+']');
+ $li = $pl.find('li[unqid='+id+']');
$li.find('.crossfade').toggle();
highlightActive($li.find('.spl_fade_control'));
});
@@ -240,20 +243,20 @@ var AIRTIME = (function(AIRTIME){
var span = $(this),
id = span.parent().attr("id").split("_").pop(),
- url = baseUrl+"Playlist/set-fade",
+ url = baseUrl+"playlist/set-fade",
fadeIn = $.trim(span.text()),
li = span.parents("li"),
unqid = li.attr("unqid"),
lastMod = getModified(),
- type = $('.obj_type').val();
+ type = $pl.find('.obj_type').val();
if (!isFadeValid(fadeIn)){
showError(span, $.i18n._("please put in a time in seconds '00 (.0)'"));
return;
}
- $.post(url,
- {format: "json", fadeIn: fadeIn, id: id, modified: lastMod, type: type},
+ $.post(url,
+ {format: "json", fadeIn: fadeIn, id: id, modified: lastMod, type: type},
function(json){
if (json.error !== undefined){
@@ -267,7 +270,7 @@ var AIRTIME = (function(AIRTIME){
setPlaylistContent(json);
- li = $('.side_playlist li[unqid='+unqid+']');
+ li = $pl.find('li[unqid='+unqid+']');
li.find('.crossfade').toggle();
highlightActive(li.find('.spl_fade_control'));
});
@@ -278,22 +281,22 @@ var AIRTIME = (function(AIRTIME){
var span = $(this),
id = span.parent().attr("id").split("_").pop(),
- url = baseUrl+"Playlist/set-fade",
+ url = baseUrl+"playlist/set-fade",
fadeOut = $.trim(span.text()),
li = span.parents("li"),
unqid = li.attr("unqid"),
lastMod = getModified(),
- type = $('.obj_type').val();
+ type = $pl.find('.obj_type').val();
if (!isFadeValid(fadeOut)){
showError(span, $.i18n._("please put in a time in seconds '00 (.0)'"));
return;
}
- $.post(url,
- {format: "json", fadeOut: fadeOut, id: id, modified: lastMod, type: type},
+ $.post(url,
+ {format: "json", fadeOut: fadeOut, id: id, modified: lastMod, type: type},
function(json){
-
+
if (json.error !== undefined){
playlistError(json);
return;
@@ -302,10 +305,10 @@ var AIRTIME = (function(AIRTIME){
showError(span, json.fade_error);
return;
}
-
+
setPlaylistContent(json);
-
- li = $('.side_playlist li[unqid='+unqid+']');
+
+ li = $pl.find('li[unqid='+unqid+']');
li.find('.crossfade').toggle();
highlightActive(li.find('.spl_fade_control'));
});
@@ -321,8 +324,8 @@ var AIRTIME = (function(AIRTIME){
function openFadeEditor(event) {
var li;
-
- event.stopPropagation();
+
+ event.stopPropagation();
li = $(this).parents("li");
li.find(".crossfade").toggle();
@@ -337,11 +340,11 @@ var AIRTIME = (function(AIRTIME){
function openCueEditor(event) {
var li, icon;
-
+
event.stopPropagation();
icon = $(this);
- li = $(this).parents("li");
+ li = $(this).parents("li");
li.find(".cue-edit").toggle();
if (li.hasClass("ui-state-active")) {
@@ -353,56 +356,38 @@ var AIRTIME = (function(AIRTIME){
highlightActive(icon);
}
}
-
+
function editName() {
- var nameElement = $(this),
- lastMod = getModified(),
- type = $('.obj_type').val();
+ var nameElement = $(this);
//remove any newlines if user somehow snuck them in (easy to do if dragging/dropping text)
nameElement.text(nameElement.text().replace("\n", ""));
-
- /* --until we decide whether Playlist name should autosave or not
- url = baseUrl+'Playlist/set-playlist-name';
-
- $.post(url,
- {format: "json", name: nameElement.text(), modified: lastMod, type: type},
- function(json){
-
- if (json.error !== undefined) {
- playlistError(json);
- }
- else {
- setModified(json.modified);
- nameElement.text(json.playlistName);
- redrawLib();
- }
- });
- */
+ var name = $pl.find(".playlist_name_display").text();
+ $(".nav.nav-tabs .active a > span.tab-name").text(name);
}
-
+
function redrawLib() {
var dt = $lib.find("#library_display").dataTable();
-
+
dt.fnStandingRedraw();
AIRTIME.library.redrawChosen();
}
-
+
function setPlaylistContent(json) {
var $html = $(json.html);
-
+
$('#spl_name > a')
.empty()
.append(json.name);
- $('.obj_length')
+ $pl.find('.obj_length')
.empty()
.append(json.length);
$('#fieldset-metadate_change textarea')
.empty()
.val(json.description);
-
- $('.spl_sortable').off('focusout keydown');
- $('.spl_sortable')
+
+ $pl.find('.spl_sortable').off('focusout keydown');
+ $pl.find('.spl_sortable')
.empty()
.append($html);
setCueEvents();
@@ -411,69 +396,153 @@ var AIRTIME = (function(AIRTIME){
AIRTIME.playlist.validatePlaylistElements();
redrawLib();
}
-
+
function setFadeIcon(){
- var contents = $(".spl_sortable");
+ var contents = $pl.find(".spl_sortable");
var show = contents.is(":visible");
- var empty = $(".spl_empty");
-
+ var empty = $pl.find(".spl_empty");
+
if (!show || empty.length > 0) {
- $("#spl_crossfade").hide();
+ $pl.find("#spl_crossfade").hide();
} else {
//get list of playlist contents
var list = contents.children();
-
+
//if first and last items are blocks, hide the fade icon
var first = list.first();
var last = list.last();
if (first.find(':first-child').children().attr('blockid') !== undefined &&
last.find(':first-child').children().attr('blockid') !== undefined) {
- $("#spl_crossfade").hide();
+ $pl.find("#spl_crossfade").hide();
} else {
- $("#spl_crossfade").show();
+ $pl.find("#spl_crossfade").show();
}
}
}
-
+
function getId() {
- return parseInt($(".obj_id").val(), 10);
+ return parseInt($pl.find(".obj_id").val(), 10);
}
-
+
function getModified() {
- return parseInt($(".obj_lastMod").val(), 10);
+ return parseInt($pl.find(".obj_lastMod").val(), 10);
}
-
+
function setModified(modified) {
- $(".obj_lastMod").val(modified);
+ $pl.find(".obj_lastMod").val(modified);
}
-
+
+ /*
+ * Should all be moved to builder.js eventually
+ */
+ function buildNewTab(json) {
+ AIRTIME.library.selectNone();
+
+ var tabId = $openTabs[json.type + json.id];
+ if (tabId !== undefined) {
+ AIRTIME.showbuilder.switchTab($("#pl-tab-content-" + tabId), $("#pl-tab-" + tabId));
+ return undefined;
+ }
+ $tabCount++;
+
+ var wrapper = "
",
+ t = $("#show_builder").append(wrapper).find("#pl-tab-content-" + $tabCount),
+ pane = $(".editor_pane_wrapper:last"),
+ name = json.type == "md" ? // file
+ pane.append(json.html).find("#track_title").val() + $.i18n._(" - Metadata Editor")
+ : pane.append(json.html).find(".playlist_name_display").text(),
+ tab =
+ "
" +
+ " " +
+ " " +
+ " " +
+ " ",
+ tabs = $(".nav.nav-tabs");
+
+ if (json.id) {
+ $openTabs[json.type + json.id] = $tabCount;
+ }
+
+ $(".nav.nav-tabs li").removeClass("active");
+ tabs.append(tab);
+ tabs.find("#pl-tab-" + $tabCount + " span.tab-name").text(name);
+
+ var newTab = $("#pl-tab-" + $tabCount);
+ AIRTIME.showbuilder.switchTab(t, newTab);
+
+ return {wrapper: pane, tab: newTab, pane: t};
+ }
+
+ function openFileMdEditor(json) {
+ var newTab = buildNewTab(json);
+ if (newTab === undefined) {
+ return;
+ }
+ newTab.tab.on("click", function() {
+ if (!$(this).hasClass('active')) {
+ AIRTIME.showbuilder.switchTab(newTab.pane, newTab.tab);
+ }
+ });
+ newTab.wrapper.find(".md-cancel").on("click", function() {
+ closeTab();
+ });
+ initialEvents();
+ }
+
function openPlaylist(json) {
- $(".side_playlist")
- .empty()
- .append(json.html);
-
- setUpPlaylist();
- setCueEvents();
- setFadeEvents();
-
+ var newTab = buildNewTab(json);
+ if (newTab === undefined) {
+ return;
+ }
+ newTab.tab.on("click", function() {
+ if (!$(this).hasClass('active')) {
+ AIRTIME.showbuilder.switchTab(newTab.pane, newTab.tab);
+ $.post(baseUrl+'playlist/edit',
+ {format: "json", id: newTab.pane.find(".obj_id").val(), type: newTab.pane.find(".obj_type").val()});
+ }
+ });
+ AIRTIME.playlist.init();
+
// functions in smart_blockbuilder.js
setupUI();
appendAddButton();
appendModAddButton();
removeButtonCheck();
}
-
+
function openPlaylistPanel() {
- var screenWidth = Math.floor(viewport.width - 40);
viewport = AIRTIME.utilities.findViewportDimensions();
+ var screenWidth = Math.floor(viewport.width - 40);
widgetHeight = viewport.height - 185;
- $lib.width(Math.floor(screenWidth * 0.53));
$pl.show().width(Math.floor(screenWidth * 0.44));
$pl.height(widgetHeight);
$("#pl_edit").hide();
}
+ function closeTab(id) {
+ var curr = $(".active-tab"),
+ pane = id ? $(".pl-content[tab-id='" + id + "']") : curr,
+ tab = id ? $(".nav.nav-tabs [tab-id='" + id + "']") : $(".nav.nav-tabs .active"),
+ toPane = pane.next().length > 0 ? pane.next() : pane.prev(),
+ toTab = tab.next().length > 0 ? tab.next() : tab.prev(),
+ objId = pane.find(".obj_id").val(),
+ pl = id ? pane : $pl;
+ delete $openTabs[tab.attr("tab-type") + objId]; // Remove the closed tab from our open tabs array
+
+ // Remove the relevant DOM elements (the tab and the tab content)
+ tab.remove();
+ pl.remove();
+
+ if (pane.get(0) == curr.get(0)) { // Closing the current tab, otherwise we don't need to switch tabs
+ AIRTIME.showbuilder.switchTab(toPane, toTab);
+ }
+ }
+
+ mod.closeTab = function(id) {
+ closeTab(id);
+ };
+
//Purpose of this function is to iterate over all playlist elements
//and verify whether they can be previewed by the browser or not. If not
//then the playlist element is greyed out
@@ -487,7 +556,7 @@ var AIRTIME = (function(AIRTIME){
if (isAudioSupported(mime)) {
$(value).bind("click", openAudioPreview);
} else {
- $(value).attr("class", "big_play_disabled dark_class");
+ $(value).attr("class", "big_play_disabled dark_class");
$(value).qtip({
content: $.i18n._("Your browser does not support playing this file type: ")+ mime,
show: 'mouseover',
@@ -505,13 +574,13 @@ var AIRTIME = (function(AIRTIME){
position: {
my: "left bottom",
at: "right center"
- },
- })
+ }
+ })
}
}
} else {
if ($(value).attr('blocktype') === 'dynamic') {
- $(value).attr("class", "big_play_disabled dark_class");
+ $(value).attr("class", "big_play_disabled dark_class");
$(value).qtip({
content: $.i18n._('Dynamic block is not previewable'),
show: 'mouseover',
@@ -529,31 +598,30 @@ var AIRTIME = (function(AIRTIME){
position: {
my: "left bottom",
at: "right center"
- },
+ }
})
} else {
$(value).bind("click", openAudioPreview);
}
}
});
- }
-
+ };
+
//sets events dynamically for playlist entries (each row in the playlist)
function setPlaylistEntryEvents() {
-
- $pl.delegate(".spl_sortable .ui-icon-closethick",
+ $pl.delegate(".spl_sortable .ui-icon-closethick",
{"click": function(ev){
var id;
id = parseInt($(this).attr("id").split("_").pop(), 10);
AIRTIME.playlist.fnDeleteItems([id]);
}});
- $pl.delegate(".spl_fade_control",
+ $pl.delegate(".spl_fade_control",
{"click": openFadeEditor});
-
- $pl.delegate(".spl_cue",
+
+ $pl.delegate(".spl_cue",
{"click": openCueEditor});
-
+
$pl.delegate(".spl_block_expand",
{"click": function(ev){
var id = parseInt($(this).attr("id").split("_").pop(), 10);
@@ -577,7 +645,7 @@ var AIRTIME = (function(AIRTIME){
$html += "
" +
""+ele.track_title+" - " +
""+ele.creator+" " +
- ""+ele.length+" " +
+ ""+ele.length+" " +
" ";
}
})
@@ -589,7 +657,7 @@ var AIRTIME = (function(AIRTIME){
"
"+ele['display_name']+" " +
"
"+ele['display_modifier']+" " +
"
"+ele['value']+" " +
- "
"+extra+" " +
+ "
"+extra+" " +
"";
});
}
@@ -605,16 +673,16 @@ var AIRTIME = (function(AIRTIME){
}
}});
}
-
+
//sets events dynamically for the cue editor.
function setCueEvents() {
- var temp = $('.spl_sortable');
+ var temp = $('.active-tab .spl_sortable');
temp.on("focusout", ".spl_cue_in span", changeCueIn);
temp.on("keydown", ".spl_cue_in span", submitOnEnter);
-
+
temp.on("focusout", ".spl_cue_out span", changeCueOut);
temp.on("keydown", ".spl_cue_out span", submitOnEnter);
-
+
//remove show waveform buttons since web audio api is not supported.
if (!(window.AudioContext || window.webkitAudioContext)) {
temp.find('.pl-waveform-cues-btn')
@@ -622,16 +690,16 @@ var AIRTIME = (function(AIRTIME){
.html($.i18n._("Waveform features are available in a browser supporting the Web Audio API"));
}
}
-
+
//sets events dynamically for the fade editor.
function setFadeEvents() {
- var temp = $('.spl_sortable');
+ var temp = $('.active-tab .spl_sortable');
temp.on("focusout", ".spl_fade_in span", changeFadeIn);
temp.on("keydown", ".spl_fade_in span", submitOnEnter);
-
+
temp.on("focusout", ".spl_fade_out span", changeFadeOut);
temp.on("keydown", ".spl_fade_out span", submitOnEnter);
-
+
//remove show waveform buttons since web audio api is not supported.
if (!(window.AudioContext || window.webkitAudioContext)) {
temp.find('.pl-waveform-fades-btn')
@@ -639,14 +707,14 @@ var AIRTIME = (function(AIRTIME){
.html($.i18n._("Waveform features are available in a browser supporting the Web Audio API"));
}
}
-
- function initialEvents() {
+
+ function initialEvents() {
var cachedDescription;
-
+
//main playlist fades events
$pl.on("click", "#spl_crossfade", function() {
var lastMod = getModified(),
- type = $('.obj_type').val();
+ type = $pl.find('.obj_type').val();
if ($(this).hasClass("ui-state-active")) {
$(this).removeClass("ui-state-active");
@@ -655,8 +723,8 @@ var AIRTIME = (function(AIRTIME){
else {
$(this).addClass("ui-state-active");
- var url = baseUrl+'Playlist/get-playlist-fades';
- $.post(url,
+ var url = baseUrl+'playlist/get-playlist-fades';
+ $.post(url,
{format: "json", modified: lastMod, type: type},
function(json){
if (json.error !== undefined){
@@ -688,24 +756,24 @@ var AIRTIME = (function(AIRTIME){
});
}
});
-
+
$pl.on("blur", "span.spl_main_fade_in", function(event){
event.stopPropagation();
- var url = baseUrl+"Playlist/set-playlist-fades",
+ var url = baseUrl+"playlist/set-playlist-fades",
span = $(this),
- fadeIn = $.trim(span.text()),
+ fadeIn = $.trim(span.text()),
lastMod = getModified(),
- type = $('.obj_type').val();
-
+ type = $pl.find('.obj_type').val();
+
if (!isFadeValid(fadeIn)){
showError(span, $.i18n._("please put in a time in seconds '00 (.0)'"));
return;
}
- $.post(url,
- {format: "json", fadeIn: fadeIn, modified: lastMod, type: type},
- function(json){
+ $.post(url,
+ {format: "json", fadeIn: fadeIn, modified: lastMod, type: type},
+ function(json){
hideError(span);
if (json.modified !== undefined) {
setModified(json.modified);
@@ -716,19 +784,19 @@ var AIRTIME = (function(AIRTIME){
$pl.on("blur", "span.spl_main_fade_out", function(event){
event.stopPropagation();
- var url = baseUrl+"Playlist/set-playlist-fades",
+ var url = baseUrl+"playlist/set-playlist-fades",
span = $(this),
- fadeOut = $.trim(span.text()),
+ fadeOut = $.trim(span.text()),
lastMod = getModified(),
- type = $('.obj_type').val();
+ type = $pl.find('.obj_type').val();
if (!isFadeValid(fadeOut)){
showError(span, $.i18n._("please put in a time in seconds '00 (.0)'"));
return;
}
- $.post(url,
- {format: "json", fadeOut: fadeOut, modified: lastMod, type: type},
+ $.post(url,
+ {format: "json", fadeOut: fadeOut, modified: lastMod, type: type},
function(json){
hideError(span);
if (json.modified !== undefined) {
@@ -748,7 +816,7 @@ var AIRTIME = (function(AIRTIME){
//edit playlist name event
$pl.on("keydown", ".playlist_name_display", submitOnEnter);
$pl.on("blur", ".playlist_name_display", editName);
-
+
//edit playlist description events
$pl.on("click", "legend", function(){
var $fs = $(this).parents("fieldset");
@@ -761,18 +829,21 @@ var AIRTIME = (function(AIRTIME){
$fs.addClass("closed");
}
});
-
+
$pl.on("click", 'button[id="playlist_shuffle_button"]', function(){
- obj_id = $('input[id="obj_id"]').val();
- url = baseUrl+"Playlist/shuffle";
+ obj_id = $pl.find('.obj_id').val();
+ url = baseUrl+"playlist/shuffle";
enableLoadingIcon();
$.post(url, {format: "json", obj_id: obj_id}, function(json){
if (json.error !== undefined) {
alert(json.error);
}
- AIRTIME.playlist.fnOpenPlaylist(json);
+ if (json.html !== undefined) {
+ closeTab();
+ openPlaylist(json);
+ }
if (json.result == "0") {
$pl.find('.success').text($.i18n._('Playlist shuffled'));
$pl.find('.success').show();
@@ -780,64 +851,69 @@ var AIRTIME = (function(AIRTIME){
disableLoadingIcon();
setTimeout(removeSuccessMsg, 5000);
});
- })
+ });
- $pl.on("click", "#webstream_save", function(){
+ $pl.find("#webstream_save").on("click", function(){
//get all fields and POST to server
//description
//stream url
- //default_length
+ //default_length
//playlist name
- var id = $pl.find(".obj_id").attr("value");
+ var id = $pl.find(".obj_id").attr("value");
var description = $pl.find("#description").val();
var streamurl = $pl.find("#streamurl-element input").val();
var length = $pl.find("#streamlength-element input").val();
var name = $pl.find(".playlist_name_display").text();
-
+
//hide any previous errors (if any)
- $(".side_playlist .errors").empty().hide();
-
- var url = baseUrl+'Webstream/save';
- $.post(url,
- {format: "json", id:id, description: description, url:streamurl, length: length, name: name},
+ $(".side_playlist.active-tab .errors").empty().hide();
+
+ var url = baseUrl+'webstream/save';
+ $.post(url,
+ {format: "json", id:id, description: description, url:streamurl, length: length, name: name},
function(json){
if (json.analysis){
for (var s in json.analysis){
var field = json.analysis[s];
-
+
if (!field[0]) {
var elemId = "#"+s+"-error";
- var $div = $(".side_playlist " + elemId).text(field[1]).show();
+ var $div = $(".side_playlist.active-tab " + elemId).text(field[1]).show();
}
}
} else {
- var $status = $(".side_playlist .status");
+ var $status = $(".side_playlist.active-tab .status");
$status.html(json.statusMessage);
$status.show();
setTimeout(function(){$status.fadeOut("slow", function(){$status.empty()})}, 5000);
- var $ws_id = $(".obj_id");
+ var $ws_id = $(".active-tab .obj_id");
$ws_id.attr("value", json.streamId);
var $ws_id = $("#ws_delete");
$ws_id.show();
- var length = $(".side_playlist .ws_length");
+ var length = $(".side_playlist.active-tab .ws_length");
length.text(json.length);
//redraw the library to show the new webstream
redrawLib();
}
-
- });
-
-
+
+ });
+
+
+ });
+
+ $pl.find("#webstream_cancel, #cancel_button").on("click", function() {
+ var tabId = $pl.attr("tab-id");
+ $("li[tab-id=" + tabId + "] .lib_pl_close").click();
});
$lib.on("click", "#pl_edit", function() {
openPlaylistPanel();
- $.ajax( {
+ $.ajax({
url : baseUrl+"usersettings/set-library-screen-settings",
type : "POST",
data : {
@@ -850,10 +926,31 @@ var AIRTIME = (function(AIRTIME){
});
});
- $pl.on("click", "#lib_pl_close", function() {
- var screenWidth = Math.floor(viewport.width - 40);
- $pl.hide();
- $lib.width(screenWidth).find("#library_display_length").append($togglePl.show());
+ // Unbind so each tab is only handled by its own close button
+ $(".lib_pl_close").unbind().click(function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+
+ $(this).unbind("click"); // Prevent repeated clicks in quick succession from closing multiple tabs
+
+ var tabId = $(this).closest("li").attr("tab-id");
+ //AIRTIME.showbuilder.switchTab($("#pl-tab-content-" + tabId), $("#pl-tab-" + tabId));
+ //$pl.hide();
+
+ // We need to update the text on the add button
+ AIRTIME.library.checkAddButton();
+ // We also need to run the draw callback to update how dragged items are drawn
+ AIRTIME.library.fnDrawCallback();
+
+ var name = $pl.find('.playlist_name_display').text().trim();
+
+ if ((name == "Untitled Playlist"
+ || name == "Untitled Smart Block")
+ && $pl.find(".spl_sortable .spl_empty").length == 1) {
+ mod.fnDelete(undefined, tabId);
+ } else {
+ closeTab(tabId);
+ }
$.ajax( {
url : baseUrl+"usersettings/set-library-screen-settings",
@@ -868,16 +965,16 @@ var AIRTIME = (function(AIRTIME){
});
});
- $('#save_button').live("click", function(event){
+ $pl.on("click", "#save_button", function(event) {
/* Smart blocks: get name, description, and criteria
* Playlists: get name, description
*/
- var criteria = $('form').serializeArray(),
- block_name = $('.playlist_name_display').text(),
- block_desc = $('textarea[name="description"]').val(),
- save_action = baseUrl+'Playlist/save',
- obj_id = $('input[id="obj_id"]').val(),
- obj_type = $('.obj_type').val(),
+ var criteria = $pl.find('form').serializeArray(),
+ block_name = $pl.find('.playlist_name_display').text(),
+ block_desc = $pl.find('textarea[name="description"]').val(),
+ save_action = baseUrl+'playlist/save',
+ obj_id = $pl.find(".obj_id").val(),
+ obj_type = $pl.find('.obj_type').val(),
lastMod = getModified(),
dt = $('table[id="library_display"]').dataTable();
enableLoadingIcon();
@@ -888,7 +985,8 @@ var AIRTIME = (function(AIRTIME){
alert(json.error);
}
if (json.html !== undefined) {
- AIRTIME.playlist.fnOpenPlaylist(json);
+ closeTab();
+ openPlaylist(json);
}
setModified(json.modified);
if (obj_type == "block") {
@@ -905,49 +1003,49 @@ var AIRTIME = (function(AIRTIME){
);
});
- $("#pl-bl-clear-content").live("click", function(event) {
+ $pl.find("#pl-bl-clear-content").unbind().on("click", function(event) {
var sUrl = baseUrl+"playlist/empty-content",
oData = {};
playlistRequest(sUrl, oData);
});
}
-
+
function setUpPlaylist() {
var sortableConf;
-
+
sortableConf = (function(){
var aReceiveItems,
html,
fnReceive,
- fnUpdate;
-
+ fnUpdate;
+
fnReceive = function(event, ui) {
var aItems = [],
aSelected,
i,
length;
-
+
AIRTIME.library.addToChosen(ui.item);
-
+
//filter out anything that isn't an audiofile.
aSelected = AIRTIME.library.getSelectedData();
-
+
for (i = 0, length = aSelected.length; i < length; i++) {
aItems.push(new Array(aSelected[i].id, aSelected[i].ftype));
}
-
+
aReceiveItems = aItems;
html = ui.helper.html();
-
+
AIRTIME.library.removeFromChosen(ui.item);
};
-
+
fnUpdate = function(event, ui) {
var prev,
aItems = [],
iAfter,
sAddType;
-
+
prev = ui.item.prev();
if (prev.hasClass("spl_empty") || prev.length === 0) {
iAfter = undefined;
@@ -957,17 +1055,17 @@ var AIRTIME = (function(AIRTIME){
iAfter = parseInt(prev.attr("id").split("_").pop(), 10);
sAddType = 'after';
}
-
+
//item was dragged in from library datatable
if (aReceiveItems !== undefined) {
-
+
$pl.find("tr.ui-draggable")
.after(html)
.empty();
-
+
aItems = aReceiveItems;
aReceiveItems = undefined;
-
+
AIRTIME.playlist.fnAddItems(aItems, iAfter, sAddType);
}
//item was reordered.
@@ -976,14 +1074,13 @@ var AIRTIME = (function(AIRTIME){
AIRTIME.playlist.fnMoveItems(aItems, iAfter);
}
};
-
+
return {
items: 'li',
//hack taken from
//http://stackoverflow.com/questions/2150002/jquery-ui-sortable-how-can-i-change-the-appearance-of-the-placeholder-object
placeholder: {
element: function(currentItem) {
-
return $('
')[0];
},
update: function(container, p) {
@@ -991,10 +1088,12 @@ var AIRTIME = (function(AIRTIME){
}
},
forcePlaceholderSize: true,
- handle: 'div.list-item-container',
+ //handle: 'div.list-item-container',
start: function(event, ui) {
ui.placeholder.height(56);
},
+ axis: "y",
+ containment: "document",
receive: fnReceive,
update: fnUpdate
};
@@ -1003,127 +1102,125 @@ var AIRTIME = (function(AIRTIME){
$pl.find(".spl_sortable").sortable(sortableConf);
AIRTIME.playlist.validatePlaylistElements();
}
-
+
mod.fnNew = function() {
- var url = baseUrl+'Playlist/new';
+ var url = baseUrl+'playlist/new';
stopAudioPreview();
-
- $.post(url,
- {format: "json", type: 'playlist'},
+
+ $.post(url,
+ {format: "json", type: 'playlist'},
function(json){
openPlaylist(json);
redrawLib();
});
};
-
+
mod.fnWsNew = function() {
- var url = baseUrl+'Webstream/new';
+ var url = baseUrl+'webstream/new';
stopAudioPreview();
-
- $.post(url,
- {format: "json"},
+
+ $.post(url,
+ {format: "json"},
function(json){
openPlaylist(json);
redrawLib();
});
};
-
+
mod.fnNewBlock = function() {
- var url = baseUrl+'Playlist/new';
+ var url = baseUrl+'playlist/new';
stopAudioPreview();
-
- $.post(url,
- {format: "json", type: 'block'},
+
+ $.post(url,
+ {format: "json", type: 'block'},
function(json){
openPlaylist(json);
redrawLib();
});
};
-
+
+ mod.fileMdEdit = function(json) {
+ openFileMdEditor(json);
+ };
+
mod.fnEdit = function(id, type, url) {
- if ($pl.is(":hidden")) {
- openPlaylistPanel();
- }
- stopAudioPreview();
-
- $.post(url,
- {format: "json", id: id, type: type},
+ //openPlaylistPanel();
+ stopAudioPreview();
+
+ $.post(url,
+ {format: "json", id: id, type: type},
function(json){
openPlaylist(json);
+ redrawLib();
});
};
-
- mod.fnDelete = function(plid) {
- var url, id, lastMod;
-
- stopAudioPreview();
+
+ mod.fnDelete = function(plid, tabId) {
+ var url, id, lastMod, type, pl = (tabId === undefined) ? $pl : $('#pl-tab-content-' + tabId);
+
+ stopAudioPreview();
id = (plid === undefined) ? getId() : plid;
lastMod = getModified();
- type = $('.obj_type').val();
- url = baseUrl+'Playlist/delete';
+ type = pl.find('.obj_type').val();
+ url = baseUrl+'playlist/delete';
- $.post(url,
- {format: "json", ids: id, modified: lastMod, type: type},
- function(json){
- openPlaylist(json);
+ $.post(url,
+ {format: "json", ids: id, modified: lastMod, type: type},
+ function(json) {
+ closeTab(tabId);
redrawLib();
});
};
-
+
mod.fnWsDelete = function(wsid) {
var url, id, lastMod;
-
- stopAudioPreview();
+
+ stopAudioPreview();
id = (wsid === undefined) ? getId() : wsid;
lastMod = getModified();
- type = $('.obj_type').val();
- url = baseUrl+'Webstream/delete';
-
- $.post(url,
- {format: "json", ids: id, modified: lastMod, type: type},
+ type = $pl.find('.obj_type').val();
+ url = baseUrl+'webstream/delete';
+
+ $.post(url,
+ {format: "json", ids: id, modified: lastMod, type: type},
function(json){
openPlaylist(json);
redrawLib();
});
};
-
+
mod.disableUI = function() {
-
- $lib.block({
+
+ $lib.block({
message: "",
theme: true,
applyPlatformOpacityRules: false
});
-
- $pl.block({
+
+ $pl.block({
message: "",
theme: true,
applyPlatformOpacityRules: false
});
};
-
+
mod.fnOpenPlaylist = function(json) {
openPlaylist(json);
};
-
+
mod.enableUI = function() {
-
$lib.unblock();
$pl.unblock();
-
- //Block UI changes the postion to relative to display the messages.
- $lib.css("position", "static");
- $pl.css("position", "static");
+
setupUI();
};
-
- function playlistResponse(json){
-
+
+ function playlistResponse(json){
if (json.error !== undefined) {
playlistError(json);
}
@@ -1131,49 +1228,50 @@ var AIRTIME = (function(AIRTIME){
setPlaylistContent(json);
setFadeIcon();
}
-
+
mod.enableUI();
}
-
+
function playlistRequest(sUrl, oData) {
var lastMod,
- obj_type = $('.obj_type').val();
-
+ obj_type = $pl.find('.obj_type').val();
+
mod.disableUI();
-
+
lastMod = getModified();
-
+
oData["modified"] = lastMod;
oData["obj_type"] = obj_type;
oData["format"] = "json";
-
+
$.post(
- sUrl,
- oData,
+ sUrl,
+ oData,
playlistResponse
);
}
-
+
mod.fnAddItems = function(aItems, iAfter, sAddType) {
+ AIRTIME.library.selectNone();
var sUrl = baseUrl+"playlist/add-items";
oData = {"aItems": aItems, "afterItem": iAfter, "type": sAddType};
playlistRequest(sUrl, oData);
};
-
+
mod.fnMoveItems = function(aIds, iAfter) {
var sUrl = baseUrl+"playlist/move-items",
oData = {"ids": aIds, "afterItem": iAfter};
-
+
playlistRequest(sUrl, oData);
};
-
+
mod.fnDeleteItems = function(aItems) {
var sUrl = baseUrl+"playlist/delete-items",
oData = {"ids": aItems};
-
+
playlistRequest(sUrl, oData);
};
-
+
mod.showFadesWaveform = function(e) {
var $el = $(e.target),
$parent = $el.parents("dl"),
@@ -1186,17 +1284,17 @@ var AIRTIME = (function(AIRTIME){
playlistEditor,
id1, id2,
id = $li.attr("unqid");
-
-
+
+
function removeDialog() {
playlistEditor.stop();
-
+
$html.dialog("destroy");
$html.remove();
}
-
+
if ($fadeOut.length > 0) {
-
+
tracks.push({
src: $fadeOut.data("fadeout"),
cuein: $fadeOut.data("cuein"),
@@ -1212,12 +1310,12 @@ var AIRTIME = (function(AIRTIME){
'shift': false
}
});
-
+
id1 = $fadeOut.data("item");
}
if ($fadeIn.length > 0) {
-
+
tracks.push({
src: $fadeIn.data("fadein"),
start: $fadeIn.data("offset"),
@@ -1234,13 +1332,13 @@ var AIRTIME = (function(AIRTIME){
'shift': false
}
});
-
+
id2 = $fadeIn.data("item");
}
-
+
//set the first track to not be moveable (might only be one track depending on what follows)
//tracks[0].states["shift"] = false;
-
+
$html.dialog({
modal: true,
title: $.i18n._("Fade Editor"),
@@ -1252,21 +1350,21 @@ var AIRTIME = (function(AIRTIME){
{text: $.i18n._("Cancel"), class: "btn btn-small", click: removeDialog},
{text: $.i18n._("Save"), class: "btn btn-small btn-inverse", click: function() {
var json = playlistEditor.getJson(),
- offset,
+ offset,
fadeIn, fadeOut,
fade;
-
+
playlistEditor.stop();
-
+
if (json.length === 0)
{
id1 = undefined;
id2 = undefined;
}
else if (json.length === 1) {
-
+
fade = json[0]["fades"][0];
-
+
if (fade["type"] === "FadeOut") {
fadeOut = fade["end"] - fade["start"];
id2 = undefined; //incase of track decode error.
@@ -1277,24 +1375,24 @@ var AIRTIME = (function(AIRTIME){
}
}
else {
-
+
offset = json[0]["end"] - json[1]["start"];
-
+
fade = json[0]["fades"][0];
fadeOut = fade["end"] - fade["start"];
-
+
fade = json[1]["fades"][0];
fadeIn = fade["end"] - fade["start"];
}
-
+
fadeIn = (fadeIn === undefined) ? undefined : fadeIn.toFixed(1);
fadeOut = (fadeOut === undefined) ? undefined : fadeOut.toFixed(1);
-
+
changeCrossfade($html, id1, id2, fadeIn, fadeOut, offset, id);
}}
],
open: function (event, ui) {
-
+
var config = new Config({
resolution: 15000,
state: "cursor",
@@ -1305,7 +1403,7 @@ var AIRTIME = (function(AIRTIME){
UITheme: "jQueryUI",
timeFormat: 'hh:mm:ss.u'
});
-
+
playlistEditor = new PlaylistEditor();
playlistEditor.setConfig(config);
playlistEditor.init(tracks);
@@ -1314,12 +1412,12 @@ var AIRTIME = (function(AIRTIME){
resizeStop: function(event, ui) {
playlistEditor.resize();
}
- });
+ });
};
-
+
mod.showCuesWaveform = function(e) {
var $el = $(e.target),
- $li = $el.parents("li"),
+ $li = $el.parents("li"),
id = $li.attr("unqid"),
$parent = $el.parent(),
uri = $parent.data("uri"),
@@ -1337,29 +1435,29 @@ var AIRTIME = (function(AIRTIME){
}],
dim = AIRTIME.utilities.findViewportDimensions(),
playlistEditor;
-
+
function removeDialog() {
playlistEditor.stop();
-
+
$html.dialog("destroy");
$html.remove();
}
-
+
$html.find('.editor-cue-in').html(cueIn);
$html.find('.editor-cue-out').html(cueOut);
-
+
$html.on("click", ".set-cue-in", function(e) {
var cueIn = $html.find('.audio_start').val();
-
+
$html.find('.editor-cue-in').html(cueIn);
});
-
+
$html.on("click", ".set-cue-out", function(e) {
var cueOut = $html.find('.audio_end').val();
-
+
$html.find('.editor-cue-out').html(cueOut);
});
-
+
$html.dialog({
modal: true,
title: $.i18n._("Cue Editor"),
@@ -1372,14 +1470,14 @@ var AIRTIME = (function(AIRTIME){
{text: $.i18n._("Save"), class: "btn btn-small btn-inverse", click: function() {
var cueIn = $html.find('.editor-cue-in').html(),
cueOut = $html.find('.editor-cue-out').html();
-
+
playlistEditor.stop();
-
+
changeCues($html, id, cueIn, cueOut);
}}
],
open: function (event, ui) {
-
+
var config = new Config({
resolution: 15000,
mono: true,
@@ -1389,109 +1487,57 @@ var AIRTIME = (function(AIRTIME){
UITheme: "jQueryUI",
timeFormat: 'hh:mm:ss.u'
});
-
+
playlistEditor = new PlaylistEditor();
playlistEditor.setConfig(config);
- playlistEditor.init(tracks);
+ playlistEditor.init(tracks);
},
close: removeDialog,
resizeStop: function(event, ui) {
playlistEditor.resize();
}
- });
- };
-
- mod.init = function() {
- /*
- $.contextMenu({
- selector: '#spl_new, #ws_new',
- trigger: "left",
- ignoreRightClick: true,
- items: {
- "sp": {name: "New Playlist", callback: AIRTIME.playlist.fnNew},
- "sb": {name: "New Smart Block", callback: AIRTIME.playlist.fnNewBlock},
- "ws": {name: "New Webstream", callback: AIRTIME.playlist.fnWsNew}
- }
});
- */
- $('#lib-new-pl').live('click', function(){AIRTIME.playlist.fnNew();});
- $('#lib-new-bl').live('click', function(){AIRTIME.playlist.fnNewBlock();});
- $('#lib-new-ws').live('click', function(){AIRTIME.playlist.fnWsNew();});
- /*
- $pl.delegate("#spl_new",
- {"click": AIRTIME.playlist.fnNew});*/
+ };
+
+ mod.setAsActive = function() {
+ $pl = $(".active-tab");
+ };
+
+ mod.init = function() {
+ AIRTIME.playlist.setAsActive();
+
+ //$pl.delegate("#spl_delete", {"click": function(ev){
+ // AIRTIME.playlist.fnDelete();
+ //}});
+ //
+ //$pl.delegate("#ws_delete", {"click": function(ev){
+ // AIRTIME.playlist.fnWsDelete();
+ //}});
- $pl.delegate("#spl_delete", {"click": function(ev){
- AIRTIME.playlist.fnDelete();
- }});
-
- $pl.delegate("#ws_delete", {"click": function(ev){
- AIRTIME.playlist.fnWsDelete();
- }});
-
$pl.delegate(".pl-waveform-cues-btn", {"click": function(ev){
AIRTIME.playlist.showCuesWaveform(ev);
}});
-
+
$pl.delegate(".pl-waveform-fades-btn", {"click": function(ev){
AIRTIME.playlist.showFadesWaveform(ev);
}});
-
+
setPlaylistEntryEvents();
setCueEvents();
setFadeEvents();
setFadeIcon();
-
+
initialEvents();
setUpPlaylist();
- };
-
- function setWidgetSize() {
- viewport = AIRTIME.utilities.findViewportDimensions();
- widgetHeight = viewport.height - 185;
- width = Math.floor(viewport.width - 80);
-
- var libTableHeight = widgetHeight - 175;
-
- if (!$pl.is(':hidden')) {
- $lib.height(widgetHeight)
- .find(".dataTables_scrolling")
- .css("max-height", libTableHeight)
- .end()
- .width(Math.floor(width * 0.54));
-
- $pl.height(widgetHeight)
- .width(Math.floor(width * 0.45));
- } else {
- $lib.height(widgetHeight)
- .find(".dataTables_scrolling")
- .css("max-height", libTableHeight)
- .end()
- .width(width + 40);
- }
- }
-
- mod.onReady = function() {
- $lib = $("#library_content");
- $pl = $(".side_playlist");
-
- setWidgetSize();
-
- AIRTIME.library.libraryInit();
- AIRTIME.playlist.init();
-
- if ($pl.is(':hidden')) {
- $lib.find("#library_display_length").append($togglePl.show());
- }
$pl.find(".ui-icon-alert").qtip({
content: {
text: sprintf($.i18n._("%s is unsure about the status of this file. This can happen when the file is on a remote drive that is unaccessible or the file is in a directory that isn't 'watched' anymore."), PRODUCT_NAME)
},
- position:{
+ position: {
adjust: {
- resize: true,
- method: "flip flip"
+ resize: true,
+ method: "flip flip"
},
at: "right center",
my: "left top",
@@ -1504,15 +1550,25 @@ var AIRTIME = (function(AIRTIME){
hide: 'mouseout'
});
};
-
- mod.onResize = function() {
-
- clearTimeout(resizeTimeout);
- resizeTimeout = setTimeout(setWidgetSize, 100);
+
+ mod.onReady = function() {
+ $lib = $("#library_content");
+
+ $('#new-playlist').live('click', function(){AIRTIME.playlist.fnNew();});
+ $('#new-smart-block').live('click', function(){AIRTIME.playlist.fnNewBlock();});
+ $('#new-webstream').live('click', function(){AIRTIME.playlist.fnWsNew();});
+
+ AIRTIME.playlist.init();
};
-
+
+ mod.onResize = function() {
+ var h = $(".panel-header .nav").height();
+ $(".pl-content").css("margin-top", h + 5); // 8px extra for padding
+ $("#show_builder_table_wrapper").css("top", h + 5);
+ };
+
return AIRTIME;
-
+
}(AIRTIME || {}));
diff --git a/airtime_mvc/public/js/airtime/playlist/_smart_blockbuilder.js b/airtime_mvc/public/js/airtime/playlist/_smart_blockbuilder.js
deleted file mode 100644
index a7335fdfd..000000000
--- a/airtime_mvc/public/js/airtime/playlist/_smart_blockbuilder.js
+++ /dev/null
@@ -1,609 +0,0 @@
-$(document).ready(function() {
- setSmartBlockEvents();
-});
-
-function setSmartBlockEvents() {
- var activeTab = $('.active-tab'),
- form = activeTab.find('.smart-block-form');
-
- /********** ADD CRITERIA ROW **********/
- form.find('#criteria_add').live('click', function(){
-
- var div = $('dd[id="sp_criteria-element"]').children('div:visible:last');
-
- 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();
- });
-
- /********** ADD MODIFIER ROW **********/
- form.find('a[id^="modifier_add"]').live('click', function(){
- var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
-
-
- //make new modifier row
- var newRow = $(this).parent().clone(),
- newRowCrit = newRow.find('select[name^="sp_criteria_field"]'),
- newRowMod = newRow.find('select[name^="sp_criteria_modifier"]'),
- newRowVal = newRow.find('input[name^="sp_criteria_value"]'),
- newRowExtra = newRow.find('input[name^="sp_criteria_extra"]'),
- newRowRemove = newRow.find('a[id^="criteria_remove"]');
-
- //remove error msg
- if (newRow.children().hasClass('errors sp-errors')) {
- newRow.find('span[class="errors sp-errors"]').remove();
- }
-
- //hide the critieria field select box
- newRowCrit.addClass('sp-invisible');
-
- //keep criteria value the same
- newRowCrit.val(criteria_value);
-
- //reset all other values
- newRowMod.val('0');
- newRowVal.val('');
- newRowExtra.val('');
- disableAndHideExtraField(newRowVal);
- sizeTextBoxes(newRowVal, 'sp_extra_input_text', 'sp_input_text');
-
- //remove the 'criteria add' button from new modifier row
- newRow.find('#criteria_add').remove();
-
- $(this).parent().after(newRow);
- reindexElements();
- appendAddButton();
- appendModAddButton();
- removeButtonCheck();
- });
-
- /********** REMOVE ROW **********/
- form.find('a[id^="criteria_remove"]').live('click', function(){
- var curr = $(this).parent();
- var curr_pos = curr.index();
- var list = curr.parent();
- var list_length = list.find("div:visible").length;
- var count = list_length - curr_pos;
- var next = curr.next();
- var item_to_hide;
- var prev;
- var index;
-
- //remove error message from current row, if any
- var error_element = curr.find('span[class="errors sp-errors"]');
- if (error_element.is(':visible')) {
- error_element.remove();
- }
-
- /* assign next row to current row for all rows below and including
- * the row getting removed
- */
- for (var i=0; i
0) {
- /* If the criteria field is hidden we know it is a modifier row
- * and can hide the previous row's modifier add button
- */
- if ($(div).find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
- $(div).prev().find('a[id^="modifier_add"]').addClass('sp-invisible');
- } else {
- $(div).prev().find('a[id^="modifier_add"]').removeClass('sp-invisible');
- }
- }
-
- //always add modifier add button to the last row
- if (i+1 == divs.length) {
- $(div).find('a[id^="modifier_add"]').removeClass('sp-invisible');
- }
- });
-}
-
-/* This function re-indexes all the form elements.
- * We need to do this everytime a row gets deleted
- */
-function reindexElements() {
- var divs = $('.active-tab .smart-block-form').find('div select[name^="sp_criteria_field"]').parent(),
- index = 0,
- modIndex = 0;
- /* Hide all logic labels
- * We will re-add them as each row gets indexed
- */
- $('.db-logic-label').text('').hide();
-
- $.each(divs, function(i, div){
- if (i > 0 && index < 26) {
-
- /* If the current row's criteria field is hidden we know it is
- * a modifier row
- */
- if ($(div).find('select[name^="sp_criteria_field"]').hasClass('sp-invisible')) {
- if ($(div).is(':visible')) {
- $(div).prev().find('.db-logic-label').text('or').show();
- }
- modIndex++;
- } else {
- if ($(div).is(':visible')) {
- $(div).prev().find('.db-logic-label').text('and').show();
- }
- index++;
- modIndex = 0;
- }
-
- $(div).find('select[name^="sp_criteria_field"]').attr('name', 'sp_criteria_field_'+index+'_'+modIndex);
- $(div).find('select[name^="sp_criteria_field"]').attr('id', 'sp_criteria_field_'+index+'_'+modIndex);
- $(div).find('select[name^="sp_criteria_modifier"]').attr('name', 'sp_criteria_modifier_'+index+'_'+modIndex);
- $(div).find('select[name^="sp_criteria_modifier"]').attr('id', 'sp_criteria_modifier_'+index+'_'+modIndex);
- $(div).find('input[name^="sp_criteria_value"]').attr('name', 'sp_criteria_value_'+index+'_'+modIndex);
- $(div).find('input[name^="sp_criteria_value"]').attr('id', 'sp_criteria_value_'+index+'_'+modIndex);
- $(div).find('input[name^="sp_criteria_extra"]').attr('name', 'sp_criteria_extra_'+index+'_'+modIndex);
- $(div).find('input[name^="sp_criteria_extra"]').attr('id', 'sp_criteria_extra_'+index+'_'+modIndex);
- $(div).find('a[name^="modifier_add"]').attr('id', 'modifier_add_'+index);
- $(div).find('a[id^="criteria_remove"]').attr('id', 'criteria_remove_'+index+'_'+modIndex);
- } else if (i > 0) {
- $(div).remove();
- }
- });
-}
-
-function buttonClickAction(clickType, url){
- var data = $('.active-tab .smart-block-form').serializeArray(),
- obj_id = $('.active-tab .obj_id').val();
-
- enableLoadingIcon();
- $.post(url, {format: "json", data: data, obj_id: obj_id}, function(data){
- callback(data, clickType);
- disableLoadingIcon();
- });
-}
-
-function setupUI() {
- var activeTab = $('.active-tab'),
- playlist_type = activeTab.find('input:radio[name=sp_type]:checked').val();
-
- /* Activate or Deactivate shuffle button
- * It is only active if playlist is not empty
- */
- var sortable = activeTab.find('.spl_sortable'),
- plContents = sortable.children(),
- shuffleButton = activeTab.find('.sp-button, #pl-bl-clear-content');
-
- if (!plContents.hasClass('spl_empty')) {
- if (shuffleButton.hasClass('ui-state-disabled')) {
- shuffleButton.removeClass('ui-state-disabled');
- shuffleButton.removeAttr('disabled');
- }
- } else if (!shuffleButton.hasClass('ui-state-disabled')) {
- shuffleButton.addClass('ui-state-disabled');
- shuffleButton.attr('disabled', 'disabled');
- }
-
- if (activeTab.find('.obj_type').val() == 'block') {
- if (playlist_type == "0") {
- shuffleButton.parent().show();
- sortable.show();
- } else {
- shuffleButton.parent().hide();
- sortable.hide();
- }
- }
-
- $(".playlist_type_help_icon").qtip({
- content: {
- text: $.i18n._("A static smart block will save the criteria and generate the block content immediately. This allows you to edit and view it in the Library before adding it to a show.")+" " +
- $.i18n._("A dynamic smart block will only save the criteria. The block content will get generated upon adding it to a show. You will not be able to view and edit the content in the Library.")
- },
- hide: {
- delay: 500,
- fixed: true
- },
- style: {
- border: {
- width: 0,
- radius: 4
- },
- classes: "ui-tooltip-dark ui-tooltip-rounded"
- },
- position: {
- my: "left bottom",
- at: "right center"
- }
- });
-
- $(".repeat_tracks_help_icon").qtip({
- content: {
- text: sprintf($.i18n._("The desired block length will not be reached if %s cannot find enough unique tracks to match your criteria. Enable this option if you wish to allow tracks to be added multiple times to the smart block."), PRODUCT_NAME)
- },
- hide: {
- delay: 500,
- fixed: true
- },
- style: {
- border: {
- width: 0,
- radius: 4
- },
- classes: "ui-tooltip-dark ui-tooltip-rounded"
- },
- position: {
- my: "left bottom",
- at: "right center"
- }
- });
-}
-
-function enableAndShowExtraField(valEle, index) {
- var spanExtra = valEle.nextAll("#extra_criteria");
- spanExtra.children('#sp_criteria_extra_'+index).removeAttr("disabled");
- spanExtra.show();
-
- //make value input smaller since we have extra element now
- var criteria_val = $('#sp_criteria_value_'+index);
- sizeTextBoxes(criteria_val, 'sp_input_text', 'sp_extra_input_text');
-}
-
-function disableAndHideExtraField(valEle, index) {
- var spanExtra = valEle.nextAll("#extra_criteria");
- spanExtra.children('#sp_criteria_extra_'+index).val("").attr("disabled", "disabled");
- spanExtra.hide();
-
- //make value input larger since we don't have extra field now
- var criteria_value = $('#sp_criteria_value_'+index);
- sizeTextBoxes(criteria_value, 'sp_extra_input_text', 'sp_input_text');
-}
-
-function sizeTextBoxes(ele, classToRemove, classToAdd) {
- if (ele.hasClass(classToRemove)) {
- ele.removeClass(classToRemove).addClass(classToAdd);
- }
-}
-
-function populateModifierSelect(e, popAllMods) {
- var criteria_type = getCriteriaOptionType(e),
- index = getRowIndex($(e).parent()),
- divs;
-
- if (popAllMods) {
- index = index.substring(0, 1);
- }
- divs = $(e).parents().find('select[id^="sp_criteria_modifier_'+index+'"]');
-
- $.each(divs, function(i, div){
- $(div).children().remove();
-
- if (criteria_type == 's') {
- $.each(stringCriteriaOptions, function(key, value){
- $(div).append($(' ')
- .attr('value', key)
- .text(value));
- });
- } else {
- $.each(numericCriteriaOptions, function(key, value){
- $(div).append($(' ')
- .attr('value', key)
- .text(value));
- });
- }
- });
-}
-
-function getCriteriaOptionType(e) {
- var criteria = $(e).val();
- return criteriaTypes[criteria];
-}
-
-function callback(json, type) {
- var dt = $('table[id="library_display"]').dataTable(),
- form = $('.active-tab .smart-block-form');
-
- if (type == 'shuffle' || type == 'generate') {
- if (json.error !== undefined) {
- alert(json.error);
- }
- AIRTIME.playlist.closeTab();
- AIRTIME.playlist.fnOpenPlaylist(json);
- if (json.result == "0") {
- if (type == 'shuffle') {
- form.find('.success').text($.i18n._('Smart block shuffled'));
- } else if (type == 'generate') {
- form.find('.success').text($.i18n._('Smart block generated and criteria saved'));
- //redraw library table so the length gets updated
- dt.fnStandingRedraw();
- }
- form.find('.success').show();
- }
- form.find('#smart_block_options').removeClass("closed");
- } else {
- AIRTIME.playlist.closeTab();
- AIRTIME.playlist.fnOpenPlaylist(json);
- if (json.result == "0") {
- $('.active-tab #sp-success-saved').text($.i18n._('Smart block saved')).show();
-
- //redraw library table so the length gets updated
- dt.fnStandingRedraw();
- }
- form.find('#smart_block_options').removeClass("closed");
- }
- setTimeout(removeSuccessMsg, 5000);
-}
-
-function appendAddButton() {
- var add_button = "" +
- " ";
- var rows = $('.active-tab #smart_block_options'),
- enabled = rows.find('select[name^="sp_criteria_field"]:enabled');
-
- rows.find('#criteria_add').remove();
-
- if (enabled.length > 1) {
- rows.find('select[name^="sp_criteria_field"]:enabled:last')
- .siblings('a[id^="criteria_remove"]')
- .after(add_button);
- } else {
- enabled.siblings('span[id="extra_criteria"]')
- .after(add_button);
- }
-}
-
-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"]');
- if (enabled.length == 1) {
- rmv_button.attr('disabled', 'disabled');
- rmv_button.hide();
- } else {
- rmv_button.removeAttr('disabled');
- rmv_button.show();
- }
-}
-
-function enableLoadingIcon() {
- $(".side_playlist.active-tab").block({
- message: $.i18n._("Processing..."),
- theme: true,
- allowBodyStretch: true,
- applyPlatformOpacityRules: false
- });
-}
-
-function disableLoadingIcon() {
- $(".side_playlist.active-tab").unblock()
-}
-// We need to know if the criteria value will be a string
-// or numeric value in order to populate the modifier
-// select list
-var criteriaTypes = {
- 0 : "",
- "album_title" : "s",
- "bit_rate" : "n",
- "bpm" : "n",
- "composer" : "s",
- "conductor" : "s",
- "copyright" : "s",
- "cuein" : "n",
- "cueout" : "n",
- "artist_name" : "s",
- "encoded_by" : "s",
- "utime" : "n",
- "mtime" : "n",
- "lptime" : "n",
- "genre" : "s",
- "isrc_number" : "s",
- "label" : "s",
- "language" : "s",
- "length" : "n",
- "mime" : "s",
- "mood" : "s",
- "owner_id" : "s",
- "replay_gain" : "n",
- "sample_rate" : "n",
- "track_title" : "s",
- "track_number" : "n",
- "info_url" : "s",
- "year" : "n"
-};
-
-var stringCriteriaOptions = {
- "0" : $.i18n._("Select modifier"),
- "contains" : $.i18n._("contains"),
- "does not contain" : $.i18n._("does not contain"),
- "is" : $.i18n._("is"),
- "is not" : $.i18n._("is not"),
- "starts with" : $.i18n._("starts with"),
- "ends with" : $.i18n._("ends with")
-};
-
-var numericCriteriaOptions = {
- "0" : $.i18n._("Select modifier"),
- "is" : $.i18n._("is"),
- "is not" : $.i18n._("is not"),
- "is greater than" : $.i18n._("is greater than"),
- "is less than" : $.i18n._("is less than"),
- "is in the range" : $.i18n._("is in the range")
-};
diff --git a/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js b/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js
index 6a654b9fd..3a9cd483e 100644
--- a/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js
+++ b/airtime_mvc/public/js/airtime/playlist/smart_blockbuilder.js
@@ -3,7 +3,8 @@ $(document).ready(function() {
});
function setSmartBlockEvents() {
- var form = $('#smart-block-form');
+ var activeTab = $('.active-tab'),
+ form = activeTab.find('.smart-block-form');
/********** ADD CRITERIA ROW **********/
form.find('#criteria_add').live('click', function(){
@@ -28,6 +29,7 @@ function setSmartBlockEvents() {
form.find('a[id^="modifier_add"]').live('click', function(){
var criteria_value = $(this).siblings('select[name^="sp_criteria_field"]').val();
+
//make new modifier row
var newRow = $(this).parent().clone(),
newRowCrit = newRow.find('select[name^="sp_criteria_field"]'),
@@ -190,13 +192,13 @@ function setSmartBlockEvents() {
// moved to spl.js
/********** GENERATE ACTION **********/
- $('button[id="generate_button"]').live("click", function(){
- buttonClickAction('generate', 'Playlist/smart-block-generate');
+ activeTab.find('button[id="generate_button"]').live("click", function(){
+ buttonClickAction('generate', 'playlist/smart-block-generate');
});
/********** SHUFFLE ACTION **********/
- $('button[id="shuffle_button"]').live("click", function(){
- buttonClickAction('shuffle', 'Playlist/smart-block-shuffle');
+ activeTab.find('button[id="shuffle_button"]').live("click", function(){
+ buttonClickAction('shuffle', 'playlist/smart-block-shuffle');
});
/********** CHANGE PLAYLIST TYPE **********/
@@ -262,7 +264,7 @@ function getRowIndex(ele) {
* remains at the criteria row
*/
function appendModAddButton() {
- var divs = $('#smart-block-form').find('div select[name^="sp_criteria_modifier"]').parent(':visible');
+ var divs = $('.active-tab .smart-block-form').find('div select[name^="sp_criteria_modifier"]').parent(':visible');
$.each(divs, function(i, div){
if (i > 0) {
/* If the criteria field is hidden we know it is a modifier row
@@ -286,7 +288,7 @@ function appendModAddButton() {
* We need to do this everytime a row gets deleted
*/
function reindexElements() {
- var divs = $('#smart-block-form').find('div select[name^="sp_criteria_field"]').parent(),
+ var divs = $('.active-tab .smart-block-form').find('div select[name^="sp_criteria_field"]').parent(),
index = 0,
modIndex = 0;
/* Hide all logic labels
@@ -330,8 +332,8 @@ function reindexElements() {
}
function buttonClickAction(clickType, url){
- var data = $('#smart-block-form').serializeArray(),
- obj_id = $('.obj_id').val();
+ var data = $('.active-tab .smart-block-form').serializeArray(),
+ obj_id = $('.active-tab .obj_id').val();
enableLoadingIcon();
$.post(url, {format: "json", data: data, obj_id: obj_id}, function(data){
@@ -341,17 +343,15 @@ function buttonClickAction(clickType, url){
}
function setupUI() {
- var playlist_type = $('input:radio[name=sp_type]:checked').val();
- var target_length = $('input[name="sp_limit_value"]').val();
- if (target_length == '') {
- target_length = '0.0';
- }
-
+ var activeTab = $('.active-tab'),
+ playlist_type = activeTab.find('input:radio[name=sp_type]:checked').val();
+
/* Activate or Deactivate shuffle button
* It is only active if playlist is not empty
*/
- var plContents = $('.spl_sortable').children();
- var shuffleButton = $('button[id="shuffle_button"], button[id="playlist_shuffle_button"], button[id="pl-bl-clear-content"]');
+ var sortable = activeTab.find('.spl_sortable'),
+ plContents = sortable.children(),
+ shuffleButton = activeTab.find('.sp-button, #pl-bl-clear-content');
if (!plContents.hasClass('spl_empty')) {
if (shuffleButton.hasClass('ui-state-disabled')) {
@@ -363,16 +363,13 @@ function setupUI() {
shuffleButton.attr('disabled', 'disabled');
}
- var dynamic_length = target_length;
- if ($('.obj_type').val() == 'block') {
+ if (activeTab.find('.obj_type').val() == 'block') {
if (playlist_type == "0") {
- $('button[id="generate_button"]').show();
- $('button[id="shuffle_button"]').show();
- $('.spl_sortable').show();
+ shuffleButton.parent().show();
+ sortable.show();
} else {
- $('button[id="generate_button"]').hide();
- $('button[id="shuffle_button"]').hide();
- $('.spl_sortable').hide();
+ shuffleButton.parent().hide();
+ sortable.hide();
}
}
@@ -395,7 +392,7 @@ function setupUI() {
position: {
my: "left bottom",
at: "right center"
- },
+ }
});
$(".repeat_tracks_help_icon").qtip({
@@ -416,7 +413,7 @@ function setupUI() {
position: {
my: "left bottom",
at: "right center"
- },
+ }
});
}
@@ -481,14 +478,15 @@ function getCriteriaOptionType(e) {
}
function callback(json, type) {
- var dt = $('table[id="library_display"]').dataTable();
+ var dt = $('table[id="library_display"]').dataTable(),
+ form = $('.active-tab .smart-block-form');
if (type == 'shuffle' || type == 'generate') {
if (json.error !== undefined) {
alert(json.error);
}
+ AIRTIME.playlist.closeTab();
AIRTIME.playlist.fnOpenPlaylist(json);
- var form = $('#smart-block-form');
if (json.result == "0") {
if (type == 'shuffle') {
form.find('.success').text($.i18n._('Smart block shuffled'));
@@ -501,14 +499,12 @@ function callback(json, type) {
}
form.find('#smart_block_options').removeClass("closed");
} else {
+ AIRTIME.playlist.closeTab();
AIRTIME.playlist.fnOpenPlaylist(json);
- var form = $('#smart-block-form');
if (json.result == "0") {
- $('#sp-success-saved').text($.i18n._('Smart block saved'));
- $('#sp-success-saved').show();
+ $('.active-tab #sp-success-saved').text($.i18n._('Smart block saved')).show();
//redraw library table so the length gets updated
- var dt = $('table[id="library_display"]').dataTable();
dt.fnStandingRedraw();
}
form.find('#smart_block_options').removeClass("closed");
@@ -519,7 +515,7 @@ function callback(json, type) {
function appendAddButton() {
var add_button = "" +
" ";
- var rows = $('#smart_block_options'),
+ var rows = $('.active-tab #smart_block_options'),
enabled = rows.find('select[name^="sp_criteria_field"]:enabled');
rows.find('#criteria_add').remove();
@@ -535,7 +531,7 @@ function appendAddButton() {
}
function removeButtonCheck() {
- var rows = $('dd[id="sp_criteria-element"]').children('div'),
+ 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"]');
if (enabled.length == 1) {
@@ -548,7 +544,7 @@ function removeButtonCheck() {
}
function enableLoadingIcon() {
- $(".side_playlist").block({
+ $(".side_playlist.active-tab").block({
message: $.i18n._("Processing..."),
theme: true,
allowBodyStretch: true,
@@ -557,7 +553,7 @@ function enableLoadingIcon() {
}
function disableLoadingIcon() {
- $(".side_playlist").unblock()
+ $(".side_playlist.active-tab").unblock()
}
// We need to know if the criteria value will be a string
// or numeric value in order to populate the modifier
diff --git a/airtime_mvc/public/js/airtime/showbuilder/_builder.js b/airtime_mvc/public/js/airtime/showbuilder/_builder.js
deleted file mode 100644
index e23a6c5f8..000000000
--- a/airtime_mvc/public/js/airtime/showbuilder/_builder.js
+++ /dev/null
@@ -1,1270 +0,0 @@
-var AIRTIME = (function(AIRTIME){
- var mod,
- oSchedTable,
- SB_SELECTED_CLASS = "sb-selected",
- CURSOR_SELECTED_CLASS = "cursor-selected-row",
- NOW_PLAYING_CLASS = "sb-now-playing",
- $sbContent,
- $sbTable,
- $toolbar,
- $lib,
- cursors = [],
- cursorIds = [],
- showInstanceIds = [],
- headerFooter = [],
- DISABLED_CLASS = 'ui-state-disabled',
- selectedRows,
- $previouslySelected,
- flagForDeselection;
-
- if (AIRTIME.showbuilder === undefined) {
- AIRTIME.showbuilder = {};
- }
- mod = AIRTIME.showbuilder;
-
- function checkError(json) {
- if (json.error !== undefined) {
- alert(json.error);
- }
- }
-
- mod.timeout = undefined;
- mod.timestamp = -1;
- mod.showInstances = [];
-
- mod.resetTimestamp = function() {
-
- mod.timestamp = -1;
- };
-
- mod.setTimestamp = function(timestamp) {
-
- mod.timestamp = timestamp;
- };
-
- mod.updateCalendarStatusIcon = function(json) {
- //make sure we are only executing this code on the calendar view, not
- //the Now Playing view.
- if (window.location.pathname.toLowerCase().indexOf("schedule") < 0) {
- return;
- }
-
-
- var instance_id = json.schedule[0].instance;
-
- var lastElem = json.schedule[json.schedule.length-1];
- var $elem = $("#fc-show-instance-"+instance_id);
-
- //if the show is linked, then replace $elem to reference all linked
- //instances
- if ($elem.data("show-linked") == "1") {
- var show_id = $elem.data("show-id");
- $elem = $('*[data-show-id="'+show_id+'"]');
- }
-
- $elem.find(".show-empty, .show-partial-filled").remove();
- if (json.schedule[1].empty) {
- $elem
- .find(".fc-event-inner")
- .append(' ');
- } else if (lastElem["fRuntime"][0] == "-") {
- $elem
- .find(".fc-event-inner")
- .append(' ');
- }
- };
-
- mod.getTimestamp = function() {
-
- if (mod.timestamp !== undefined) {
- return mod.timestamp;
- }
- else {
- return -1;
- }
- };
-
- mod.setShowInstances = function(showInstances) {
- mod.showInstances = showInstances;
- };
-
- mod.getShowInstances = function() {
- return mod.showInstances;
- };
-
- mod.refresh = function(schedId) {
- mod.resetTimestamp();
-
- // once a track plays out we need to check if we can update
- // the is_scheduled flag in cc_files
- if (schedId > 0) {
- $.post(baseUrl+"schedule/update-future-is-scheduled",
- {"format": "json", "schedId": schedId}, function(data) {
- if (data.redrawLibTable !== undefined && data.redrawLibTable) {
- $("#library_content").find("#library_display").dataTable().fnStandingRedraw();
- }
- });
- oSchedTable.fnDraw();
- }
- };
-
- mod.switchTab = function(tab, el) {
- $(".active-tab").hide().removeClass("active-tab");
- tab.addClass("active-tab").show();
-
- $(".nav.nav-tabs .active").removeClass("active");
- el.addClass("active");
-
- if (tab.hasClass("pl-content")) {
- AIRTIME.playlist.setAsActive();
- }
- AIRTIME.playlist.onResize();
- AIRTIME.library.fnRedraw();
- };
-
-
- mod.checkSelectButton = function() {
- var $selectable = $sbTable.find("tr");
-
- if ($selectable.length !== 0) {
- AIRTIME.button.enableButton("btn-group #timeline-select", false);
- } else {
- AIRTIME.button.disableButton("btn-group #timeline-select", false);
- }
-
- //need to check if the 'Select' button is disabled
- var select = $(".btn-group #timeline-select");
- if (select.is(":disabled")) {
- select.removeAttr("disabled");
- }
- };
-
- mod.checkTrimButton = function() {
- var $over = $sbTable.find(".sb-over.sb-allowed");
-
- if ($over.length !== 0) {
- AIRTIME.button.enableButton("icon-cut", true);
- }
- else {
- AIRTIME.button.disableButton("icon-cut", true);
- }
- };
-
- mod.checkDeleteButton = function() {
- var $selected = $sbTable.find("tr."+SB_SELECTED_CLASS);
-
- var button = $("#show_builder").find(".icon-trash").parent();
- if ($selected.length !== 0) {
- button.removeClass(DISABLED_CLASS);
- button.removeAttr('disabled');
- } else {
- button.addClass(DISABLED_CLASS);
- button.attr('disabled', 'disabled');
- }
- };
-
- mod.checkJumpToCurrentButton = function() {
- var $current = $sbTable.find("."+NOW_PLAYING_CLASS);
-
- if ($current.length !== 0) {
- AIRTIME.button.enableButton("icon-step-forward", true);
- }
- else {
- AIRTIME.button.disableButton("icon-step-forward", true);
- }
- };
-
- mod.checkCancelButton = function() {
-
- var $current = $sbTable.find(".sb-current-show"),
- //this user type should be refactored into a separate users module later
- //when there's more time and more JS will need to know user data.
- userType = localStorage.getItem('user-type'),
- canCancel = false;
-
- if ($current.length !== 0 && $current.hasClass("sb-allowed")) {
- canCancel = true;
- }
- else if ($current.length !== 0 && (userType === 'A' || userType === 'P')) {
- canCancel = true;
- }
-
- if (canCancel === true) {
- AIRTIME.button.enableButton("icon-ban-circle", true);
- }
- else {
- AIRTIME.button.disableButton("icon-ban-circle", true);
- }
- };
-
- mod.checkToolBarIcons = function() {
-
- //library may not be on the page.
- if (AIRTIME.library !== undefined) {
- AIRTIME.library.checkAddButton();
- }
-
- mod.checkSelectButton();
- mod.checkTrimButton();
- mod.checkDeleteButton();
- mod.checkJumpToCurrentButton();
- mod.checkCancelButton();
- };
-
- mod.selectCursor = function($el) {
-
- $el.addClass(CURSOR_SELECTED_CLASS);
- mod.checkToolBarIcons();
- };
-
- mod.removeCursor = function($el) {
-
- $el.removeClass(CURSOR_SELECTED_CLASS);
- mod.checkToolBarIcons();
- };
-
- /*
- * sNot is an optional string to filter selected elements by. (ex removing the currently playing item)
- */
- mod.getSelectedData = function(sNot) {
- var $selected = $sbTable.find("tr."+SB_SELECTED_CLASS),
- aData = [],
- i, length,
- $item;
-
- if (sNot !== undefined) {
- $selected = $selected.not("."+sNot);
- }
-
- for (i = 0, length = $selected.length; i < length; i++) {
- $item = $($selected.get(i));
- aData.push($item.data('aData'));
- }
-
- return aData.reverse();
- };
-
- mod.selectAll = function () {
- var $trs = $sbTable.find("tr.lib-audio").not(".sb-past, .sb-empty");
- $trs.addClass(SB_SELECTED_CLASS).find(".sb-checkbox > input").prop('checked', true);
-
- mod.checkToolBarIcons();
- };
-
- mod.selectNone = function () {
- var $trs = $sbTable.find("tr.lib-audio");
- $trs.removeClass(SB_SELECTED_CLASS).find(".sb-checkbox > input").prop('checked', false);
- $previouslySelected = undefined;
- selectedRows = undefined;
-
- mod.checkToolBarIcons();
- };
-
- mod.disableUI = function() {
-
- $lib.block({
- message: "",
- theme: true,
- applyPlatformOpacityRules: false
- });
-
- $sbContent.block({
- message: "",
- theme: true,
- applyPlatformOpacityRules: false
- });
- };
-
- mod.enableUI = function() {
- $lib.unblock();
- $sbContent.unblock();
- };
-
- mod.fnItemCallback = function(json) {
- checkError(json);
-
- mod.getSelectedCursors();
- selectedRows = $("." + SB_SELECTED_CLASS);
- oSchedTable.fnDraw();
- mod.enableUI();
-
- //Unneccessary reload of the library pane after moving tracks in the showbuilder pane.
- //$("#library_content").find("#library_display").dataTable().fnStandingRedraw();
-
- getUsabilityHint();
- };
-
- mod.getSelectedCursors = function() {
- cursorIds = [];
-
- /* We need to keep record of which show the cursor belongs to
- * in the case where more than one show is displayed in the show builder
- * because header and footer rows have the same id
- */
- showInstanceIds = [];
-
- /* Keeps track if the row is a footer. We need to do this because
- * header and footer rows have the save cursorIds and showInstanceId
- * so both will be selected in the draw callback
- */
- headerFooter = [];
-
- cursors = $(".cursor-selected-row");
- for (i = 0; i < cursors.length; i++) {
- cursorIds.push(($(cursors.get(i)).attr("id")));
- showInstanceIds.push(($(cursors.get(i)).attr("si_id")));
- if ($(cursors.get(i)).hasClass("sb-footer")) {
- headerFooter.push("f");
- } else {
- headerFooter.push("n");
- }
- }
- };
-
- mod.fnAdd = function(aMediaIds, aSchedIds) {
- AIRTIME.library.selectNone();
- mod.disableUI();
-
- $.post(baseUrl+"showbuilder/schedule-add",
- {"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
- mod.fnItemCallback
- );
- };
-
- mod.fnMove = function(aSelect, aAfter) {
-
- mod.disableUI();
-
- $.post(baseUrl+"showbuilder/schedule-move",
- {"format": "json", "selectedItem": aSelect, "afterItem": aAfter},
- mod.fnItemCallback
- );
- };
-
- mod.fnRemove = function(aItems) {
-
- mod.disableUI();
- if (confirm($.i18n._("Delete selected item(s)?"))) {
- $.post( baseUrl+"showbuilder/schedule-remove",
- {"items": aItems, "format": "json"},
- mod.fnItemCallback
- );
- } else {
- mod.enableUI();
- }
- };
-
- mod.fnRemoveSelectedItems = function() {
- var aData = mod.getSelectedData(),
- i,
- length,
- temp,
- aItems = [];
-
- for (i=0, length = aData.length; i < length; i++) {
- temp = aData[i];
- aItems.push({"id": temp.id, "instance": temp.instance, "timestamp": temp.timestamp});
- }
-
- mod.fnRemove(aItems);
- };
-
- mod.fnServerData = function fnBuilderServerData( sSource, aoData, fnCallback ) {
-
- aoData.push( { name: "timestamp", value: mod.getTimestamp()} );
- aoData.push( { name: "instances", value: mod.getShowInstances()} );
- aoData.push( { name: "format", value: "json"} );
-
- if (mod.fnServerData.hasOwnProperty("start")) {
- aoData.push( { name: "start", value: mod.fnServerData.start} );
- }
- if (mod.fnServerData.hasOwnProperty("end")) {
- aoData.push( { name: "end", value: mod.fnServerData.end} );
- }
- if (mod.fnServerData.hasOwnProperty("ops")) {
- aoData.push( { name: "myShows", value: mod.fnServerData.ops.myShows} );
- aoData.push( { name: "showFilter", value: mod.fnServerData.ops.showFilter} );
- aoData.push( { name: "showInstanceFilter", value: mod.fnServerData.ops.showInstanceFilter} );
- }
-
- $.ajax({
- "dataType": "json",
- "type": "POST",
- "url": sSource,
- "data": aoData,
- "success": function(json) {
- mod.updateCalendarStatusIcon(json);
- mod.setTimestamp(json.timestamp);
- mod.setShowInstances(json.instances);
- mod.getSelectedCursors();
- fnCallback(json);
- }
- });
- };
-
- mod.jumpToCurrentTrack = function() {
- var $scroll = $sbContent.find(".dataTables_scrolling");
- var scrolled = $scroll.scrollTop();
- var scrollingTop = $scroll.offset().top;
- var current = $sbTable.find("."+NOW_PLAYING_CLASS);
- var currentTop = current.offset().top;
-
- $scroll.scrollTop(currentTop - scrollingTop + scrolled);
- };
-
- mod.builderDataTable = function() {
- $sbContent = $('#show_builder');
- $lib = $("#library_content");
- $sbTable = $sbContent.find('table');
- var isInitialized = false;
-
- var lockedPreviewIcon = document.createElement('span');
- lockedPreviewIcon.setAttribute('class', 'ui-icon ui-icon-locked');
- var previewIcon = document.createElement('img');
- previewIcon.setAttribute('src', baseUrl+'css/images/icon_audioclip.png');
- previewIcon.setAttribute('title', $.i18n._("Track preview"));
-
- oSchedTable = $sbTable.dataTable( {
- "aoColumns": [
- /* checkbox */ {"mDataProp": "allowed", "sTitle": "", "sWidth": "16px", "sClass": "sb-checkbox"},
- /* Type */ {"mDataProp": "image", "sTitle": "", "sClass": "library_image sb-image", "sWidth": "16px"},
- /* starts */ {"mDataProp": "starts", "sTitle": $.i18n._("Start"), "sClass": "sb-starts", "sWidth": "60px"},
- /* ends */ {"mDataProp": "ends", "sTitle": $.i18n._("End"), "sClass": "sb-ends", "sWidth": "60px"},
- /* runtime */ {"mDataProp": "runtime", "sTitle": $.i18n._("Duration"), "sClass": "library_length sb-length", "sWidth": "65px"},
- /* title */ {"mDataProp": "title", "sTitle": $.i18n._("Title"), "sClass": "sb-title"},
- /* creator */ {"mDataProp": "creator", "sTitle": $.i18n._("Creator"), "sClass": "sb-creator"},
- /* album */ {"mDataProp": "album", "sTitle": $.i18n._("Album"), "sClass": "sb-album"},
- /* cue in */ {"mDataProp": "cuein", "sTitle": $.i18n._("Cue In"), "bVisible": false, "sClass": "sb-cue-in"},
- /* cue out */ {"mDataProp": "cueout", "sTitle": $.i18n._("Cue Out"), "bVisible": false, "sClass": "sb-cue-out"},
- /* fade in */ {"mDataProp": "fadein", "sTitle": $.i18n._("Fade In"), "bVisible": false, "sClass": "sb-fade-in"},
- /* fade out */ {"mDataProp": "fadeout", "sTitle": $.i18n._("Fade Out"), "bVisible": false, "sClass": "sb-fade-out"},
- /* Mime */ {"mDataProp" : "mime", "sTitle" : $.i18n._("Mime"), "bVisible": false, "sClass": "sb-mime"}
- ],
-
- "bJQueryUI": true,
- "bSort": false,
- "bFilter": false,
- "bProcessing": true,
- "bServerSide": true,
- "bInfo": false,
- "bAutoWidth": false,
- "bDeferRender": true,
-
- "bStateSave": true,
- "fnStateSaveParams": function (oSettings, oData) {
- //remove oData components we don't want to save.
- delete oData.oSearch;
- delete oData.aoSearchCols;
- },
- "fnStateSave": function fnStateSave(oSettings, oData) {
- localStorage.setItem('datatables-timeline', JSON.stringify(oData));
- },
- "fnStateLoad": function fnBuilderStateLoad(oSettings) {
- var settings = localStorage.getItem('datatables-timeline');
-
- if (settings !== "") {
- return JSON.parse(settings);
- }
- },
- "fnStateLoadParams": function (oSettings, oData) {
- var i,
- length,
- a = oData.abVisCols;
-
- //putting serialized data back into the correct js type to make
- //sure everything works properly.
- for (i = 0, length = a.length; i < length; i++) {
- if (typeof(a[i]) === "string") {
- a[i] = (a[i] === "true");
- }
- }
-
- oData.iCreate = parseInt(oData.iCreate, 10);
- },
-
- "fnServerData": mod.fnServerData,
- "fnRowCallback": function fnRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
- var i, length,
- sSeparatorHTML,
- fnPrepareSeparatorRow,
- $node,
- cl="",
- //background-color to imitate calendar color.
- r,g,b,a,
- $nRow = $(nRow),
- $image,
- $div,
- headerIcon;
-
- fnPrepareSeparatorRow = function fnPrepareSeparatorRow(sRowContent, sClass, iNodeIndex) {
- //Albert:
- //$(nRow.children[iNodeIndex]).replaceWith(emptyNode);
-
- $node = $(nRow.children[iNodeIndex]);
- $node.html(sRowContent);
-
- $node.attr('colspan',100);
- for (i = iNodeIndex + 1, length = nRow.children.length; i < length; i = i+1) {
- $node = $(nRow.children[i]);
- $node.html("");
- $node.attr("style", "display : none");
- }
-
- $nRow.addClass(sClass);
-
- };
-
- if (aData.header === true) {
- //remove the column classes from all tds.
- $nRow.find('td').removeClass();
-
- $node = $(nRow.children[0]);
- $node.html("");
- cl = 'sb-header';
-
- if (aData.record === true) {
- $div = $("
", {
- "class": "small-icon " + headerIcon
- });
- $node.append($div);
- }
- else if (aData.rebroadcast === true) {
- $div = $("
", {
- "class": "small-icon rebroadcast"
- });
- $node.append($div);
- }
-
- sSeparatorHTML = ''+aData.title+' ';
-
- if (aData.rebroadcast === true) {
- sSeparatorHTML += ''+aData.rebroadcast_title+' ';
- }
-
- sSeparatorHTML += '';
-
- if (aData.startDate === aData.endDate) {
- sSeparatorHTML += ''+aData.startDate+' '+aData.startTime+' ';
- sSeparatorHTML +='-'+aData.endTime+' ';
- }
- else {
- sSeparatorHTML += ''+aData.startDate+' '+aData.startTime+' ';
- sSeparatorHTML +='-'+aData.endDate+' '+aData.endTime+' ';
- }
-
- sSeparatorHTML += ' ';
-
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
- }
- else if (aData.footer === true) {
- //remove the column classes from all tds.
- $nRow.find('td').removeClass();
-
- $node = $(nRow.children[0]);
- cl = 'sb-footer';
-
- //check the show's content status.
- if (aData.runtime >= 0) {
- $node.html(' ');
- cl = cl + ' ui-state-highlight';
- }
- else {
- $node.html(' ');
- cl = cl + ' ui-state-error';
- }
-
- sSeparatorHTML = ''+aData.fRuntime+' ';
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
- }
- else if (aData.empty === true) {
- //remove the column classes from all tds.
- $nRow.find('td').removeClass();
-
- $node = $(nRow.children[0]);
- if ($node) {
- $node.empty();
- }
-
- sSeparatorHTML = ''+$.i18n._("Drag tracks here from the library")+' ';
- cl = cl + " sb-empty odd";
-
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
- }
- else if (aData.record === true) {
- //remove the column classes from all tds.
- $nRow.find('td').removeClass();
-
- $node = $(nRow.children[0]);
- $node.html('');
-
- sSeparatorHTML = ''+$.i18n._("Recording From Line In")+' ';
- cl = cl + " sb-record odd";
- fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
- }
- else {
-
- //add the play function if the file exists on disk.
- $image = $nRow.find('td.sb-image');
- $image.empty();
- //check if the file exists.
- if (aData.image === true) {
- $nRow.addClass("lib-audio");
- if (!isAudioSupported(aData.mime)) {
- //$image.html(' ');
- $image.append(lockedPreviewIcon);
- } else {
- $image.append(previewIcon.cloneNode(false));
- $image.click(function() {
- open_show_preview(aData.instance, aData.pos);
- return false;
- });
-
- }
- }
- else {
- $image.html(' ');
- $image.find(".ui-icon-alert").qtip({
- content: {
- text: $.i18n._("Airtime is unsure about the status of this file. This can happen when the file is on a remote drive that is unaccessible or the file is in a directory that isn't \"watched\" anymore.")
- },
- style: {
- classes: "ui-tooltip-dark"
- },
- show: 'mouseover',
- hide: 'mouseout'
- });
- }
-
- $node = $(nRow.children[0]);
- if (aData.allowed === true && aData.scheduled >= 1 && aData.linked_allowed) {
- $node.html(' ');
- }
- else {
- $node.empty();
- }
- }
-
- //add the show colour to the leftmost td
- if (aData.footer !== true) {
-
- if ($nRow.hasClass('sb-header')) {
- a = 1;
- }
- else if ($nRow.hasClass('odd')) {
- a = 0.3;
- }
- else if ($nRow.hasClass('even')) {
- a = 0.4;
- }
-
- //convert from hex to rgb.
- r = parseInt((aData.backgroundColor).substring(0,2), 16);
- g = parseInt((aData.backgroundColor).substring(2,4), 16);
- b = parseInt((aData.backgroundColor).substring(4,6), 16);
-
- $nRow.find('td:first').css('background', 'rgba('+r+', '+g+', '+b+', '+a+')');
- }
-
- //save some info for reordering purposes.
- $nRow.data({"aData": aData});
-
- if (aData.scheduled === 1) {
- $nRow.addClass(NOW_PLAYING_CLASS);
- }
- else if (aData.scheduled === 0 || aData.scheduled === undefined) {
- $nRow.addClass("sb-past");
- }
- else {
- $nRow.addClass("sb-future");
- }
-
- if (aData.allowed !== true || aData.linked_allowed === false) {
- $nRow.addClass("sb-not-allowed");
- }
- else {
- $nRow.addClass("sb-allowed");
- $nRow.attr("id", aData.id);
- $nRow.attr("si_id", aData.instance);
- }
-
- //status used to colour tracks.
- if (aData.status === 2) {
- $nRow.addClass("sb-boundry");
- }
- else if (aData.status === 0) {
- $nRow.addClass("sb-over");
- }
-
- if (aData.currentShow === true) {
- $nRow.addClass("sb-current-show");
- }
- },
- //remove any selected nodes before the draw.
- "fnPreDrawCallback": function( oSettings ) {
-
- //make sure any dragging helpers are removed or else they'll be stranded on the screen.
- $("#draggingContainer").remove();
- },
- "fnDrawCallback": function fnBuilderDrawCallback(oSettings, json) {
-
- if (!isInitialized) {
- //when coming to 'Now Playing' page we want the page
- //to jump to the current track
- if ($(this).find("."+NOW_PLAYING_CLASS).length > 0) {
- mod.jumpToCurrentTrack();
- }
- }
-
- isInitialized = true;
- var aData,
- elements,
- i, length, temp;
-
- clearTimeout(mod.timeout);
-
- //order of importance of elements for setting the next timeout.
- elements = [
- $sbTable.find("tr."+NOW_PLAYING_CLASS),
- $sbTable.find("tbody").find("tr.sb-future.sb-footer, tr.sb-future.sb-header").filter(":first")
- ];
-
- //check which element we should set a timeout relative to.
- for (i = 0, length = elements.length; i < length; i++) {
- temp = elements[i];
-
- if (temp.length > 0) {
- aData = temp.data("aData");
- // max time interval
- // setTimeout allows only up to (2^31)-1 millisecs timeout value
- maxRefreshInterval = Math.pow(2, 31) - 1;
- refreshInterval = aData.refresh * 1000;
- if(refreshInterval > maxRefreshInterval){
- refreshInterval = maxRefreshInterval;
- }
- mod.timeout = setTimeout(function() {mod.refresh(aData.id)}, refreshInterval); //need refresh in milliseconds
- break;
- }
- }
-
-
- mod.checkToolBarIcons();
-
- var sid;
- if (selectedRows !== undefined) {
- selectedRows.each(function (i, el) {
- sid = $(el).attr("id");
- var tr = $("#" + sid);
- tr.addClass(SB_SELECTED_CLASS);
- tr.find("input[type='checkbox']").prop("checked", true);
- });
- }
- },
-
- // R = ColReorder, C = ColVis
- "sDom": 'R<"dt-process-rel"r><"sb-padded"<"H"C>><"dataTables_scrolling sb-padded"t><"F">',
-
- "oColVis": {
- "aiExclude": [ 0, 1 ],
- "buttonText": $.i18n._("Columns")
- },
-
- "oColReorder": {
- "iFixedColumns": 2
- },
-
- "sAjaxDataProp": "schedule",
- "oLanguage": getDatatablesStrings({
- "sZeroRecords": $.i18n._("There are no shows scheduled during the specified time period."),
- "sEmptyTable": $.i18n._("There are no shows scheduled during the specified time period."),
- }),
- "sAjaxSource": baseUrl+"showbuilder/builder-feed",
-
- "bScrollCollapseY": false
- });
-
- $sbTable.find("tbody").on("mousedown", "tr:not(.sb-header, .sb-footer, .sb-past, .sb-empty, :has(td.dataTables_empty))", function(ev) {
- var $tr = $(this),
- // Get the ID of the selected row
- $rowId = $tr.attr("id");
-
- if (!$tr.hasClass(SB_SELECTED_CLASS)) {
- if (ev.shiftKey && $previouslySelected !== undefined) {
- if ($previouslySelected.attr("id") == $rowId) {
- return;
- }
-
- // If the selected row comes before the previously selected row,
- // we want to select previous rows, otherwise we select next
- if ($previouslySelected.prevAll("#" + $rowId).length !== 0) {
- $previouslySelected.prevUntil($tr).each(function (i, el) {
- $(el).addClass(SB_SELECTED_CLASS);
- $(el).find(".sb-checkbox > input").prop('checked', true);
- });
- } else {
- $previouslySelected.nextUntil($tr).each(function (i, el) {
- $(el).addClass(SB_SELECTED_CLASS);
- $(el).find(".sb-checkbox > input").prop('checked', true);
- });
- }
- }
- $tr.addClass(SB_SELECTED_CLASS);
- $tr.find(".sb-checkbox > input").prop('checked', true);
- } else {
- flagForDeselection = true;
- }
-
- selectedRows = $("." + SB_SELECTED_CLASS);
- // Remember this row so we can properly multiselect
- $previouslySelected = $tr;
- });
-
- $sbTable.find("tbody").on("click", "tr:not(.sb-header, .sb-footer, .sb-past, .sb-empty, :has(td.dataTables_empty))", function(ev) {
- if (flagForDeselection) {
- flagForDeselection = false;
- $(this).removeClass(SB_SELECTED_CLASS);
- $(this).find(".sb-checkbox > input").prop('checked', false);
- } else {
- $(this).find(".sb-checkbox > input").prop('checked', true);
- }
- selectedRows = $("." + SB_SELECTED_CLASS);
- mod.checkToolBarIcons();
- });
-
- //begin context menu initialization.
- $.contextMenu({
- selector: '#show_builder tr.lib-audio:not(.sb-past)',
- trigger: "right",
-
- build: function($el, e) {
- var items,
- $tr = $el,
- data = $tr.data("aData"),
- cursorClass = "cursor-selected-row",
- callback;
-
- function processMenuItems(oItems) {
-
- //define a preview callback.
- if (oItems.preview !== undefined) {
-
- callback = function() {
- open_show_preview(data.instance, data.pos);
- };
-
- oItems.preview.callback = callback;
- }
-
- //define a select cursor callback.
- if (oItems.selCurs !== undefined) {
-
- callback = function() {
- var $tr = $(this).parents('tr').next();
-
- mod.selectCursor($tr);
- };
-
- oItems.selCurs.callback = callback;
- }
-
- //define a remove cursor callback.
- if (oItems.delCurs !== undefined) {
-
- callback = function() {
- var $tr = $(this).parents('tr').next();
-
- mod.removeCursor($tr);
- };
-
- oItems.delCurs.callback = callback;
- }
-
- //define a delete callback.
- if (oItems.del !== undefined) {
-
- callback = function() {
- AIRTIME.showbuilder.fnRemove([{
- id: data.id,
- timestamp: data.timestamp,
- instance: data.instance
- }]);
- };
-
- oItems.del.callback = callback;
- }
-
- //only show the cursor selecting options if the library is visible on the page.
- if ($tr.next().find('.marker').length === 0) {
- delete oItems.selCurs;
- delete oItems.delCurs;
- }
- //check to include either select or remove cursor.
- else {
- if ($tr.next().hasClass(cursorClass)) {
- delete oItems.selCurs;
- }
- else {
- delete oItems.delCurs;
- }
- }
-
- items = oItems;
- }
-
- request = $.ajax({
- url: baseUrl+"showbuilder/context-menu",
- type: "GET",
- data: {id : data.id, format: "json"},
- dataType: "json",
- async: false,
- success: function(json){
- processMenuItems(json.items);
- }
- });
-
- return {
- items: items
- };
-
- }
- });
-
- var sortableConf = (function(){
- var origTrs,
- aItemData = [],
- oPrevData,
- fnAdd,
- fnMove,
- fnReceive,
- fnUpdate,
- i,
- html,
- helperData,
- draggingContainer;
-
- fnAdd = function() {
- var aMediaIds = [],
- aSchedIds = [];
-
- for(i = 0; i < aItemData.length; i++) {
- aMediaIds.push({"id": aItemData[i].id, "type": aItemData[i].ftype});
- }
- aSchedIds.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
-
- mod.fnAdd(aMediaIds, aSchedIds);
- };
-
- fnMove = function() {
- var aSelect = [],
- aAfter = [];
-
- for(i = 0; i < helperData.length; i++) {
- aSelect.push({"id": helperData[i].id, "instance": helperData[i].instance, "timestamp": helperData[i].timestamp});
- }
-
- aAfter.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
-
- mod.fnMove(aSelect, aAfter);
- };
-
- fnReceive = function(event, ui) {
- var aItems = [];
-
- AIRTIME.library.addToChosen(ui.item);
-
- aItems = AIRTIME.library.getSelectedData();
- origTrs = aItems;
- html = ui.helper.html();
-
- AIRTIME.library.removeFromChosen(ui.item);
- };
-
- fnUpdate = function(event, ui) {
- var prev = ui.item.prev();
-
- //can't add items outside of shows.
- if (prev.find("td:first").hasClass("dataTables_empty")
- || prev.length === 0) {
- alert($.i18n._("Cannot schedule outside a show."));
- ui.item.remove();
- return;
- }
-
- //if item is added after a footer, add the item after the last item in the show.
- if (prev.hasClass("sb-footer")) {
- prev = prev.prev();
- }
-
- aItemData = [];
- oPrevData = prev.data("aData");
-
- //item was dragged in
- if (origTrs !== undefined) {
-
- $sbTable.find("tr.ui-draggable")
- .empty()
- .after(html);
-
- aItemData = origTrs;
- origTrs = undefined;
- fnAdd();
- }
- //item was reordered.
- else {
-
- //ui.item
- // .empty()
- // .after(draggingContainer.html());
-
- aItemData.push(ui.item.data("aData"));
- fnMove();
- }
- };
-
- return {
- placeholder: "sb-placeholder ui-state-highlight",
- //forcePlaceholderSize: true,
- distance: 25,
- helper:
- function(event, item) {
- var selected = mod.getSelectedData(NOW_PLAYING_CLASS),
- thead = $("#show_builder_table thead"),
- colspan = thead.find("th").length,
- trfirst = thead.find("tr:first"),
- width = trfirst.width(),
- height = trfirst.height(),
- message;
-
- //if nothing is checked select the dragged item.
- if (selected.length === 0) {
- selected = [item.data("aData")];
- }
-
- if (selected.length === 1) {
- message = sprintf($.i18n._("Moving %s"), selected[0].title);
- //draggingContainer = item; //Default DataTables drag and drop
- draggingContainer = $(' ')
- .addClass('sb-helper')
- .append(' ')
- .find("td")
- .attr("colspan", colspan)
- .width(width)
- .height(height)
- .addClass("ui-state-highlight")
- .append(message)
- .end();
- }
- else {
- message = sprintf($.i18n._("Moving %s Items"), selected.length);
- draggingContainer = $(' ')
- .addClass('sb-helper')
- .append(' ')
- .find("td")
- .attr("colspan", colspan)
- .width(width)
- .height(height)
- .addClass("ui-state-highlight")
- .append(message)
- .end();
- }
-
- helperData = selected;
-
- return draggingContainer;
- },
- items: 'tr:not(:first, :last, .sb-header, .sb-not-allowed, .sb-past, .sb-now-playing, .sb-empty)',
- cancel: '.sb-footer',
- receive: fnReceive,
- update: fnUpdate,
- axis: "y",
- containment: "document",
- start: function(event, ui) {
- var elements = $sbTable.find('tr.'+SB_SELECTED_CLASS).not("."+NOW_PLAYING_CLASS);
- elements.hide();
- },
- stop: function() {
- var elements = $sbTable.find('tr.'+SB_SELECTED_CLASS).not("."+NOW_PLAYING_CLASS);
- elements.show();
- }
- };
- }());
-
- $sbTable.sortable(sortableConf);
-
- //start setup of the builder toolbar.
- $toolbar = $(".sb-content .fg-toolbar:first");
- var footer = $(".sb-content .fg-toolbar:last"),
- timerange = $(".sb-timerange");
- $toolbar.append(timerange);
-
- $menu = $("
");
- $menu.append("" +
- "" +
- $.i18n._("Select")+" " +
- " " +
- "" +
- "
")
- .append("" +
- "" +
- " " +
- "" + $.i18n._('Trim overbooked shows') + " " +
- "
")
- .append("" +
- "" +
- " " +
- "" + $.i18n._('Remove') + " " +
- "
");
-
- //if 'Add/Remove content' was chosen from the context menu
- //in the Calendar do not append these buttons
- if ($(".ui-dialog-content").length === 0) {
- $menu.append("" +
- "" +
- " " +
- "" + $.i18n._('Jump to Current') + " " +
- "
")
- .append("" +
- "" +
- " " +
- "" + $.i18n._('Cancel current show') + " " +
- "
");
- }
-
- if (localStorage.getItem('user-type') != 'G') {
- $toolbar.append($menu);
- }
-
- $menu = undefined;
-
- $('#timeline-sa').click(function(){mod.selectAll();});
- $('#timeline-sn').click(function(){mod.selectNone();});
-
- //cancel current show
- $toolbar.find('.icon-ban-circle').parent()
- .click(function() {
- var $tr,
- data,
- msg = $.i18n._('Cancel Current Show?');
-
- if (AIRTIME.button.isDisabled('icon-ban-circle', true) === true) {
- return;
- }
-
- $tr = $sbTable.find('tr.sb-future:first');
-
- if ($tr.hasClass('sb-current-show')) {
- data = $tr.data("aData");
-
- if (data.record === true) {
- msg = $.i18n._('Stop recording current show?');
- }
-
- if (confirm(msg)) {
- var url = baseUrl+"Schedule/cancel-current-show";
- $.ajax({
- url: url,
- data: {format: "json", id: data.instance},
- success: function(data){
- $("#library_content").find("#library_display").dataTable().fnStandingRedraw();
- var oTable = $sbTable.dataTable();
- oTable.fnDraw();
- }
- });
- }
- }
- });
-
- //jump to current
- $toolbar.find('.icon-step-forward').parent()
- .click(function() {
-
- if (AIRTIME.button.isDisabled('icon-step-forward', true) === true) {
- return;
- }
- /*
- var $scroll = $sbContent.find(".dataTables_scrolling"),
- scrolled = $scroll.scrollTop(),
- scrollingTop = $scroll.offset().top,
- current = $sbTable.find("."+NOW_PLAYING_CLASS),
- currentTop = current.offset().top;
-
- $scroll.scrollTop(currentTop - scrollingTop + scrolled);
- */
- mod.jumpToCurrentTrack();
- });
-
- //delete overbooked tracks.
- $toolbar.find('.icon-cut', true).parent()
- .click(function() {
-
- if (AIRTIME.button.isDisabled('icon-cut', true) === true) {
- return;
- }
-
- var temp,
- aItems = [],
- trs = $sbTable.find(".sb-over.sb-future.sb-allowed");
-
- trs.each(function(){
- temp = $(this).data("aData");
- aItems.push({"id": temp.id, "instance": temp.instance, "timestamp": temp.timestamp});
- });
-
- mod.fnRemove(aItems);
- });
-
- //delete selected tracks
- $toolbar.find('.icon-trash').parent()
- .click(function() {
-
- var button = $("#show_builder").find(".icon-trash").parent();
-
- if (button.hasClass(DISABLED_CLASS)) {
- return;
- }
-
- mod.fnRemoveSelectedItems();
- });
-
- //add events to cursors.
- $sbTable.find("tbody").on("click", "div.marker", function(event) {
- var $tr = $(this).parents("tr"),
- $trs;
-
- if ($tr.hasClass(CURSOR_SELECTED_CLASS)) {
- mod.removeCursor($tr);
- }
- else {
- mod.selectCursor($tr);
- }
-
- if (event.ctrlKey === false) {
- $trs = $sbTable.find('.'+CURSOR_SELECTED_CLASS).not($tr);
- mod.removeCursor($trs);
- }
-
- return false;
- });
-
- /*
- * Select button dropdown state in the toolbar.
- * The button has to be disabled to prevent the dropdown
- * from opening
- */
- $sbContent.on("mouseenter", ".btn-group #timeline-select", function(ev) {
- $el = $(this);
-
- if ($el.hasClass("ui-state-disabled")) {
- $el.attr("disabled", "disabled");
- }
- else {
- $el.removeAttr("disabled");
- }
- });
- };
-
- return AIRTIME;
-
-}(AIRTIME || {}));
diff --git a/airtime_mvc/public/js/airtime/showbuilder/_main_builder.js b/airtime_mvc/public/js/airtime/showbuilder/_main_builder.js
deleted file mode 100644
index 768b24d55..000000000
--- a/airtime_mvc/public/js/airtime/showbuilder/_main_builder.js
+++ /dev/null
@@ -1,360 +0,0 @@
-AIRTIME = (function(AIRTIME) {
-
- var viewport,
- $lib,
- $libWrapper,
- $builder,
- $fs,
- widgetHeight,
- screenWidth,
- resizeTimeout,
- oBaseDatePickerSettings,
- oBaseTimePickerSettings,
- oRange,
- dateStartId = "#sb_date_start",
- timeStartId = "#sb_time_start",
- dateEndId = "#sb_date_end",
- timeEndId = "#sb_time_end",
- mod;
-
- if (AIRTIME.builderMain === undefined) {
- AIRTIME.builderMain = {};
- }
- mod = AIRTIME.builderMain;
-
- oBaseDatePickerSettings = {
- dateFormat: 'yy-mm-dd',
- //i18n_months, i18n_days_short are in common.js
- monthNames: i18n_months,
- dayNamesMin: i18n_days_short,
- onClick: function(sDate, oDatePicker) {
- $(this).datepicker( "setDate", sDate );
- },
- onClose: validateTimeRange
- };
-
- oBaseTimePickerSettings = {
- showPeriodLabels: false,
- showCloseButton: true,
- closeButtonText: $.i18n._("Done"),
- showLeadingZero: false,
- defaultTime: '0:00',
- hourText: $.i18n._("Hour"),
- minuteText: $.i18n._("Minute"),
- onClose: validateTimeRange
- };
-
- function setWidgetSize() {
- viewport = AIRTIME.utilities.findViewportDimensions();
- widgetHeight = viewport.height - 180;
- screenWidth = Math.floor(viewport.width - 50);
-
- var libTableHeight = widgetHeight - 175,
- builderTableHeight = widgetHeight - 95,
- oTable;
-
- if ($fs.is(':visible')) {
- builderTableHeight = builderTableHeight - 40;
- }
-
- //set the heights of the main widgets.
- $builder//.height(widgetHeight)
- .find(".dataTables_scrolling")
- //.css("max-height", builderTableHeight)
- .end();
- //.width(screenWidth);
-
- $lib//.height(widgetHeight)
- .find(".dataTables_scrolling")
- //.css("max-height", libTableHeight)
- .end();
-
- if ($lib.filter(':visible').length > 0) {
-
- //$lib.width(Math.floor(screenWidth * 0.47));
-
- $builder//.width(Math.floor(screenWidth * 0.47))
- .find("#sb_edit")
- .remove()
- .end()
- .find("#sb_date_start")
- .css("margin-left", 0)
- .end();
-
- oTable = $('#show_builder_table').dataTable();
- //oTable.fnDraw();
- }
- }
-
- function validateTimeRange() {
- var oRange,
- inputs = $('.sb-timerange > input'),
- start, end;
-
- oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId);
-
- start = oRange.start;
- end = oRange.end;
-
- if (end >= start) {
- inputs.removeClass('error');
- }
- else {
- if (!inputs.hasClass('error')) {
- inputs.addClass('error');
- }
- }
-
- return {
- start: start,
- end: end,
- isValid: end >= start
- };
- }
-
- function showSearchSubmit() {
- var fn,
- op,
- oTable = $('#show_builder_table').dataTable(),
- check;
-
- check = validateTimeRange();
-
- if (check.isValid) {
-
- //reset timestamp value since input values could have changed.
- AIRTIME.showbuilder.resetTimestamp();
-
- fn = oTable.fnSettings().fnServerData;
- fn.start = check.start;
- fn.end = check.end;
-
- op = $("div.sb-advanced-options");
- if (op.is(":visible")) {
-
- if (fn.ops === undefined) {
- fn.ops = {};
- }
- fn.ops.showFilter = op.find("#sb_show_filter").val();
- fn.ops.myShows = op.find("#sb_my_shows").is(":checked") ? 1 : 0;
- }
-
- oTable.fnDraw();
- }
- }
-
- mod.onReady = function() {
- // Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a)
- // We initialize the acceptedMimeTypes variable in Bootstrap so we don't have to duplicate the list
- Dropzone.options.content = {
- url:'/rest/media',
- clickable: false,
- acceptedFiles: acceptedMimeTypes.join(),
- init: function () {
- this.on("sending", function (file, xhr, data) {
- data.append("csrf_token", $("#csrf").val());
- });
- },
- dictDefaultMessage: '',
- createImageThumbnails: false,
- previewTemplate : '
'
- };
-
- // define module vars.
- $lib = $("#library_content");
- $builder = $("#show_builder");
- $fs = $builder.find('fieldset');
-
- $("#schedule-tab").on("click", function() {
- if (!$(this).hasClass('active')) {
- AIRTIME.showbuilder.switchTab($("#show_builder .outer-datatable-wrapper"), $(this));
- }
- });
-
- /*
- * Icon hover states for search.
- */
- $builder.on("mouseenter", ".sb-timerange .ui-button", function(ev) {
- $(this).addClass("ui-state-hover");
- });
- $builder.on("mouseleave", ".sb-timerange .ui-button", function(ev) {
- $(this).removeClass("ui-state-hover");
- });
-
- $builder.find(dateStartId)
- .datepicker(oBaseDatePickerSettings)
- .blur(validateTimeRange);
-
- $builder.find(timeStartId)
- .timepicker(oBaseTimePickerSettings)
- .blur(validateTimeRange);
-
- $builder.find(dateEndId)
- .datepicker(oBaseDatePickerSettings)
- .blur(validateTimeRange);
-
- $builder.find(timeEndId)
- .timepicker(oBaseTimePickerSettings)
- .blur(validateTimeRange);
-
-
- oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId,
- dateEndId, timeEndId);
- AIRTIME.showbuilder.fnServerData.start = oRange.start;
- AIRTIME.showbuilder.fnServerData.end = oRange.end;
-
- //the user might not have the library on the page (guest user)
- if (AIRTIME.library !== undefined) {
- AIRTIME.library.libraryInit();
- }
-
- AIRTIME.showbuilder.builderDataTable();
- setWidgetSize();
-
- $libWrapper = $lib.find("#library_display_wrapper");
- //$builder.find('.dataTables_scrolling').css("max-height",
- // widgetHeight - 95);
-
- $builder.on("click", "#sb_submit", showSearchSubmit);
-
- $builder.on("click", "#sb_edit", function(ev) {
- var schedTable = $("#show_builder_table").dataTable();
-
- // reset timestamp to redraw the cursors.
- AIRTIME.showbuilder.resetTimestamp();
-
- $lib.show().width(Math.floor(screenWidth * 0.48));
-
- $builder.width(Math.floor(screenWidth * 0.48)).find("#sb_edit")
- .remove().end().find("#sb_date_start")
- .css("margin-left", 0).end();
-
- schedTable.fnDraw();
-
- $.ajax( {
- url : baseUrl+"usersettings/set-now-playing-screen-settings",
- type : "POST",
- data : {
- settings : {
- library : true
- },
- format : "json"
- },
- dataType : "json",
- success : function() {
- }
- });
- });
-
- $lib.on("click", "#sb_lib_close", function() {
- var schedTable = $("#show_builder_table").dataTable();
-
- $lib.hide();
- $builder.width(screenWidth).find(".sb-timerange").find("#sb_date_start").css("margin-left", 30)
- .end().end();
-
- schedTable.fnDraw();
-
- $.ajax( {
- url : baseUrl+"usersettings/set-now-playing-screen-settings",
- type : "POST",
- data : {
- settings : {
- library : false
- },
- format : "json"
- },
- dataType : "json",
- success : function() {
- }
- });
- });
-
- $builder.find('legend').click(
- function(ev, item) {
-
- if ($fs.hasClass("closed")) {
-
- $fs.removeClass("closed");
- //$builder.find('.dataTables_scrolling').css(
- // "max-height", widgetHeight - 150);
- } else {
- $fs.addClass("closed");
-
- // set defaults for the options.
- $fs.find('select').val(0);
- $fs.find('input[type="checkbox"]').attr("checked",
- false);
- //$builder.find('.dataTables_scrolling').css(
- // "max-height", widgetHeight - 110);
- }
- });
-
- // set click event for all my shows checkbox.
- $builder.on("click", "#sb_my_shows", function(ev) {
-
- if ($(this).is(':checked')) {
- $(ev.delegateTarget).find('#sb_show_filter').val(0);
- }
-
- showSearchSubmit();
- });
-
- //set select event for choosing a show.
- $builder.on("change", '#sb_show_filter', function(ev) {
-
- if ($(this).val() !== 0) {
- $(ev.delegateTarget).find('#sb_my_shows')
- .attr("checked", false);
- }
-
- showSearchSubmit();
-
- });
-
- function checkScheduleUpdates() {
- var data = {}, oTable = $('#show_builder_table').dataTable(), fn = oTable
- .fnSettings().fnServerData, start = fn.start, end = fn.end;
-
- data["format"] = "json";
- data["start"] = start;
- data["end"] = end;
- data["timestamp"] = AIRTIME.showbuilder.getTimestamp();
- data["instances"] = AIRTIME.showbuilder.getShowInstances();
-
- if (fn.hasOwnProperty("ops")) {
- data["myShows"] = fn.ops.myShows;
- data["showFilter"] = fn.ops.showFilter;
- data["showInstanceFilter"] = fn.ops.showInstanceFilter;
- }
-
- $.ajax( {
- "dataType" : "json",
- "type" : "GET",
- "url" : baseUrl+"showbuilder/check-builder-feed",
- "data" : data,
- "success" : function(json) {
- if (json.update === true) {
- oTable.fnDraw();
- }
- setTimeout(checkScheduleUpdates, 5000);
- }
- });
-
- //check if the timeline view needs updating.
- setTimeout(checkScheduleUpdates, 5000);
- }
- };
-
- mod.onResize = function() {
-
- clearTimeout(resizeTimeout);
- resizeTimeout = setTimeout(setWidgetSize, 100);
- };
-
- return AIRTIME;
-
-} (AIRTIME || {}));
-
-$(document).ready(AIRTIME.builderMain.onReady);
-$(window).resize(AIRTIME.builderMain.onResize);
diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js
index 8c1ff1dfe..e23a6c5f8 100644
--- a/airtime_mvc/public/js/airtime/showbuilder/builder.js
+++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js
@@ -7,36 +7,38 @@ var AIRTIME = (function(AIRTIME){
$sbContent,
$sbTable,
$toolbar,
- $ul,
$lib,
cursors = [],
cursorIds = [],
showInstanceIds = [],
headerFooter = [],
- DISABLED_CLASS = 'ui-state-disabled';
-
+ DISABLED_CLASS = 'ui-state-disabled',
+ selectedRows,
+ $previouslySelected,
+ flagForDeselection;
+
if (AIRTIME.showbuilder === undefined) {
AIRTIME.showbuilder = {};
}
mod = AIRTIME.showbuilder;
-
+
function checkError(json) {
if (json.error !== undefined) {
alert(json.error);
}
}
-
+
mod.timeout = undefined;
mod.timestamp = -1;
mod.showInstances = [];
-
+
mod.resetTimestamp = function() {
-
+
mod.timestamp = -1;
};
-
+
mod.setTimestamp = function(timestamp) {
-
+
mod.timestamp = timestamp;
};
@@ -70,10 +72,10 @@ var AIRTIME = (function(AIRTIME){
.find(".fc-event-inner")
.append(' ');
}
- }
-
+ };
+
mod.getTimestamp = function() {
-
+
if (mod.timestamp !== undefined) {
return mod.timestamp;
}
@@ -81,50 +83,65 @@ var AIRTIME = (function(AIRTIME){
return -1;
}
};
-
+
mod.setShowInstances = function(showInstances) {
mod.showInstances = showInstances;
};
-
+
mod.getShowInstances = function() {
return mod.showInstances;
};
-
+
mod.refresh = function(schedId) {
mod.resetTimestamp();
// once a track plays out we need to check if we can update
// the is_scheduled flag in cc_files
if (schedId > 0) {
- $.post(baseUrl+"schedule/update-future-is-scheduled",
- {"format": "json", "schedId": schedId}, function(data) {
- if (data.redrawLibTable !== undefined && data.redrawLibTable) {
- $("#library_content").find("#library_display").dataTable().fnStandingRedraw();
- }
- });
+ $.post(baseUrl+"schedule/update-future-is-scheduled",
+ {"format": "json", "schedId": schedId}, function(data) {
+ if (data.redrawLibTable !== undefined && data.redrawLibTable) {
+ $("#library_content").find("#library_display").dataTable().fnStandingRedraw();
+ }
+ });
oSchedTable.fnDraw();
}
};
-
+
+ mod.switchTab = function(tab, el) {
+ $(".active-tab").hide().removeClass("active-tab");
+ tab.addClass("active-tab").show();
+
+ $(".nav.nav-tabs .active").removeClass("active");
+ el.addClass("active");
+
+ if (tab.hasClass("pl-content")) {
+ AIRTIME.playlist.setAsActive();
+ }
+ AIRTIME.playlist.onResize();
+ AIRTIME.library.fnRedraw();
+ };
+
+
mod.checkSelectButton = function() {
- var $selectable = $sbTable.find("tbody").find("input:checkbox");
-
+ var $selectable = $sbTable.find("tr");
+
if ($selectable.length !== 0) {
AIRTIME.button.enableButton("btn-group #timeline-select", false);
- }
- else {
+ } else {
AIRTIME.button.disableButton("btn-group #timeline-select", false);
}
-
+
//need to check if the 'Select' button is disabled
- if ($(".btn-group #timeline-select").is(":disabled")) {
- $(".btn-group #timeline-select").removeAttr("disabled");
+ var select = $(".btn-group #timeline-select");
+ if (select.is(":disabled")) {
+ select.removeAttr("disabled");
}
};
-
+
mod.checkTrimButton = function() {
var $over = $sbTable.find(".sb-over.sb-allowed");
-
+
if ($over.length !== 0) {
AIRTIME.button.enableButton("icon-cut", true);
}
@@ -132,9 +149,9 @@ var AIRTIME = (function(AIRTIME){
AIRTIME.button.disableButton("icon-cut", true);
}
};
-
+
mod.checkDeleteButton = function() {
- var $selected = $sbTable.find("tbody").find("input:checkbox").filter(":checked");
+ var $selected = $sbTable.find("tr."+SB_SELECTED_CLASS);
var button = $("#show_builder").find(".icon-trash").parent();
if ($selected.length !== 0) {
@@ -145,10 +162,10 @@ var AIRTIME = (function(AIRTIME){
button.attr('disabled', 'disabled');
}
};
-
+
mod.checkJumpToCurrentButton = function() {
var $current = $sbTable.find("."+NOW_PLAYING_CLASS);
-
+
if ($current.length !== 0) {
AIRTIME.button.enableButton("icon-step-forward", true);
}
@@ -156,61 +173,61 @@ var AIRTIME = (function(AIRTIME){
AIRTIME.button.disableButton("icon-step-forward", true);
}
};
-
+
mod.checkCancelButton = function() {
-
+
var $current = $sbTable.find(".sb-current-show"),
- //this user type should be refactored into a separate users module later
- //when there's more time and more JS will need to know user data.
+ //this user type should be refactored into a separate users module later
+ //when there's more time and more JS will need to know user data.
userType = localStorage.getItem('user-type'),
canCancel = false;
-
+
if ($current.length !== 0 && $current.hasClass("sb-allowed")) {
- canCancel = true;
+ canCancel = true;
}
else if ($current.length !== 0 && (userType === 'A' || userType === 'P')) {
canCancel = true;
}
-
+
if (canCancel === true) {
- AIRTIME.button.enableButton("icon-ban-circle", true);
+ AIRTIME.button.enableButton("icon-ban-circle", true);
}
else {
- AIRTIME.button.disableButton("icon-ban-circle", true);
+ AIRTIME.button.disableButton("icon-ban-circle", true);
}
};
-
+
mod.checkToolBarIcons = function() {
-
- //library may not be on the page.
- if (AIRTIME.library !== undefined) {
- AIRTIME.library.checkAddButton();
- }
-
+
+ //library may not be on the page.
+ if (AIRTIME.library !== undefined) {
+ AIRTIME.library.checkAddButton();
+ }
+
mod.checkSelectButton();
mod.checkTrimButton();
mod.checkDeleteButton();
mod.checkJumpToCurrentButton();
mod.checkCancelButton();
};
-
+
mod.selectCursor = function($el) {
$el.addClass(CURSOR_SELECTED_CLASS);
mod.checkToolBarIcons();
};
-
+
mod.removeCursor = function($el) {
-
+
$el.removeClass(CURSOR_SELECTED_CLASS);
mod.checkToolBarIcons();
};
-
+
/*
* sNot is an optional string to filter selected elements by. (ex removing the currently playing item)
*/
mod.getSelectedData = function(sNot) {
- var $selected = $sbTable.find("tbody").find("input:checkbox").filter(":checked").parents("tr"),
+ var $selected = $sbTable.find("tr."+SB_SELECTED_CLASS),
aData = [],
i, length,
$item;
@@ -218,134 +235,125 @@ var AIRTIME = (function(AIRTIME){
if (sNot !== undefined) {
$selected = $selected.not("."+sNot);
}
-
+
for (i = 0, length = $selected.length; i < length; i++) {
$item = $($selected.get(i));
aData.push($item.data('aData'));
}
-
+
return aData.reverse();
};
-
+
mod.selectAll = function () {
- $inputs = $sbTable.find("input:checkbox");
-
- $inputs.attr("checked", true);
-
- $trs = $inputs.parents("tr");
- $trs.addClass(SB_SELECTED_CLASS);
-
+ var $trs = $sbTable.find("tr.lib-audio").not(".sb-past, .sb-empty");
+ $trs.addClass(SB_SELECTED_CLASS).find(".sb-checkbox > input").prop('checked', true);
+
mod.checkToolBarIcons();
};
-
+
mod.selectNone = function () {
- $inputs = $sbTable.find("input:checkbox");
-
- $inputs.attr("checked", false);
-
- $trs = $inputs.parents("tr");
- $trs.removeClass(SB_SELECTED_CLASS);
-
+ var $trs = $sbTable.find("tr.lib-audio");
+ $trs.removeClass(SB_SELECTED_CLASS).find(".sb-checkbox > input").prop('checked', false);
+ $previouslySelected = undefined;
+ selectedRows = undefined;
+
mod.checkToolBarIcons();
};
-
+
mod.disableUI = function() {
-
- $lib.block({
+
+ $lib.block({
message: "",
theme: true,
applyPlatformOpacityRules: false
});
-
- $sbContent.block({
+
+ $sbContent.block({
message: "",
theme: true,
applyPlatformOpacityRules: false
});
};
-
+
mod.enableUI = function() {
-
$lib.unblock();
$sbContent.unblock();
-
- //Block UI changes the postion to relative to display the messages.
- $lib.css("position", "static");
- $sbContent.css("position", "static");
};
-
+
mod.fnItemCallback = function(json) {
checkError(json);
mod.getSelectedCursors();
+ selectedRows = $("." + SB_SELECTED_CLASS);
oSchedTable.fnDraw();
-
mod.enableUI();
+
//Unneccessary reload of the library pane after moving tracks in the showbuilder pane.
//$("#library_content").find("#library_display").dataTable().fnStandingRedraw();
getUsabilityHint();
};
-
+
mod.getSelectedCursors = function() {
cursorIds = [];
-
+
/* We need to keep record of which show the cursor belongs to
* in the case where more than one show is displayed in the show builder
* because header and footer rows have the same id
- */
+ */
showInstanceIds = [];
-
+
/* Keeps track if the row is a footer. We need to do this because
* header and footer rows have the save cursorIds and showInstanceId
* so both will be selected in the draw callback
- */
+ */
headerFooter = [];
-
+
cursors = $(".cursor-selected-row");
for (i = 0; i < cursors.length; i++) {
cursorIds.push(($(cursors.get(i)).attr("id")));
showInstanceIds.push(($(cursors.get(i)).attr("si_id")));
if ($(cursors.get(i)).hasClass("sb-footer")) {
- headerFooter.push("f");
+ headerFooter.push("f");
} else {
- headerFooter.push("n");
+ headerFooter.push("n");
}
}
};
-
+
mod.fnAdd = function(aMediaIds, aSchedIds) {
+ AIRTIME.library.selectNone();
mod.disableUI();
- $.post(baseUrl+"showbuilder/schedule-add",
+ $.post(baseUrl+"showbuilder/schedule-add",
{"format": "json", "mediaIds": aMediaIds, "schedIds": aSchedIds},
mod.fnItemCallback
);
};
-
+
mod.fnMove = function(aSelect, aAfter) {
-
+
mod.disableUI();
-
- $.post(baseUrl+"showbuilder/schedule-move",
- {"format": "json", "selectedItem": aSelect, "afterItem": aAfter},
+
+ $.post(baseUrl+"showbuilder/schedule-move",
+ {"format": "json", "selectedItem": aSelect, "afterItem": aAfter},
mod.fnItemCallback
);
};
-
+
mod.fnRemove = function(aItems) {
-
+
mod.disableUI();
if (confirm($.i18n._("Delete selected item(s)?"))) {
- $.post( baseUrl+"showbuilder/schedule-remove",
- {"items": aItems, "format": "json"},
- mod.fnItemCallback
- );
- }else{
- mod.enableUI();
+ $.post( baseUrl+"showbuilder/schedule-remove",
+ {"items": aItems, "format": "json"},
+ mod.fnItemCallback
+ );
+ } else {
+ mod.enableUI();
}
};
-
+
mod.fnRemoveSelectedItems = function() {
var aData = mod.getSelectedData(),
i,
@@ -355,18 +363,18 @@ var AIRTIME = (function(AIRTIME){
for (i=0, length = aData.length; i < length; i++) {
temp = aData[i];
- aItems.push({"id": temp.id, "instance": temp.instance, "timestamp": temp.timestamp});
+ aItems.push({"id": temp.id, "instance": temp.instance, "timestamp": temp.timestamp});
}
-
+
mod.fnRemove(aItems);
};
-
+
mod.fnServerData = function fnBuilderServerData( sSource, aoData, fnCallback ) {
-
+
aoData.push( { name: "timestamp", value: mod.getTimestamp()} );
aoData.push( { name: "instances", value: mod.getShowInstances()} );
aoData.push( { name: "format", value: "json"} );
-
+
if (mod.fnServerData.hasOwnProperty("start")) {
aoData.push( { name: "start", value: mod.fnServerData.start} );
}
@@ -378,14 +386,14 @@ var AIRTIME = (function(AIRTIME){
aoData.push( { name: "showFilter", value: mod.fnServerData.ops.showFilter} );
aoData.push( { name: "showInstanceFilter", value: mod.fnServerData.ops.showInstanceFilter} );
}
-
+
$.ajax({
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(json) {
- mod.updateCalendarStatusIcon(json)
+ mod.updateCalendarStatusIcon(json);
mod.setTimestamp(json.timestamp);
mod.setShowInstances(json.instances);
mod.getSelectedCursors();
@@ -393,25 +401,23 @@ var AIRTIME = (function(AIRTIME){
}
});
};
-
+
mod.jumpToCurrentTrack = function() {
var $scroll = $sbContent.find(".dataTables_scrolling");
var scrolled = $scroll.scrollTop();
var scrollingTop = $scroll.offset().top;
- var oTable = $('#show_builder_table').dataTable();
var current = $sbTable.find("."+NOW_PLAYING_CLASS);
var currentTop = current.offset().top;
$scroll.scrollTop(currentTop - scrollingTop + scrolled);
- }
+ };
mod.builderDataTable = function() {
$sbContent = $('#show_builder');
- $lib = $("#library_content"),
+ $lib = $("#library_content");
$sbTable = $sbContent.find('table');
var isInitialized = false;
- var emptyNode = document.createElement('div');
var lockedPreviewIcon = document.createElement('span');
lockedPreviewIcon.setAttribute('class', 'ui-icon ui-icon-locked');
var previewIcon = document.createElement('img');
@@ -420,19 +426,19 @@ var AIRTIME = (function(AIRTIME){
oSchedTable = $sbTable.dataTable( {
"aoColumns": [
- /* checkbox */ {"mDataProp": "allowed", "sTitle": "", "sWidth": "15px", "sClass": "sb-checkbox"},
- /* Type */ {"mDataProp": "image", "sTitle": "", "sClass": "library_image sb-image", "sWidth": "16px"},
- /* starts */ {"mDataProp": "starts", "sTitle": $.i18n._("Start"), "sClass": "sb-starts", "sWidth": "60px"},
- /* ends */ {"mDataProp": "ends", "sTitle": $.i18n._("End"), "sClass": "sb-ends", "sWidth": "60px"},
- /* runtime */ {"mDataProp": "runtime", "sTitle": $.i18n._("Duration"), "sClass": "library_length sb-length", "sWidth": "65px"},
- /* title */ {"mDataProp": "title", "sTitle": $.i18n._("Title"), "sClass": "sb-title"},
- /* creator */ {"mDataProp": "creator", "sTitle": $.i18n._("Creator"), "sClass": "sb-creator"},
- /* album */ {"mDataProp": "album", "sTitle": $.i18n._("Album"), "sClass": "sb-album"},
- /* cue in */ {"mDataProp": "cuein", "sTitle": $.i18n._("Cue In"), "bVisible": false, "sClass": "sb-cue-in"},
- /* cue out */ {"mDataProp": "cueout", "sTitle": $.i18n._("Cue Out"), "bVisible": false, "sClass": "sb-cue-out"},
- /* fade in */ {"mDataProp": "fadein", "sTitle": $.i18n._("Fade In"), "bVisible": false, "sClass": "sb-fade-in"},
- /* fade out */ {"mDataProp": "fadeout", "sTitle": $.i18n._("Fade Out"), "bVisible": false, "sClass": "sb-fade-out"},
- /* Mime */ {"mDataProp" : "mime", "sTitle" : $.i18n._("Mime"), "bVisible": false, "sClass": "sb-mime"}
+ /* checkbox */ {"mDataProp": "allowed", "sTitle": "", "sWidth": "16px", "sClass": "sb-checkbox"},
+ /* Type */ {"mDataProp": "image", "sTitle": "", "sClass": "library_image sb-image", "sWidth": "16px"},
+ /* starts */ {"mDataProp": "starts", "sTitle": $.i18n._("Start"), "sClass": "sb-starts", "sWidth": "60px"},
+ /* ends */ {"mDataProp": "ends", "sTitle": $.i18n._("End"), "sClass": "sb-ends", "sWidth": "60px"},
+ /* runtime */ {"mDataProp": "runtime", "sTitle": $.i18n._("Duration"), "sClass": "library_length sb-length", "sWidth": "65px"},
+ /* title */ {"mDataProp": "title", "sTitle": $.i18n._("Title"), "sClass": "sb-title"},
+ /* creator */ {"mDataProp": "creator", "sTitle": $.i18n._("Creator"), "sClass": "sb-creator"},
+ /* album */ {"mDataProp": "album", "sTitle": $.i18n._("Album"), "sClass": "sb-album"},
+ /* cue in */ {"mDataProp": "cuein", "sTitle": $.i18n._("Cue In"), "bVisible": false, "sClass": "sb-cue-in"},
+ /* cue out */ {"mDataProp": "cueout", "sTitle": $.i18n._("Cue Out"), "bVisible": false, "sClass": "sb-cue-out"},
+ /* fade in */ {"mDataProp": "fadein", "sTitle": $.i18n._("Fade In"), "bVisible": false, "sClass": "sb-fade-in"},
+ /* fade out */ {"mDataProp": "fadeout", "sTitle": $.i18n._("Fade Out"), "bVisible": false, "sClass": "sb-fade-out"},
+ /* Mime */ {"mDataProp" : "mime", "sTitle" : $.i18n._("Mime"), "bVisible": false, "sClass": "sb-mime"}
],
"bJQueryUI": true,
@@ -451,16 +457,7 @@ var AIRTIME = (function(AIRTIME){
delete oData.aoSearchCols;
},
"fnStateSave": function fnStateSave(oSettings, oData) {
-
localStorage.setItem('datatables-timeline', JSON.stringify(oData));
-
- /*
- $.ajax({
- url: baseUrl+"usersettings/set-timeline-datatable",
- type: "POST",
- data: {settings : oData, format: "json"},
- dataType: "json"
- });*/
},
"fnStateLoad": function fnBuilderStateLoad(oSettings) {
var settings = localStorage.getItem('datatables-timeline');
@@ -478,20 +475,10 @@ var AIRTIME = (function(AIRTIME){
//sure everything works properly.
for (i = 0, length = a.length; i < length; i++) {
if (typeof(a[i]) === "string") {
- a[i] = (a[i] === "true") ? true : false;
+ a[i] = (a[i] === "true");
}
}
- /*
- a = oData.ColReorder;
- if (a) {
- for (i = 0, length = a.length; i < length; i++) {
- if (typeof(a[i]) === "string") {
- a[i] = parseInt(a[i], 10);
- }
- }
- }*/
-
oData.iCreate = parseInt(oData.iCreate, 10);
},
@@ -502,7 +489,7 @@ var AIRTIME = (function(AIRTIME){
fnPrepareSeparatorRow,
$node,
cl="",
- //background-color to imitate calendar color.
+ //background-color to imitate calendar color.
r,g,b,a,
$nRow = $(nRow),
$image,
@@ -513,7 +500,6 @@ var AIRTIME = (function(AIRTIME){
//Albert:
//$(nRow.children[iNodeIndex]).replaceWith(emptyNode);
-
$node = $(nRow.children[iNodeIndex]);
$node.html(sRowContent);
@@ -599,7 +585,7 @@ var AIRTIME = (function(AIRTIME){
$node.empty();
}
- sSeparatorHTML = ''+$.i18n._("Show Empty")+' ';
+ sSeparatorHTML = ''+$.i18n._("Drag tracks here from the library")+' ';
cl = cl + " sb-empty odd";
fnPrepareSeparatorRow(sSeparatorHTML, cl, 1);
@@ -617,7 +603,7 @@ var AIRTIME = (function(AIRTIME){
}
else {
- //add the play function if the file exists on disk.
+ //add the play function if the file exists on disk.
$image = $nRow.find('td.sb-image');
$image.empty();
//check if the file exists.
@@ -627,12 +613,6 @@ var AIRTIME = (function(AIRTIME){
//$image.html(' ');
$image.append(lockedPreviewIcon);
} else {
- /*
- $image.html(' ')
- .click(function() {
- open_show_preview(aData.instance, aData.pos);
- return false;
- });*/
$image.append(previewIcon.cloneNode(false));
$image.click(function() {
open_show_preview(aData.instance, aData.pos);
@@ -691,7 +671,7 @@ var AIRTIME = (function(AIRTIME){
if (aData.scheduled === 1) {
$nRow.addClass(NOW_PLAYING_CLASS);
}
- else if (aData.scheduled === 0) {
+ else if (aData.scheduled === 0 || aData.scheduled === undefined) {
$nRow.addClass("sb-past");
}
else {
@@ -718,14 +698,6 @@ var AIRTIME = (function(AIRTIME){
if (aData.currentShow === true) {
$nRow.addClass("sb-current-show");
}
-
- //call the context menu so we can prevent the event from propagating.
- $nRow.find('td:gt(1)').click(function(e){
-
- $(this).contextMenu({x: e.pageX, y: e.pageY});
-
- return false;
- });
},
//remove any selected nodes before the draw.
"fnPreDrawCallback": function( oSettings ) {
@@ -744,95 +716,12 @@ var AIRTIME = (function(AIRTIME){
}
isInitialized = true;
- var wrapperDiv,
- markerDiv,
- $td,
- aData,
+ var aData,
elements,
- i, length, temp,
- $cursorRows,
- $table = $(this),
- $parent = $table.parent(),
- $tr,
- //use this array to cache DOM heights then we can detach the table to manipulate it to increase speed.
- heights = [];
+ i, length, temp;
clearTimeout(mod.timeout);
- /*
- //only create the cursor arrows if the library is on the page.
- if ($lib.length > 0 && $lib.filter(":visible").length > 0) {
-
- $cursorRows = $sbTable.find("tbody tr.sb-future.sb-allowed:not(.sb-header, .sb-empty)");
-
- //need to get heights of tds while elements are still in the DOM.
- for (i = 0, length = $cursorRows.length; i < length; i++) {
- $td = $($cursorRows.get(i)).find("td:first");
- heights.push($td.height());
- }
-
- //detach the table to increase speed.
- $table.detach();
-
- for (i = 0, length = $cursorRows.length; i < length; i++) {
-
- $td = $($cursorRows.get(i)).find("td:first");
- if ($td.hasClass("dataTables_empty")) {
- $parent.append($table);
- return false;
- }
-
- wrapperDiv = $("
", {
- "class": "innerWrapper",
- "css": {
- "height": heights[i]
- }
- });
- markerDiv = $("
", {
- "class": "marker"
- });
-
- $td.append(markerDiv).wrapInner(wrapperDiv);
-
- }
-
- //re-highlight selected cursors before draw took place
- for (i = 0; i < cursorIds.length; i++) {
- if (headerFooter[i] == "f") {
- $tr = $table.find("tbody tr.sb-footer[id="+cursorIds[i]+"][si_id="+showInstanceIds[i]+"]");
- } else {
- $tr = $table.find("tr[id="+cursorIds[i]+"][si_id="+showInstanceIds[i]+"]");
- }
-
- //If the currently playing track's cursor is selected,
- //and that track is deleted, the cursor position becomes
- //unavailble. We have to check the position is available
- // before re-highlighting it.
- //
- if ($tr.find(".sb-checkbox").children().hasClass("innerWrapper")) {
- mod.selectCursor($tr);
-
- // If the selected cursor is the footer row we need to
- //explicitly select it because that row does not have
- // innerWrapper class
- //
- } else if ($tr.hasClass("sb-footer")) {
- mod.selectCursor($tr);
- }
- }
-
- //if there is only 1 cursor on the page highlight it by default.
- if ($cursorRows.length === 1) {
- $td = $cursorRows.find("td:first");
- if (!$td.hasClass("dataTables_empty")) {
- $cursorRows.addClass("cursor-selected-row");
- }
- }
-
- $parent.append($table);
-
- }
- */
//order of importance of elements for setting the next timeout.
elements = [
$sbTable.find("tr."+NOW_PLAYING_CLASS),
@@ -846,27 +735,37 @@ var AIRTIME = (function(AIRTIME){
if (temp.length > 0) {
aData = temp.data("aData");
// max time interval
- // setTimeout allows only up to (2^31)-1 millisecs timeout value
- maxRefreshInterval = Math.pow(2, 31) - 1;
- refreshInterval = aData.refresh * 1000;
- if(refreshInterval > maxRefreshInterval){
- refreshInterval = maxRefreshInterval;
- }
- mod.timeout = setTimeout(function() {mod.refresh(aData.id)}, refreshInterval); //need refresh in milliseconds
+ // setTimeout allows only up to (2^31)-1 millisecs timeout value
+ maxRefreshInterval = Math.pow(2, 31) - 1;
+ refreshInterval = aData.refresh * 1000;
+ if(refreshInterval > maxRefreshInterval){
+ refreshInterval = maxRefreshInterval;
+ }
+ mod.timeout = setTimeout(function() {mod.refresh(aData.id)}, refreshInterval); //need refresh in milliseconds
break;
}
}
mod.checkToolBarIcons();
+
+ var sid;
+ if (selectedRows !== undefined) {
+ selectedRows.each(function (i, el) {
+ sid = $(el).attr("id");
+ var tr = $("#" + sid);
+ tr.addClass(SB_SELECTED_CLASS);
+ tr.find("input[type='checkbox']").prop("checked", true);
+ });
+ }
},
// R = ColReorder, C = ColVis
- "sDom": 'R<"dt-process-rel"r><"sb-padded"<"H"C>><"dataTables_scrolling sb-padded"t>',
+ "sDom": 'R<"dt-process-rel"r><"sb-padded"<"H"C>><"dataTables_scrolling sb-padded"t><"F">',
"oColVis": {
"aiExclude": [ 0, 1 ],
- "buttonText": $.i18n._("Show / hide columns"),
+ "buttonText": $.i18n._("Columns")
},
"oColReorder": {
@@ -874,425 +773,114 @@ var AIRTIME = (function(AIRTIME){
},
"sAjaxDataProp": "schedule",
- "oLanguage": datatables_dict,
- "sAjaxSource": baseUrl+"showbuilder/builder-feed"
+ "oLanguage": getDatatablesStrings({
+ "sZeroRecords": $.i18n._("There are no shows scheduled during the specified time period."),
+ "sEmptyTable": $.i18n._("There are no shows scheduled during the specified time period."),
+ }),
+ "sAjaxSource": baseUrl+"showbuilder/builder-feed",
+
+ "bScrollCollapseY": false
});
-
- $sbTable.find("tbody").on("click", "input:checkbox", function(ev) {
-
- var $cb = $(this),
- $tr = $cb.parents("tr"),
- $prev;
-
- if ($cb.is(":checked")) {
-
- if (ev.shiftKey) {
- $prev = $sbTable.find("tbody").find("tr."+SB_SELECTED_CLASS).eq(-1);
-
- $prev.nextUntil($tr)
- .addClass(SB_SELECTED_CLASS)
- .find("input:checkbox")
- .attr("checked", true)
- .end();
- }
-
- $tr.addClass(SB_SELECTED_CLASS);
- }
- else {
- $tr.removeClass(SB_SELECTED_CLASS);
- }
-
- mod.checkToolBarIcons();
- });
-
- var sortableConf = (function(){
- var origTrs,
- aItemData = [],
- oPrevData,
- fnAdd,
- fnMove,
- fnReceive,
- fnUpdate,
- i,
- html,
- helperData,
- draggingContainer;
-
- fnAdd = function() {
- var aMediaIds = [],
- aSchedIds = [];
-
- for(i = 0; i < aItemData.length; i++) {
- aMediaIds.push({"id": aItemData[i].id, "type": aItemData[i].ftype});
- }
- aSchedIds.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
-
- mod.fnAdd(aMediaIds, aSchedIds);
- };
-
- fnMove = function() {
- var aSelect = [],
- aAfter = [];
-
- for(i = 0; i < helperData.length; i++) {
- aSelect.push({"id": helperData[i].id, "instance": helperData[i].instance, "timestamp": helperData[i].timestamp});
- }
-
- aAfter.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
-
- mod.fnMove(aSelect, aAfter);
- };
-
- fnReceive = function(event, ui) {
- var aItems = [];
-
- AIRTIME.library.addToChosen(ui.item);
-
- aItems = AIRTIME.library.getSelectedData();
- origTrs = aItems;
- html = ui.helper.html();
-
- AIRTIME.library.removeFromChosen(ui.item);
- };
-
- fnUpdate = function(event, ui) {
- var prev = ui.item.prev();
-
- //can't add items outside of shows.
- if (prev.find("td:first").hasClass("dataTables_empty")
- || prev.length === 0) {
- alert($.i18n._("Cannot schedule outside a show."));
- ui.item.remove();
- return;
- }
-
- //if item is added after a footer, add the item after the last item in the show.
- if (prev.hasClass("sb-footer")) {
- prev = prev.prev();
- }
-
- aItemData = [];
- oPrevData = prev.data("aData");
-
- //item was dragged in
- if (origTrs !== undefined) {
-
- $sbTable.find("tr.ui-draggable")
- .empty()
- .after(html);
-
- aItemData = origTrs;
- origTrs = undefined;
- fnAdd();
- }
- //item was reordered.
- else {
-
- //ui.item
- // .empty()
- // .after(draggingContainer.html());
-
- aItemData.push(ui.item.data("aData"));
- fnMove();
- }
- };
-
- return {
- placeholder: "sb-placeholder ui-state-highlight",
- //forcePlaceholderSize: true,
- distance: 10,
- helper:
- function(event, item) {
- var selected = mod.getSelectedData(NOW_PLAYING_CLASS),
- thead = $("#show_builder_table thead"),
- colspan = thead.find("th").length,
- trfirst = thead.find("tr:first"),
- width = trfirst.width(),
- height = trfirst.height(),
- message;
-
- //if nothing is checked select the dragged item.
- if (selected.length === 0) {
- selected = [item.data("aData")];
- }
-
- if (selected.length === 1) {
- message = sprintf($.i18n._("Moving %s"), selected[0].title);
- //draggingContainer = item; //Default DataTables drag and drop
- draggingContainer = $(' ')
- .addClass('sb-helper')
- .append(' ')
- .find("td")
- .attr("colspan", colspan)
- .width(width)
- .height(height)
- .addClass("ui-state-highlight")
- .append(message)
- .end();
- }
- else {
- message = sprintf($.i18n._("Moving %s Items"), selected.length);
- draggingContainer = $(' ')
- .addClass('sb-helper')
- .append(' ')
- .find("td")
- .attr("colspan", colspan)
- .width(width)
- .height(height)
- .addClass("ui-state-highlight")
- .append(message)
- .end();
+ $sbTable.find("tbody").on("mousedown", "tr:not(.sb-header, .sb-footer, .sb-past, .sb-empty, :has(td.dataTables_empty))", function(ev) {
+ var $tr = $(this),
+ // Get the ID of the selected row
+ $rowId = $tr.attr("id");
+
+ if (!$tr.hasClass(SB_SELECTED_CLASS)) {
+ if (ev.shiftKey && $previouslySelected !== undefined) {
+ if ($previouslySelected.attr("id") == $rowId) {
+ return;
}
- helperData = selected;
-
- return draggingContainer;
- },
- items: 'tr:not(:first, :last, .sb-header, .sb-not-allowed, .sb-past, .sb-now-playing, .sb-empty)',
- cancel: '.sb-footer',
- receive: fnReceive,
- update: fnUpdate,
- start: function(event, ui) {
- /*
- var elements = $sbTable.find('tr input:checked').parents('tr')
- .not(ui.item)
- .not("."+NOW_PLAYING_CLASS);
-
- //remove all other items from the screen,
- //don't remove ui.item or else we can not get position information when the user drops later.
- elements.remove();
- */
-
- var elements = $sbTable.find('tr input:checked').parents('tr').not("."+NOW_PLAYING_CLASS);
-
- elements.hide();
- },
- stop: function() {
- var elements = $sbTable.find('tr.'+SB_SELECTED_CLASS).not("."+NOW_PLAYING_CLASS);
- elements.show();
- }
- };
- }());
-
- $sbTable.sortable(sortableConf);
-
- //start setup of the builder toolbar.
- $toolbar = $(".sb-content .fg-toolbar");
-
- $menu = $("
");
- $menu.append("" +
- "" +
- $.i18n._("Select")+" " +
- " " +
- "" +
- "
")
- .append("" +
- "" +
- "
")
- .append("" +
- "" +
- "
");
-
- //if 'Add/Remove content' was chosen from the context menu
- //in the Calendar do not append these buttons
- if ($(".ui-dialog-content").length === 0) {
- $menu.append("" +
- "" +
- "
")
- .append("" +
- "" +
- "
");
- }
-
- if (localStorage.getItem('user-type') != 'G') {
- $toolbar.append($menu);
- }
-
- $menu = undefined;
-
- $('#timeline-sa').click(function(){mod.selectAll();});
- $('#timeline-sn').click(function(){mod.selectNone();});
-
- //cancel current show
- $toolbar.find('.icon-ban-circle').parent()
- .click(function() {
- var $tr,
- data,
- msg = $.i18n._('Cancel Current Show?');
-
- if (AIRTIME.button.isDisabled('icon-ban-circle', true) === true) {
- return;
- }
-
- $tr = $sbTable.find('tr.sb-future:first');
-
- if ($tr.hasClass('sb-current-show')) {
- data = $tr.data("aData");
-
- if (data.record === true) {
- msg = $.i18n._('Stop recording current show?');
- }
-
- if (confirm(msg)) {
- var url = baseUrl+"Schedule/cancel-current-show";
- $.ajax({
- url: url,
- data: {format: "json", id: data.instance},
- success: function(data){
- $("#library_content").find("#library_display").dataTable().fnStandingRedraw();
- var oTable = $sbTable.dataTable();
- oTable.fnDraw();
- }
+ // If the selected row comes before the previously selected row,
+ // we want to select previous rows, otherwise we select next
+ if ($previouslySelected.prevAll("#" + $rowId).length !== 0) {
+ $previouslySelected.prevUntil($tr).each(function (i, el) {
+ $(el).addClass(SB_SELECTED_CLASS);
+ $(el).find(".sb-checkbox > input").prop('checked', true);
+ });
+ } else {
+ $previouslySelected.nextUntil($tr).each(function (i, el) {
+ $(el).addClass(SB_SELECTED_CLASS);
+ $(el).find(".sb-checkbox > input").prop('checked', true);
});
}
- }
- });
-
- //jump to current
- $toolbar.find('.icon-step-forward').parent()
- .click(function() {
-
- if (AIRTIME.button.isDisabled('icon-step-forward', true) === true) {
- return;
}
- /*
- var $scroll = $sbContent.find(".dataTables_scrolling"),
- scrolled = $scroll.scrollTop(),
- scrollingTop = $scroll.offset().top,
- current = $sbTable.find("."+NOW_PLAYING_CLASS),
- currentTop = current.offset().top;
-
- $scroll.scrollTop(currentTop - scrollingTop + scrolled);
- */
- mod.jumpToCurrentTrack();
- });
-
- //delete overbooked tracks.
- $toolbar.find('.icon-cut', true).parent()
- .click(function() {
-
- if (AIRTIME.button.isDisabled('icon-cut', true) === true) {
- return;
- }
-
- var temp,
- aItems = [],
- trs = $sbTable.find(".sb-over.sb-future.sb-allowed");
-
- trs.each(function(){
- temp = $(this).data("aData");
- aItems.push({"id": temp.id, "instance": temp.instance, "timestamp": temp.timestamp});
- });
-
- mod.fnRemove(aItems);
- });
-
- //delete selected tracks
- $toolbar.find('.icon-trash').parent()
- .click(function() {
+ $tr.addClass(SB_SELECTED_CLASS);
+ $tr.find(".sb-checkbox > input").prop('checked', true);
+ } else {
+ flagForDeselection = true;
+ }
- var button = $("#show_builder").find(".icon-trash").parent();
+ selectedRows = $("." + SB_SELECTED_CLASS);
+ // Remember this row so we can properly multiselect
+ $previouslySelected = $tr;
+ });
- if (button.hasClass(DISABLED_CLASS)) {
- return;
- }
-
- mod.fnRemoveSelectedItems();
- });
-
- //add events to cursors.
- $sbTable.find("tbody").on("click", "div.marker", function(event) {
- var $tr = $(this).parents("tr"),
- $trs;
-
- if ($tr.hasClass(CURSOR_SELECTED_CLASS)) {
- mod.removeCursor($tr);
+ $sbTable.find("tbody").on("click", "tr:not(.sb-header, .sb-footer, .sb-past, .sb-empty, :has(td.dataTables_empty))", function(ev) {
+ if (flagForDeselection) {
+ flagForDeselection = false;
+ $(this).removeClass(SB_SELECTED_CLASS);
+ $(this).find(".sb-checkbox > input").prop('checked', false);
+ } else {
+ $(this).find(".sb-checkbox > input").prop('checked', true);
}
- else {
- mod.selectCursor($tr);
- }
-
- if (event.ctrlKey === false) {
- $trs = $sbTable.find('.'+CURSOR_SELECTED_CLASS).not($tr);
- mod.removeCursor($trs);
- }
-
- return false;
+ selectedRows = $("." + SB_SELECTED_CLASS);
+ mod.checkToolBarIcons();
});
-
- /*
- * Select button dropdown state in the toolbar.
- * The button has to be disabled to prevent the dropdown
- * from opening
- */
- $sbContent.on("mouseenter", ".btn-group #timeline-select", function(ev) {
- $el = $(this);
-
- if ($el.hasClass("ui-state-disabled")) {
- $el.attr("disabled", "disabled");
- }
- else {
- $el.removeAttr("disabled");
- }
- });
-
-
+
//begin context menu initialization.
$.contextMenu({
- selector: '.sb-content table tbody tr:not(.sb-empty, .sb-footer, .sb-header, .sb-record) td:not(.sb-checkbox, .sb-image)',
- trigger: "left",
- ignoreRightClick: true,
-
+ selector: '#show_builder tr.lib-audio:not(.sb-past)',
+ trigger: "right",
+
build: function($el, e) {
- var items,
- $tr = $el.parent(),
- data = $tr.data("aData"),
+ var items,
+ $tr = $el,
+ data = $tr.data("aData"),
cursorClass = "cursor-selected-row",
callback;
function processMenuItems(oItems) {
-
+
//define a preview callback.
if (oItems.preview !== undefined) {
-
+
callback = function() {
open_show_preview(data.instance, data.pos);
};
-
+
oItems.preview.callback = callback;
}
-
+
//define a select cursor callback.
if (oItems.selCurs !== undefined) {
-
+
callback = function() {
var $tr = $(this).parents('tr').next();
-
+
mod.selectCursor($tr);
};
-
+
oItems.selCurs.callback = callback;
}
-
- //define a remove cursor callback.
+
+ //define a remove cursor callback.
if (oItems.delCurs !== undefined) {
-
+
callback = function() {
var $tr = $(this).parents('tr').next();
-
+
mod.removeCursor($tr);
};
-
+
oItems.delCurs.callback = callback;
}
-
+
//define a delete callback.
if (oItems.del !== undefined) {
-
+
callback = function() {
AIRTIME.showbuilder.fnRemove([{
id: data.id,
@@ -1300,10 +888,10 @@ var AIRTIME = (function(AIRTIME){
instance: data.instance
}]);
};
-
+
oItems.del.callback = callback;
}
-
+
//only show the cursor selecting options if the library is visible on the page.
if ($tr.next().find('.marker').length === 0) {
delete oItems.selCurs;
@@ -1317,30 +905,366 @@ var AIRTIME = (function(AIRTIME){
else {
delete oItems.delCurs;
}
- }
-
+ }
+
items = oItems;
}
-
+
request = $.ajax({
- url: baseUrl+"showbuilder/context-menu",
- type: "GET",
- data: {id : data.id, format: "json"},
- dataType: "json",
- async: false,
- success: function(json){
- processMenuItems(json.items);
- }
+ url: baseUrl+"showbuilder/context-menu",
+ type: "GET",
+ data: {id : data.id, format: "json"},
+ dataType: "json",
+ async: false,
+ success: function(json){
+ processMenuItems(json.items);
+ }
});
return {
items: items
};
-
+
+ }
+ });
+
+ var sortableConf = (function(){
+ var origTrs,
+ aItemData = [],
+ oPrevData,
+ fnAdd,
+ fnMove,
+ fnReceive,
+ fnUpdate,
+ i,
+ html,
+ helperData,
+ draggingContainer;
+
+ fnAdd = function() {
+ var aMediaIds = [],
+ aSchedIds = [];
+
+ for(i = 0; i < aItemData.length; i++) {
+ aMediaIds.push({"id": aItemData[i].id, "type": aItemData[i].ftype});
+ }
+ aSchedIds.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
+
+ mod.fnAdd(aMediaIds, aSchedIds);
+ };
+
+ fnMove = function() {
+ var aSelect = [],
+ aAfter = [];
+
+ for(i = 0; i < helperData.length; i++) {
+ aSelect.push({"id": helperData[i].id, "instance": helperData[i].instance, "timestamp": helperData[i].timestamp});
+ }
+
+ aAfter.push({"id": oPrevData.id, "instance": oPrevData.instance, "timestamp": oPrevData.timestamp});
+
+ mod.fnMove(aSelect, aAfter);
+ };
+
+ fnReceive = function(event, ui) {
+ var aItems = [];
+
+ AIRTIME.library.addToChosen(ui.item);
+
+ aItems = AIRTIME.library.getSelectedData();
+ origTrs = aItems;
+ html = ui.helper.html();
+
+ AIRTIME.library.removeFromChosen(ui.item);
+ };
+
+ fnUpdate = function(event, ui) {
+ var prev = ui.item.prev();
+
+ //can't add items outside of shows.
+ if (prev.find("td:first").hasClass("dataTables_empty")
+ || prev.length === 0) {
+ alert($.i18n._("Cannot schedule outside a show."));
+ ui.item.remove();
+ return;
+ }
+
+ //if item is added after a footer, add the item after the last item in the show.
+ if (prev.hasClass("sb-footer")) {
+ prev = prev.prev();
+ }
+
+ aItemData = [];
+ oPrevData = prev.data("aData");
+
+ //item was dragged in
+ if (origTrs !== undefined) {
+
+ $sbTable.find("tr.ui-draggable")
+ .empty()
+ .after(html);
+
+ aItemData = origTrs;
+ origTrs = undefined;
+ fnAdd();
+ }
+ //item was reordered.
+ else {
+
+ //ui.item
+ // .empty()
+ // .after(draggingContainer.html());
+
+ aItemData.push(ui.item.data("aData"));
+ fnMove();
+ }
+ };
+
+ return {
+ placeholder: "sb-placeholder ui-state-highlight",
+ //forcePlaceholderSize: true,
+ distance: 25,
+ helper:
+ function(event, item) {
+ var selected = mod.getSelectedData(NOW_PLAYING_CLASS),
+ thead = $("#show_builder_table thead"),
+ colspan = thead.find("th").length,
+ trfirst = thead.find("tr:first"),
+ width = trfirst.width(),
+ height = trfirst.height(),
+ message;
+
+ //if nothing is checked select the dragged item.
+ if (selected.length === 0) {
+ selected = [item.data("aData")];
+ }
+
+ if (selected.length === 1) {
+ message = sprintf($.i18n._("Moving %s"), selected[0].title);
+ //draggingContainer = item; //Default DataTables drag and drop
+ draggingContainer = $(' ')
+ .addClass('sb-helper')
+ .append(' ')
+ .find("td")
+ .attr("colspan", colspan)
+ .width(width)
+ .height(height)
+ .addClass("ui-state-highlight")
+ .append(message)
+ .end();
+ }
+ else {
+ message = sprintf($.i18n._("Moving %s Items"), selected.length);
+ draggingContainer = $(' ')
+ .addClass('sb-helper')
+ .append(' ')
+ .find("td")
+ .attr("colspan", colspan)
+ .width(width)
+ .height(height)
+ .addClass("ui-state-highlight")
+ .append(message)
+ .end();
+ }
+
+ helperData = selected;
+
+ return draggingContainer;
+ },
+ items: 'tr:not(:first, :last, .sb-header, .sb-not-allowed, .sb-past, .sb-now-playing, .sb-empty)',
+ cancel: '.sb-footer',
+ receive: fnReceive,
+ update: fnUpdate,
+ axis: "y",
+ containment: "document",
+ start: function(event, ui) {
+ var elements = $sbTable.find('tr.'+SB_SELECTED_CLASS).not("."+NOW_PLAYING_CLASS);
+ elements.hide();
+ },
+ stop: function() {
+ var elements = $sbTable.find('tr.'+SB_SELECTED_CLASS).not("."+NOW_PLAYING_CLASS);
+ elements.show();
+ }
+ };
+ }());
+
+ $sbTable.sortable(sortableConf);
+
+ //start setup of the builder toolbar.
+ $toolbar = $(".sb-content .fg-toolbar:first");
+ var footer = $(".sb-content .fg-toolbar:last"),
+ timerange = $(".sb-timerange");
+ $toolbar.append(timerange);
+
+ $menu = $("
");
+ $menu.append("" +
+ "" +
+ $.i18n._("Select")+" " +
+ " " +
+ "" +
+ "
")
+ .append("" +
+ "" +
+ " " +
+ "" + $.i18n._('Trim overbooked shows') + " " +
+ "
")
+ .append("" +
+ "" +
+ " " +
+ "" + $.i18n._('Remove') + " " +
+ "
");
+
+ //if 'Add/Remove content' was chosen from the context menu
+ //in the Calendar do not append these buttons
+ if ($(".ui-dialog-content").length === 0) {
+ $menu.append("" +
+ "" +
+ " " +
+ "" + $.i18n._('Jump to Current') + " " +
+ "
")
+ .append("" +
+ "" +
+ " " +
+ "" + $.i18n._('Cancel current show') + " " +
+ "
");
+ }
+
+ if (localStorage.getItem('user-type') != 'G') {
+ $toolbar.append($menu);
+ }
+
+ $menu = undefined;
+
+ $('#timeline-sa').click(function(){mod.selectAll();});
+ $('#timeline-sn').click(function(){mod.selectNone();});
+
+ //cancel current show
+ $toolbar.find('.icon-ban-circle').parent()
+ .click(function() {
+ var $tr,
+ data,
+ msg = $.i18n._('Cancel Current Show?');
+
+ if (AIRTIME.button.isDisabled('icon-ban-circle', true) === true) {
+ return;
+ }
+
+ $tr = $sbTable.find('tr.sb-future:first');
+
+ if ($tr.hasClass('sb-current-show')) {
+ data = $tr.data("aData");
+
+ if (data.record === true) {
+ msg = $.i18n._('Stop recording current show?');
+ }
+
+ if (confirm(msg)) {
+ var url = baseUrl+"Schedule/cancel-current-show";
+ $.ajax({
+ url: url,
+ data: {format: "json", id: data.instance},
+ success: function(data){
+ $("#library_content").find("#library_display").dataTable().fnStandingRedraw();
+ var oTable = $sbTable.dataTable();
+ oTable.fnDraw();
+ }
+ });
+ }
+ }
+ });
+
+ //jump to current
+ $toolbar.find('.icon-step-forward').parent()
+ .click(function() {
+
+ if (AIRTIME.button.isDisabled('icon-step-forward', true) === true) {
+ return;
+ }
+ /*
+ var $scroll = $sbContent.find(".dataTables_scrolling"),
+ scrolled = $scroll.scrollTop(),
+ scrollingTop = $scroll.offset().top,
+ current = $sbTable.find("."+NOW_PLAYING_CLASS),
+ currentTop = current.offset().top;
+
+ $scroll.scrollTop(currentTop - scrollingTop + scrolled);
+ */
+ mod.jumpToCurrentTrack();
+ });
+
+ //delete overbooked tracks.
+ $toolbar.find('.icon-cut', true).parent()
+ .click(function() {
+
+ if (AIRTIME.button.isDisabled('icon-cut', true) === true) {
+ return;
+ }
+
+ var temp,
+ aItems = [],
+ trs = $sbTable.find(".sb-over.sb-future.sb-allowed");
+
+ trs.each(function(){
+ temp = $(this).data("aData");
+ aItems.push({"id": temp.id, "instance": temp.instance, "timestamp": temp.timestamp});
+ });
+
+ mod.fnRemove(aItems);
+ });
+
+ //delete selected tracks
+ $toolbar.find('.icon-trash').parent()
+ .click(function() {
+
+ var button = $("#show_builder").find(".icon-trash").parent();
+
+ if (button.hasClass(DISABLED_CLASS)) {
+ return;
+ }
+
+ mod.fnRemoveSelectedItems();
+ });
+
+ //add events to cursors.
+ $sbTable.find("tbody").on("click", "div.marker", function(event) {
+ var $tr = $(this).parents("tr"),
+ $trs;
+
+ if ($tr.hasClass(CURSOR_SELECTED_CLASS)) {
+ mod.removeCursor($tr);
+ }
+ else {
+ mod.selectCursor($tr);
+ }
+
+ if (event.ctrlKey === false) {
+ $trs = $sbTable.find('.'+CURSOR_SELECTED_CLASS).not($tr);
+ mod.removeCursor($trs);
+ }
+
+ return false;
+ });
+
+ /*
+ * Select button dropdown state in the toolbar.
+ * The button has to be disabled to prevent the dropdown
+ * from opening
+ */
+ $sbContent.on("mouseenter", ".btn-group #timeline-select", function(ev) {
+ $el = $(this);
+
+ if ($el.hasClass("ui-state-disabled")) {
+ $el.attr("disabled", "disabled");
+ }
+ else {
+ $el.removeAttr("disabled");
}
});
};
-
+
return AIRTIME;
-
+
}(AIRTIME || {}));
diff --git a/airtime_mvc/public/js/airtime/showbuilder/main_builder.js b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js
index ee23aa6f1..768b24d55 100644
--- a/airtime_mvc/public/js/airtime/showbuilder/main_builder.js
+++ b/airtime_mvc/public/js/airtime/showbuilder/main_builder.js
@@ -15,12 +15,6 @@ AIRTIME = (function(AIRTIME) {
timeStartId = "#sb_time_start",
dateEndId = "#sb_date_end",
timeEndId = "#sb_time_end",
- $toggleLib = $(""+$.i18n._("Add / Remove Content")+" "),
- $libClose = $(' ', {
- "class": "close-round",
- "href": "#",
- "id": "sb_lib_close"
- }),
mod;
if (AIRTIME.builderMain === undefined) {
@@ -64,22 +58,22 @@ AIRTIME = (function(AIRTIME) {
}
//set the heights of the main widgets.
- $builder.height(widgetHeight)
+ $builder//.height(widgetHeight)
.find(".dataTables_scrolling")
- .css("max-height", builderTableHeight)
- .end()
- .width(screenWidth);
+ //.css("max-height", builderTableHeight)
+ .end();
+ //.width(screenWidth);
- $lib.height(widgetHeight)
+ $lib//.height(widgetHeight)
.find(".dataTables_scrolling")
- .css("max-height", libTableHeight)
+ //.css("max-height", libTableHeight)
.end();
if ($lib.filter(':visible').length > 0) {
- $lib.width(Math.floor(screenWidth * 0.47));
+ //$lib.width(Math.floor(screenWidth * 0.47));
- $builder.width(Math.floor(screenWidth * 0.47))
+ $builder//.width(Math.floor(screenWidth * 0.47))
.find("#sb_edit")
.remove()
.end()
@@ -150,11 +144,33 @@ AIRTIME = (function(AIRTIME) {
}
mod.onReady = function() {
+ // Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a)
+ // We initialize the acceptedMimeTypes variable in Bootstrap so we don't have to duplicate the list
+ Dropzone.options.content = {
+ url:'/rest/media',
+ clickable: false,
+ acceptedFiles: acceptedMimeTypes.join(),
+ init: function () {
+ this.on("sending", function (file, xhr, data) {
+ data.append("csrf_token", $("#csrf").val());
+ });
+ },
+ dictDefaultMessage: '',
+ createImageThumbnails: false,
+ previewTemplate : '
'
+ };
+
// define module vars.
$lib = $("#library_content");
$builder = $("#show_builder");
$fs = $builder.find('fieldset');
+ $("#schedule-tab").on("click", function() {
+ if (!$(this).hasClass('active')) {
+ AIRTIME.showbuilder.switchTab($("#show_builder .outer-datatable-wrapper"), $(this));
+ }
+ });
+
/*
* Icon hover states for search.
*/
@@ -196,10 +212,8 @@ AIRTIME = (function(AIRTIME) {
setWidgetSize();
$libWrapper = $lib.find("#library_display_wrapper");
- $libWrapper.prepend($libClose);
-
- $builder.find('.dataTables_scrolling').css("max-height",
- widgetHeight - 95);
+ //$builder.find('.dataTables_scrolling').css("max-height",
+ // widgetHeight - 95);
$builder.on("click", "#sb_submit", showSearchSubmit);
@@ -236,11 +250,9 @@ AIRTIME = (function(AIRTIME) {
var schedTable = $("#show_builder_table").dataTable();
$lib.hide();
- $builder.width(screenWidth).find(".sb-timerange").prepend(
- $toggleLib).find("#sb_date_start").css("margin-left", 30)
+ $builder.width(screenWidth).find(".sb-timerange").find("#sb_date_start").css("margin-left", 30)
.end().end();
- $toggleLib.removeClass("ui-state-hover");
schedTable.fnDraw();
$.ajax( {
@@ -264,8 +276,8 @@ AIRTIME = (function(AIRTIME) {
if ($fs.hasClass("closed")) {
$fs.removeClass("closed");
- $builder.find('.dataTables_scrolling').css(
- "max-height", widgetHeight - 150);
+ //$builder.find('.dataTables_scrolling').css(
+ // "max-height", widgetHeight - 150);
} else {
$fs.addClass("closed");
@@ -273,8 +285,8 @@ AIRTIME = (function(AIRTIME) {
$fs.find('select').val(0);
$fs.find('input[type="checkbox"]').attr("checked",
false);
- $builder.find('.dataTables_scrolling').css(
- "max-height", widgetHeight - 110);
+ //$builder.find('.dataTables_scrolling').css(
+ // "max-height", widgetHeight - 110);
}
});