Changeset 37053


Ignore:
Timestamp:
2022-12-23T11:24:13+13:00 (16 months ago)
Author:
davidb
Message:

Several changes: main one is introducing some 'TopLevel' template rules, which here just go in to call the Wrapped versions. This has been done so when an interface wants to customize these rules, it doesn't have to copy over such a gargantuan rule; the commit also comments out some <br><br> tags, leaving it to CSS to create the space; there was also a recursively called block of XSL (to do with the right-side bar) that used 'id' attributes, however before the change it would generate multiple versions of the same 'id'. The code has been changed to use doc/section ID so the ids area always unique; some white-space indent changes also present

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl

    r37023 r37053  
    2020
    2121    <xsl:variable name="docID" select="/page/pageRequest/paramList/param[@name='d']/@value"/>
     22
     23    <!--
     24         The 'bookswitch' variable was invented for the Flash-based Realistic Books project:
     25
     26           * If set to 'on' then this triggers in JavaScript loadBook(), which creates a version
     27             of the document URL that sets 'bookswitch; to flashxml (&book=flashxml)
     28         The Flash plugin uses this version of the URL to load in the doc for the Flash plugin
     29
     30           * If not set, then defaults to 'off'
     31
     32               * Subsequent to its invention for Realistic Books, the book/bookswitch variable has
     33             been extended to other alternative (richly interative) views of the document, such
     34         as with the Mirador document viewer, for IIIF compliant books
     35    -->
    2236
    2337    <xsl:variable name="bookswitch">
     
    8397    <!-- content of a simple document. Will not be used for editing mode -->
    8498    <xsl:template name="documentContent">
    85         <div id="gs-document">
    86             <xsl:call-template name="documentPre"/>
    87             <xsl:call-template name="wrappedSectionImage"/>
    88             <div id="gs-document-text">
    89                 <xsl:call-template name="documentNodeText"/>
    90             </div>
    91             <xsl:call-template name="documentPost"/>
    92         </div>
     99      <div id="gs-document">
     100        <xsl:call-template name="documentPre"/>
     101        <xsl:call-template name="wrappedSectionImage"/>
     102        <div id="gs-document-text">
     103          <xsl:call-template name="documentNodeText"/>
     104        </div>
     105        <xsl:call-template name="documentPost"/>
     106      </div>
     107    </xsl:template>
     108
     109    <!-- For symmetry reasons, companion template to wrappedDocumentTopLevel -->
     110    <xsl:template name="documentContentTopLevel">
     111      <xsl:call-template name="documentContent"/>
    93112    </xsl:template>
    94113   
     
    108127
    109128    <xsl:template name="wrappedSectionTextForEditing">
    110         <br /><br />
     129        <!-- <br /><br /> --> <!-- **** better to do with CSS .sectionText -->
    111130        <div id="text{@nodeID}" class="sectionText" style="display:block;"><!-- *** -->
    112131                        <xsl:attribute name="contenteditable">
     
    118137
    119138    <xsl:template name="wrappedSectionText">
    120       <br /><br />
     139      <!-- <br /><br /> --> <!-- **** better to do with CSS .setionText -->
    121140     
    122141        <div id="text{@nodeID}" class="sectionText"><!-- *** -->
     
    401420    <!-- the page content -->
    402421    <xsl:template match="/page/pageResponse/document">
    403       <xsl:if test="$bookswitch = 'off'">
     422      <xsl:if test="$bookswitch = 'off' or ($bookswitch != 'on' and $bookswitch != 'flashxml')"> <!-- true when bookswitch=mirador, for example -->
    404423      <xsl:call-template name="javascriptForDocumentView"/>
    405424      <gslib:langfrag name="doc"/>
     
    409428          if(document.URL.indexOf("book=on") != -1)
    410429          {
    411           loadBook();
     430              loadBook();
    412431          }
    413432        </xsl:text>
     
    421440      </xsl:if>
    422441
    423         <xsl:if test="$bookswitch = 'off'">
     442        <xsl:if test="$bookswitch = 'off' or ($bookswitch != 'on' and $bookswitch != 'flashxml')">
    424443            <div id="bookdiv" style="visibility:hidden; height:0px; display:inline;"><xsl:text> </xsl:text></div>
    425444       
     
    437456              <script type="text/javascript">
    438457              if (keep_editing_controls_visible) {
    439               $(function() {
    440               moveScroller();
    441               });
     458                  $(function() {
     459                      moveScroller();
     460                  });
    442461              }
    443462            </script>   
     
    457476            <xsl:when test="$bookswitch = 'on'">
    458477                <div id="bookdiv" style="display:inline;"><xsl:text> </xsl:text></div>
    459                 <!-- *** in document-scripts.js *** -->
    460478                <script type="text/javascript">
    461479                    <xsl:text disable-output-escaping="yes">
    462480                        if(document.URL.indexOf("book=on") != -1)
    463481                        {
    464                             loadBook();
     482                            <!-- in document_scripts.js -->
     483                            loadBook();
    465484                        }
    466485                    </xsl:text>
     
    489508            <xsl:when test="@docType='simple'">
    490509                <xsl:call-template name="documentHeading"/><br/>
    491                 <xsl:call-template name="documentContent"/>
     510                <xsl:call-template name="documentContentTopLevel"/>
    492511                <br /><xsl:call-template name="userCommentsSection"/>
    493512            </xsl:when>
    494513            <xsl:otherwise> <!-- display the standard greenstone document -->
    495                 <xsl:call-template name="wrappedDocument"/>
     514                <xsl:call-template name="wrappedDocumentTopLevel"/>
    496515                <br /><xsl:call-template name="userCommentsSection"/>
    497516            </xsl:otherwise>
     
    588607        <div class="clear"><xsl:text> </xsl:text></div>
    589608    </xsl:template>
     609
     610    <!--
     611         The follow is a useful template to redefine in an interface/site/collection
     612         through which extra tests can be introduced to drive new document displays,
     613         such as the IIIF Manifest based Mirador viewer
     614    -->
     615    <xsl:template name="wrappedDocumentTopLevel">     
     616      <xsl:call-template name="wrappedDocument"/>
     617    </xsl:template>
    590618   
    591619    <xsl:template name="editBar">
     
    640668        <gsf:variable name="imageWidth"><gsf:metadata name="ImageWidth"/></gsf:variable>
    641669        <gsf:variable name="imageHeight"><gsf:metadata name="ImageHeight"/></gsf:variable>
     670        <gsf:variable name="docNodeID"><xsl:value-of select="@nodeID"/></gsf:variable> <!-- used to make each 'tidyDiv' unique -->
    642671
    643672        <xsl:choose>
    644673          <!-- **** Should the test of 'Source' perhaps be changed to 'Image' to be more consistent with usage else where for showing an web friendy Image-->
    645           <xsl:when test="metadataList/metadata[@name = 'Screen'] and metadataList/metadata[@name = 'Source'] and ($imageWidth div $screenImageWidth > 1.2) and (not(/page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']) or /page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']/@value='false')">
    646             <gsf:div id="tidyDiv" />
     674          <xsl:when test="metadataList/metadata[@name = 'Screen'] and (metadataList/metadata[@name = 'Source'] or metadataList/metadata[@name = 'Image']) and ($imageWidth div $screenImageWidth > 1.2) and (not(/page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']) or /page/pageResponse/format[@type='display']/gsf:option[@name='disableZoom']/@value='false')">
     675            <gsf:div id="tidyDiv-{@nodeID}" />
    647676            <!-- adding a div with clear:both when the image doesn't nicely fit in beside the side bar. Otherwise, the divs stays up, but the image moves down and everything looks and acts weird. -->
    648677            <script type="text/javascript">
     
    650679           
    651680            var containerWidth = document.getElementById("container").offsetWidth;
    652             var sidebarWidth = document.getElementById("rightSidebar").offsetWidth;
    653             if (containerWidth - sidebarWidth &lt; </xsl:text><xsl:value-of select="$screenImageWidth"/><xsl:text disable-output-escaping="yes">) {
    654               $("#tidyDiv").css("clear", "both");
     681            var rightSidebar = document.getElementById("rightSidebar");
     682            if (rightSidebar) {
     683                var rightSidebarWidth = rightSidebar.offsetWidth;
     684                if (containerWidth - rightSidebarWidth &lt; </xsl:text><xsl:value-of select="$screenImageWidth"/><xsl:text disable-output-escaping="yes">) {
     685                    $("#tidyDiv-"+gs.variables.docNodeID).css("clear", "both");
     686                }
    655687            }
    656688              </xsl:text>
Note: See TracChangeset for help on using the changeset viewer.