diff options
author | Shaun McCance <shaunm@gnome.org> | 2012-02-24 11:38:57 -0500 |
---|---|---|
committer | Shaun McCance <shaunm@gnome.org> | 2012-02-24 11:38:57 -0500 |
commit | f915d25097ffa7a8fc9f15170c64bbe58aab506d (patch) | |
tree | 8df1d7024ea5a043be922f8c8b0c4555faa361e2 | |
parent | dc0a2155414f318ad8cba05581900a727ed296ef (diff) | |
download | yelp-xsl-f915d25097ffa7a8fc9f15170c64bbe58aab506d.tar.gz |
mal2html-facets: Use common links template for facets
-rw-r--r-- | xslt/mallard/html/mal2html-api.xsl | 19 | ||||
-rw-r--r-- | xslt/mallard/html/mal2html-facets.xsl | 55 | ||||
-rw-r--r-- | xslt/mallard/html/mal2html-links.xsl | 145 |
3 files changed, 122 insertions, 97 deletions
diff --git a/xslt/mallard/html/mal2html-api.xsl b/xslt/mallard/html/mal2html-api.xsl index 3b7956f9..6a89fea2 100644 --- a/xslt/mallard/html/mal2html-api.xsl +++ b/xslt/mallard/html/mal2html-api.xsl @@ -99,6 +99,12 @@ the synopsis. <xsl:choose> <xsl:when test="$function/api:name"> <api:pre> + <div class="{$link/@class}"> + <xsl:for-each select="$link/@*"> + <xsl:if test="starts-with(name(.), 'data-')"> + <xsl:copy-of select="."/> + </xsl:if> + </xsl:for-each> <xsl:apply-templates mode="mal2html.inline.mode" select="$function/api:returns/api:type/node()"/> <xsl:variable name="tab" select="20 - string-length($function/api:returns/api:type)"/> <xsl:choose> @@ -172,6 +178,7 @@ the synopsis. <xsl:if test="not($function/api:arg or $function/api:varargs)"> <xsl:text>void);
</xsl:text> </xsl:if> + </div> </api:pre> </xsl:when> <xsl:otherwise> @@ -182,11 +189,13 @@ the synopsis. </xsl:for-each> </xsl:variable> <xsl:variable name="out" select="exsl:node-set($out_)"/> - <div class="synopsis"> - <pre class="contents"> - <xsl:copy-of select="$out/api:pre/node()"/> - </pre> - </div> + <xsl:if test="$out/api:pre"> + <div class="synopsis"> + <pre class="contents"> + <xsl:copy-of select="$out/api:pre/*"/> + </pre> + </div> + </xsl:if> <xsl:if test="$out/mal:link"> <xsl:call-template name="mal2html.links.ul"> <xsl:with-param name="node" select="$node"/> diff --git a/xslt/mallard/html/mal2html-facets.xsl b/xslt/mallard/html/mal2html-facets.xsl index 8d39bff1..8589f857 100644 --- a/xslt/mallard/html/mal2html-facets.xsl +++ b/xslt/mallard/html/mal2html-facets.xsl @@ -63,6 +63,7 @@ REMARK: Describe this template <xsl:value-of select="@values"/> </xsl:attribute> </input> + <xsl:text> </xsl:text> <span> <xsl:apply-templates mode="mal2html.inline.mode"/> </span> @@ -91,34 +92,32 @@ tag and VALUES is the values. --> <xsl:template name="mal2html.facets.links"> <xsl:param name="node" select="."/> - <div> - <xsl:variable name="facetlinks"> - <xsl:call-template name="mal.link.facetlinks"> - <xsl:with-param name="node" select="$node"/> - </xsl:call-template> - </xsl:variable> + <xsl:variable name="facetlinks"> + <xsl:call-template name="mal.link.facetlinks"> + <xsl:with-param name="node" select="$node"/> + </xsl:call-template> + </xsl:variable> + <xsl:variable name="links"> <xsl:for-each select="exsl:node-set($facetlinks)/mal:link"> - <xsl:sort select="mal:title[@type = 'sort']"/> - <xsl:variable name="link" select="."/> - <xsl:variable name="xref" select="@xref"/> - <xsl:for-each select="$mal.cache"> - <xsl:call-template name="_mal2html.links.divs.link"> - <xsl:with-param name="source" select="$node"/> - <xsl:with-param name="target" select="key('mal.cache.key', $xref)"/> - <xsl:with-param name="class" select="'facet'"/> - <xsl:with-param name="attrs"> - <a> - <xsl:for-each select="$link/facet:tag"> - <xsl:attribute name="data-facet-{@key}"> - <xsl:value-of select="@values"/> - </xsl:attribute> - </xsl:for-each> - </a> - </xsl:with-param> - </xsl:call-template> - </xsl:for-each> + <xsl:copy> + <xsl:copy-of select="@*"/> + <xsl:attribute name="class"> + <xsl:value-of select="'facet-link'"/> + </xsl:attribute> + <xsl:for-each select="facet:tag"> + <xsl:attribute name="data-facet-{@key}"> + <xsl:value-of select="@values"/> + </xsl:attribute> + </xsl:for-each> + </xsl:copy> </xsl:for-each> - </div> + </xsl:variable> + <xsl:call-template name="mal2html.links.links"> + <xsl:with-param name="node" select="($node | $node/mal:links[@type='facet'])[last()]"/> + <xsl:with-param name="links" select="exsl:node-set($links)/mal:link"/> + <xsl:with-param name="role" select="'facet'"/> + <xsl:with-param name="divs" select="true()"/> + </xsl:call-template> </xsl:template> @@ -133,7 +132,7 @@ $(document).ready(function () { $('input.facet').change(function () { var control = $(this); var content = control.closest('div.body,div.sect'); - content.find('a.facet').each(function () { + content.find('.facet-link').each(function () { var link = $(this); var facets = link.parents('div.body,div.sect').children('div.region').children('div.contents').children('div.facets').children('div.facet'); var visible = true; @@ -147,7 +146,7 @@ $(document).ready(function () { var key = input.attr('data-facet-key'); var values = input.attr('data-facet-values').split(' '); for (var k = 0; k < values.length; k++) { - if (link.is('a[data-facet-' + key + ' ~= "' + values[k] + '"]')) { + if (link.is('*[data-facet-' + key + ' ~= "' + values[k] + '"]')) { inputvis = true; break; } diff --git a/xslt/mallard/html/mal2html-links.xsl b/xslt/mallard/html/mal2html-links.xsl index 729af849..8727fc92 100644 --- a/xslt/mallard/html/mal2html-links.xsl +++ b/xslt/mallard/html/mal2html-links.xsl @@ -43,7 +43,7 @@ Mallard links element and implicitly. <!--**========================================================================== mal2html.links.links Output links in one of a number of formats. -:Revision:version="3.4" date="2012-02-23" status="final" +:Revision:version="3.4" date="2012-02-24" status="final" $node: A #{links}, #{page}, or #{section} element to link from. $depth: The depth level for the HTML header element. $links: A list of links, as from a template in !{mal-link}. @@ -53,7 +53,9 @@ $title: A default title to use if no #{title} element is found. This is a common formatting template used by some #{links} element handlers. It selects an appropriate way to render the links based on style hints and -extension attributes on ${node}. +extension attributes on ${node}. This template (or the templates it calls) +will pass through #{class} and #{data-*} attributes found on the #{link} +elements to the top-level container element of each output link. This template will handle sorting of the links. @@ -190,7 +192,7 @@ parameter will be used if provided. <xsl:variable name="bold" select="contains($style, ' bold ')"/> <xsl:call-template name="mal2html.links.ul"> <xsl:with-param name="links" select="$links"/> - <xsl:with-param name="role" select="'topic'"/> + <xsl:with-param name="role" select="$role"/> <xsl:with-param name="bold" select="$bold"/> <xsl:with-param name="nodesc" select="$nodesc"/> </xsl:call-template> @@ -227,6 +229,7 @@ This template will handle sorting of the links. <xsl:sort data-type="number" select="@groupsort"/> <xsl:sort select="mal:title[@type = 'sort']"/> <xsl:call-template name="mal2html.links.ul.li"> + <xsl:with-param name="link" select="."/> <xsl:with-param name="role" select="$role"/> <xsl:with-param name="bold" select="$bold"/> <xsl:with-param name="nodesc" select="$nodesc"/> @@ -240,6 +243,7 @@ This template will handle sorting of the links. mal2html.links.ul.li Output a list item with a link. :Revision:version="1.0" date="2011-06-15" status="final" +$link: The #{link} element from a list of links. $xref: An #{xref} string pointing to the target node. $role: A link role, used to select the appropriate title. $bold: Whether to bold the link titles. @@ -249,13 +253,19 @@ This template is called by *{mal2html.links.ul} to output a list item with a link for each target. --> <xsl:template name="mal2html.links.ul.li"> + <xsl:param name="link" select="/false"/> <xsl:param name="xref" select="@xref"/> <xsl:param name="role" select="''"/> <xsl:param name="bold" select="false()"/> <xsl:param name="nodesc" select="false()"/> <xsl:for-each select="$mal.cache"> <xsl:variable name="target" select="key('mal.cache.key', $xref)"/> - <li class="links"> + <li class="links {$link/@class}"> + <xsl:for-each select="$link/@*"> + <xsl:if test="starts-with(name(.), 'data-')"> + <xsl:copy-of select="."/> + </xsl:if> + </xsl:for-each> <a> <xsl:if test="$bold"> <xsl:attribute name="class"> @@ -799,7 +809,12 @@ when determining which links to output. <xsl:sort data-type="number" select="@groupsort"/> <xsl:sort select="mal:title[@type = 'sort']"/> <xsl:variable name="xref" select="@xref"/> - <div class="links-grid"> + <div class="links-grid {@class}"> + <xsl:for-each select="@*"> + <xsl:if test="starts-with(name(.), 'data-')"> + <xsl:copy-of select="."/> + </xsl:if> + </xsl:for-each> <xsl:for-each select="$mal.cache"> <xsl:variable name="target" select="key('mal.cache.key', $xref)"/> <div class="links-grid-link"><a> @@ -842,71 +857,62 @@ when determining which links to output. <xsl:for-each select="$links"> <xsl:sort data-type="number" select="@groupsort"/> <xsl:sort select="mal:title[@type = 'sort']"/> - <xsl:variable name="xref" select="@xref"/> <xsl:if test="($max = -1 or position() <= $max) and ($min = -1 or position() > $min)"> + <xsl:variable name="link" select="."/> + <xsl:variable name="xref" select="@xref"/> <xsl:for-each select="$mal.cache"> - <xsl:call-template name="_mal2html.links.divs.link"> - <xsl:with-param name="source" select="$node"/> - <xsl:with-param name="target" select="key('mal.cache.key', $xref)"/> - <xsl:with-param name="role" select="$role"/> - <xsl:with-param name="nodesc" select="$nodesc"/> - </xsl:call-template> + <xsl:variable name="target" select="key('mal.cache.key', $xref)"/> + <div class="linkdiv {$link/@class}"> + <xsl:for-each select="$link/@*"> + <xsl:if test="starts-with(name(.), 'data-')"> + <xsl:copy-of select="."/> + </xsl:if> + </xsl:for-each> + <a class="linkdiv"> + <xsl:attribute name="href"> + <xsl:call-template name="mal.link.target"> + <xsl:with-param name="node" select="$node"/> + <xsl:with-param name="xref" select="$target/@id"/> + </xsl:call-template> + </xsl:attribute> + <xsl:attribute name="title"> + <xsl:call-template name="mal.link.tooltip"> + <xsl:with-param name="node" select="$node"/> + <xsl:with-param name="xref" select="$target/@id"/> + <xsl:with-param name="role" select="$role"/> + </xsl:call-template> + </xsl:attribute> + <span class="title"> + <xsl:call-template name="mal.link.content"> + <xsl:with-param name="node" select="$node"/> + <xsl:with-param name="xref" select="$target/@id"/> + <xsl:with-param name="role" select="$role"/> + </xsl:call-template> + <xsl:call-template name="mal2html.editor.badge"> + <xsl:with-param name="target" select="$target"/> + </xsl:call-template> + </span> + <xsl:if test="not($nodesc) and $target/mal:info/mal:desc"> + <span class="linkdiv-dash"> + <xsl:text> — </xsl:text> + </span> + <span class="desc"> + <xsl:variable name="desc"> + <xsl:apply-templates mode="mal2html.inline.mode" + select="$target/mal:info/mal:desc[1]/node()"/> + </xsl:variable> + <xsl:apply-templates mode="_mal2html.links.divs.nolink.mode" + select="exsl:node-set($desc)"/> + </span> + </xsl:if> + </a> + </div> </xsl:for-each> </xsl:if> </xsl:for-each> </xsl:template> -<xsl:template name="_mal2html.links.divs.link"> - <xsl:param name="source" select="."/> - <xsl:param name="target"/> - <xsl:param name="class" select="''"/> - <xsl:param name="attrs"/> - <xsl:param name="role" select="''"/> - <xsl:param name="nodesc" select="false()"/> - <div class="linkdiv"> - <a class="{concat($class, ' linkdiv')}"> - <xsl:attribute name="href"> - <xsl:call-template name="mal.link.target"> - <xsl:with-param name="node" select="$source"/> - <xsl:with-param name="xref" select="$target/@id"/> - </xsl:call-template> - </xsl:attribute> - <xsl:attribute name="title"> - <xsl:call-template name="mal.link.tooltip"> - <xsl:with-param name="node" select="$source"/> - <xsl:with-param name="xref" select="$target/@id"/> - <xsl:with-param name="role" select="$role"/> - </xsl:call-template> - </xsl:attribute> - <xsl:copy-of select="exsl:node-set($attrs)/*/@*"/> - <span class="title"> - <xsl:call-template name="mal.link.content"> - <xsl:with-param name="node" select="$source"/> - <xsl:with-param name="xref" select="$target/@id"/> - <xsl:with-param name="role" select="$role"/> - </xsl:call-template> - <xsl:call-template name="mal2html.editor.badge"> - <xsl:with-param name="target" select="$target"/> - </xsl:call-template> - </span> - <xsl:if test="not($nodesc) and $target/mal:info/mal:desc"> - <span class="linkdiv-dash"> - <xsl:text> — </xsl:text> - </span> - <span class="desc"> - <xsl:variable name="desc"> - <xsl:apply-templates mode="mal2html.inline.mode" - select="$target/mal:info/mal:desc[1]/node()"/> - </xsl:variable> - <xsl:apply-templates mode="_mal2html.links.divs.nolink.mode" - select="exsl:node-set($desc)"/> - </span> - </xsl:if> - </a> - </div> -</xsl:template> - <!--#% _mal2html.links.divs.nolink.mode --> <xsl:template mode="_mal2html.links.divs.nolink.mode" match="*"> <xsl:copy> @@ -951,7 +957,12 @@ when determining which links to output. <xsl:variable name="link" select="."/> <xsl:for-each select="$mal.cache"> <xsl:variable name="target" select="key('mal.cache.key', $link/@xref)"/> - <div class="links-ui-grid"> + <div class="links-ui-grid {$link/@class}"> + <xsl:for-each select="$link/@*"> + <xsl:if test="starts-with(name(.), 'data-')"> + <xsl:copy-of select="."/> + </xsl:if> + </xsl:for-each> <xsl:variable name="thumbs" select="$target/mal:info/ui:thumb"/> <a> <xsl:attribute name="href"> @@ -1035,11 +1046,17 @@ when determining which links to output. <xsl:for-each select="$links"> <xsl:sort data-type="number" select="@groupsort"/> <xsl:sort select="mal:title[@type = 'sort']"/> + <xsl:variable name="link" select="."/> <xsl:variable name="xref" select="@xref"/> <xsl:for-each select="$mal.cache"> <xsl:variable name="target" select="key('mal.cache.key', $xref)"/> <xsl:variable name="thumbs" select="$target/mal:info/ui:thumb"/> - <li class="links"> + <li class="links {$link/@class}"> + <xsl:for-each select="$link/@*"> + <xsl:if test="starts-with(name(.), 'data-')"> + <xsl:copy-of select="."/> + </xsl:if> + </xsl:for-each> <a class="bold"> <xsl:attribute name="href"> <xsl:call-template name="mal.link.target"> |