From 02661b1bfc7353e5b0bdb93cc2870831f1254460 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Fri, 5 May 2017 16:12:49 +0200 Subject: [PATCH] toggle answers and highlighting --- .../CustomLayer/webhelp/hdmextensions.xsl | 101 ++++++++++++++++++ ws/Docbook/CustomLayer/webhelp/webhelpHdm.xsl | 26 +++-- 2 files changed, 117 insertions(+), 10 deletions(-) create mode 100644 ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl diff --git a/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl b/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl new file mode 100644 index 000000000..03288826f --- /dev/null +++ b/ws/Docbook/CustomLayer/webhelp/hdmextensions.xsl @@ -0,0 +1,101 @@ +<?xml version="1.0" encoding="UTF-8"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:d="http://docbook.org/ns/docbook" + xmlns:m="http://www.w3.org/1998/Math/MathML" + xmlns="http://www.w3.org/1999/xhtml" + exclude-result-prefixes="d" + version="1.1"> + + <xsl:template name="user.webhelp.head.content"> + <xsl:param name="node"/> + + <script type="text/javascript"> <!-- goiks extension head start --> + function toggleDisplay(inputEl) { + divElem = nextSibling(inputEl); + if (divElem.style.visibility == 'hidden') { + divElem.style.visibility = 'visible'; + inputEl.setAttribute('value','-'); + } else { + divElem.style.visibility = 'hidden'; + inputEl.setAttribute('value','+'); + } + } + function nextSibling(n) { + x=n.nextSibling; + while (x.nodeType!=1) { + x=x.nextSibling; + } + return x; + } + </script> + + <xsl:if test="//m:math"> + <script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script> + <script src="https://prog.mi.hdm-stuttgart.de/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"> + <xsl:comment>Self closing tags disallowed!</xsl:comment> + </script> + </xsl:if> + </xsl:template> + + + <!--Allow for opening and closing of answers --> + + <xsl:template match="d:answer"> + <xsl:variable name="deflabel"> + <xsl:apply-templates select="." mode="qanda.defaultlabel"/> + </xsl:variable> + + <tr> + <xsl:apply-templates select="." mode="common.html.attributes"/> + <xsl:call-template name="id.attribute"/> + <td align="{$direction.align.start}" valign="top"> + <xsl:call-template name="anchor"/> + <xsl:variable name="answer.label"> + <xsl:apply-templates select="." mode="label.markup"/> + </xsl:variable> + <xsl:if test="string-length($answer.label) > 0"> + <p><strong> + <xsl:copy-of select="$answer.label"/> + </strong></p> + </xsl:if> + </td> + <td align="{$direction.align.start}" valign="top"> + <input onclick="toggleDisplay(this)" type="button" value="+"/> <!--goik: start "header" clickable answer modification --> + <div style="visibility:hidden;"> <!--goik: end "header" clickable answer modification --> + <xsl:apply-templates select="*[local-name(.) != 'label' and local-name(.) != 'qandaentry']"/> + <!-- * handle nested answer/qandaentry instances --> + <!-- * (bug 1509043 from Daniel Leidert) --> + <xsl:if test="descendant::d:question"> + <xsl:call-template name="process.qandaset"/> + </xsl:if> + </div> <!--goik: "footer" clickable answer modification --> + </td> + </tr> + </xsl:template> + + + <xsl:template match="m:*"> + <xsl:element name="{local-name()}"> + <xsl:copy-of select="@*"/> + <xsl:apply-templates/> + </xsl:element> + </xsl:template> + + <xsl:template match="d:videodata"> + <video controls="controls" preload="auto"> + <xsl:attribute name="title"> + <xsl:value-of select="normalize-space(../../../d:title)"/> + </xsl:attribute> + + <xsl:variable name="hdm_ImageFilename"> <!-- hdm_ prefix: do not mess with docbook! --> + <xsl:call-template name="mediaobject.filename"> + <xsl:with-param name="object" select=".."/> + </xsl:call-template> + </xsl:variable> + + <source src="{$hdm_ImageFilename}" type='video/webm' /> + <source src="{$hdm_ImageFilename}.mp4" type='video/mp4'/> + </video> + </xsl:template> + +</xsl:stylesheet> diff --git a/ws/Docbook/CustomLayer/webhelp/webhelpHdm.xsl b/ws/Docbook/CustomLayer/webhelp/webhelpHdm.xsl index dd77bf4ae..2f33aa937 100644 --- a/ws/Docbook/CustomLayer/webhelp/webhelpHdm.xsl +++ b/ws/Docbook/CustomLayer/webhelp/webhelpHdm.xsl @@ -1,14 +1,20 @@ <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" - xmlns:d="http://docbook.org/ns/docbook" - xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" - xmlns:exsl="http://exslt.org/common" - xmlns:set="http://exslt.org/sets" - version="1.0" - exclude-result-prefixes="doc exsl set d"> - -<xsl:import href="../../docbook-xsl/xhtml/chunk.xsl"/> -<xsl:import href="../../docbook-xsl/webhelp/xsl/webhelp-common.xsl"/> -<xsl:import href="../../docbook-xsl/webhelp/xsl/titlepage.templates.xsl"/> + xmlns:d="http://docbook.org/ns/docbook" + xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" + xmlns:exsl="http://exslt.org/common" + xmlns:set="http://exslt.org/sets" + version="1.0" + exclude-result-prefixes="doc exsl set d"> + + <xsl:import href="../../docbook-xsl/xhtml/chunk.xsl"/> + <xsl:import href="../../docbook-xsl/xhtml/highlight.xsl"/> + <xsl:import href="../../docbook-xsl/webhelp/xsl/webhelp-common.xsl"/> + <xsl:import href="../../docbook-xsl/webhelp/xsl/titlepage.templates.xsl"/> + <!-- + --> + <xsl:include href="hdmextensions.xsl"/> + + </xsl:stylesheet> -- GitLab