Changeset 25660 for main


Ignore:
Timestamp:
2012-05-23T17:00:28+12:00 (12 years ago)
Author:
sjm84
Message:

Some fixes for document views that use an href instead of a docid, also removing the use of modes in document.xsl, also split document.xsl up and took the TOC parts of it out

Location:
main/trunk/greenstone3/web/interfaces/oran
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/oran/js/document_scripts.js

    r25641 r25660  
    2020    template +=       '<xsl:call-template name="sectionImage"/>';
    2121    template +=       '<div id="text' + sectionID + '">';
    22     template +=         '<xsl:apply-templates select="." mode="document"/>';
     22    template +=         '<xsl:call-template name="documentNodeContent"/>';
    2323    template +=       '</div>';
    2424    template +=     '</xsl:for-each>';
     
    334334    else if(gs.cgiParams.href && gs.cgiParams.href.length > 0)
    335335    {
    336         url += "&d=&lb=1&rl=1&href=" + gs.cgiParams.href;
     336        url += "&d=&alb=1&rl=1&href=" + gs.cgiParams.href;
    337337    }
    338338   
     
    378378    else if(gs.cgiParams.href && gs.cgiParams.href.length > 0)
    379379    {
    380         url += "&a=d&d=&lb=1&rl=1&href=" + gs.cgiParams.href;
     380        url += "&a=d&d=&alb=1&rl=1&href=" + gs.cgiParams.href;
    381381    }
    382382   
     
    566566    var ilt = "";
    567567    ilt += '<xsl:template match="/">';
    568     ilt +=   '<xsl:apply-templates select="/page/pageResponse/document/documentNode" mode="TOC"/>';
     568    ilt +=   '<xsl:for-each select="/page/pageResponse/document/documentNode">';
     569    ilt +=     '<xsl:call-template name="documentNodeTOC"/>';
     570    ilt +=   '</xsl:for-each>';
    569571    ilt += '</xsl:template>';
    570572
  • main/trunk/greenstone3/web/interfaces/oran/transform/pages/document.xsl

    r25593 r25660  
    1111    <!-- use the 'main' layout -->
    1212    <xsl:import href="layouts/main.xsl"/>
     13    <xsl:import href="layouts/toc.xsl"/>
    1314   
    1415    <!-- style includes global params interface_name, library_name -->
     
    8990                <xsl:choose>
    9091                    <xsl:when test="not(/page/pageRequest/paramList/param[@name = 'dmd']) or /page/pageRequest/paramList/param[@name = 'dmd']/@value = 'false'">
    91                         <xsl:apply-templates select="." mode="sectionTitleFormat"/>
     92                        <xsl:call-template name="sectionTitleFormat"/><!--<xsl:apply-templates select="." mode="sectionTitleFormat"/>-->
    9293                    </xsl:when>
    9394                    <xsl:otherwise>
    94                         <xsl:apply-templates select="." mode="sectionTitle"/>
     95                        <xsl:call-template name="sectionTitle"/><!--<xsl:apply-templates select="." mode="sectionTitle"/>-->
    9596                    </xsl:otherwise>
    9697                </xsl:choose>
     
    176177                </xsl:attribute>
    177178                <!-- Get the section content from the document template -->
    178                 <xsl:apply-templates select="." mode="document"/>
     179                <xsl:call-template name="documentNodeContent"/><!--xxx<xsl:apply-templates select="." mode="document"/>-->
    179180            </div>
    180181            <xsl:if test="documentNode">
     
    241242            </xsl:when>
    242243            <xsl:when test="$bookswitch = 'flashxml'">
    243                 <xsl:apply-templates mode="flashxml"/>
     244                <xsl:call-template name="documentNodeFlashXML"/><!--xxx<xsl:apply-templates mode="flashxml"/>-->
    244245            </xsl:when>
    245246            <xsl:when test="$bookswitch = 'on'">
     
    257258            <xsl:otherwise>
    258259                <xsl:choose>
    259                     <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or not(util:contains(/page/pageResponse/document/@selectedNode, '.'))">
     260                    <xsl:when test="/page/pageRequest/paramList/param[@name = 'alb']/@value = '1' or (string-length(/page/pageRequest/paramList/param[@name = 'd']/@value) > 0 and (/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or not(util:contains(/page/pageResponse/document/@selectedNode, '.'))))">
    260261                        <div id="gs-document">
    261262                            <xsl:call-template name="documentPre"/>
     
    340341    </xsl:template>
    341342   
    342     <xsl:template name="rightSidebar">
    343         <table id="rightSidebar">
    344             <tr><td>
    345                 <xsl:call-template name="viewOptions"/>
    346             </td></tr>
    347             <tr><td>
    348                 <div id="contentsArea">
    349                     <!-- show the berry basket if it's turned on -->
    350                     <gslib:berryBasket/>
    351 
    352                     <!-- Need to be in the context of the top-level documentNode rather than the document for the gsf:metadata call to work -->
    353                     <xsl:for-each select="documentNode">
    354                         <xsl:variable name="hasCover"><gsf:metadata name="hascover"/></xsl:variable>
    355                         <xsl:if test="$hasCover = '1'">
    356                             <!-- the book's cover image -->
    357                             <div id="coverImage">
    358                                 <xsl:attribute name="class">
    359                                     <xsl:choose>
    360                                         <xsl:when test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']) or /page/pageResponse/format[@type='display']/gsf:option[@name='coverImage']/@value='true'">visible</xsl:when>
    361                                         <xsl:otherwise>hidden</xsl:otherwise>   
    362                                     </xsl:choose>
    363                                 </xsl:attribute>
    364                                 <gslib:coverImage/><xsl:text> </xsl:text>
    365                             </div>
    366                         </xsl:if>
    367                     </xsl:for-each>
    368 
    369                     <!-- the contents (if enabled) -->
    370                     <xsl:choose>
    371                         <xsl:when test="/page/pageResponse/document/documentNode/@docType = 'paged'">
    372                             <gsf:image type="Thumb"/>
    373                             <!-- Table of contents will be dynamically retrieved when viewing a paged document -->
    374                             <script type="text/javascript">
    375                                 <xsl:text disable-output-escaping="yes">
    376                                     $(window).load(function()
    377                                     {
    378                                         retrieveTableOfContentsAndTitles();
    379                                     });
    380                                 </xsl:text>
    381                             </script>
    382                             <div id="tableOfContents"><xsl:text> </xsl:text></div>
    383                             <div id="tocLoadingImage" style="text-align:center;">
    384                                 <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/><xsl:text>...</xsl:text>
    385                             </div>
    386                             <table style="width:100%;"><tbody><tr>
    387                                 <td><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.filter_pages')"/><xsl:text>: </xsl:text><input id="filterText" type="text" size="27"/></td>
    388                             </tr></tbody></table>
    389                         </xsl:when>
    390                         <xsl:when test="not(/page/pageRequest/paramList/param[@name = 'ed']/@value = '1')">
    391                             <div id="tableOfContents">
    392                                 <div id="tocLoadingImage" style="text-align:center;">
    393                                     <img src="{util:getInterfaceText($interface_name, /page/@lang, 'loading_image')}"/><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.loading')"/><xsl:text>...</xsl:text>
    394                                 </div>
    395                             </div>
    396                             <script type="text/javascript">
    397                                 <xsl:text disable-output-escaping="yes">
    398                                     $(window).load(function()
    399                                     {
    400                                         retrieveFullTableOfContents();
    401                                     });
    402                                 </xsl:text>
    403                             </script>
    404                         </xsl:when>
    405                         <xsl:otherwise>
    406                             <div id="tableOfContents">
    407                                 <xsl:attribute name="class">
    408                                     <xsl:choose>
    409                                         <xsl:when test="count(//documentNode) > 1 and not(/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']) or /page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">visible</xsl:when>
    410                                         <xsl:otherwise>hidden</xsl:otherwise>
    411                                     </xsl:choose>
    412                                 </xsl:attribute>
    413                                 <xsl:apply-templates select="documentNode" mode="TOC"/>
    414                             </div>
    415                         </xsl:otherwise>
    416                     </xsl:choose>
    417                 </div>
    418             </td></tr>
    419         </table>
    420     </xsl:template>
    421    
    422343    <!-- Highlight annotations if requested -->
    423344    <xsl:template match="annotation">
     
    432353    </xsl:template>
    433354   
    434     <xsl:template match="documentNode" mode="sectionTitleFormat">
     355    <xsl:template name="sectionTitleFormat"><!--xxx<xsl:template match="documentNode" mode="sectionTitleFormat">-->
    435356        <p>
    436357            <xsl:attribute name="class"><xsl:value-of select="util:hashToDepthClass(@nodeID)"/> sectionHeader</xsl:attribute>
     
    443364            </xsl:if>
    444365            <!-- Display the title for the section regardless of whether automatic section numbering is turned on -->
    445             <span><xsl:apply-templates select="." mode="sectionTitle"/></span>
     366            <span><xsl:call-template name="sectionTitle"/><!--xxx<xsl:apply-templates select="." mode="sectionTitle"/>--></span>
    446367        </p>
    447368    </xsl:template>
    448369   
     370       
    449371    <!-- The default template for displaying section titles -->
    450     <xsl:template match="documentNode" mode="sectionTitle">
     372    <xsl:template name="sectionTitle"><!--xxx<xsl:template match="documentNode" mode="sectionTitle">-->
    451373        <xsl:value-of disable-output-escaping="yes" select="metadataList/metadata[@name = 'Title']"/>
    452374    </xsl:template>
     
    517439   
    518440    <!-- The default template for displaying the document content -->
    519     <xsl:template match="documentNode" mode="document">
     441    <xsl:template name="documentNodeContent"><!--xxx<xsl:template match="documentNode" mode="document">-->
    520442        <!-- Hides the "This document has no text." message -->
    521443        <xsl:variable name="noText"><gsf:metadata name="NoText"/></xsl:variable>
     
    531453                    </xsl:when>
    532454                    <xsl:otherwise>
    533                         <xsl:apply-templates select="."/>
     455                        <xsl:for-each select="nodeContent"><!--xxx<xsl:apply-templates select="."/>-->
     456                            <xsl:call-template name="documentNodeContent"/>
     457                        </xsl:for-each>
    534458                    </xsl:otherwise>
    535459                </xsl:choose>
     
    537461        </xsl:for-each><xsl:text> </xsl:text>
    538462    </xsl:template>
    539 
    540     <!-- This template is used to display the table of contents -->
    541     <xsl:template match="documentNode" mode="TOC">
    542 
    543         <!-- check if this is the currently selected table of contents item -->
    544         <xsl:variable name="isCurrent" select="nodeContent"/>
    545 
    546         <!-- formulate the link -->
    547         <xsl:variable name="contentsLink">
    548             <xsl:value-of select='$library_name'/>?a=d&amp;c=<gslib:collectionNameShort/>&amp;d=<xsl:value-of select='@nodeID'/><xsl:if test="documentNode">.pr</xsl:if>&amp;sib=1
    549         </xsl:variable>
    550 
    551         <ul>
    552             <table><tr>
    553                 <!-- The expand/collapse button (not displayed for the top level node) -->
    554                 <xsl:if test="util:hashToDepthClass(@nodeID) != 'sectionHeaderDepthTitle'">
    555                     <td>
    556                         <xsl:choose>
    557                             <xsl:when test="not(nodeContent and not(documentNode))">
    558                                 <img id="ttoggle{@nodeID}" onclick="toggleSection('{@nodeID}');" class="icon">
    559                                     <xsl:attribute name="src">
    560                                         <xsl:choose>
    561                                             <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
    562                                                 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
    563                                             </xsl:when>
    564                                             <xsl:otherwise>
    565                                                 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
    566                                             </xsl:otherwise>
    567                                         </xsl:choose>
    568                                     </xsl:attribute>
    569                                 </img>
    570                             </xsl:when>
    571                             <xsl:otherwise>
    572                                 <xsl:attribute name="class">emptyIcon</xsl:attribute>
    573                             </xsl:otherwise>
    574                         </xsl:choose>
    575                     </td>
    576                 </xsl:if>
    577                
    578                 <!-- The chapter/page icon -->
    579                 <td>
    580                     <img>
    581                         <xsl:if test="nodeContent and not(documentNode)">
    582                             <xsl:attribute name="class">leafNode</xsl:attribute>
    583                         </xsl:if>
    584                        
    585                         <xsl:attribute name="src">
    586                             <xsl:choose>
    587                                 <xsl:when test="nodeContent and not(documentNode)">
    588                                     <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'page_image')"/>
    589                                 </xsl:when>
    590                                 <xsl:otherwise>
    591                                     <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'chapter_image')"/>
    592                                 </xsl:otherwise>
    593                             </xsl:choose>
    594                         </xsl:attribute>
    595                     </img>
    596                 </td>
    597                
    598                 <!-- The section name, links to the section in the document -->
    599                 <td>               
    600                     <a id="toclink{@nodeID}">
    601                         <xsl:choose>
    602                             <xsl:when test="/page/pageResponse/document/@docType = 'paged'">
    603                                 <xsl:attribute name="href"><xsl:value-of select="$library_name"/>?a=d&amp;c=<xsl:value-of select="/page/pageResponse/collection/@name"/>&amp;d=<xsl:value-of select="@nodeID"/>&amp;dt=<xsl:value-of select="@docType"/>&amp;p.a=b&amp;p.s=<xsl:value-of select="/page/pageResponse/service/@name"/></xsl:attribute>
    604                             </xsl:when>
    605                             <xsl:otherwise>
    606                                 <xsl:attribute name="href">javascript:focusSection('<xsl:value-of select="@nodeID"/>');</xsl:attribute>
    607                             </xsl:otherwise>
    608                         </xsl:choose>
    609                         <xsl:if test="util:hashToSectionId(@nodeID)">
    610                             <xsl:value-of select="util:hashToSectionId(@nodeID)"/>
    611                             <xsl:text> </xsl:text>
    612                         </xsl:if>
    613                         <xsl:apply-templates select="." mode="sectionTitle"/>
    614                     </a>
    615                 </td>
    616             </tr></table>
    617        
    618             <!-- display any child items -->       
    619             <xsl:if test="documentNode">
    620                 <li id="toc{@nodeID}">
    621                     <xsl:attribute name="style">
    622                         <xsl:choose>
    623                             <xsl:when test="/page/pageRequest/paramList/param[@name = 'ed']/@value = '1' or /page/pageResponse/document/@selectedNode = @nodeID">
    624                                 <xsl:text>display:block;</xsl:text>
    625                             </xsl:when>
    626                             <xsl:otherwise>
    627                                 <xsl:text>display:none;</xsl:text>
    628                             </xsl:otherwise>
    629                         </xsl:choose>
    630                     </xsl:attribute>
    631                     <xsl:apply-templates select="documentNode" mode="TOC"/>
    632                 </li>
    633             </xsl:if>
    634            
    635         </ul>
    636     </xsl:template>
    637463   
    638464    <!-- Used to produce a version of the page in a format that can be read by the realistic books plugin -->
    639     <xsl:template match="documentNode" mode="flashxml">
     465    <xsl:template name="documentNodeFlashXML"><!--xxx<xsl:template match="documentNode" mode="flashxml">-->
    640466        <xsl:text disable-output-escaping="yes">
    641467            &lt;Section&gt;
     
    651477        <xsl:value-of select="normalize-space(nodeContent)" disable-output-escaping="yes"/>
    652478               
    653         <xsl:if test="documentNode">
    654             <xsl:apply-templates select="documentNode" mode="flashxml"/>
    655         </xsl:if>
     479        <xsl:for-each select="documentNode">
     480            <xsl:call-template name="documentNodeFlashXML"/><!--<xsl:apply-templates select="documentNode" mode="flashxml"/>-->
     481        </xsl:for-each>
    656482               
    657483        <xsl:text disable-output-escaping="yes">
     
    675501
    676502    <xsl:template match="/page"><xsl:apply-templates select="/page/pageResponse/document"/></xsl:template> <!-- this to be deleted eventually -->
    677    
    678     <xsl:template name="viewOptions">
    679         <table class="viewOptions ui-state-default ui-corner-all"><tr>
    680        
    681             <!-- Paged-image options -->
    682             <xsl:if test="count(//documentNode/metadataList/metadata[@name = 'Screen']) > 0 or /page/pageResponse/document/documentNode/@docType = 'paged'">
    683                 <td>
    684                     <select id="viewSelection" onchange="changeView();">
    685                         <xsl:choose>
    686                             <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'image'">
    687                                 <option>Default view</option>
    688                                 <option selected="true">Image view</option>
    689                                 <option>Text view</option>
    690                             </xsl:when>
    691                             <xsl:when test="/page/pageRequest/paramList/param[@name = 'view']/@value = 'text'">
    692                                 <option>Default view</option>
    693                                 <option>Image view</option>
    694                                 <option selected="true">Text view</option>
    695                             </xsl:when>
    696                             <xsl:otherwise>
    697                                 <option selected="true">Default view</option>
    698                                 <option>Image view</option>
    699                                 <option>Text view</option>
    700                             </xsl:otherwise>
    701                         </xsl:choose>
    702                     </select>
    703                 </td>
    704             </xsl:if>
    705        
    706             <!-- Realistic books link -->
    707             <xsl:if test="/page/pageResponse/collection[@name = $collName]/metadataList/metadata[@name = 'tidyoption'] = 'tidy'">
    708                 <td>
    709                     <img>
    710                         <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'realistic_books_image')"/></xsl:attribute>
    711                     </img>
    712                     <input id="rbOption" type="checkbox" onclick="bookInit();" class="optionCheckBox"/>
    713                 </td>
    714             </xsl:if>
    715            
    716             <!-- Highlight on/off button -->
    717             <xsl:if test="/page/pageRequest/paramList/param[@name = 'p.a']/@value = 'q' or /page/pageRequest/paramList/param[@name = 's1.query']">
    718                 <td>
    719                     <img>
    720                         <xsl:attribute name="src"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'highlight_image')"/></xsl:attribute>
    721                     </img>
    722                     <input id="highlightOption" type="checkbox" class="optionCheckBox">
    723                         <xsl:choose>
    724                             <xsl:when test="/page/pageRequest/paramList/param[@name = 'hl']/@value = 'on'">
    725                                 <xsl:attribute name="onclick">
    726                                     <xsl:text>removeHighlight();</xsl:text>
    727                                 </xsl:attribute>
    728                                 <xsl:attribute name="checked">true</xsl:attribute>
    729                             </xsl:when>
    730                             <xsl:otherwise>
    731                                 <xsl:attribute name="onclick">
    732                                     <xsl:text>addHighlight();</xsl:text>
    733                                 </xsl:attribute>
    734                             </xsl:otherwise>
    735                         </xsl:choose>
    736                     </input>
    737                 </td>
    738             </xsl:if>
    739             <td style="vertical-align:top; text-align:right;">
    740                 <xsl:if test="not(/page/pageResponse/format[@type='display']/gsf:option[@name='TOC']) or /page/pageResponse/format[@type='display']/gsf:option[@name='TOC']/@value='true'">
    741                     <span class="tableOfContentsTitle"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.table_of_contents')"/></span>
    742 
    743                     <a id="sidebarMinimizeButton" href="javascript:minimizeSidebar();" style="float: right; font-size:0.6em;">
    744                         <img class="icon" style="padding-top:3px;">
    745                             <xsl:attribute name="src">
    746                                 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'collapse_image')"/>
    747                             </xsl:attribute>
    748                         </img>
    749                     </a>
    750                     <a id="sidebarMaximizeButton" href="javascript:maximizeSidebar();" style="float: right; font-size:0.6em; display:none;">
    751                         <img class="icon" style="padding-top:3px;">
    752                             <xsl:attribute name="src">
    753                                 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'expand_image')"/>
    754                             </xsl:attribute>
    755                         </img>
    756                     </a>
    757                 </xsl:if>
    758             </td>
    759         </tr>
    760         <tr id="zoomOptions">
    761             <!-- This is invisible unless it is made visible by Javascript controlling the image zooming -->
    762             <xsl:attribute name="style">display: none;</xsl:attribute>
    763             <td style="width:40%;">
    764                 <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.zoom')"/><input id="zoomToggle" type="checkbox"/>
    765                 <script type="text/javascript">
    766                     <xsl:text disable-output-escaping="yes">
    767                         $("#zoomToggle").change(function()
    768                         {
    769                             _imageZoomEnabled = !_imageZoomEnabled;
    770                         });
    771                     </xsl:text>
    772                 </script>
    773             </td>
    774             <td style="width:60%;">
    775                 <div>
    776                     <div style="float:left; width:30%;"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'doc.zoom_size')"/><xsl:text>:</xsl:text></div>
    777                     <div id="zoomSlider" style="float:right; width:65%; height:5px; margin-top:6px;"><xsl:text> </xsl:text></div>
    778                     <script type="text/javascript">
    779                         <xsl:text disable-output-escaping="yes">
    780                             $("#zoomSlider").slider(
    781                             {
    782                                 change: function(event, ui)
    783                                 {
    784                                     var sliderValue = ui.value;
    785                                     var divs = document.getElementsByTagName("DIV");
    786                                     for(var i = 0; i &lt; divs.length; i++)
    787                                     {
    788                                         if(divs[i].getAttribute("id") &amp;&amp; divs[i].getAttribute("id").search(/^mover.*/) != -1)
    789                                         {
    790                                             divs[i].style.height = 200 + (2 * sliderValue) + "px";
    791                                             divs[i].style.width = 200 + (2 * sliderValue) + "px";
    792                                         }
    793                                     }
    794                                 }
    795                             });
    796                         </xsl:text>
    797                     </script>
    798                     <style>.ui-slider .ui-slider-handle{height:0.8em; width:1.0em;}</style>
    799                     <div style="float:clear;"><xsl:text> </xsl:text></div>
    800                 </div>
    801             </td>
    802         </tr>
    803         </table>   
    804     </xsl:template>
    805503   
    806504    <xsl:template name="documentPre">
Note: See TracChangeset for help on using the changeset viewer.