Ignore:
Timestamp:
2022-02-02T11:26:41+13:00 (2 years ago)
Author:
cstephen
Message:

WMTB Interface: Implemented a navigation bar on the left side of the content and removed the existing top-bar navigation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/wmtb/transform/layouts/main.xsl

    r35280 r36036  
    9898        <div class="container wrapper-old col2" id="browse-search-bars">
    9999          <div id="topbar">
    100             <div id="topnav">
    101               <ul>
    102             <xsl:call-template name="navBar"/>
    103               </ul>
    104             </div>
    105             <!--**********************************************************************-->
    106100            <xsl:choose>
    107101              <xsl:when test="page/pageRequest/@subaction='home'">
     
    127121      <!--<hr class="spacer" />-->
    128122      <div class="outer">
     123            <xsl:if test="page/pageResponse/collection">
     124                <xsl:attribute name="class">outer collectionDisplay</xsl:attribute>
     125                <xsl:call-template name="sideNavBar"/>
     126            </xsl:if>
     127         
    129128        <div id="gs_content" class="container">
    130129          <xsl:apply-templates select="/page"/>             
     
    138137      </div> <!-- end shifted-frame -->
    139138      </div> <!-- end wrapper-->
    140     </body>
    141 </html>
     139        </body>
     140    </html>
    142141</xsl:template>
    143142
    144    
    145 <xsl:template name="navBar">
    146 <xsl:choose>
    147   <xsl:when test="page/pageResponse/collection">
    148     <!-- Using select statement to count only non-empty elements, is harder than testing
    149          for non-empty elements. Solution of using normalize-space() is from
    150          https://stackoverflow.com/questions/31602369/xsl-return-only-the-first-non-empty-element
    151     -->
    152     <xsl:variable name="count" select="count(/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier/displayItem[@name = 'name'][normalize-space()])"/>
    153     <xsl:variable name="currentPage" select="page/pageRequest/@fullURL"/>
    154 
    155 <xsl:call-template name="loginLinks"/>
    156 <li><a href="{$library_name}">DL Six Pou</a></li>
    157 <li>
    158 <xsl:if test="page/pageRequest/@subaction='about'"><xsl:attribute name="class">active</xsl:attribute></xsl:if>
    159 <a href="{$library_name}/collection/{$collNameChecked}/page/about">About</a>
    160 </li>
    161 
    162 <xsl:choose>
    163 <xsl:when test="$count > 3">
    164 <!--<li><a href="{$currentPage}">Browse</a>-->
    165 <li>Browse by:
    166 <ul class="drop-down-list">
    167 <xsl:call-template name="Browsing"/>
    168 </ul>
    169 </li>
    170 </xsl:when>
    171 <xsl:otherwise>
    172 <li>Browse by:</li>
    173 <xsl:call-template name="Browsing"/>
    174 <hr class="spacer"/>
    175 </xsl:otherwise>
    176 </xsl:choose>
     143<xsl:template name="sideNavBar">
     144  <div class="side-navbar">
     145        <!--
     146            Using select statement to count only non-empty elements, is harder than testing
     147            for non-empty elements. Solution of using normalize-space() is from
     148            https://stackoverflow.com/questions/31602369/xsl-return-only-the-first-non-empty-element
     149        -->
     150        <xsl:variable name="classifierCount" select="count(/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier/displayItem[@name = 'name'][normalize-space()])"/>
     151
     152        <!-- TODO: Hardcoded strings! -->
     153
     154        <a href="{$library_name}">Our Six Pou</a>
     155
     156        <a href="{$library_name}/collection/{$collNameChecked}/page/about">
     157            <xsl:if test="page/pageRequest/@subaction='about'">
     158                <xsl:attribute name="class">active</xsl:attribute>
     159            </xsl:if>
     160
     161            About Collection
     162        </a>
     163
     164        <hr class="side-navbar-separator" />
     165
     166        <xsl:if test="$classifierCount > 0">
     167            <span>Browse by:</span>
     168            <ul>
     169                <xsl:call-template name="listBrowsingClassifiers"/>
     170            </ul>
     171        </xsl:if>
     172
     173        <!--Login link is disabled, as it was determined to be confusing with Whakatohea's existing login elements -->
     174        <!-- <hr class="side-navbar-separator" />
     175        <xsl:call-template name="loginLinks"/> -->
     176    </div>
     177</xsl:template>
     178
    177179<!--
    178 <xsl:if test="/page/pageResponse/collection/serviceList/service/@type='query'">
    179 <li><a href="{$currentPage}">Search</a>
    180 <ul>
    181 <xsl:for-each select="/page/pageResponse/collection/serviceList/service[@type='query']">
    182 <xsl:variable name="search" select="@name"/>
    183 <xsl:variable name="search_name" select="displayItem[@name='name']"/>
    184 <li><a href="{$library_name}/collection/{$collNameChecked}/search/{$search}"><xsl:value-of select="$search_name"/></a></li>
    185 </xsl:for-each>
    186 </ul>
    187 </li>
    188 </xsl:if>
     180    This was in the old navbar. Might come in useful?
     181
     182    <xsl:variable name="currentPage" select="page/pageRequest/@fullURL"/>
     183    <xsl:if test="/page/pageResponse/collection/serviceList/service/@type='query'">
     184        <li>
     185            <a href="{$currentPage}">Search</a>
     186            <ul>
     187                <xsl:for-each select="/page/pageResponse/collection/serviceList/service[@type='query']">
     188                    <xsl:variable name="search" select="@name"/>
     189                    <xsl:variable name="search_name" select="displayItem[@name='name']"/>
     190
     191                    <li>
     192                        <a href="{$library_name}/collection/{$collNameChecked}/search/{$search}">
     193                            <xsl:value-of select="$search_name"/>
     194                        </a>
     195                    </li>
     196                </xsl:for-each>
     197            </ul>
     198        </li>
     199    </xsl:if>
    189200-->
    190 </xsl:when>
    191 <xsl:otherwise> </xsl:otherwise>
    192 </xsl:choose>
    193 </xsl:template>
    194 
    195 <xsl:template name="Browsing">
     201
     202<!-- Builds a list of the named browsing classifiers that are defined in the response. -->
     203<xsl:template name="listBrowsingClassifiers">
    196204  <xsl:for-each select="/page/pageResponse/collection/serviceList/service[@name='ClassifierBrowse']/classifierList/classifier">
    197205    <xsl:choose>
    198       <!-- Only display browsing classifiers that have a name.
    199            Those that don't have a name are empty classifiers
    200            denoted by no value/empty value for displayItem name=name elements.
    201            Testing for non empty elements is easy: not() test. -->
     206      <!--
     207                Only display browsing classifiers that have a name.
     208                Those that don't have a name are empty classifiers
     209                denoted by no value/empty value for displayItem name=name elements.
     210                Testing for non empty elements is easy: not() test.
     211            -->
    202212      <xsl:when test="not(displayItem[@name='name'] ='')">
    203         <li>
    204             <xsl:choose>
    205             <!-- If this tab is selected then colour it differently -->
    206                 <xsl:when test="util:contains(/page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value, @name)">
    207                 <xsl:attribute name='class'>active</xsl:attribute>
    208                 </xsl:when>
    209                 <xsl:otherwise> </xsl:otherwise>
    210             </xsl:choose>
    211             <a>
    212                 <!-- Add a title element to the <a> tag if a description exists for this classifier -->
    213                 <xsl:if test="displayItem[@name='description']">
    214                     <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
    215                 </xsl:if>
    216 
    217                 <!-- Add the href element to the <a> tag -->
    218                 <xsl:choose>
    219                     <xsl:when test="@name">
    220                         <xsl:attribute name="href"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>/browse/<xsl:value-of select="@name"/></xsl:attribute>
    221                     </xsl:when>
    222                     <xsl:otherwise>
    223                         <xsl:attribute name="href"><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>/browse/1</xsl:attribute>
    224                     </xsl:otherwise>
    225                 </xsl:choose>
    226 
    227                 <!-- Add the actual text of the <a> tag -->
    228                 <xsl:value-of select="displayItem[@name='name']"/>
    229             </a>
    230         </li>
    231           </xsl:when>
    232            </xsl:choose>
     213                <li>
     214                    <a>
     215                        <!-- Indicates that this classifier's content is being displayed -->
     216                        <xsl:if test="util:contains(/page/pageRequest/paramList/param[@name = 'cl' and /page/pageRequest/@action = 'b']/@value, @name)">
     217                            <xsl:attribute name="class">active</xsl:attribute>
     218                        </xsl:if>
     219
     220                        <!-- Add a title element to the <a> tag if a description exists for this classifier -->
     221                        <xsl:if test="displayItem[@name='description']">
     222                            <xsl:attribute name='title'><xsl:value-of select="displayItem[@name='description']"/></xsl:attribute>
     223                        </xsl:if>
     224
     225                        <!-- Add the href element to the <a> tag -->
     226                        <xsl:choose>
     227                            <xsl:when test="@name">
     228                                <xsl:attribute name="href">
     229                                    <xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>/browse/<xsl:value-of select="@name"/>
     230                                </xsl:attribute>
     231                            </xsl:when>
     232                            <xsl:otherwise>
     233                                <xsl:attribute name="href">
     234                                    <xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="/page/pageResponse/collection[@name=$collNameChecked]/@name"/>/browse/1
     235                                </xsl:attribute>
     236                            </xsl:otherwise>
     237                        </xsl:choose>
     238
     239                        <!-- Add the actual text of the <a> tag -->
     240                        <xsl:value-of select="displayItem[@name='name']"/>
     241                    </a>
     242                </li>
     243            </xsl:when>
     244        </xsl:choose>
    233245    </xsl:for-each>
    234246</xsl:template>
Note: See TracChangeset for help on using the changeset viewer.