From 661a87dfbcee582a7b40ebd3cf070d466b34cfc8 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Wed, 29 Jul 2015 13:35:01 -0400 Subject: [PATCH] SAAS-948 - Frontend tweaks and fixes --- .../controllers/ShowBuilderController.php | 14 +- ...ShowBuilderTest.php => ShowBuilderNew.php} | 6 +- .../views/scripts/form/show-builder.phtml | 22 +- .../views/scripts/show-builder/index.phtml | 9 +- .../views/scripts/webstream/webstream.phtml | 2 +- ...{showbuilder-test.css => _showbuilder.css} | 59 +- airtime_mvc/public/css/media_library.css | 2 +- airtime_mvc/public/css/styles.css | 2 +- .../library/{library-test.js => _library.js} | 373 ++++++------ .../airtime/library/{spl-test.js => _spl.js} | 460 +++++++------- ...uilder_test.js => _library_showbuilder.js} | 3 +- .../{builder_test.js => _builder.js} | 565 +++++++++--------- ...{main_builder_test.js => _main_builder.js} | 0 13 files changed, 806 insertions(+), 711 deletions(-) rename airtime_mvc/application/forms/{ShowBuilderTest.php => ShowBuilderNew.php} (95%) rename airtime_mvc/public/css/{showbuilder-test.css => _showbuilder.css} (75%) rename airtime_mvc/public/js/airtime/library/{library-test.js => _library.js} (75%) rename airtime_mvc/public/js/airtime/library/{spl-test.js => _spl.js} (92%) rename airtime_mvc/public/js/airtime/library/events/{library_showbuilder_test.js => _library_showbuilder.js} (99%) rename airtime_mvc/public/js/airtime/showbuilder/{builder_test.js => _builder.js} (78%) rename airtime_mvc/public/js/airtime/showbuilder/{main_builder_test.js => _main_builder.js} (100%) diff --git a/airtime_mvc/application/controllers/ShowBuilderController.php b/airtime_mvc/application/controllers/ShowBuilderController.php index 66ac4bfb4..a5dfdc3a5 100644 --- a/airtime_mvc/application/controllers/ShowBuilderController.php +++ b/airtime_mvc/application/controllers/ShowBuilderController.php @@ -29,25 +29,25 @@ class ShowBuilderController extends Zend_Controller_Action { $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.contextMenu.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColVis.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/datatables/css/ColReorder.css?'.$CC_CONFIG['airtime_version']); - $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/library-test.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/library_showbuilder_test.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/_library.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/events/_library_showbuilder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); // PLUPLOAD $this->view->headScript()->appendFile($baseUrl.'js/libs/dropzone.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'css/dropzone/dropzone.min.css?'.$CC_CONFIG['airtime_version']); $this->view->headScript()->appendFile($baseUrl.'js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/builder_test.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/main_builder_test.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/_builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/showbuilder/_main_builder.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); // MEDIA BUILDER - $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/spl-test.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/library/_spl.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); $this->view->headScript()->appendFile($baseUrl.'js/airtime/playlist/smart_blockbuilder.js?'.$CC_CONFIG['airtime_version'], 'text/javascript'); $this->view->headLink()->appendStylesheet($baseUrl.'css/playlist_builder.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']); $this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder.css?'.$CC_CONFIG['airtime_version']); - $this->view->headLink()->appendStylesheet($baseUrl.'css/showbuilder-test.css?'.$CC_CONFIG['airtime_version']); + $this->view->headLink()->appendStylesheet($baseUrl.'css/_showbuilder.css?'.$CC_CONFIG['airtime_version']); $csrf_namespace = new Zend_Session_Namespace('csrf_namespace'); $csrf_element = new Zend_Form_Element_Hidden('csrf'); @@ -68,7 +68,7 @@ class ShowBuilderController extends Zend_Controller_Action { $end = DateTime::createFromFormat("U", $to, $utcTimezone); $end->setTimezone($displayTimeZone); - $form = new Application_Form_ShowBuilderTest(); + $form = new Application_Form_ShowBuilderNew(); $form->populate(array( 'sb_date_start' => $start->format("Y-m-d"), 'sb_time_start' => $start->format("H:i"), diff --git a/airtime_mvc/application/forms/ShowBuilderTest.php b/airtime_mvc/application/forms/ShowBuilderNew.php similarity index 95% rename from airtime_mvc/application/forms/ShowBuilderTest.php rename to airtime_mvc/application/forms/ShowBuilderNew.php index d4b8b2d75..8a51e685c 100644 --- a/airtime_mvc/application/forms/ShowBuilderTest.php +++ b/airtime_mvc/application/forms/ShowBuilderNew.php @@ -1,6 +1,6 @@ setLabel(_("Show:")); + $showSelect->setLabel(_("Filter by Show")); $showSelect->setMultiOptions($this->getShowNames()); $showSelect->setValue(null); $showSelect->setDecorators(array('ViewHelper')); @@ -85,7 +85,7 @@ class Application_Form_ShowBuilderTest extends Zend_Form_SubForm private function getShowNames() { - $showNames = array("0" => "-------------------------"); + $showNames = array("0" => "Filter by Show"); $shows = CcShowQuery::create() ->setFormatter(ModelCriteria::FORMAT_ON_DEMAND) diff --git a/airtime_mvc/application/views/scripts/form/show-builder.phtml b/airtime_mvc/application/views/scripts/form/show-builder.phtml index d1ec22648..bba94655c 100644 --- a/airtime_mvc/application/views/scripts/form/show-builder.phtml +++ b/airtime_mvc/application/views/scripts/form/show-builder.phtml @@ -1,8 +1,16 @@ -element->getElement('sb_date_start'); ?> -element->getElement('sb_time_start'); ?> -element->getElement('sb_date_end'); ?> -element->getElement('sb_time_end'); ?> +
+ element->getElement('sb_date_start'); ?> + element->getElement('sb_time_start'); ?> + element->getElement('sb_date_end'); ?> + element->getElement('sb_time_end'); ?> + + + - - - + element->getElement('sb_show_filter') ?> + + element->getElement('sb_my_shows')):?> + + element->getElement('sb_my_shows'); ?> + +
diff --git a/airtime_mvc/application/views/scripts/show-builder/index.phtml b/airtime_mvc/application/views/scripts/show-builder/index.phtml index 3b69bf1af..1060ad562 100644 --- a/airtime_mvc/application/views/scripts/show-builder/index.phtml +++ b/airtime_mvc/application/views/scripts/show-builder/index.phtml @@ -10,11 +10,14 @@ .wrapper { position: absolute; background: #242424; - top: 138px; left: 0; right: 0; - /*padding: 0;*/ - padding: 2em; + padding: 0 12em; + height: calc(100% - 141px); /* Height of top panel + border */ + } + + .usability_hint { + margin-top: 1em; }
quotaLimitReached) { ?> class="hidden" > diff --git a/airtime_mvc/application/views/scripts/webstream/webstream.phtml b/airtime_mvc/application/views/scripts/webstream/webstream.phtml index 45790bb3b..698c955a5 100644 --- a/airtime_mvc/application/views/scripts/webstream/webstream.phtml +++ b/airtime_mvc/application/views/scripts/webstream/webstream.phtml @@ -21,7 +21,7 @@ -obj)) : ?> +obj)) : ?>\ obj->getLastModified('U'); ?>"/> diff --git a/airtime_mvc/public/css/showbuilder-test.css b/airtime_mvc/public/css/_showbuilder.css similarity index 75% rename from airtime_mvc/public/css/showbuilder-test.css rename to airtime_mvc/public/css/_showbuilder.css index b896f471c..4e5c883f5 100644 --- a/airtime_mvc/public/css/showbuilder-test.css +++ b/airtime_mvc/public/css/_showbuilder.css @@ -1,7 +1,8 @@ /* Show Builder*/ -@media screen and (max-width: 1175px) { +@media screen and (max-width: 1475px) { .lib-test, .sb-test, .media-builder-test, #media_type_nav { + height: auto !important; width: 100% !important; } .media-builder-test { @@ -28,6 +29,20 @@ width: calc(100% - 1em) !important; margin: 0 .5em .5em 0; } + .wrapper { + padding: 1em !important; + } +} + +@media screen and (max-width: 555px) { + #sb_show_filter { + float: none !important; + margin-top: 4px; + } +} + +.btn { + color: #efefef; } .lib-test .dataTables_filter { @@ -36,7 +51,7 @@ .lib-test .dataTables_filter input[type="text"], .lib-test .dataTables_filter select { margin-top: .5em; - width: 30%; + width: 20%; float: right; height: 26px; } @@ -63,26 +78,56 @@ overflow: hidden !important; } +.lib-test .dataTables_scrolling { + /* Subtract Advanced search (32) + header (38) + footer (38) */ + height: calc(100% - 108px); +} + +#library_display_wrapper, #show_builder_table_wrapper { + background-color: #474747; +} + .lib-test, .sb-test, .media-builder-test { + height: 70%; /* 1em for the middle margin, 6 for half the width of the left pane */ width: calc(50% - 8em); min-width: 470px; } +#library_display_wrapper, #show_builder_table_wrapper { + height: 100%; +} + /* Timeline */ .sb-test { - margin-top: 1.5em; + margin-top: 2em; } #sb_submit { text-decoration: none; padding: .35em; color: #efefef; + float: none; } -.sb-timerange { - margin-bottom: 5px; +.sb-options-form { + width: 100%; + float: left; + padding-bottom: 5px; +} + +.sb-options-form label { + color: #efefef; + line-height: 26px; +} + +#sb_show_filter { + float: right; +} + +#show_builder_table_wrapper { + clear: both; } /* Media builder */ @@ -102,7 +147,7 @@ #media_type_nav { float: left; - margin: 2em 0 0 0; + margin: 5.2em 0 0 0; width: 12em; @@ -159,4 +204,6 @@ font-size: 20px; font-weight: 300; line-height: 1.4rem; + + margin-top: 1em; } diff --git a/airtime_mvc/public/css/media_library.css b/airtime_mvc/public/css/media_library.css index 7f980b328..99f18a737 100644 --- a/airtime_mvc/public/css/media_library.css +++ b/airtime_mvc/public/css/media_library.css @@ -166,7 +166,7 @@ td.library_bitrate { } .lib-content fieldset.closed { border-width: 1px 0 0; - margin-bottom: -6px; + margin-bottom: 0; margin-left: 1px; } .dataTables_filter input[type="text"], .dataTables_filter select { diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index 47f27e6bf..b51c8b049 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -550,7 +550,7 @@ input[type="text"]:focus, input[type="password"]:focus, textarea:focus, .input_t border: 1px solid #5b5b5b; font-family: Arial,Helvetica,sans-serif; font-size: 12px; - height: 25px; + height: 26px; margin: 0; padding: 2px 2px 2px 0; vertical-align: top; diff --git a/airtime_mvc/public/js/airtime/library/library-test.js b/airtime_mvc/public/js/airtime/library/_library.js similarity index 75% rename from airtime_mvc/public/js/airtime/library/library-test.js rename to airtime_mvc/public/js/airtime/library/_library.js index 3454aeaf0..016699084 100644 --- a/airtime_mvc/public/js/airtime/library/library-test.js +++ b/airtime_mvc/public/js/airtime/library/_library.js @@ -51,12 +51,12 @@ 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, @@ -69,14 +69,14 @@ var AIRTIME = (function(AIRTIME) { 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, @@ -85,7 +85,7 @@ 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("tr"); $trs.each(function(i){ @@ -93,13 +93,13 @@ var AIRTIME = (function(AIRTIME) { 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++; } @@ -107,22 +107,22 @@ var AIRTIME = (function(AIRTIME) { visibleChosenItems = {}; return count; }; - + mod.changeAddButtonText = function($button, btnText) { $button.text(btnText); }; - - mod.createToolbarButtons = function() { + + mod.createToolbarButtons = function () { $menu = $("
"); $menu .append("") .append("
" + @@ -147,7 +147,7 @@ var AIRTIME = (function(AIRTIME) { "" + "
"); }; - + mod.createToolbarDropDown = function() { $('#sb-select-page').click(function(){mod.selectCurrentPage();}); $('#sb-dselect-page').click(function(){mod.deselectCurrentPage();}); @@ -208,15 +208,15 @@ var AIRTIME = (function(AIRTIME) { 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){ @@ -224,9 +224,9 @@ var AIRTIME = (function(AIRTIME) { if (cItem === $(this).attr("id")) { visibleChosenItems[cItem] = $(this).data('aData'); } - } + } }); - + for (id in visibleChosenItems) { if (visibleChosenItems.hasOwnProperty(id)) { data.push(visibleChosenItems[id]); @@ -235,64 +235,64 @@ 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.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.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) @@ -311,9 +311,9 @@ var AIRTIME = (function(AIRTIME) { }); mod.checkToolBarIcons(); - + }; - + /* * deselects all items that the user can currently see. (behaviour taken * from gmail) @@ -321,32 +321,33 @@ var AIRTIME = (function(AIRTIME) { mod.deselectCurrentPage = function() { var $trs = $libTable.find("tr"), id; $trs.removeClass(LIB_SELECTED_CLASS); - + $trs.each(function(i, el){ $el = $(this); id = $el.attr("id"); delete chosenItems[id]; }); - - mod.checkToolBarIcons(); + + mod.checkToolBarIcons(); }; - + mod.selectNone = function() { var $trs = $libTable.find("tr"); $trs.removeClass(LIB_SELECTED_CLASS); - + $previouslySelected = undefined; + chosenItems = {}; - + mod.checkToolBarIcons(); }; - + 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); - $.post(baseUrl+"library/delete", - {"format": "json", "media": aMedia}, + $.post(baseUrl+"library/delete", + {"format": "json", "media": aMedia}, function(json){ if (json.message !== undefined) { alert(json.message); @@ -359,7 +360,7 @@ 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(), @@ -376,7 +377,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; } } @@ -396,37 +397,37 @@ var AIRTIME = (function(AIRTIME) { } } }; - + 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 ; } @@ -437,28 +438,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( "
" + - "" + - "
" + + "" + + "
" + "
"); } else { advanceSearchDiv.append( ""); } - + if (libraryColumnTypes[ele.mDataProp] == "s") { var obj = { sSelector: "#"+ele.mDataProp } } else { @@ -469,80 +470,80 @@ 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(); - + tableHeight = getTableHeight(), + searchHeight = $fs.height(); + $libContent.find(".dataTables_scrolling").css("max-height", tableHeight - searchHeight); } - + 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 } , - /* Type */ { "sTitle" : "" , "mDataProp" : "image" , "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" : "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" , "bVisible" : false , "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 } , + /* Type */ { "sTitle" : "" , "mDataProp" : "image" , "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" : "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" , "bVisible" : false , "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" } + ], + "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. @@ -552,19 +553,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) { @@ -575,17 +576,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 = oData.ColReorder; if (a) { for (i = 0, length = a.length; i < length; i++) { @@ -594,16 +595,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 @@ -623,6 +624,8 @@ var AIRTIME = (function(AIRTIME) { type = (type === undefined) ? 1 : type; aoData.push( { name: "type", value: type} ); + getUsabilityHint(); + $.ajax( { "dataType": 'json', "type": "POST", @@ -673,36 +676,38 @@ var AIRTIME = (function(AIRTIME) { return false; }); }, - // 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": datatables_dict, - + // R = ColReorder, C = ColVis "sDom": 'R<"#library_display_type"><"dt-process-rel"r><"H"<"library_toolbar"Cf>><"dataTables_scrolling"t><"F"ilp>>', - + "oColVis": { "sAlign": "right", "aiExclude": [0, 1, 2], "sSize": "css", "fnStateChange": setFilterElement, - "buttonText": $.i18n._("Show / hide columns") + "buttonText": $.i18n._("Columns") }, - + "oColReorder": { "iFixedColumns": 3 - } - + }, + + "bScrollCollapse": false + }); setColumnFilter(oTable); @@ -713,9 +718,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"); @@ -728,7 +733,7 @@ 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); @@ -747,21 +752,21 @@ 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 + + //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); $libTable.find("tbody").on("dblclick", "tr", function(ev) { @@ -770,7 +775,7 @@ var AIRTIME = (function(AIRTIME) { AIRTIME.library.dblClickAdd(data, data.ftype); }); - $libTable.find("tbody").on("click", "tr", function(ev) { + $libTable.find("tbody").on("mousedown", "tr", function(ev) { var $tr = $(this), // Get the ID of the selected row $rowId = $tr.attr("id"); @@ -793,28 +798,40 @@ var AIRTIME = (function(AIRTIME) { } mod.selectItem($tr); - } else if (ev.ctrlKey && $previouslySelected !== undefined) { + } else if (ev.ctrlKey) { mod.selectItem($tr); } else { - $("."+LIB_SELECTED_CLASS).each(function(i, el) { - mod.deselectItem($(el)) - }); + if (!$tr.hasClass(LIB_SELECTED_CLASS)) { + $("." + LIB_SELECTED_CLASS).each(function (i, el) { + mod.deselectItem($(el)) + }); + } mod.selectItem($tr); } // Remember this row so we can properly multiselect $previouslySelected = $tr; }); + + $libTable.find("tbody").on("click", "tr", function(ev) { + if (!ev.ctrlKey && !ev.shiftKey) { + $("." + LIB_SELECTED_CLASS).each(function (i, el) { + mod.deselectItem($(el)) + }); + mod.selectItem($(this)); + } + }); }; + mod.libraryInit = libraryInit; - + return AIRTIME; - + }(AIRTIME || {})); function buildEditMetadataDialog (json){ var dialog = $(json.dialog); - + dialog.dialog({ autoOpen: false, title: $.i18n._("Edit Metadata"), @@ -854,12 +871,12 @@ function validateAdvancedSearch(divs) { 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") { @@ -877,29 +894,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] === ""){ + 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').hasClass('not-available-icon')) { $(field).closest('div').children(':last-child').remove(); } } - + if (!valid) { return false; } @@ -920,10 +937,10 @@ 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')) { // remove invalid icon before adding valid icon @@ -997,7 +1014,7 @@ $(document).ready(function() { } }); }); - + $('#editmdcancel').live("click", function() { $("#edit-md-dialog").dialog().remove(); }); diff --git a/airtime_mvc/public/js/airtime/library/spl-test.js b/airtime_mvc/public/js/airtime/library/_spl.js similarity index 92% rename from airtime_mvc/public/js/airtime/library/spl-test.js rename to airtime_mvc/public/js/airtime/library/_spl.js index 3e5a91876..6b1c29df1 100644 --- a/airtime_mvc/public/js/airtime/library/spl-test.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, @@ -16,30 +16,30 @@ var AIRTIME = (function(AIRTIME){ widgetHeight, resizeTimeout, width; - + 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); } - + function stopAudioPreview() { // stop any preview playing $('#jquery_jplayer_1').jPlayer('stop'); } - + function highlightActive(el) { $(el).addClass("ui-state-active"); @@ -73,13 +73,13 @@ var AIRTIME = (function(AIRTIME){ unqid = li.attr("unqid"), lastMod = getModified(), type = $('#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){ @@ -115,9 +115,9 @@ var AIRTIME = (function(AIRTIME){ 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){ @@ -137,16 +137,16 @@ var AIRTIME = (function(AIRTIME){ highlightActive(li.find('.spl_cue')); }); } - + /* used from waveform pop-up */ function changeCues($el, id, cueIn, cueOut) { - + var url = baseUrl+"Playlist/set-cue", lastMod = getModified(), type = $('#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 +154,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 +162,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,27 +175,27 @@ var AIRTIME = (function(AIRTIME){ return; } if (json.cue_error !== undefined) { - + li = $('#side_playlist 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; } @@ -207,18 +207,18 @@ var AIRTIME = (function(AIRTIME){ 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", lastMod = getModified(), type = $('#obj_type').val(); - - $.post(url, - {format: "json", fadeIn: fadeIn, fadeOut: fadeOut, id1: id1, id2: id2, offset: offset, modified: lastMod, type: type}, + + $.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,7 +226,7 @@ var AIRTIME = (function(AIRTIME){ playlistError(json); return; } - + setPlaylistContent(json); $li = $('#side_playlist li[unqid='+id+']'); @@ -252,8 +252,8 @@ var AIRTIME = (function(AIRTIME){ 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){ @@ -290,10 +290,10 @@ var AIRTIME = (function(AIRTIME){ 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,9 +302,9 @@ var AIRTIME = (function(AIRTIME){ showError(span, json.fade_error); return; } - + setPlaylistContent(json); - + li = $('#side_playlist li[unqid='+unqid+']'); li.find('.crossfade').toggle(); highlightActive(li.find('.spl_fade_control')); @@ -321,8 +321,8 @@ var AIRTIME = (function(AIRTIME){ function openFadeEditor(event) { var li; - - event.stopPropagation(); + + event.stopPropagation(); li = $(this).parents("li"); li.find(".crossfade").toggle(); @@ -337,11 +337,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,23 +353,23 @@ var AIRTIME = (function(AIRTIME){ 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", "")); } - + 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); @@ -379,7 +379,7 @@ var AIRTIME = (function(AIRTIME){ $('#fieldset-metadate_change textarea') .empty() .val(json.description); - + $('#spl_sortable').off('focusout keydown'); $('#spl_sortable') .empty() @@ -390,18 +390,18 @@ var AIRTIME = (function(AIRTIME){ AIRTIME.playlist.validatePlaylistElements(); redrawLib(); } - + function setFadeIcon(){ var contents = $("#spl_sortable"); var show = contents.is(":visible"); var empty = $(".spl_empty"); - + if (!show || empty.length > 0) { $("#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(); @@ -413,35 +413,35 @@ var AIRTIME = (function(AIRTIME){ } } } - + function getId() { return parseInt($("#obj_id").val(), 10); } - + function getModified() { return parseInt($("#obj_lastMod").val(), 10); } - + function setModified(modified) { $("#obj_lastMod").val(modified); } - + function openPlaylist(json) { $("#side_playlist") .empty() .append(json.html); - + setUpPlaylist(); setCueEvents(); setFadeEvents(); - + // functions in smart_blockbuilder.js setupUI(); appendAddButton(); appendModAddButton(); removeButtonCheck(); } - + function openPlaylistPanel() { viewport = AIRTIME.utilities.findViewportDimensions(); var screenWidth = Math.floor(viewport.width - 40); @@ -465,7 +465,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', @@ -484,12 +484,12 @@ var AIRTIME = (function(AIRTIME){ 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', @@ -515,23 +515,23 @@ var AIRTIME = (function(AIRTIME){ } }); } - + //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); @@ -555,7 +555,7 @@ var AIRTIME = (function(AIRTIME){ $html += "
  • " + ""+ele.track_title+" - " + ""+ele.creator+"" + - ""+ele.length+"" + + ""+ele.length+"" + "
  • "; } }) @@ -567,7 +567,7 @@ var AIRTIME = (function(AIRTIME){ ""+ele['display_name']+"" + ""+ele['display_modifier']+"" + ""+ele['value']+"" + - ""+extra+"" + + ""+extra+"" + ""; }); } @@ -583,16 +583,16 @@ var AIRTIME = (function(AIRTIME){ } }}); } - + //sets events dynamically for the cue editor. function setCueEvents() { var temp = $('#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') @@ -600,16 +600,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'); 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') @@ -617,10 +617,10 @@ 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(), @@ -634,7 +634,7 @@ var AIRTIME = (function(AIRTIME){ $(this).addClass("ui-state-active"); var url = baseUrl+'Playlist/get-playlist-fades'; - $.post(url, + $.post(url, {format: "json", modified: lastMod, type: type}, function(json){ if (json.error !== undefined){ @@ -666,24 +666,24 @@ var AIRTIME = (function(AIRTIME){ }); } }); - + $pl.on("blur", "span.spl_main_fade_in", function(event){ event.stopPropagation(); var url = baseUrl+"Playlist/set-playlist-fades", span = $(this), - fadeIn = $.trim(span.text()), + fadeIn = $.trim(span.text()), lastMod = getModified(), type = $('#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); @@ -696,7 +696,7 @@ var AIRTIME = (function(AIRTIME){ var url = baseUrl+"Playlist/set-playlist-fades", span = $(this), - fadeOut = $.trim(span.text()), + fadeOut = $.trim(span.text()), lastMod = getModified(), type = $('#obj_type').val(); @@ -705,8 +705,8 @@ var AIRTIME = (function(AIRTIME){ 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) { @@ -726,7 +726,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"); @@ -739,7 +739,7 @@ var AIRTIME = (function(AIRTIME){ $fs.addClass("closed"); } }); - + $pl.on("click", 'button[id="playlist_shuffle_button"]', function(){ obj_id = $('input[id="obj_id"]').val(); @@ -764,25 +764,25 @@ var AIRTIME = (function(AIRTIME){ //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(); - + 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}, + $.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(); @@ -807,10 +807,10 @@ var AIRTIME = (function(AIRTIME){ //redraw the library to show the new webstream redrawLib(); } - - }); - - + + }); + + }); $lib.on("click", "#pl_edit", function() { @@ -836,6 +836,14 @@ var AIRTIME = (function(AIRTIME){ // We also need to run the draw callback to update how dragged items are drawn AIRTIME.library.fnDrawCallback(); + var name = $('#playlist_name_display').text().trim(); + + if ((name == "Untitled Playlist" + || name == "Untitled Smart Block") + && $("#spl_sortable .spl_empty").length == 1) { + mod.fnDelete(); + } + $.ajax( { url : baseUrl+"usersettings/set-library-screen-settings", type : "POST", @@ -892,43 +900,43 @@ var AIRTIME = (function(AIRTIME){ 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; @@ -938,17 +946,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. @@ -957,14 +965,14 @@ 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) { @@ -984,37 +992,37 @@ var AIRTIME = (function(AIRTIME){ $pl.find("#spl_sortable").sortable(sortableConf); AIRTIME.playlist.validatePlaylistElements(); } - + mod.fnNew = function() { var url = baseUrl+'Playlist/new'; $("#side_playlist").show(); $("#show_builder").hide(); 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'; $("#side_playlist").show(); $("#show_builder").hide(); stopAudioPreview(); - - $.post(url, - {format: "json"}, + + $.post(url, + {format: "json"}, function(json){ openPlaylist(json); redrawLib(); }); }; - + mod.fnNewBlock = function() { var url = baseUrl+'Playlist/new'; @@ -1022,15 +1030,15 @@ var AIRTIME = (function(AIRTIME){ $("#show_builder").hide(); stopAudioPreview(); - - $.post(url, - {format: "json", type: 'block'}, + + $.post(url, + {format: "json", type: 'block'}, function(json){ openPlaylist(json); redrawLib(); }); }; - + mod.fnEdit = function(id, type, url) { $("#side_playlist").show(); $("#show_builder").hide(); @@ -1038,82 +1046,82 @@ var AIRTIME = (function(AIRTIME){ if ($pl.is(":hidden")) { openPlaylistPanel(); } - stopAudioPreview(); - - $.post(url, - {format: "json", id: id, type: type}, + stopAudioPreview(); + + $.post(url, + {format: "json", id: id, type: type}, function(json){ openPlaylist(json); }); }; - + mod.fnDelete = function(plid) { var url, id, lastMod; - - stopAudioPreview(); + + stopAudioPreview(); id = (plid === undefined) ? getId() : plid; lastMod = getModified(); type = $('#obj_type').val(); url = baseUrl+'Playlist/delete'; - $.post(url, - {format: "json", ids: id, modified: lastMod, type: type}, + $.post(url, + {format: "json", ids: id, modified: lastMod, type: type}, function(json){ openPlaylist(json); 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}, + + $.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); } @@ -1121,49 +1129,49 @@ var AIRTIME = (function(AIRTIME){ setPlaylistContent(json); setFadeIcon(); } - + mod.enableUI(); } - + function playlistRequest(sUrl, oData) { var lastMod, obj_type = $('#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) { 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"), @@ -1176,17 +1184,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"), @@ -1202,12 +1210,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"), @@ -1224,13 +1232,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"), @@ -1242,21 +1250,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. @@ -1267,24 +1275,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", @@ -1295,7 +1303,7 @@ var AIRTIME = (function(AIRTIME){ UITheme: "jQueryUI", timeFormat: 'hh:mm:ss.u' }); - + playlistEditor = new PlaylistEditor(); playlistEditor.setConfig(config); playlistEditor.init(tracks); @@ -1304,12 +1312,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"), @@ -1327,29 +1335,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"), @@ -1362,14 +1370,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, @@ -1379,18 +1387,18 @@ 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() { $('#new-playlist').live('click', function(){AIRTIME.playlist.fnNew();}); $('#new-smart-block').live('click', function(){AIRTIME.playlist.fnNewBlock();}); @@ -1399,24 +1407,24 @@ var AIRTIME = (function(AIRTIME){ $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(); }; @@ -1449,12 +1457,12 @@ var AIRTIME = (function(AIRTIME){ hide: 'mouseout' }); }; - + mod.onResize = function() { }; - + return AIRTIME; - + }(AIRTIME || {})); diff --git a/airtime_mvc/public/js/airtime/library/events/library_showbuilder_test.js b/airtime_mvc/public/js/airtime/library/events/_library_showbuilder.js similarity index 99% rename from airtime_mvc/public/js/airtime/library/events/library_showbuilder_test.js rename to airtime_mvc/public/js/airtime/library/events/_library_showbuilder.js index 6fa450632..49bf64f27 100644 --- a/airtime_mvc/public/js/airtime/library/events/library_showbuilder_test.js +++ b/airtime_mvc/public/js/airtime/library/events/_library_showbuilder.js @@ -228,7 +228,7 @@ var AIRTIME = (function(AIRTIME) { $toolbar.append($menu); // add to timeline button $toolbar - .find('.icon-plus').parent() + .find('#library-plus') .click( function() { @@ -286,7 +286,6 @@ var AIRTIME = (function(AIRTIME) { } var selection = $(".media_type_selector.selected").attr("selection_id"); - console.log(selection); if (selection == 2) { AIRTIME.playlist.fnNew(); diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder_test.js b/airtime_mvc/public/js/airtime/showbuilder/_builder.js similarity index 78% rename from airtime_mvc/public/js/airtime/showbuilder/builder_test.js rename to airtime_mvc/public/js/airtime/showbuilder/_builder.js index efdf76127..8a53fb9d5 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder_test.js +++ b/airtime_mvc/public/js/airtime/showbuilder/_builder.js @@ -14,29 +14,29 @@ var AIRTIME = (function(AIRTIME){ headerFooter = [], DISABLED_CLASS = 'ui-state-disabled', $previouslySelected; - + 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; }; @@ -71,9 +71,9 @@ var AIRTIME = (function(AIRTIME){ .append(''); } }; - + mod.getTimestamp = function() { - + if (mod.timestamp !== undefined) { return mod.timestamp; } @@ -81,50 +81,50 @@ 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.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); } @@ -132,7 +132,7 @@ var AIRTIME = (function(AIRTIME){ AIRTIME.button.disableButton("icon-cut", true); } }; - + mod.checkDeleteButton = function() { var $selected = $sbTable.find("tr."+SB_SELECTED_CLASS); @@ -145,10 +145,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,56 +156,56 @@ 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) */ @@ -226,45 +226,46 @@ var AIRTIME = (function(AIRTIME){ return aData.reverse(); }; - + mod.selectAll = function () { var $trs = $sbTable.find("tr.lib-audio").not(".sb-past, .sb-empty"); $trs.addClass(SB_SELECTED_CLASS); - + mod.checkToolBarIcons(); }; - + mod.selectNone = function () { var $trs = $sbTable.find("tr.lib-audio"); $trs.removeClass(SB_SELECTED_CLASS); - + $previouslySelected = 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); @@ -274,35 +275,37 @@ var AIRTIME = (function(AIRTIME){ 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) { mod.disableUI(); @@ -311,30 +314,30 @@ var AIRTIME = (function(AIRTIME){ 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 - ); + $.post( baseUrl+"showbuilder/schedule-remove", + {"items": aItems, "format": "json"}, + mod.fnItemCallback + ); }else{ - mod.enableUI(); + mod.enableUI(); } }; - + mod.fnRemoveSelectedItems = function() { var aData = mod.getSelectedData(), i, @@ -344,18 +347,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} ); } @@ -367,7 +370,7 @@ 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", @@ -382,7 +385,7 @@ var AIRTIME = (function(AIRTIME){ } }); }; - + mod.jumpToCurrentTrack = function() { var $scroll = $sbContent.find(".dataTables_scrolling"); var scrolled = $scroll.scrollTop(); @@ -407,20 +410,20 @@ var AIRTIME = (function(AIRTIME){ oSchedTable = $sbTable.dataTable( { "aoColumns": [ - /* 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"} + /* 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, @@ -429,7 +432,7 @@ var AIRTIME = (function(AIRTIME){ "bInfo": false, "bAutoWidth": false, "bDeferRender": true, - + "bStateSave": true, "fnStateSaveParams": function (oSettings, oData) { //remove oData components we don't want to save. @@ -441,19 +444,19 @@ var AIRTIME = (function(AIRTIME){ }, "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++) { + for (i = 0, length = a.length; i < length; i++) { if (typeof(a[i]) === "string") { a[i] = (a[i] === "true") ? true : false; } @@ -461,7 +464,7 @@ var AIRTIME = (function(AIRTIME){ oData.iCreate = parseInt(oData.iCreate, 10); }, - + "fnServerData": mod.fnServerData, "fnRowCallback": function fnRowCallback( nRow, aData, iDisplayIndex, iDisplayIndexFull ) { var i, length, @@ -469,7 +472,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, @@ -489,19 +492,19 @@ var AIRTIME = (function(AIRTIME){ $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 @@ -514,15 +517,15 @@ var AIRTIME = (function(AIRTIME){ }); $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+''; @@ -531,7 +534,7 @@ var AIRTIME = (function(AIRTIME){ sSeparatorHTML += ''+aData.startDate+''+aData.startTime+''; sSeparatorHTML +='-'+aData.endDate+''+aData.endTime+''; } - + sSeparatorHTML += ''; fnPrepareSeparatorRow(sSeparatorHTML, cl, 1); @@ -539,10 +542,10 @@ var AIRTIME = (function(AIRTIME){ 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(''); @@ -552,38 +555,38 @@ var AIRTIME = (function(AIRTIME){ $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._("Show Empty")+''; 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. + + //add the play function if the file exists on disk. $image = $nRow.find('td.sb-image'); $image.empty(); //check if the file exists. @@ -615,10 +618,10 @@ var AIRTIME = (function(AIRTIME){ }); } } - + //add the show colour to the leftmost td if (aData.footer !== true) { - + if ($nRow.hasClass('sb-header')) { a = 1; } @@ -628,15 +631,15 @@ var AIRTIME = (function(AIRTIME){ 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}); @@ -649,7 +652,7 @@ var AIRTIME = (function(AIRTIME){ else { $nRow.addClass("sb-future"); } - + if (aData.allowed !== true || aData.linked_allowed === false) { $nRow.addClass("sb-not-allowed"); } @@ -658,7 +661,7 @@ var AIRTIME = (function(AIRTIME){ $nRow.attr("id", aData.id); $nRow.attr("si_id", aData.instance); } - + //status used to colour tracks. if (aData.status === 2) { $nRow.addClass("sb-boundry"); @@ -666,14 +669,14 @@ var AIRTIME = (function(AIRTIME){ 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(); }, @@ -699,47 +702,49 @@ var AIRTIME = (function(AIRTIME){ $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 + // 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(); }, - + // R = ColReorder, C = ColVis "sDom": 'R<"dt-process-rel"r><"sb-padded"<"H"C>><"dataTables_scrolling sb-padded"t>', - + "oColVis": { "aiExclude": [ 0, 1 ], - "buttonText": $.i18n._("Show / hide columns"), + "buttonText": $.i18n._("Columns") }, - + "oColReorder": { "iFixedColumns": 2 }, - + "sAjaxDataProp": "schedule", "oLanguage": datatables_dict, - "sAjaxSource": baseUrl+"showbuilder/builder-feed" + "sAjaxSource": baseUrl+"showbuilder/builder-feed" , + + "bScrollCollapseY": false }); - - $sbTable.find("tbody").on("click", "tr:not(.sb-past, .sb-empty)", function(ev) { + + $sbTable.find("tbody").on("mousedown", "tr:not(.sb-past, .sb-empty)", function(ev) { var $tr = $(this), // Get the ID of the selected row @@ -765,7 +770,9 @@ var AIRTIME = (function(AIRTIME){ } else if (ev.ctrlKey && $previouslySelected !== undefined) { $tr.addClass(SB_SELECTED_CLASS); } else { - $("."+SB_SELECTED_CLASS).removeClass(SB_SELECTED_CLASS); + if (!$tr.hasClass(SB_SELECTED_CLASS)) { + $("."+SB_SELECTED_CLASS).removeClass(SB_SELECTED_CLASS); + } $tr.addClass(SB_SELECTED_CLASS); } @@ -774,7 +781,14 @@ var AIRTIME = (function(AIRTIME){ mod.checkToolBarIcons(); }); - + + $sbTable.find("tbody").on("click", "tr:not(.sb-past, .sb-empty)", function(ev) { + if (!ev.ctrlKey && !ev.shiftKey) { + $("."+SB_SELECTED_CLASS).removeClass(SB_SELECTED_CLASS); + $(this).addClass(SB_SELECTED_CLASS); + } + }); + var sortableConf = (function(){ var origTrs, aItemData = [], @@ -783,142 +797,141 @@ var AIRTIME = (function(AIRTIME){ fnMove, fnReceive, fnUpdate, - i, + 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) { + || 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")]; - } + 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 (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(); + //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; - }, + 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, @@ -933,69 +946,69 @@ var AIRTIME = (function(AIRTIME){ } }; }()); - + $sbTable.sortable(sortableConf); - + //start setup of the builder toolbar. $toolbar = $(".sb-content .fg-toolbar"); $menu = $("
    "); $menu.append("
    " + - "" + - "" + - "
    ") + "" + + "" + + "
    ") .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("
    " + - "
    "); + "") + .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({ @@ -1008,48 +1021,48 @@ var AIRTIME = (function(AIRTIME){ } }); } - } + } }); - + //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); - */ + 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}); + aItems.push({"id": temp.id, "instance": temp.instance, "timestamp": temp.timestamp}); }); - + mod.fnRemove(aItems); }); - + //delete selected tracks $toolbar.find('.icon-trash').parent() .click(function() { @@ -1059,30 +1072,30 @@ var AIRTIME = (function(AIRTIME){ 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 @@ -1090,16 +1103,16 @@ var AIRTIME = (function(AIRTIME){ */ $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_test.js b/airtime_mvc/public/js/airtime/showbuilder/_main_builder.js similarity index 100% rename from airtime_mvc/public/js/airtime/showbuilder/main_builder_test.js rename to airtime_mvc/public/js/airtime/showbuilder/_main_builder.js