Commit 282fcde3 authored by Jérôme Chauveau's avatar Jérôme Chauveau
Browse files

toc + text scroll sync

parent fa259e01
Loading
Loading
Loading
Loading
+40 −3
Changes for certic-jats2html.xsl: 40 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -324,7 +324,7 @@
    <xsl:template match="title">

        <xsl:variable name="ancestors">
            <xs:value-of select="count(ancestor::sec)"/>
            <xs:value-of select="count(ancestor::sec) + count(ancestor::caption)"/>
        </xsl:variable>

        <xsl:variable name="n">
@@ -362,16 +362,53 @@

    </xsl:template>

    <xsl:template match="boxed-text">
        <div class="boxed-text">
            <xsl:apply-templates/>
        </div>
    </xsl:template>

    <!-- table -->
    <xsl:template match="table-wrap">
        <xsl:choose>
            <xsl:when test="label or title">
                <table>

                        <caption>
                <xsl:value-of select="label"/> -
                            <xsl:value-of select="label"/>
                            <xsl:text> </xsl:text>
                            <xsl:value-of select=".//title"/>
                        </caption>
            <xsl:apply-templates select=".//thead | .//tbody"></xsl:apply-templates>

                    <xsl:apply-templates></xsl:apply-templates>
                </table>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates></xsl:apply-templates>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


    <!-- list -->
    <xsl:template match="list[@list-type='ordered']">
        <ol>
            <xsl:apply-templates/>
        </ol>
    </xsl:template>

    <xsl:template match="list[@list-type='unordered' or not(@list-type)]">
        <ul>
            <xsl:apply-templates/>
        </ul>
    </xsl:template>

    <xsl:template match="list-item">
        <li><xsl:apply-templates/></li>
    </xsl:template>



    <xsl:template match="italic">
        <em>
            <xsl:apply-templates/>
+24
Changes for resources/javascript/xml2html.js: 24 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -10,8 +10,32 @@ window.addEventListener('DOMContentLoaded', (event) => {
    //footnotes binding
    bindFootnotes();

    //toc hightlighing on scroll
    document.querySelector('.left-contents').addEventListener("scroll", () => {
        let scrollTop = document.querySelector('.left-contents').scrollTop;
        let anchors = document.querySelector('.article-wrap').querySelectorAll('h2, h3, h4');
        for (let i = 0; i < anchors.length; i++){
            let tocItemRef = '#' + anchors[i].getAttribute('id');
            let tocItem = document.getElementById("toc-contents").querySelector("a[href='"+tocItemRef+"']");
            if(!tocItem)
                continue;
            //console.log(anchors[i].offsetTop, anchors[i].clientHeight)
            if (scrollTop + 100> anchors[i].offsetTop) {
                document.getElementById("toc-contents").querySelectorAll('a').forEach(
                    (a) => a.classList.remove('active')
                )
                tocItem.classList.add('active');
            }
        }
    });

});






function openTab(tabName) {
    let i;
    let tabs = document.querySelectorAll(".content-tab");
+44 −9
Changes for resources/styles/article.css: 44 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ body.dark{
}

.wrap {
    padding-top: calc(var(--nav-height));
    /*padding-top: calc(var(--nav-height));*/
    font-family: "Noto Sans",-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif;
    border-top: 1px solid black;
}
@@ -123,6 +123,10 @@ section.back{
    line-height: normal;
    padding-top:5px;
}

.article-wrap ul, .article-wrap ol{
    margin-left: 40px;
}
/*.left-contents section.body, .left-contents h1{*/
    /*width: 65%;*/
/*}*/
@@ -194,6 +198,7 @@ section.front ol, section.front ol {
    border-color: var(--dark-theme-txt);
}


section.body p{
    margin-top:10px ;
    line-height: 150% ;
@@ -259,21 +264,27 @@ section.body {
    counter-reset: section;
}

section.body  h2{
section.body  h2:not(div.boxed-text *){
    counter-reset: subsection;
}
section.body h3{
section.body h3:not(div.boxed-text *){
    counter-reset: subsubsection;
}
section.body h2:before{
section.body h4:not(div.boxed-text *){
    counter-reset: subsubsubsection;
}
section.body h2:not(div.boxed-text *):before{
    counter-increment: section;
    content: counter(section) ". ";
}

section.body h3:before{
section.body h3:not(div.boxed-text *):before{
    counter-increment: subsection;
    content: counter(section)"."counter(subsection)" ";
}
section.body h4:not(div.boxed-text *):before{
    counter-increment: subsubsection;
    content: counter(section)"."counter(subsection)"."counter(subsubsection)" ";
}

/************/

@@ -283,6 +294,9 @@ section.body h3:before{
#toc a {
    color: black;
    text-decoration: none;
   /* padding-left: 5px;
    padding-right: 5px;*/
    /*display: inline-block;*/
}

#toc a:hover{
@@ -293,16 +307,32 @@ section.body h3:before{
    color: var(--dark-theme-txt);
}

#toc a.active {
    color: white;
    background-color: black;
    padding-left: 5px;
    padding-right: 5px;
}

.dark #toc a.active {
    color: var(--dark-theme-bg);
    background-color: var(--dark-theme-txt);
}

/***********/
span.fn-call, sup { /** must not affect line height **/
    font-size: .60em;
    vertical-align: 0.65em;
    line-height: 0;
}

span.fn-call {
    font-variant-position: super;
    /*font-variant-position: super;*/
    color: var(--third-color);
    cursor: pointer;
}

#footnotes ul {
    /*margin-left: 50px;*/
    /*margin-top:20px;*/
    list-style-type: none;
}

@@ -397,3 +427,8 @@ span.fn-call {
    margin-left:5px;
    content: "·";
}
/******************************/
div.boxed-text{
    border: 1px solid var(--grey-color);
    padding: 15px;
}