From 4cbc49391b52d0d639ca8f5770f53cae36fc5ca2 Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Wed, 5 Aug 2015 18:14:56 -0400 Subject: [PATCH] Reintroduce checkboxes --- .../views/scripts/show-builder/index.phtml | 2 +- airtime_mvc/public/css/_showbuilder.css | 21 ++++++++-- .../public/js/airtime/library/_library.js | 41 +++++++++++++++++-- airtime_mvc/public/js/airtime/library/_spl.js | 4 ++ .../public/js/airtime/showbuilder/_builder.js | 1 + 5 files changed, 61 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/views/scripts/show-builder/index.phtml b/airtime_mvc/application/views/scripts/show-builder/index.phtml index 331d40d09..a50a7c2d7 100644 --- a/airtime_mvc/application/views/scripts/show-builder/index.phtml +++ b/airtime_mvc/application/views/scripts/show-builder/index.phtml @@ -51,7 +51,7 @@
diff --git a/airtime_mvc/public/css/_showbuilder.css b/airtime_mvc/public/css/_showbuilder.css index fb9de6d33..be5e5dfae 100644 --- a/airtime_mvc/public/css/_showbuilder.css +++ b/airtime_mvc/public/css/_showbuilder.css @@ -233,6 +233,19 @@ div.ColVis_collectionBackground { border: none; } +/* Library Context Menu */ + +.context-menu-item.icon { + min-height: 26px; + padding: 0 5px; + background-position: 4px 5px; +} + +.context-menu-item > span { + padding: 0 20px; + line-height: 26px; +} + /* Library Search */ #filter_options { @@ -297,6 +310,8 @@ div.ColVis_collectionBackground { right: 4px; left: 4px; z-index: 1; /* Display above the content wrapper */ + + flex: 1 100%; } /* Timeline */ @@ -389,7 +404,7 @@ div.ColVis_collectionBackground { color: #efefef; } -#side_playlist .zend_form dt { +#edit-md-dialog .zend_form dt { float: left; width: 40%; @@ -400,7 +415,7 @@ div.ColVis_collectionBackground { padding-right: 4px; } -#side_playlist .zend_form dd { +#edit-md-dialog .zend_form dd { float: left; width: auto; @@ -411,7 +426,7 @@ div.ColVis_collectionBackground { /* Playlist/Block/Webstream Editors */ #side_playlist { - margin-top: 34px; + /*margin-top: 34px;*/ width: 100%; /* Override because we're using flexbox */ overflow-x: hidden; diff --git a/airtime_mvc/public/js/airtime/library/_library.js b/airtime_mvc/public/js/airtime/library/_library.js index 662d47e4b..fb0500fa8 100644 --- a/airtime_mvc/public/js/airtime/library/_library.js +++ b/airtime_mvc/public/js/airtime/library/_library.js @@ -507,8 +507,9 @@ var AIRTIME = (function(AIRTIME) { // https://wiki.sourcefabric.org/display/CC/Adding+a+new+library+datatable+column "aoColumns": [ /* ftype */ { "sTitle" : "" , "mDataProp" : "ftype" , "bSearchable" : false , "bVisible" : false } , + /* Checkbox */ { "sTitle" : "" , "mDataProp" : "checkbox" , "bSortable" : false , "bSearchable" : false , "sWidth" : "10px" , "sClass" : "library_checkbox" } , /* 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 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" } , @@ -636,6 +637,9 @@ var AIRTIME = (function(AIRTIME) { }, "fnRowCallback": AIRTIME.library.fnRowCallback, "fnCreatedRow": function( nRow, aData, iDataIndex ) { + // add checkbox + $(nRow).find('td.library_checkbox').html(""); + // add audio preview image/button if (aData.ftype === "audioclip") { $(nRow).find('td.library_type').html(''); @@ -759,9 +763,37 @@ var AIRTIME = (function(AIRTIME) { AIRTIME.library.setupLibraryToolbar(oTable); + $libTable.find("tbody").on("click", ".library_checkbox", function(ev) { + var $cb = $(this), + $tr = $cb.parents("tr"), + // Get the ID of the selected row + $rowId = $tr.attr("id"); + + if (!$tr.hasClass(LIB_SELECTED_CLASS)) { + if (ev.shiftKey && $previouslySelected !== undefined) { + // If the selected row comes before the previously selected row, + // we want to select previous rows, otherwise we select next + if ($previouslySelected.prevAll("#"+$rowId).length !== 0) { + $previouslySelected.prevUntil($tr).each(function(i, el) { + mod.selectItem($(el)); + }); + } else { + $previouslySelected.nextUntil($tr).each(function(i, el) { + mod.selectItem($(el)); + }); + } + } + + mod.selectItem($tr); + // Remember this row so we can properly multiselect + $previouslySelected = $tr; + } else { + mod.deselectItem($tr); + } + }); + $libTable.find("tbody").on("dblclick", "tr", function(ev) { - var $tr = $(this), - data = $tr.data("aData"); + var data = $(this).data("aData"); AIRTIME.library.dblClickAdd(data, data.ftype); }); @@ -811,6 +843,7 @@ var AIRTIME = (function(AIRTIME) { mod.selectItem($(this)); } }); + // begin context menu initialization. $.contextMenu({ selector: '#library_display tr', @@ -1219,7 +1252,7 @@ $(document).ready(function() { $(".media_type_selector").on("click", function() { if (!$(this).hasClass("selected")) { - // TODO: deselect any highlighted items when we switch filtering + AIRTIME.library.selectNone(); $(".media_type_selector").each(function () { $(this).removeClass("selected"); }); diff --git a/airtime_mvc/public/js/airtime/library/_spl.js b/airtime_mvc/public/js/airtime/library/_spl.js index 72e335cd3..37c01af2f 100644 --- a/airtime_mvc/public/js/airtime/library/_spl.js +++ b/airtime_mvc/public/js/airtime/library/_spl.js @@ -469,6 +469,7 @@ var AIRTIME = (function(AIRTIME){ function openPlaylist(json) { $tabCount++; + console.log(json); var tabId = $openTabs[json.id]; if ($openTabs[json.id] !== undefined) { AIRTIME.showbuilder.switchTab($(".pl-tab-content-" + tabId), $("#pl-tab-" + tabId)); @@ -1526,6 +1527,9 @@ var AIRTIME = (function(AIRTIME){ }; mod.onResize = function() { + var h = $(".panel-header .nav").height(); + $(".pl-content").css("margin-top", h + 4); // 8px extra for padding + $("#show_builder_table_wrapper").css("top", h + 4); }; return AIRTIME; diff --git a/airtime_mvc/public/js/airtime/showbuilder/_builder.js b/airtime_mvc/public/js/airtime/showbuilder/_builder.js index 78e2a8d44..9c65bc767 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/_builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/_builder.js @@ -116,6 +116,7 @@ var AIRTIME = (function(AIRTIME){ if (tab.hasClass("pl-content")) { AIRTIME.playlist.setAsActive(); } + AIRTIME.playlist.onResize(); };