gnucash maint: [new-owner-report] change highlight trigger: onclick to onmousedown

Christopher Lam clam at code.gnucash.org
Sat Feb 8 22:30:08 EST 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/58ddb47f (commit)
	from  https://github.com/Gnucash/gnucash/commit/3be42beb (commit)



commit 58ddb47f5696191b33b5fbacf632485d88ab73c7
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Feb 9 11:13:59 2020 +0800

    [new-owner-report] change highlight trigger: onclick to onmousedown
    
    and also disable event propagation; this disables text selection

diff --git a/gnucash/report/business-reports/new-owner-report.scm b/gnucash/report/business-reports/new-owner-report.scm
index ec67270c7..e42b8df78 100644
--- a/gnucash/report/business-reports/new-owner-report.scm
+++ b/gnucash/report/business-reports/new-owner-report.scm
@@ -63,9 +63,10 @@
 (define javascript "
 <script>
   function getID(cell) { return cell.getAttribute('link-id'); }
-  function clicky() {
-      var id = getID(this);
-      var ishighlighted = this.classList.contains('highlight');
+  function mousedown(e) {
+      var id = getID(e.target);
+      var ishighlighted = e.target.classList.contains('highlight');
+      e.preventDefault ();
       TDs.forEach(TD => TD.classList.remove('highlight'));
       if (ishighlighted) return;
       TDs
@@ -73,7 +74,7 @@
           .forEach (TD => TD.classList.add('highlight'));}
   var TDs = document.getElementsByTagName('td');
   TDs = [...TDs].filter(getID);
-  TDs.forEach(TD => TD.onclick = clicky);
+  TDs.forEach(TD => TD.onmousedown = mousedown);
 </script>
 ")
 



Summary of changes:
 gnucash/report/business-reports/new-owner-report.scm | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)



More information about the gnucash-changes mailing list