26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
+
+
+
-
+
+
|
});
window.fossil.onPageLoad(function(){
/**
Adds toggle checkboxes to each file entry in the diff views for
/info and similar pages.
*/
if( !window.fossil.page.diffControlContainer ){
return;
}
const D = window.fossil.dom;
const allToggles = [/*collection of all diff-toggle checkboxes*/];
let checkedCount =
0 /* When showing more than one diff, keep track of how many
"show/hide" checkboxes are are checked so we can update the
"show/hide all" label dynamically. */;
let btnAll /* show/hide all diffs UI control */;
let btnAll /* UI control to show/hide all diffs */;
/* Install a diff-toggle button for the given diff table element. */
const addToggle = function(diffElem){
const sib = diffElem.previousElementSibling,
ckbox = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0;
if(!sib) return;
const lblToggle = D.label();
D.append(lblToggle, ckbox, D.text(" show/hide "));
const wrapper = D.append(D.span(), lblToggle);
|
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
+
+
+
+
+
|
}, false);
};
if( !document.querySelector('body.fdiff') ){
/* Don't show the diff toggle button for /fdiff because it only
has a single file to show (and also a different DOM layout). */
document.querySelectorAll('table.diff').forEach(addToggle);
}
/**
Set up a "toggle all diffs" button which toggles all of the
above-installed checkboxes, but only if more than one diff is
rendered.
*/
const icm = allToggles.length>1 ? window.fossil.page.diffControlContainer : 0;
if(icm) {
btnAll = D.addClass(D.a("#", "Hide diffs"), "button");
D.append( icm, btnAll );
btnAll.addEventListener('click', function(ev){
ev.preventDefault();
ev.stopPropagation();
|