Modularing stuff, javascript logic in its own spot and not in onclick= elements
This commit is contained in:
parent
11f7d1ce2d
commit
143c916fde
28
view.xsl
28
view.xsl
|
@ -2,7 +2,32 @@
|
|||
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
<xsl:output method="html"/>
|
||||
|
||||
<xsl:variable name="global_script">
|
||||
<script type='text/javascript'>
|
||||
var more_txt = "▼ more";
|
||||
var less_txt = "▲ less";
|
||||
$(document).ready(function() {
|
||||
$(".morelessbutton").click(function() {
|
||||
var examples_div = $(this).parent().parent().find('.hidden').first();
|
||||
console.log(examples_div.is(":visible"));
|
||||
if(examples_div.is(":hidden")) {
|
||||
$(this).text(less_txt);
|
||||
} else {
|
||||
$(this).text(more_txt);
|
||||
}
|
||||
examples_div.slideToggle();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:variable name="button">
|
||||
|
||||
</xsl:variable>
|
||||
|
||||
|
||||
<xsl:template match="clanek">
|
||||
<xsl:copy-of select="$global_script" />
|
||||
<div style="font-family: Verdana, sans-serif; font-size: 1rem; line-height: 1.5em;">
|
||||
<xsl:apply-templates/>
|
||||
</div>
|
||||
|
@ -57,8 +82,7 @@
|
|||
<xsl:choose>
|
||||
<xsl:when test="count(../pomen)>1 and (skladenjske_skupine//text() | skladenjske_zveze//text() | stalne_zveze//text() | frazeoloske_zveze//text())">
|
||||
<div style="padding: 0.5em 0;">
|
||||
<a class="morelessbutton" style="" href="javascript:void(null)" onclick="$(this).parent().parent().find('.hidden').first().slideToggle(); $(this).parent().find('a').toggle();">▼ more</a>
|
||||
<a class="morelessbutton" style="display: none;" href="javascript:void(null)" onclick="$(this).parent().parent().find('.hidden').first().slideToggle(); $(this).parent().find('a').toggle();">▲ less</a>
|
||||
<a class="morelessbutton" href="javascript:void(null)">▼ more</a>
|
||||
</div>
|
||||
<div class="hidden" style="display: none">
|
||||
<xsl:apply-templates select="skladenjske_skupine | skladenjske_zveze | stalne_zveze | frazeoloske_zveze"/>
|
||||
|
|
Loading…
Reference in New Issue
Block a user