From c9f9bed2d6e1d33489b09107876c0091cd1485c9 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Mon, 10 Aug 2015 18:46:12 -0400 Subject: [PATCH] SAAS-948 - fix smartblock save and tab close functionality, implement 'super' checkbox --- .../controllers/NewPlaylistController.php | 6 +++-- airtime_mvc/public/css/_showbuilder.css | 15 ++++++++--- .../public/js/airtime/library/_library.js | 27 +++++++++++++++---- airtime_mvc/public/js/airtime/library/_spl.js | 21 ++++++++------- .../library/events/_library_showbuilder.js | 10 ++++--- .../public/js/airtime/showbuilder/_builder.js | 6 ++++- 6 files changed, 61 insertions(+), 24 deletions(-) diff --git a/airtime_mvc/application/controllers/NewPlaylistController.php b/airtime_mvc/application/controllers/NewPlaylistController.php index 01ec5dff5..217f21943 100644 --- a/airtime_mvc/application/controllers/NewPlaylistController.php +++ b/airtime_mvc/application/controllers/NewPlaylistController.php @@ -539,14 +539,16 @@ class NewPlaylistController extends Zend_Controller_Action $result['html'] = $this->createFullResponse($bl, true, true); $result['result'] = 0; } else { - $this->view->obj = $bl; - $this->view->id = $bl->getId(); $this->view->form = $form; $this->view->unsavedName = $params['name']; $this->view->unsavedDesc = $params['description']; $viewPath = 'playlist/_smart-block.phtml'; + $this->view->obj = $bl; + $this->view->id = $bl->getId(); $result['html'] = $this->view->render($viewPath); $result['result'] = 1; + $result['type'] = "sb"; + $result['id'] = $bl->getId(); } } else if ($params['type'] == 'playlist') { $this->setPlaylistNameDescAction(); diff --git a/airtime_mvc/public/css/_showbuilder.css b/airtime_mvc/public/css/_showbuilder.css index 1b3da7eef..a580b5152 100644 --- a/airtime_mvc/public/css/_showbuilder.css +++ b/airtime_mvc/public/css/_showbuilder.css @@ -549,8 +549,6 @@ textarea { flex: 1 auto; padding: 0; - /*margin-right: 10px;*/ - /*text-align: center;*/ background: #353535; border: 1px solid #242424; @@ -663,15 +661,19 @@ textarea { text-align: center; } +th.library_checkbox { + text-align: center !important; +} + .datatable tr td { /*, .datatable tr th {*/ line-height: 28px; font-size: 14px; padding: 5px; } -.datatable tr[class$='selected'] td, +.datatable tr[class*='selected'] td, .datatable tr.sb-now-playing td { - color: #efefef; + color: #000; } .datatable tr, .datatable td, @@ -687,6 +689,11 @@ textarea { position: fixed !important; } +.datatable .ui-state-highlight, .spl_sortable .ui-state-highlight { + background: rgba(255, 93, 26, .6); + border: none; +} + /* Uploads/Dropzone */ #upload_form { diff --git a/airtime_mvc/public/js/airtime/library/_library.js b/airtime_mvc/public/js/airtime/library/_library.js index f4d36bf83..877749cd1 100644 --- a/airtime_mvc/public/js/airtime/library/_library.js +++ b/airtime_mvc/public/js/airtime/library/_library.js @@ -287,10 +287,14 @@ var AIRTIME = (function(AIRTIME) { 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) { @@ -362,20 +366,23 @@ var AIRTIME = (function(AIRTIME) { 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(aMedia[i].id.toString()); + mediaIds.push(parseInt(aMedia[i].id)); } openTabObjectIds.each(function(i, el) { - var v = $(el).val(); + var v = parseInt($(el).val()); if ($.inArray(v, mediaIds) > -1) { - AIRTIME.playlist.fnOpenPlaylist({id: v}); - AIRTIME.playlist.closeTab(); + AIRTIME.playlist.closeTab($(el).closest(".pl-content").attr("tab-id")); } }); @@ -841,9 +848,19 @@ var AIRTIME = (function(AIRTIME) { } }); + $libTable.find("thead").on("click", "th > input[type='checkbox']", function(ev) { + if ($(this).is(":checked")) { + AIRTIME.library.selectCurrentPage(); + $(this).prop("checked", true); + } else { + AIRTIME.library.selectNone(); + $(this).prop("checked", false); + } + }); + // begin context menu initialization. $.contextMenu({ - selector: '#library_display tr', + selector: '#library_display tr:has(td)', trigger: "right", build: function($el, e) { diff --git a/airtime_mvc/public/js/airtime/library/_spl.js b/airtime_mvc/public/js/airtime/library/_spl.js index 3a56b8977..a9912145a 100644 --- a/airtime_mvc/public/js/airtime/library/_spl.js +++ b/airtime_mvc/public/js/airtime/library/_spl.js @@ -443,7 +443,7 @@ var AIRTIME = (function(AIRTIME){ } $tabCount++; - var wrapper = "
", + var wrapper = "
", t = $("#show_builder").append(wrapper).find("#pl-tab-content-" + $tabCount), pane = $(".editor_pane_wrapper:last"), name = json.type == "md" ? // file @@ -514,20 +514,21 @@ var AIRTIME = (function(AIRTIME){ $("#pl_edit").hide(); } - function closeTab() { - var pane = $(".active-tab"), - tab = $(".nav.nav-tabs .active"), + function closeTab(id) { + var pane = id ? $(".pl-content[tab-id='" + id + "']") : $(".active-tab"), + 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(); + objId = id ? id : pane.find(".obj_id").val(); delete $openTabs[tab.attr("tab-type") + objId]; + tab.remove(); $pl.remove(); AIRTIME.showbuilder.switchTab(toPane, toTab); } - mod.closeTab = function() { - closeTab(); + mod.closeTab = function(id) { + closeTab(id); }; //Purpose of this function is to iterate over all playlist elements @@ -967,6 +968,7 @@ var AIRTIME = (function(AIRTIME){ alert(json.error); } if (json.html !== undefined) { + console.log(json); closeTab(); openPlaylist(json); } @@ -1063,7 +1065,6 @@ var AIRTIME = (function(AIRTIME){ //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) { @@ -1071,10 +1072,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 }; 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 1be9df875..0be551dc3 100644 --- a/airtime_mvc/public/js/airtime/library/events/_library_showbuilder.js +++ b/airtime_mvc/public/js/airtime/library/events/_library_showbuilder.js @@ -70,6 +70,11 @@ var AIRTIME = (function(AIRTIME) { 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( @@ -116,9 +121,8 @@ var AIRTIME = (function(AIRTIME) { helper: function () { var $el = $(this), selected = mod - .getChosenAudioFilesLength(), container, message, li = $(".side_playlist.active-tab ul.spl_sortable li:first"), - width = li.width(), height = 55; - if (width > 798) width = 798; + .getChosenAudioFilesLength(), container, message, + width = $(this).width(), height = 55; // dragging an element that has an unselected // checkbox. diff --git a/airtime_mvc/public/js/airtime/showbuilder/_builder.js b/airtime_mvc/public/js/airtime/showbuilder/_builder.js index b0fc13645..11889c5a4 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/_builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/_builder.js @@ -119,6 +119,7 @@ var AIRTIME = (function(AIRTIME){ AIRTIME.playlist.setAsActive(); } AIRTIME.playlist.onResize(); + AIRTIME.library.fnRedraw(); }; @@ -822,6 +823,7 @@ var AIRTIME = (function(AIRTIME){ $(this).find(".sb-checkbox > input").prop('checked', true); } selectedRows = $("." + SB_SELECTED_CLASS); + mod.checkToolBarIcons(); }); //begin context menu initialization. @@ -1017,7 +1019,7 @@ var AIRTIME = (function(AIRTIME){ return { placeholder: "sb-placeholder ui-state-highlight", //forcePlaceholderSize: true, - distance: 10, + distance: 25, helper: function(event, item) { var selected = mod.getSelectedData(NOW_PLAYING_CLASS), @@ -1069,6 +1071,8 @@ var AIRTIME = (function(AIRTIME){ 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();