Fossil SCM
pikchrshow: saved some space in the button bar and added help buttonlets to explain its two checkboxes.
Commit
7ddd2781a0b568d2fad90aefd25359965f5b77bcd07c4af8a1e06064c8b2f73d
Parent
d4bb5251b342eb5…
2 files changed
+29
-5
+3
-2
+29
-5
| --- src/fossil.page.pikchrshow.js | ||
| +++ src/fossil.page.pikchrshow.js | ||
| @@ -2,11 +2,11 @@ | ||
| 2 | 2 | "use strict"; |
| 3 | 3 | /** |
| 4 | 4 | Client-side implementation of the /pikchrshow app. Requires that |
| 5 | 5 | the fossil JS bootstrapping is complete and that these fossil JS |
| 6 | 6 | APIs have been installed: fossil.fetch, fossil.dom, |
| 7 | - fossil.copybutton | |
| 7 | + fossil.copybutton, fossil.popupwidget | |
| 8 | 8 | */ |
| 9 | 9 | const E = (s)=>document.querySelector(s), |
| 10 | 10 | D = F.dom, |
| 11 | 11 | P = F.page; |
| 12 | 12 | |
| @@ -77,11 +77,23 @@ | ||
| 77 | 77 | ; |
| 78 | 78 | D.append( |
| 79 | 79 | cbWrap, |
| 80 | 80 | selectScript, |
| 81 | 81 | cbAutoPreview, |
| 82 | - D.label(cbAutoPreview,"Auto-preview?") | |
| 82 | + D.label(cbAutoPreview,"Auto-preview?"), | |
| 83 | + F.helpButtonlets.create( | |
| 84 | + D.append(D.div(), | |
| 85 | + 'Auto-preview automatically previews selected ', | |
| 86 | + 'built-in pikchr scripts by sending them to ', | |
| 87 | + 'the server for rendering. Not recommended on a ', | |
| 88 | + 'slow connection/server.', | |
| 89 | + D.br(),D.br(), | |
| 90 | + 'Pikchr scripts may also be dragged/dropped from ', | |
| 91 | + 'the local filesystem into the text area, but ', | |
| 92 | + 'the auto-preview option does not apply to them.' | |
| 93 | + ) | |
| 94 | + ) | |
| 83 | 95 | ).childNodes.forEach(function(ch){ |
| 84 | 96 | ch.style.margin = "0 0.25em"; |
| 85 | 97 | }); |
| 86 | 98 | D.append(P.e.uiControls, cbWrap); |
| 87 | 99 | P.predefinedPiks.forEach(function(script,ndx){ |
| @@ -97,12 +109,25 @@ | ||
| 97 | 109 | P.e.taContent.value = val; |
| 98 | 110 | if(cbAutoPreview.checked) P.preview(); |
| 99 | 111 | }, false); |
| 100 | 112 | } |
| 101 | 113 | |
| 102 | - // Move dark mode checkbox to the end | |
| 103 | - D.append(P.e.uiControls, P.e.cbDarkMode.parentNode); | |
| 114 | + // Move dark mode checkbox to the end and add a help buttonlet | |
| 115 | + D.append( | |
| 116 | + P.e.uiControls, | |
| 117 | + D.append( | |
| 118 | + P.e.cbDarkMode.parentNode, | |
| 119 | + F.helpButtonlets.create( | |
| 120 | + D.span(), | |
| 121 | + 'Dark mode changes the colors of rendered SVG to ', | |
| 122 | + 'make them more visible in dark-themed skins. ', | |
| 123 | + 'This only changes (using CSS) how they are rendered, ', | |
| 124 | + 'not any actual colors written in the script.' | |
| 125 | + ) | |
| 126 | + ) | |
| 127 | + ); | |
| 128 | + | |
| 104 | 129 | |
| 105 | 130 | // File drag/drop pikchr scripts into P.e.taContent. |
| 106 | 131 | // Adapted from: https://stackoverflow.com/a/58677161 |
| 107 | 132 | const dropfile = function(file){ |
| 108 | 133 | const reader = new FileReader(); |
| @@ -253,11 +278,10 @@ | ||
| 253 | 278 | |
| 254 | 279 | } |
| 255 | 280 | */ |
| 256 | 281 | P.predefinedPiks = [ |
| 257 | 282 | {name: "--Predefined Scripts--"}, |
| 258 | - {name: "Tip: drag/drop pikchr files into the textarea"}, | |
| 259 | 283 | /* |
| 260 | 284 | The following were imported from the pikchr test scripts: |
| 261 | 285 | |
| 262 | 286 | https://fossil-scm.org/pikchr/dir/tests |
| 263 | 287 | */ |
| 264 | 288 |
| --- src/fossil.page.pikchrshow.js | |
| +++ src/fossil.page.pikchrshow.js | |
| @@ -2,11 +2,11 @@ | |
| 2 | "use strict"; |
| 3 | /** |
| 4 | Client-side implementation of the /pikchrshow app. Requires that |
| 5 | the fossil JS bootstrapping is complete and that these fossil JS |
| 6 | APIs have been installed: fossil.fetch, fossil.dom, |
| 7 | fossil.copybutton |
| 8 | */ |
| 9 | const E = (s)=>document.querySelector(s), |
| 10 | D = F.dom, |
| 11 | P = F.page; |
| 12 | |
| @@ -77,11 +77,23 @@ | |
| 77 | ; |
| 78 | D.append( |
| 79 | cbWrap, |
| 80 | selectScript, |
| 81 | cbAutoPreview, |
| 82 | D.label(cbAutoPreview,"Auto-preview?") |
| 83 | ).childNodes.forEach(function(ch){ |
| 84 | ch.style.margin = "0 0.25em"; |
| 85 | }); |
| 86 | D.append(P.e.uiControls, cbWrap); |
| 87 | P.predefinedPiks.forEach(function(script,ndx){ |
| @@ -97,12 +109,25 @@ | |
| 97 | P.e.taContent.value = val; |
| 98 | if(cbAutoPreview.checked) P.preview(); |
| 99 | }, false); |
| 100 | } |
| 101 | |
| 102 | // Move dark mode checkbox to the end |
| 103 | D.append(P.e.uiControls, P.e.cbDarkMode.parentNode); |
| 104 | |
| 105 | // File drag/drop pikchr scripts into P.e.taContent. |
| 106 | // Adapted from: https://stackoverflow.com/a/58677161 |
| 107 | const dropfile = function(file){ |
| 108 | const reader = new FileReader(); |
| @@ -253,11 +278,10 @@ | |
| 253 | |
| 254 | } |
| 255 | */ |
| 256 | P.predefinedPiks = [ |
| 257 | {name: "--Predefined Scripts--"}, |
| 258 | {name: "Tip: drag/drop pikchr files into the textarea"}, |
| 259 | /* |
| 260 | The following were imported from the pikchr test scripts: |
| 261 | |
| 262 | https://fossil-scm.org/pikchr/dir/tests |
| 263 | */ |
| 264 |
| --- src/fossil.page.pikchrshow.js | |
| +++ src/fossil.page.pikchrshow.js | |
| @@ -2,11 +2,11 @@ | |
| 2 | "use strict"; |
| 3 | /** |
| 4 | Client-side implementation of the /pikchrshow app. Requires that |
| 5 | the fossil JS bootstrapping is complete and that these fossil JS |
| 6 | APIs have been installed: fossil.fetch, fossil.dom, |
| 7 | fossil.copybutton, fossil.popupwidget |
| 8 | */ |
| 9 | const E = (s)=>document.querySelector(s), |
| 10 | D = F.dom, |
| 11 | P = F.page; |
| 12 | |
| @@ -77,11 +77,23 @@ | |
| 77 | ; |
| 78 | D.append( |
| 79 | cbWrap, |
| 80 | selectScript, |
| 81 | cbAutoPreview, |
| 82 | D.label(cbAutoPreview,"Auto-preview?"), |
| 83 | F.helpButtonlets.create( |
| 84 | D.append(D.div(), |
| 85 | 'Auto-preview automatically previews selected ', |
| 86 | 'built-in pikchr scripts by sending them to ', |
| 87 | 'the server for rendering. Not recommended on a ', |
| 88 | 'slow connection/server.', |
| 89 | D.br(),D.br(), |
| 90 | 'Pikchr scripts may also be dragged/dropped from ', |
| 91 | 'the local filesystem into the text area, but ', |
| 92 | 'the auto-preview option does not apply to them.' |
| 93 | ) |
| 94 | ) |
| 95 | ).childNodes.forEach(function(ch){ |
| 96 | ch.style.margin = "0 0.25em"; |
| 97 | }); |
| 98 | D.append(P.e.uiControls, cbWrap); |
| 99 | P.predefinedPiks.forEach(function(script,ndx){ |
| @@ -97,12 +109,25 @@ | |
| 109 | P.e.taContent.value = val; |
| 110 | if(cbAutoPreview.checked) P.preview(); |
| 111 | }, false); |
| 112 | } |
| 113 | |
| 114 | // Move dark mode checkbox to the end and add a help buttonlet |
| 115 | D.append( |
| 116 | P.e.uiControls, |
| 117 | D.append( |
| 118 | P.e.cbDarkMode.parentNode, |
| 119 | F.helpButtonlets.create( |
| 120 | D.span(), |
| 121 | 'Dark mode changes the colors of rendered SVG to ', |
| 122 | 'make them more visible in dark-themed skins. ', |
| 123 | 'This only changes (using CSS) how they are rendered, ', |
| 124 | 'not any actual colors written in the script.' |
| 125 | ) |
| 126 | ) |
| 127 | ); |
| 128 | |
| 129 | |
| 130 | // File drag/drop pikchr scripts into P.e.taContent. |
| 131 | // Adapted from: https://stackoverflow.com/a/58677161 |
| 132 | const dropfile = function(file){ |
| 133 | const reader = new FileReader(); |
| @@ -253,11 +278,10 @@ | |
| 278 | |
| 279 | } |
| 280 | */ |
| 281 | P.predefinedPiks = [ |
| 282 | {name: "--Predefined Scripts--"}, |
| 283 | /* |
| 284 | The following were imported from the pikchr test scripts: |
| 285 | |
| 286 | https://fossil-scm.org/pikchr/dir/tests |
| 287 | */ |
| 288 |
+3
-2
| --- src/pikchrshow.c | ||
| +++ src/pikchrshow.c | ||
| @@ -117,11 +117,11 @@ | ||
| 117 | 117 | CX("<textarea id='content' name='content' rows='15'>%s</textarea>", |
| 118 | 118 | zContent/*safe-for-%s*/); |
| 119 | 119 | CX("<div id='pikchrshow-controls'>"); |
| 120 | 120 | CX("<button id='pikchr-submit-preview'>Preview</button>"); |
| 121 | 121 | style_labeled_checkbox("flipcolors-wrapper", "flipcolors", |
| 122 | - "Simulate dark theme?", | |
| 122 | + "Dark mode?", | |
| 123 | 123 | "1", flipColors, 0); |
| 124 | 124 | CX("</div>"/*#pikchrshow-controls*/); |
| 125 | 125 | CX("</div>"/*#pikchrshow-form*/); |
| 126 | 126 | CX("<fieldset id='pikchrshow-output-wrapper'>"); |
| 127 | 127 | CX("<legend>Preview <span class='copy-button'></span></legend>"); |
| @@ -140,11 +140,12 @@ | ||
| 140 | 140 | } |
| 141 | 141 | CX("</div>"/*#pikchrshow-output*/); |
| 142 | 142 | CX("</fieldset>"); |
| 143 | 143 | CX("</div>"/*sbs-wrapper*/); |
| 144 | 144 | if(!builtin_bundle_all_fossil_js_apis()){ |
| 145 | - builtin_emit_fossil_js_apis("dom", "fetch", "copybutton", 0); | |
| 145 | + builtin_emit_fossil_js_apis("dom", "fetch", "copybutton", | |
| 146 | + "popupwidget", 0); | |
| 146 | 147 | } |
| 147 | 148 | builtin_emit_fossil_js_apis("page.pikchrshow", 0); |
| 148 | 149 | builtin_fulfill_js_requests(); |
| 149 | 150 | style_footer(); |
| 150 | 151 | } |
| 151 | 152 |
| --- src/pikchrshow.c | |
| +++ src/pikchrshow.c | |
| @@ -117,11 +117,11 @@ | |
| 117 | CX("<textarea id='content' name='content' rows='15'>%s</textarea>", |
| 118 | zContent/*safe-for-%s*/); |
| 119 | CX("<div id='pikchrshow-controls'>"); |
| 120 | CX("<button id='pikchr-submit-preview'>Preview</button>"); |
| 121 | style_labeled_checkbox("flipcolors-wrapper", "flipcolors", |
| 122 | "Simulate dark theme?", |
| 123 | "1", flipColors, 0); |
| 124 | CX("</div>"/*#pikchrshow-controls*/); |
| 125 | CX("</div>"/*#pikchrshow-form*/); |
| 126 | CX("<fieldset id='pikchrshow-output-wrapper'>"); |
| 127 | CX("<legend>Preview <span class='copy-button'></span></legend>"); |
| @@ -140,11 +140,12 @@ | |
| 140 | } |
| 141 | CX("</div>"/*#pikchrshow-output*/); |
| 142 | CX("</fieldset>"); |
| 143 | CX("</div>"/*sbs-wrapper*/); |
| 144 | if(!builtin_bundle_all_fossil_js_apis()){ |
| 145 | builtin_emit_fossil_js_apis("dom", "fetch", "copybutton", 0); |
| 146 | } |
| 147 | builtin_emit_fossil_js_apis("page.pikchrshow", 0); |
| 148 | builtin_fulfill_js_requests(); |
| 149 | style_footer(); |
| 150 | } |
| 151 |
| --- src/pikchrshow.c | |
| +++ src/pikchrshow.c | |
| @@ -117,11 +117,11 @@ | |
| 117 | CX("<textarea id='content' name='content' rows='15'>%s</textarea>", |
| 118 | zContent/*safe-for-%s*/); |
| 119 | CX("<div id='pikchrshow-controls'>"); |
| 120 | CX("<button id='pikchr-submit-preview'>Preview</button>"); |
| 121 | style_labeled_checkbox("flipcolors-wrapper", "flipcolors", |
| 122 | "Dark mode?", |
| 123 | "1", flipColors, 0); |
| 124 | CX("</div>"/*#pikchrshow-controls*/); |
| 125 | CX("</div>"/*#pikchrshow-form*/); |
| 126 | CX("<fieldset id='pikchrshow-output-wrapper'>"); |
| 127 | CX("<legend>Preview <span class='copy-button'></span></legend>"); |
| @@ -140,11 +140,12 @@ | |
| 140 | } |
| 141 | CX("</div>"/*#pikchrshow-output*/); |
| 142 | CX("</fieldset>"); |
| 143 | CX("</div>"/*sbs-wrapper*/); |
| 144 | if(!builtin_bundle_all_fossil_js_apis()){ |
| 145 | builtin_emit_fossil_js_apis("dom", "fetch", "copybutton", |
| 146 | "popupwidget", 0); |
| 147 | } |
| 148 | builtin_emit_fossil_js_apis("page.pikchrshow", 0); |
| 149 | builtin_fulfill_js_requests(); |
| 150 | style_footer(); |
| 151 | } |
| 152 |