Skip to content

Commit 72c6d3b

Browse files
committed
Add shift clicking to list checkboxes
1 parent 99eea5e commit 72c6d3b

File tree

1 file changed

+15
-1
lines changed
  • bolt-staff/bolt/admin/assets/admin

1 file changed

+15
-1
lines changed

bolt-staff/bolt/admin/assets/admin/list.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ jQuery(function ($) {
33
var $actionPks = $('[name="action_pks"]');
44
var $actionSelect = $('[name="action_name"]');
55
var $actionSubmit = $('[data-actions-form] [type="submit"]');
6+
var $lastActionCheckboxChecked = null;
67

78
$actionCheckbox.on("change", function () {
89
var pks = [];
@@ -29,5 +30,18 @@ jQuery(function ($) {
2930
}
3031
}
3132

32-
// TODO Enable shift-clicking to select a range of checkboxes
33+
// Enable shift-clicking to select a range of checkboxes
34+
$actionCheckbox.on("click", function (e) {
35+
if (e.shiftKey) {
36+
var $this = $(this);
37+
var thisIndex = $actionCheckbox.index($this);
38+
var lastIndex = $actionCheckbox.index($lastActionCheckboxChecked);
39+
var minIndex = Math.min(thisIndex, lastIndex);
40+
var maxIndex = Math.max(thisIndex, lastIndex);
41+
var $checkboxes = $actionCheckbox.slice(minIndex, maxIndex + 1);
42+
$checkboxes.prop("checked", $this.is(":checked"));
43+
} else {
44+
$lastActionCheckboxChecked = $(this);
45+
}
46+
});
3347
});

0 commit comments

Comments
 (0)