Fossil SCM

pikchr js: hide/show the SVG's parent element instead of the SVG, so that output from pikchr print commands is hidden when the source is shown.

stephan 2020-09-18 04:10 trunk
Commit 43116c73fdae36d34856178a2d2e1d8351a1e1ee8504e8eb36a54c8c963d1780
1 file changed +2 -3
--- src/fossil.pikchr.js
+++ src/fossil.pikchr.js
@@ -53,11 +53,11 @@
5353
intercepted by most Linux window managers to control
5454
window movement! So... we just listen for *any* of them
5555
(except Shift) and the user will need to find one which
5656
works on on their environment. */
5757
|| this.classList.contains('toggle')){
58
- this._childs.forEach((e)=>e.classList.toggle('hidden'));
58
+ this._toHide.forEach((e)=>e.classList.toggle('hidden'));
5959
}
6060
};
6161
};
6262
if(!svg) svg = 'svg.pikchr';
6363
if('string' === typeof svg){
@@ -75,12 +75,11 @@
7575
const srcView = parent.nextElementSibling;
7676
if(!srcView || !srcView.classList.contains('pikchr-src')){
7777
/* Without this element, there's nothing for us to do here. */
7878
return this;
7979
}
80
- parent.dataset.origMaxWidth = parent.style.maxWidth;
81
- parent._childs = [svg, srcView];
80
+ parent._toHide = [parent, srcView];
8281
D.addClass(srcView, 'hidden');
8382
D.removeClass(svg, 'hidden');
8483
parent.addEventListener('click', f.parentClick, false);
8584
/* When the parent is hidden, it has 0 height so cannot be clicked, so... */
8685
srcView.addEventListener('click', (ev)=>f.parentClick.call(parent, ev), false);
8786
--- src/fossil.pikchr.js
+++ src/fossil.pikchr.js
@@ -53,11 +53,11 @@
53 intercepted by most Linux window managers to control
54 window movement! So... we just listen for *any* of them
55 (except Shift) and the user will need to find one which
56 works on on their environment. */
57 || this.classList.contains('toggle')){
58 this._childs.forEach((e)=>e.classList.toggle('hidden'));
59 }
60 };
61 };
62 if(!svg) svg = 'svg.pikchr';
63 if('string' === typeof svg){
@@ -75,12 +75,11 @@
75 const srcView = parent.nextElementSibling;
76 if(!srcView || !srcView.classList.contains('pikchr-src')){
77 /* Without this element, there's nothing for us to do here. */
78 return this;
79 }
80 parent.dataset.origMaxWidth = parent.style.maxWidth;
81 parent._childs = [svg, srcView];
82 D.addClass(srcView, 'hidden');
83 D.removeClass(svg, 'hidden');
84 parent.addEventListener('click', f.parentClick, false);
85 /* When the parent is hidden, it has 0 height so cannot be clicked, so... */
86 srcView.addEventListener('click', (ev)=>f.parentClick.call(parent, ev), false);
87
--- src/fossil.pikchr.js
+++ src/fossil.pikchr.js
@@ -53,11 +53,11 @@
53 intercepted by most Linux window managers to control
54 window movement! So... we just listen for *any* of them
55 (except Shift) and the user will need to find one which
56 works on on their environment. */
57 || this.classList.contains('toggle')){
58 this._toHide.forEach((e)=>e.classList.toggle('hidden'));
59 }
60 };
61 };
62 if(!svg) svg = 'svg.pikchr';
63 if('string' === typeof svg){
@@ -75,12 +75,11 @@
75 const srcView = parent.nextElementSibling;
76 if(!srcView || !srcView.classList.contains('pikchr-src')){
77 /* Without this element, there's nothing for us to do here. */
78 return this;
79 }
80 parent._toHide = [parent, srcView];
 
81 D.addClass(srcView, 'hidden');
82 D.removeClass(svg, 'hidden');
83 parent.addEventListener('click', f.parentClick, false);
84 /* When the parent is hidden, it has 0 height so cannot be clicked, so... */
85 srcView.addEventListener('click', (ev)=>f.parentClick.call(parent, ev), false);
86

Keyboard Shortcuts

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