Fossil SCM

Internal tweaks and docs in the diff-toggling code. No visible changes.

stephan 2024-12-16 07:40 trunk
Commit 6f26395422a580dc61d5b4d76a7e3941bbd956338dc684cfd35c562eb8f37647
1 file changed +10 -1
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -28,17 +28,21 @@
2828
window.fossil.onPageLoad(function(){
2929
/**
3030
Adds toggle checkboxes to each file entry in the diff views for
3131
/info and similar pages.
3232
*/
33
+ if( !window.fossil.page.diffControlContainer ){
34
+ return;
35
+ }
3336
const D = window.fossil.dom;
3437
const allToggles = [/*collection of all diff-toggle checkboxes*/];
3538
let checkedCount =
3639
0 /* When showing more than one diff, keep track of how many
3740
"show/hide" checkboxes are are checked so we can update the
3841
"show/hide all" label dynamically. */;
39
- let btnAll /* show/hide all diffs UI control */;
42
+ let btnAll /* UI control to show/hide all diffs */;
43
+ /* Install a diff-toggle button for the given diff table element. */
4044
const addToggle = function(diffElem){
4145
const sib = diffElem.previousElementSibling,
4246
ckbox = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
4347
if(!sib) return;
4448
const lblToggle = D.label();
@@ -59,10 +63,15 @@
5963
if( !document.querySelector('body.fdiff') ){
6064
/* Don't show the diff toggle button for /fdiff because it only
6165
has a single file to show (and also a different DOM layout). */
6266
document.querySelectorAll('table.diff').forEach(addToggle);
6367
}
68
+ /**
69
+ Set up a "toggle all diffs" button which toggles all of the
70
+ above-installed checkboxes, but only if more than one diff is
71
+ rendered.
72
+ */
6473
const icm = allToggles.length>1 ? window.fossil.page.diffControlContainer : 0;
6574
if(icm) {
6675
btnAll = D.addClass(D.a("#", "Hide diffs"), "button");
6776
D.append( icm, btnAll );
6877
btnAll.addEventListener('click', function(ev){
6978
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -28,17 +28,21 @@
28 window.fossil.onPageLoad(function(){
29 /**
30 Adds toggle checkboxes to each file entry in the diff views for
31 /info and similar pages.
32 */
 
 
 
33 const D = window.fossil.dom;
34 const allToggles = [/*collection of all diff-toggle checkboxes*/];
35 let checkedCount =
36 0 /* When showing more than one diff, keep track of how many
37 "show/hide" checkboxes are are checked so we can update the
38 "show/hide all" label dynamically. */;
39 let btnAll /* show/hide all diffs UI control */;
 
40 const addToggle = function(diffElem){
41 const sib = diffElem.previousElementSibling,
42 ckbox = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
43 if(!sib) return;
44 const lblToggle = D.label();
@@ -59,10 +63,15 @@
59 if( !document.querySelector('body.fdiff') ){
60 /* Don't show the diff toggle button for /fdiff because it only
61 has a single file to show (and also a different DOM layout). */
62 document.querySelectorAll('table.diff').forEach(addToggle);
63 }
 
 
 
 
 
64 const icm = allToggles.length>1 ? window.fossil.page.diffControlContainer : 0;
65 if(icm) {
66 btnAll = D.addClass(D.a("#", "Hide diffs"), "button");
67 D.append( icm, btnAll );
68 btnAll.addEventListener('click', function(ev){
69
--- src/fossil.diff.js
+++ src/fossil.diff.js
@@ -28,17 +28,21 @@
28 window.fossil.onPageLoad(function(){
29 /**
30 Adds toggle checkboxes to each file entry in the diff views for
31 /info and similar pages.
32 */
33 if( !window.fossil.page.diffControlContainer ){
34 return;
35 }
36 const D = window.fossil.dom;
37 const allToggles = [/*collection of all diff-toggle checkboxes*/];
38 let checkedCount =
39 0 /* When showing more than one diff, keep track of how many
40 "show/hide" checkboxes are are checked so we can update the
41 "show/hide all" label dynamically. */;
42 let btnAll /* UI control to show/hide all diffs */;
43 /* Install a diff-toggle button for the given diff table element. */
44 const addToggle = function(diffElem){
45 const sib = diffElem.previousElementSibling,
46 ckbox = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
47 if(!sib) return;
48 const lblToggle = D.label();
@@ -59,10 +63,15 @@
63 if( !document.querySelector('body.fdiff') ){
64 /* Don't show the diff toggle button for /fdiff because it only
65 has a single file to show (and also a different DOM layout). */
66 document.querySelectorAll('table.diff').forEach(addToggle);
67 }
68 /**
69 Set up a "toggle all diffs" button which toggles all of the
70 above-installed checkboxes, but only if more than one diff is
71 rendered.
72 */
73 const icm = allToggles.length>1 ? window.fossil.page.diffControlContainer : 0;
74 if(icm) {
75 btnAll = D.addClass(D.a("#", "Hide diffs"), "button");
76 D.append( icm, btnAll );
77 btnAll.addEventListener('click', function(ev){
78

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button