<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0" 
    xmlns:eg="http://www.tei-c.org/ns/Examples"
    xmlns:tei="http://www.tei-c.org/ns/1.0" 
    xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
    xmlns:exsl="http://exslt.org/common"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    extension-element-prefixes="exsl msxsl"
    xmlns="http://www.w3.org/1999/xhtml" 
    xmlns:html="http://www.w3.org/1999/xhtml" 
    exclude-result-prefixes="xsl tei xd eg fn #default">
    
    <!-- import teibp.xsl, which allows templates, 
         variables, and parameters from teibp.xsl 
         to be overridden here. -->
    <xsl:import href="teibp.xsl"/>
    
    <xsl:variable name="omekaItemURL" select="//tei:publicationStmt/tei:ab"/>
    
    <xsl:param name="pbNote"><text>p. </text></xsl:param>
    
    <xsl:param name="transcription" select="concat($filePrefix,'/css/transcription.css')"/>
    <xsl:param name="edition" select="concat($filePrefix,'/css/edition.css')"/>
    <xsl:param name="edition_markup" select="concat($filePrefix,'/css/edition_markup.css')"/>
    <xsl:param name="edition_semantic" select="concat($filePrefix,'/css/edition_semantic.css')"/>
    <!-- The following tells selector which to use  -->
    <xsl:param name="switchCSS" select="concat($filePrefix,'/css/edition.css')"/>


    <!-- The following creates the CSS switching toolbox. It overrides the same in teibp.xsl-->
     <xsl:template name="teibpToolbox">
        <div id="teibpToolbox">
            <div>
                <!-- <h1>Display Options</h1> -->
                <table>
                    <tr><td>
                <input type="checkbox" id="pbToggle" checked="true"/> 
                 <!--   </td>
                        <td> -->
                        <label for="pbToggle" class="tooltip">Images <seg class="tooltiptext">Show document images</seg></label>
                    </td>
     
                        
                
                <!-- this is what I'm adding, 11-24-20 -->
                 
                <!--
                <label for="headNoteToggle">Hide head note</label>
                <input type="checkbox" id="headNoteToggle" />
                -->
                <!-- end addition -->
                
                <!-- this is what I'm adding -->
                        <!--
                        <td>
                            <input type="checkbox" id="edNoteToggle" checked="true"/> 
                        </td>
                        
                        <td>
                            <label for="edNoteToggle">Editorial notes</label>
                        </td>
                        -->
                       
                        

                        <!--
                <td>
                    <input type="checkbox" id="noteToggle" checked="true"/> 
                </td>
                        <td>
                <label for="noteToggle">Annotations</label>
                </td>
                -->
                <!-- end addition -->
                <td>
                    <!--
                    <h3>Select Text View:</h3>
                    -->
                    <span class="tooltip"> <seg class="tooltiptext">Select text view</seg>
                    <select style="display:inline;" id="themeBox" onchange="switchTextView(this);" >
                        <option value="{$edition}">Reading</option>
                        <option value="{$edition_markup}">Intermediate</option>
                        <option value="{$edition_semantic}">Semantic</option>
                        <option value="{$transcription}">Transcription</option>
                    </select>           </span>
            </td>
               <!--     </tr>
  
                </table>  -->
                        <!-- add --> <td>
                <div n="readingVersionKey">
                    <table>
                        <tr>
                    <td>
                        <input type="checkbox" id="allNoteToggle" checked="true"/> 
                    </td>
                    <td>
                        <label for="allNoteToggle" class="tooltip">Notes<seg class="tooltiptext">Show all notes</seg>
                        </label>
                    </td>
                        <td>
                    
                    <div n="readingVersionNoteList" style="center" >
                    <table>
                        <tr>
                            <td id="geoNoteTD">
                        <input type="checkbox" id="geoNoteToggle" checked="true"/> 
                                <!--     </td>
                    <td>-->
                                <label for="geoNoteToggle" class="tooltip">Geo.<seg class="tooltiptext">Geographical notes</seg></label>
                    </td>
                    
                    <td id="histNoteTD">
                        <input type="checkbox" id="histNoteToggle" checked="true"/> 
               <!--     </td>
                    <td>-->
                        <label for="histNoteToggle" class="tooltip">Hist.<seg class="tooltiptext">Historical notes</seg></label>
                    </td>
                    
                            <td id="bioNoteTD">
                        <input type="checkbox" id="bioNoteToggle" checked="true"/> 
                                <!--     </td>
                    <td>-->
                                <label for="bioNoteToggle" class="tooltip">Bio.<seg class="tooltiptext">Biographical notes</seg></label>
                    </td>
                    
                            <td id="lexNoteTD"> 
                        <input type="checkbox" id="lexNoteToggle" checked="true"/> 
                                <!--     </td>
                    <td>-->
                                <label for="lexNoteToggle" class="tooltip">Lex.<seg class="tooltiptext">Lexical notes</seg></label>
                    </td>
                    
                            <td id="geneticNoteTD">
                        <input type="checkbox" id="geneticNoteToggle" checked="true"/> 
                                <!--     </td>
                    <td>-->
                                <label for="geneticNoteToggle" class="tooltip">Gen.<seg class="tooltiptext">Genetic notes</seg></label>
                    </td>
                    
                            <td id="generalNoteTD">
                        <input type="checkbox" id="generalNoteToggle" checked="true"/> 
                                <!--     </td>
                    <td>-->
                                <label for="generalNoteToggle" class="tooltip">Misc.<seg class="tooltiptext">Miscellaneous notes</seg></label>
                    </td>
                            
                        </tr>
                    </table>
                    </div>
                    </td>
                            
                </tr>
                </table> 
             
                
                </div> 
                        
                            
                <div n="transcriptionKey"><table><tr>
                    <td>
                        <input type="checkbox" id="transNoteToggle" checked="true"/> 
                    </td>
                    <td>
                        <label for="transNoteToggle">Notes</label>
                    </td>
                    <td><spacer><!-- trying to create space --></spacer></td>
                    <td id="transUnclearTD">difficult to read</td><td id="transSicTD">thus in original</td><td id="transSuppliedTD">added by editor</td>
                </tr></table></div>
                
       
                            
                            <div n="intermediateKey"><table><tr>
                                <td id="intermediateSicTD">Thus in original</td>
                                <td id="intermediateCorrTD">corrected</td>
                                <td id="intermediateOrigTD">original form</td>
                                <td id="intermediateRegTD">regularized form</td>
                                <td id="intermediateAbbrTD">abbreviation</td>
                                <td id="intermediateExpanTD">expansion of abbreviation</td>
                            </tr></table></div>
                
                            <div n="semanticKey"><table><tr>
                                <td id="semanticPersonTD"><name type="person">person</name></td>
                                <td id="semanticPlaceTD"><name type="place">place</name></td>
                                <td id="semanticOrganizationTD"><name type="institution">organization</name></td>
                                <td id="semanticEventTD"><name type="event">event</name></td>
                                <td id="semanticDateTD">date</td>
                            </tr></table></div>
                
                            </td>
                        </tr>
                    </table>
            </div>
        </div>
        
         
        
    </xsl:template>

    <!-- This constructs the pretend-HTML head of the document.  The main change from teibp.xsl is that I've added a javascript function switchTextView(theme) and a CSS line calling $switchCSS from above. -->
    <xsl:template name="htmlHead">
        <head>
            <meta charset="UTF-8"/>
            <link id="maincss" rel="stylesheet" type="text/css" href="{$teibpCSS}"/>
            <link id="customcss" rel="stylesheet" type="text/css" href="{$customCSS}"/>
            <link id="switchcss" rel="stylesheet" type="text/css" href="{$switchCSS}" />
            <!-- I am adding this line to try to get refs to open in same window. not working -->
            <base target="_self"/>
            <script type="text/javascript" src="{$jqueryJS}"></script>
            <script type="text/javascript" src="{$jqueryBlockUIJS}"></script>
            <script type="text/javascript" src="{$teibpJS}"></script>
            <script type="text/javascript">
                $(document).ready(function() {
                    $("html > head > title").text($("TEI > teiHeader > fileDesc > titleStmt > title:first").text());
                    $.unblockUI();  
                });
                <!-- cm adding 
                $(document).ready(function() {
                $("html > head > title").text($("TEI > teiHeader > fileDesc > publicationStmt > p").text());
                $.unblockUI();  
                });
                
                 end cm add -->
                function switchTextView(theme) {
                    document.getElementById('switchcss').href=theme.options[theme.selectedIndex].value;
                }
            </script>
            <xsl:call-template name="tagUsage2style"/>
            <xsl:call-template name="rendition2style"/>
            <title><!-- don't leave empty. --></title>
        </head>
    </xsl:template>
    
    <!-- I have copied this from teipb.xsl and added target="_self", to try to open links in same window, but not working) -->
    <xd:doc>
        <xd:desc>
            <xd:p>Transforms TEI ref element to html a (link) element. </xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="tei:ref[@target]" priority="99">
        <a href="{@target}" target="_self">
            <xsl:apply-templates select="@*"/>
            <xsl:call-template name="rendition"/>
            <xsl:apply-templates select="node()"/>
        </a>
    </xsl:template>
    
    
    <xd:doc>
        <xd:desc>
            <xd:p>Wraps note inside span to enable tooltips, adds tooltip text</xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="tei:note">
            <span class="tooltip" type="wrapperForTooltip">
                <xsl:copy-of select="."/>
                
                <seg class="tooltiptext"><xsl:value-of select="@subtype"/> note</seg>
            </span> 
    </xsl:template>
    <!--
    
    <xd:doc>
        <xd:desc>
            <xd:p>Wraps orig inside span to enable tooltip, adds tooltip text</xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="tei:orig">
        <span class="tooltip" type="inlineWrapperForTooltip">
            <xsl:copy-of select="."/>
            <seg class="tooltiptext">original form</seg>
        </span> 
    </xsl:template>
    

    <xd:doc>
        <xd:desc>
            <xd:p>Wraps reg inside span to enable tooltip, adds tooltip text</xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="tei:reg">
        <span class="tooltip" type="inlineWrapperForTooltip">
            <xsl:copy-of select="."/>
            <seg class="tooltiptext">regularized form</seg>
        </span> 
    </xsl:template>
    
    <xd:doc>
        <xd:desc>
            <xd:p>Wraps sic inside span to enable tooltip, adds tooltip text</xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="tei:sic">
        <span class="tooltip" type="inlineWrapperForTooltip">
            <xsl:copy-of select="."/>
            <seg class="tooltiptext">thus in original</seg>
        </span> 
    </xsl:template>
    
    <xd:doc>
        <xd:desc>
            <xd:p>Wraps corr inside span to enable tooltip, adds tooltip text</xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="tei:corr">
        <span class="tooltip" type="inlineWrapperForTooltip">
            <xsl:copy-of select="."/>
            <seg class="tooltiptext">corrected</seg>
        </span> 
    </xsl:template>
    
    <xd:doc>
        <xd:desc>
            <xd:p>Wraps abbr inside span to enable tooltip, adds tooltip text</xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="tei:abbr">
        <span class="tooltip" type="inlineWrapperForTooltip">
            <xsl:copy-of select="."/>
            <seg class="tooltiptext">abbreviation</seg>
        </span> 
    </xsl:template>
    
    <xd:doc>
        <xd:desc>
            <xd:p>Wraps expan inside span to enable tooltip, adds tooltip text</xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="tei:expan">
        <span class="tooltip" type="inlineWrapperForTooltip">
            <xsl:copy-of select="."/>
            <seg class="tooltiptext">expansion of abbreviation</seg>
        </span> 
    </xsl:template>
    -->
    
    
  <!--
    
    <xsl:template match="tei:name">
        <span class="tooltip" type="inlineWrapperForTooltip">
            <xsl:copy-of select="."/>
            <xsl:choose>
            <xsl:when test="@type='person'">
                <seg class="tooltiptext"><xsl:value-of select="@type"/><spacer/><xsl:value-of select="@subtype"/></seg>
            </xsl:when>
            <xsl:when test="@type='place'">
                <seg class="tooltiptext"><xsl:value-of select="@type"/>: <xsl:value-of select="@subtype"/></seg>
            </xsl:when>
            <xsl:when test="@type='event'">
                <seg class="tooltiptext">event</seg>
            </xsl:when>
                <xsl:when test="@type='organization'">
                    <seg class="tooltiptext"><xsl:value-of select="@type"/>: <xsl:value-of select="@subtype"/></seg>
                </xsl:when>
            </xsl:choose>
        </span> 
    </xsl:template>
    
    
    
    <xd:doc>
        <xd:desc>
            <xd:p>Wraps date inside span to enable tooltips, adds tooltip text</xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="tei:date">
        <span class="tooltip" type="inlineWrapperForTooltip">
            <xsl:copy-of select="."/>
            
            <seg class="tooltiptext">date</seg>
        </span> 
    </xsl:template>
    -->
    

    <!-- I've copied this over and commented out function calls, to make title disappear from top of page. This works.
    <xsl:template match="tei:teiHeader//tei:title">
        <tei-title>
            <xsl:call-template name="addID"/>
            <xsl:apply-templates select="@*|node()"/> 
        </tei-title>
    </xsl:template>
-->
    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
        <xd:desc>
            <xd:p>Template for adding footer to html document.</xd:p>
        </xd:desc>
    </xd:doc>
    
    <xsl:variable name="htmlFooter">
        
        <footer> 
          <!--  <p><xsl:copy-of select="//tei:publicationStmt/tei:p"/></p> -->
            <p>Produced as part of the <a href="https://violamuse.unfdhi.org/">Viola Muse Digital Edition</a>, based at the University of North Florida. See the <a href="{string($omekaItemURL)}">complete metadata for this item</a>.</p>
            
            <!--<p><xsl:copy-of select="{$omekaItemURL}"/></p> -->
            <p> Powered by <a href="{$teibpHome}">TEI Boilerplate</a>. TEI Boilerplate is licensed under a <a
            href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0
                Unported License</a>. <!--<a href="http://creativecommons.org/licenses/by/3.0/"><img
                alt="Creative Commons License" style="border-width:0;"
                src="http://i.creativecommons.org/l/by/3.0/80x15.png"/></a>-->
        </p>
            
        </footer>
    </xsl:variable>
</xsl:stylesheet>