Fossil SCM

pikchr source view: tentatively re-added the copy button (only in source view, not SVG), but it now switches back to SVG mode if it successfully copies the source code.

stephan 2020-09-17 17:13 trunk
Commit d369f4f389c6a4471cdd314ea93e02d8552f5e5ba6da337f8c5f65eb9f56cf8c
1 file changed +7 -1
--- src/fossil.pikchr.js
+++ src/fossil.pikchr.js
@@ -152,11 +152,17 @@
152152
}
153153
const buttonBar = D.addClass(D.span(), 'pikchr-button-bar');
154154
const btnFlip = D.append(
155155
D.addClass(D.span(), 'pikchr-src-button'),
156156
);
157
- D.append(buttonBar, btnFlip);
157
+ const btnCopy = F.copyButton(D.span(), {
158
+ cssClass: ['copy-button', 'pikchr-copy-button'],
159
+ extractText: ()=>(srcView.classList.contains('hidden') ? svg.outerHTML : srcView.value),
160
+ oncopy: ()=>D.flashOnce(btnCopy, ()=>btnFlip.click())
161
+ // ^^^ after copying and flashing, flip back to SVG mode. */
162
+ });
163
+ D.append(buttonBar, btnFlip, btnCopy);
158164
// not yet sure which options we can/should support:
159165
// opt = F.mergeLastWins({},opt);
160166
D.addClass(srcView, 'hidden')/*should already be so, but just in case*/;
161167
D.append(parent, D.addClass(buttonBar, 'hidden'));
162168
163169
--- src/fossil.pikchr.js
+++ src/fossil.pikchr.js
@@ -152,11 +152,17 @@
152 }
153 const buttonBar = D.addClass(D.span(), 'pikchr-button-bar');
154 const btnFlip = D.append(
155 D.addClass(D.span(), 'pikchr-src-button'),
156 );
157 D.append(buttonBar, btnFlip);
 
 
 
 
 
 
158 // not yet sure which options we can/should support:
159 // opt = F.mergeLastWins({},opt);
160 D.addClass(srcView, 'hidden')/*should already be so, but just in case*/;
161 D.append(parent, D.addClass(buttonBar, 'hidden'));
162
163
--- src/fossil.pikchr.js
+++ src/fossil.pikchr.js
@@ -152,11 +152,17 @@
152 }
153 const buttonBar = D.addClass(D.span(), 'pikchr-button-bar');
154 const btnFlip = D.append(
155 D.addClass(D.span(), 'pikchr-src-button'),
156 );
157 const btnCopy = F.copyButton(D.span(), {
158 cssClass: ['copy-button', 'pikchr-copy-button'],
159 extractText: ()=>(srcView.classList.contains('hidden') ? svg.outerHTML : srcView.value),
160 oncopy: ()=>D.flashOnce(btnCopy, ()=>btnFlip.click())
161 // ^^^ after copying and flashing, flip back to SVG mode. */
162 });
163 D.append(buttonBar, btnFlip, btnCopy);
164 // not yet sure which options we can/should support:
165 // opt = F.mergeLastWins({},opt);
166 D.addClass(srcView, 'hidden')/*should already be so, but just in case*/;
167 D.append(parent, D.addClass(buttonBar, 'hidden'));
168
169

Keyboard Shortcuts

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