Created
August 20, 2019 21:03
-
-
Save craigtommola/2af935355a903b938520cec06b17bb4d to your computer and use it in GitHub Desktop.
Accordions with Subheading and Pre-Expansion with Named Anchor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
if(window.location.hash) { | |
var target = $(window.location.hash); | |
var accordion = $(target).parent().prev("dt"); | |
$(accordion).addClass("expanded"); | |
$(accordion).next("dd").slideDown(); | |
$('html, body').animate({scrollTop: target.offset().top - 200}, | |
500); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dl.definitions dt dfn span.vertical { | |
display: block; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- S2. DL Accordion List --> | |
<xsl:template match="table[@class='ou_accordion']" > | |
<dl class="definitions"> | |
<!-- for each content row --> | |
<xsl:for-each select="tbody/tr[position() mod 2 =0]"> | |
<dt class="accordion-term"> | |
<dfn> | |
<!-- This line watches for a "pseudo-tag" using underscores: _subhead_ ... _/subhead_ and converts to styled span tags --> | |
<xsl:value-of select="replace(replace(preceding-sibling::tr[1]/element(), '_subhead_','<span class="vertical">'), '_/subhead_', '</span>')" disable-output-escaping="yes"/> | |
</dfn> | |
</dt> | |
<dd class="accordion-desc"> | |
<a> | |
<xsl:attribute name="id"> | |
<xsl:value-of select="lower-case(translate(normalize-space(string-join(replace(translate(substring-before(preceding-sibling::tr[1]/element(),'_subhead_'), '’', ''),'[^a-zA-Z0-9]', ' '))), ' ,', '-'))"/> | |
</xsl:attribute> | |
<xsl:attribute name="title"> | |
<xsl:value-of select="replace(substring-before(preceding-sibling::tr[1]/element(),'_subhead_'), ' ',' ')"/> | |
</xsl:attribute> | |
</a> | |
<!-- current row copy tr or td --> | |
<xsl:apply-templates select="element()/node()"/> | |
</dd> | |
</xsl:for-each> | |
</dl><!-- /.definitions --> | |
</xsl:template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment