Simplify the log tree implementation a bit

In particular use the :last-child selector, which is non-standard but
supported by all major browsers.
This commit is contained in:
Eelco Dolstra
2013-02-19 17:14:02 +01:00
parent 8c37f46955
commit 4266632eb0
3 changed files with 45 additions and 54 deletions

View File

@ -8,11 +8,11 @@
<xsl:template match="logfile">
<p>
<a href="javascript:" class="btn btn-info logTreeExpandAll"><i class="icon-plus icon-white"></i> Expand all</a>
<a href="javascript:" class="btn btn-info tree-expand-all"><i class="icon-plus icon-white"></i> Expand all</a>
<xsl:text> </xsl:text>
<a href="javascript:" class="btn btn-info logTreeCollapseAll"><i class="icon-minus icon-white"></i> Collapse all</a>
<a href="javascript:" class="btn btn-info tree-collapse-all"><i class="icon-minus icon-white"></i> Collapse all</a>
</p>
<ul class='toplevel'>
<ul class='tree'>
<xsl:for-each select='line|nest'>
<li>
<xsl:apply-templates select='.'/>
@ -21,7 +21,7 @@
</ul>
</xsl:template>
<xsl:template match="nest">
<!-- The tree should be collapsed by default if all children are
@ -29,40 +29,33 @@
<!-- <xsl:variable name="collapsed"
select="count(.//line[not(@priority = 3)]) = 0 or ./head[@priority = 3]" /> -->
<xsl:variable name="collapsed" select="count(.//*[@error]) = 0"/>
<xsl:variable name="style"><xsl:if test="$collapsed">display: none;</xsl:if></xsl:variable>
<xsl:variable name="arg"><xsl:choose><xsl:when test="$collapsed">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose></xsl:variable>
<xsl:if test="line|nest">
<a href="javascript:" class="logTreeToggle"></a>
<a href="javascript:" class="tree-toggle"></a>
<xsl:text> </xsl:text>
</xsl:if>
<xsl:apply-templates select='head'/>
<!-- Be careful to only generate <ul>s if there are <li>s, otherwise its malformed. -->
<xsl:if test="line|nest">
<ul class='nesting' style="{$style}">
<xsl:for-each select='line|nest'>
<!-- Is this the last line? If so, mark it as such so that it
can be rendered differently. -->
<xsl:variable name="class"><xsl:choose><xsl:when test="position() != last()">line</xsl:when><xsl:otherwise>lastline</xsl:otherwise></xsl:choose></xsl:variable>
<li class='{$class}'>
<span class='lineconn' />
<span class='linebody'>
<xsl:apply-templates select='.'/>
</span>
<ul class='subtree' style="{$style}">
<xsl:for-each select='line|nest'>
<li class='tree-line'>
<span class='tree-conn' />
<xsl:apply-templates select='.'/>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="head|line">
<span class="code">
<xsl:if test="@error">
@ -78,12 +71,12 @@
</span>
</xsl:template>
<xsl:template match="storeref">
<em class='storeref'>
<span class='popup'><xsl:apply-templates/></span>
<span class='elided'>/...</span><xsl:apply-templates select='name'/><xsl:apply-templates select='path'/>
</em>
</xsl:template>
</xsl:stylesheet>