From b15160d0fbc133a33373456189d01a44fe9870df Mon Sep 17 00:00:00 2001 From: Duncan Sommerville Date: Fri, 21 Aug 2015 14:39:30 -0400 Subject: [PATCH] Fix more selection bugs --- airtime_mvc/public/css/styles.css | 2 +- .../public/js/airtime/library/library.js | 17 +++++++++---- .../public/js/airtime/showbuilder/builder.js | 24 ++++++++++++------- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/airtime_mvc/public/css/styles.css b/airtime_mvc/public/css/styles.css index ed7c765b2..9f626521c 100644 --- a/airtime_mvc/public/css/styles.css +++ b/airtime_mvc/public/css/styles.css @@ -1836,7 +1836,7 @@ button, input { font-weight: bold; } .user-list-wrapper .ui-widget-header:first-child .dataTables_filter { - /*margin:0;*/ + margin:0; } .user-management h2 { font-size: 1.7em; diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 29c25e3d9..b2d49d8d1 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -870,6 +870,12 @@ var AIRTIME = (function(AIRTIME) { // Get the ID of the selected row $rowId = $tr.attr("id"); + if (ev.which === 3 /* Right click */) { + mod.selectNone(); + mod.selectItem($tr); + return; + } + if (!$tr.hasClass(LIB_SELECTED_CLASS)) { if (ev.shiftKey && $previouslySelected !== undefined) { if ($previouslySelected.attr("id") == $rowId) { @@ -893,10 +899,7 @@ var AIRTIME = (function(AIRTIME) { mod.selectItem($tr); } else if (ev.ctrlKey) { - mod.deselectItem($tr); - } else if (ev.which === 3 /* Right click */) { - mod.selectNone(); - mod.selectItem($tr); + flagForDeselection = true; } }); @@ -913,7 +916,11 @@ var AIRTIME = (function(AIRTIME) { $libTable.find("tbody").on("click", "tr > td:not(.library_checkbox)", function(e) { var tr = $(this).parent(); - if (!(e.shiftKey || e.ctrlKey)) { + if (flagForDeselection) { + flagForDeselection = false; + $previouslySelected = undefined; + mod.deselectItem(tr); + } else if (!(e.shiftKey || e.ctrlKey)) { mod.selectNone(); mod.selectItem(tr); } diff --git a/airtime_mvc/public/js/airtime/showbuilder/builder.js b/airtime_mvc/public/js/airtime/showbuilder/builder.js index 528424007..fcb5724d4 100644 --- a/airtime_mvc/public/js/airtime/showbuilder/builder.js +++ b/airtime_mvc/public/js/airtime/showbuilder/builder.js @@ -824,6 +824,14 @@ var AIRTIME = (function(AIRTIME){ // Get the ID of the selected row $rowId = $tr.attr("id"); + if (ev.which === 3 /* Right click */) { + mod.selectNone(); + $tr.addClass(SB_SELECTED_CLASS); + $tr.find(".sb-checkbox > input").prop('checked', true); + mod.checkToolBarIcons(); + return; + } + if (!$tr.hasClass(SB_SELECTED_CLASS)) { if (ev.shiftKey && $previouslySelected !== undefined) { if ($previouslySelected.attr("id") == $rowId) { @@ -851,13 +859,7 @@ var AIRTIME = (function(AIRTIME){ $tr.find(".sb-checkbox > input").prop('checked', true); mod.checkToolBarIcons(); } else if (ev.ctrlKey) { - $tr.removeClass(SB_SELECTED_CLASS); - $tr.find(".sb-checkbox > input").prop('checked', false); - } else if (ev.which === 3 /* Right click */) { - mod.selectNone(); - $tr.addClass(SB_SELECTED_CLASS); - $tr.find(".sb-checkbox > input").prop('checked', true); - mod.checkToolBarIcons(); + flagForDeselection = true; } selectedRows = $("." + SB_SELECTED_CLASS); @@ -882,7 +884,13 @@ var AIRTIME = (function(AIRTIME){ $sbTable.find("tbody").on("click", "tr:not(.sb-header, .sb-footer, .sb-past, .sb-empty, :has(td.dataTables_empty)) > td:not(.sb-checkbox)", function(e) { var tr = $(this).parent(); - if (!(e.shiftKey || e.ctrlKey)) { + if (flagForDeselection) { + flagForDeselection = false; + $previouslySelected = undefined; + tr.removeClass(SB_SELECTED_CLASS); + tr.find(".sb-checkbox > input").prop('checked', false); + mod.checkToolBarIcons(); + } else if (!(e.shiftKey || e.ctrlKey)) { mod.selectNone(); tr.addClass(SB_SELECTED_CLASS); tr.find(".sb-checkbox > input").prop('checked', true);