Skip to content

Commit

Permalink
Add shift clicking to list checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
davegaeddert committed Jan 18, 2024
1 parent 99eea5e commit 72c6d3b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion bolt-staff/bolt/admin/assets/admin/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ jQuery(function ($) {
var $actionPks = $('[name="action_pks"]');
var $actionSelect = $('[name="action_name"]');
var $actionSubmit = $('[data-actions-form] [type="submit"]');
var $lastActionCheckboxChecked = null;

$actionCheckbox.on("change", function () {
var pks = [];
Expand All @@ -29,5 +30,18 @@ jQuery(function ($) {
}
}

// TODO Enable shift-clicking to select a range of checkboxes
// Enable shift-clicking to select a range of checkboxes
$actionCheckbox.on("click", function (e) {
if (e.shiftKey) {
var $this = $(this);
var thisIndex = $actionCheckbox.index($this);
var lastIndex = $actionCheckbox.index($lastActionCheckboxChecked);
var minIndex = Math.min(thisIndex, lastIndex);
var maxIndex = Math.max(thisIndex, lastIndex);
var $checkboxes = $actionCheckbox.slice(minIndex, maxIndex + 1);
$checkboxes.prop("checked", $this.is(":checked"));
} else {
$lastActionCheckboxChecked = $(this);
}
});
});

0 comments on commit 72c6d3b

Please sign in to comment.