Skip to content

Commit

Permalink
Merge pull request #139 from eroamane/master-org-range-select
Browse files Browse the repository at this point in the history
add range select by 'ctrl' key.
  • Loading branch information
binux authored May 9, 2020
2 parents 8816da2 + ce0b261 commit 04e6c8f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

.select-box {
cursor: pointer;
user-select: none;
-moz-user-select: none;
}
.btn-inline {
/* fix for MAC/chrome */
Expand Down
29 changes: 27 additions & 2 deletions js/yaaw.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

var YAAW = (function() {
var selected_tasks = false;
var selected_range_start = null;
var selected_range_close = null;
var on_gid = null;
var torrent_file = null, file_type = null;
return {
Expand Down Expand Up @@ -149,8 +151,31 @@ var YAAW = (function() {

$("[rel=tooltip]").tooltip({"placement": "bottom"});

$(".task .select-box").live("click", function() {
YAAW.tasks.toggle($(this).parents(".task"));
$(".task .select-box").live("click", function(e) {
if (!e.shiftKey) {
YAAW.tasks.toggle($(this).parents(".task"));
selected_range_start = $(this).parents(".task").hasClass("selected") ? $(this).parents(".task")[0] : null;
selected_range_close = null;
} else {
YAAW.tasks.select($(this).parents(".task"));
if (!selected_range_start)
selected_range_start = $(this).parents(".task")[0];
else if (!selected_range_close)
selected_range_close = $(this).parents(".task")[0];
}
if (selected_range_start && selected_range_close) {
if (selected_range_start == selected_range_close) {
selected_range_close = null;
} else {
var task_in_range = false;
$(".tasks-table .task").each(function (i, n) {
if (n == selected_range_start || n == selected_range_close) task_in_range = !task_in_range;
if (task_in_range) YAAW.tasks.select(n);
});
selected_range_start = selected_range_close;
selected_range_close = null;
}
}
YAAW.tasks.check_select();
});

Expand Down

0 comments on commit 04e6c8f

Please sign in to comment.