Fix shift selection in library and builder views

This commit is contained in:
Duncan Sommerville 2015-06-25 18:21:22 -04:00
parent a3f1cf1d56
commit c59f401eb1
1 changed files with 23 additions and 14 deletions

View File

@ -6,7 +6,9 @@ var AIRTIME = (function(AIRTIME) {
$libTable,
LIB_SELECTED_CLASS = "lib-selected",
chosenItems = {},
visibleChosenItems = {};
visibleChosenItems = {},
$previouslySelected;
// we need to know whether the criteria value is string or
// numeric in order to provide a single textbox or range textboxes
@ -868,28 +870,35 @@ var AIRTIME = (function(AIRTIME) {
});
$libTable.find("tbody").on("click", "input[type=checkbox]", function(ev) {
var $cb = $(this),
$prev,
$tr = $cb.parents("tr"),
$trs;
// Get the ID of the selected row
$rowId = $tr.attr("id");
if ($cb.is(":checked")) {
if (ev.shiftKey) {
$prev = $libTable.find("tbody").find("tr."+LIB_SELECTED_CLASS).eq(-1);
$trs = $prev.nextUntil($tr);
$trs.each(function(i, el){
mod.selectItem($(el));
});
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);
mod.deselectItem($tr);
}
});
checkImportStatus();