[Libreoffice-commits] help.git: help3xsl/help2.js help3xsl/online_transform.xsl
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Mar 13 19:11:56 UTC 2019
help3xsl/help2.js | 16 ++++
help3xsl/online_transform.xsl | 145 +++++++++++++++++++-----------------------
2 files changed, 82 insertions(+), 79 deletions(-)
New commits:
commit 3d0fcf7a37859e0e8b61d4a560042dfef6b3c99b
Author: Ilmari Lauhakangas <ilmari.lauhakangas at libreoffice.org>
AuthorDate: Tue Mar 12 23:36:46 2019 +0200
Commit: Olivier Hallot <olivier.hallot at libreoffice.org>
CommitDate: Wed Mar 13 20:11:32 2019 +0100
New approach to switch cases
My previous JS patch broke the sys and appl switch behaviour.
This patch removes the inline function calls from
online_transform.xsl. Instead, help2.js now finds the relevant spans
and calls the functions for them.
Change-Id: I45d5b75bdb70a7c18eaa0b215beb57e3e1b6719a
Reviewed-on: https://gerrit.libreoffice.org/69137
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot at libreoffice.org>
diff --git a/help3xsl/help2.js b/help3xsl/help2.js
index 5a48c394f..0003b72d8 100644
--- a/help3xsl/help2.js
+++ b/help3xsl/help2.js
@@ -65,6 +65,20 @@ function setSystemSpan(spanID) {
}
}
}
+// Find spans that need the switch treatment and give it to them
+var spans = document.querySelectorAll("[class^=switch]");
+var n = spans.length;
+for (z = 0; z < n; z++) {
+ var id = spans[z].getAttribute("id");
+ if (id === null) {
+ continue;
+ }
+ else if (id.startsWith("swlnsys")) {
+ setSystemSpan(id);
+ } else {
+ setApplSpan(id);
+ }
+}
/* add &DbPAR= and &System= to the links in DisplayArea div */
/* skip for object files */
function fixURL(module, system) {
@@ -168,7 +182,7 @@ function setupLanguages(target, page) {
}
// Test, if we are online
-if (document.body.getElementsByTagName('meta')[0].getAttribute('itemprop') === 'version') {
+if (document.body.getElementsByTagName('meta')) {
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['disableCookies']);
diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl
index 33a9537d3..f3b71bac9 100644
--- a/help3xsl/online_transform.xsl
+++ b/help3xsl/online_transform.xsl
@@ -162,7 +162,8 @@
</head>
<body itemscope="true" itemtype="http://schema.org/TechArticle">
<xsl:if test="$online">
- <meta itemprop="version" content="{$productversion}"/><!-- This is used by help2.js to test, if we are online -->
+ <!-- help2.js checks, if meta elements exist in the body -->
+ <meta itemprop="version" content="{$productversion}"/>
<meta itemprop="inLanguage" content="{$lang}"/>
<meta itemprop="datePublished" content="2017"/>
<meta itemprop="headline" content="{$titleL10N}"/>
@@ -615,94 +616,82 @@
<!-- SWITCH -->
<xsl:template match="switch">
- <xsl:variable name="idsw" select="concat('swln',generate-id())"/>
- <span id="{$idsw}" class="switch">
- <xsl:choose>
- <xsl:when test ="@select = 'sys'">
- <xsl:apply-templates />
- <script type="text/javascript">
- <![CDATA[setSystemSpan("]]><xsl:value-of select="$idsw"/><![CDATA[");]]>
- </script>
- </xsl:when>
- <xsl:when test ="@select = 'appl'">
+ <xsl:choose>
+ <xsl:when test ="@select = 'sys'">
+ <xsl:variable name="idsw" select="concat('swlnsys',generate-id())"/>
+ <span id="{$idsw}" class="switch">
<xsl:apply-templates />
- <script type="text/javascript">
- <![CDATA[setApplSpan("]]><xsl:value-of select="$idsw"/><![CDATA[");]]>
- </script>
- </xsl:when>
- <xsl:otherwise>
+ </span>
+ </xsl:when>
+ <xsl:when test ="@select = 'appl'">
+ <xsl:variable name="idsw" select="concat('swlnappl',generate-id())"/>
+ <span id="{$idsw}" class="switch">
<xsl:apply-templates />
- </xsl:otherwise>
- </xsl:choose>
- </span>
+ </span>
+ </xsl:when>
+ <xsl:otherwise>
+ <p class="debug">Unsupported switch condition.</p>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template match="switch" mode="embedded">
- <xsl:variable name="idsw" select="concat('swln',generate-id())"/>
- <span id="{$idsw}" class="switch">
- <xsl:choose>
- <xsl:when test ="@select = 'sys'">
+ <xsl:choose>
+ <xsl:when test ="@select = 'sys'">
+ <xsl:variable name="idsw" select="concat('swlnsys',generate-id())"/>
+ <span id="{$idsw}" class="switch">
<xsl:apply-templates mode="embedded"/>
- <script type="text/javascript">
- <![CDATA[setSystemSpan("]]><xsl:value-of select="$idsw"/><![CDATA[");]]>
- </script>
- </xsl:when>
- <xsl:when test ="@select = 'appl'">
- <xsl:apply-templates />
- <script type="text/javascript">
- <![CDATA[setApplSpan("]]><xsl:value-of select="$idsw"/><![CDATA[");]]>
- </script>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates />
- </xsl:otherwise>
- </xsl:choose>
- </span>
+ </span>
+ </xsl:when>
+ <xsl:when test ="@select = 'appl'">
+ <xsl:variable name="idsw" select="concat('swlnappl',generate-id())"/>
+ <span id="{$idsw}" class="switch">
+ <xsl:apply-templates mode="embedded"/>
+ </span>
+ </xsl:when>
+ <xsl:otherwise>
+ <p class="debug">Unsupported switch condition.</p>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<!-- SWITCHINLINE -->
<xsl:template match="switchinline">
- <xsl:variable name="idsw" select="concat('swln',generate-id())"/>
- <span id="{$idsw}" class="switchinline">
- <xsl:choose>
- <xsl:when test ="@select = 'sys'">
+ <xsl:choose>
+ <xsl:when test ="@select = 'sys'">
+ <xsl:variable name="idsw" select="concat('swlnsys',generate-id())"/>
+ <span id="{$idsw}" class="switchinline">
<xsl:apply-templates />
- <script type="text/javascript">
- <![CDATA[setSystemSpan("]]><xsl:value-of select="$idsw"/><![CDATA[");]]>
- </script>
- </xsl:when>
- <xsl:when test ="@select = 'appl'">
+ </span>
+ </xsl:when>
+ <xsl:when test ="@select = 'appl'">
+ <xsl:variable name="idsw" select="concat('swlnappl',generate-id())"/>
+ <span id="{$idsw}" class="switchinline">
<xsl:apply-templates />
- <script type="text/javascript">
- <![CDATA[setApplSpan("]]><xsl:value-of select="$idsw"/><![CDATA[");]]>
- </script>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates />
- </xsl:otherwise>
- </xsl:choose>
- </span>
+ </span>
+ </xsl:when>
+ <xsl:otherwise>
+ <p class="debug">Unsupported switch condition.</p>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<xsl:template match="switchinline" mode="embedded">
- <xsl:variable name="idsw" select="concat('swln',generate-id())"/>
- <span id="{$idsw}" class="switchinline">
- <xsl:choose>
- <xsl:when test ="@select = 'sys'">
- <xsl:apply-templates />
- <script type="text/javascript">
- <![CDATA[setSystemSpan("]]><xsl:value-of select="$idsw"/><![CDATA[");]]>
- </script>
- </xsl:when>
- <xsl:when test ="@select = 'appl'">
- <xsl:apply-templates />
- <script type="text/javascript">
- <![CDATA[setApplSpan("]]><xsl:value-of select="$idsw"/><![CDATA[");]]>
- </script>
- </xsl:when>
- <xsl:otherwise>
- <xsl:apply-templates />
- </xsl:otherwise>
- </xsl:choose>
- </span>
+ <xsl:choose>
+ <xsl:when test ="@select = 'sys'">
+ <xsl:variable name="idsw" select="concat('swlnsys',generate-id())"/>
+ <span id="{$idsw}" class="switchinline">
+ <xsl:apply-templates mode="embedded"/>
+ </span>
+ </xsl:when>
+ <xsl:when test ="@select = 'appl'">
+ <xsl:variable name="idsw" select="concat('swlnappl',generate-id())"/>
+ <span id="{$idsw}" class="switchinline">
+ <xsl:apply-templates mode="embedded"/>
+ </span>
+ </xsl:when>
+ <xsl:otherwise>
+ <p class="debug">Unsupported switch condition.</p>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<!-- TABLE -->
@@ -1017,10 +1006,10 @@
<xsl:variable name="auxID" select="concat(@select,generate-id())"/>
<xsl:choose>
<xsl:when test="$embedded = 'yes'">
- <span hidden="true" id="{$auxID}"><xsl:apply-templates mode="embedded"/></span>
+ <span hidden="true" id="{$auxID}" class="{@select}"><xsl:apply-templates mode="embedded"/></span>
</xsl:when>
<xsl:otherwise>
- <span hidden="true" id="{$auxID}"><xsl:apply-templates/></span>
+ <span hidden="true" id="{$auxID}" class="{@select}"><xsl:apply-templates/></span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
More information about the Libreoffice-commits
mailing list