Fossil

Check-in [43116c73]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 43116c73fdae36d34856178a2d2e1d8351a1e1ee8504e8eb36a54c8c963d1780
User & Date: stephan 2020-09-18 04:10:08
Context
2020-09-18
05:07
Minor C-side fossil JS API simplification to ease upcoming changes. ... (check-in: 58d86b16 user: stephan tags: trunk)
04:10
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. ... (check-in: 43116c73 user: stephan tags: trunk)
03:28
Clarify the origin of JS in the generated HTML. ... (check-in: 68542449 user: drh tags: trunk)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/fossil.pikchr.js.

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
              meta) is handled differently everywhere. Shift is used
              by the browser, Ctrl doesn't work on an iMac, and Alt is
              intercepted by most Linux window managers to control
              window movement! So...  we just listen for *any* of them
              (except Shift) and the user will need to find one which
              works on on their environment. */
           || this.classList.contains('toggle')){
          this._childs.forEach((e)=>e.classList.toggle('hidden'));
        }
      };
    };
    if(!svg) svg = 'svg.pikchr';
    if('string' === typeof svg){
      document.querySelectorAll(svg).forEach((e)=>f.call(this, e));
      return this;







|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
              meta) is handled differently everywhere. Shift is used
              by the browser, Ctrl doesn't work on an iMac, and Alt is
              intercepted by most Linux window managers to control
              window movement! So...  we just listen for *any* of them
              (except Shift) and the user will need to find one which
              works on on their environment. */
           || this.classList.contains('toggle')){
          this._toHide.forEach((e)=>e.classList.toggle('hidden'));
        }
      };
    };
    if(!svg) svg = 'svg.pikchr';
    if('string' === typeof svg){
      document.querySelectorAll(svg).forEach((e)=>f.call(this, e));
      return this;
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
    svg.dataset.pikchrProcessed = 1;
    const parent = svg.parentNode;
    const srcView = parent.nextElementSibling;
    if(!srcView || !srcView.classList.contains('pikchr-src')){
      /* Without this element, there's nothing for us to do here. */
      return this;
    }
    parent.dataset.origMaxWidth = parent.style.maxWidth;
    parent._childs = [svg, srcView];
    D.addClass(srcView, 'hidden');
    D.removeClass(svg, 'hidden');
    parent.addEventListener('click', f.parentClick, false);
    /* When the parent is hidden, it has 0 height so cannot be clicked, so... */
    srcView.addEventListener('click', (ev)=>f.parentClick.call(parent, ev), false);
    if(parent.classList.contains('source')){
      /* Start off in source-view mode via a very fake click event */
      f.parentClick.call(parent, {ctrlKey:true});
    }
  };
})(window.fossil);







<
|











73
74
75
76
77
78
79

80
81
82
83
84
85
86
87
88
89
90
91
    svg.dataset.pikchrProcessed = 1;
    const parent = svg.parentNode;
    const srcView = parent.nextElementSibling;
    if(!srcView || !srcView.classList.contains('pikchr-src')){
      /* Without this element, there's nothing for us to do here. */
      return this;
    }

    parent._toHide = [parent, srcView];
    D.addClass(srcView, 'hidden');
    D.removeClass(svg, 'hidden');
    parent.addEventListener('click', f.parentClick, false);
    /* When the parent is hidden, it has 0 height so cannot be clicked, so... */
    srcView.addEventListener('click', (ev)=>f.parentClick.call(parent, ev), false);
    if(parent.classList.contains('source')){
      /* Start off in source-view mode via a very fake click event */
      f.parentClick.call(parent, {ctrlKey:true});
    }
  };
})(window.fossil);