Skip to content

Commit

Permalink
Attempt to activate row_click less often, e.g. when selecting a title.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Sep 6, 2023
1 parent 0394fcf commit 768ebac
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -8296,24 +8296,38 @@ function unload_list() {
if (hl.str && (!cookie_set_at || cookie_set_at + 3 < now_msec()))
set_cookie(hl);
}

var row_click_sel = null;
function row_click(evt) {
if (!hasClass(this.parentElement, "pltable-tbody")
|| evt.target.closest("a, input, textarea, select, button, .ui, .uic"))
|| evt.target.closest("a, input, textarea, select, button, .ui, .uic")
|| evt.button !== 0) {
row_click_sel = null;
return;
}
let current_sel = window.getSelection().toString();
if (evt.type === "mousedown") {
row_click_sel = current_sel;
return;
var pl = this, td = evt.target.closest("td");
if (!td)
} else if (row_click_sel === null
|| (current_sel !== row_click_sel && current_sel !== "")) {
row_click_sel = null;
return;
while (pl.nodeType !== 1 || /^plx/.test(pl.className)) {
pl = pl.previousSibling;
}
var $inputs = $(pl).find("input, textarea, select, button")
.not("input[type=hidden], .pl_sel > *");
if ($inputs.length) {
$inputs.first().focus().scrollIntoView();
} else if (hasClass(td, "pl_id") || hasClass(td, "pl_title") || hasClass(td, "pl_rowclick")) {
var $a = $(pl).find("a.pnum").first(),
href = $a[0].getAttribute("href");
handle_list($a[0], href);
}

let pl = this, td = evt.target.closest("td");
if (pl.className.startsWith("plx")) {
pl = pl.previousElementSibling;
}
let $i = $(pl).find("input, textarea, select, button")
.not("input[type=hidden], .pl_sel *");
if ($i.length) {
$i.first().focus().scrollIntoView();
} else if (td && (hasClass(td, "pl_id")
|| hasClass(td, "pl_title")
|| hasClass(td, "pl_rowclick"))) {
let a = pl.querySelector("a.pnum"), href = a.getAttribute("href");
handle_list(a, href);
if (event_key.is_default_a(evt)) {
window.location = href;
} else {
Expand All @@ -8325,6 +8339,8 @@ function row_click(evt) {
}
evt.preventDefault();
}
$(document).on("mousedown click", "tr.pl, tr.plx", row_click);

handle_ui.on("js-edit-comment", function (evt) {
if (this.tagName !== "A" || event_key.is_default_a(evt)) {
evt.preventDefault();
Expand Down Expand Up @@ -8370,7 +8386,6 @@ $(document).on("submit", "form", function (evt) {
}
});

$(document).on("click", "tr.pl, tr.plx", row_click);
$(window).on("beforeunload", unload_list);

$(function () {
Expand Down

0 comments on commit 768ebac

Please sign in to comment.