Fossil SCM
Internal tweaks and docs in the diff-toggling code. No visible changes.
Commit
6f26395422a580dc61d5b4d76a7e3941bbd956338dc684cfd35c562eb8f37647
Parent
7f1958acf834743…
1 file changed
+10
-1
+10
-1
| --- src/fossil.diff.js | ||
| +++ src/fossil.diff.js | ||
| @@ -28,17 +28,21 @@ | ||
| 28 | 28 | window.fossil.onPageLoad(function(){ |
| 29 | 29 | /** |
| 30 | 30 | Adds toggle checkboxes to each file entry in the diff views for |
| 31 | 31 | /info and similar pages. |
| 32 | 32 | */ |
| 33 | + if( !window.fossil.page.diffControlContainer ){ | |
| 34 | + return; | |
| 35 | + } | |
| 33 | 36 | const D = window.fossil.dom; |
| 34 | 37 | const allToggles = [/*collection of all diff-toggle checkboxes*/]; |
| 35 | 38 | let checkedCount = |
| 36 | 39 | 0 /* When showing more than one diff, keep track of how many |
| 37 | 40 | "show/hide" checkboxes are are checked so we can update the |
| 38 | 41 | "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. */ | |
| 40 | 44 | const addToggle = function(diffElem){ |
| 41 | 45 | const sib = diffElem.previousElementSibling, |
| 42 | 46 | ckbox = sib ? D.addClass(D.checkbox(true), 'diff-toggle') : 0; |
| 43 | 47 | if(!sib) return; |
| 44 | 48 | const lblToggle = D.label(); |
| @@ -59,10 +63,15 @@ | ||
| 59 | 63 | if( !document.querySelector('body.fdiff') ){ |
| 60 | 64 | /* Don't show the diff toggle button for /fdiff because it only |
| 61 | 65 | has a single file to show (and also a different DOM layout). */ |
| 62 | 66 | document.querySelectorAll('table.diff').forEach(addToggle); |
| 63 | 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 | + */ | |
| 64 | 73 | const icm = allToggles.length>1 ? window.fossil.page.diffControlContainer : 0; |
| 65 | 74 | if(icm) { |
| 66 | 75 | btnAll = D.addClass(D.a("#", "Hide diffs"), "button"); |
| 67 | 76 | D.append( icm, btnAll ); |
| 68 | 77 | btnAll.addEventListener('click', function(ev){ |
| 69 | 78 |
| --- 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 |