summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Hallot <olivier.hallot@libreoffice.org>2018-04-15 22:43:17 -0300
committerOlivier Hallot <olivier.hallot@libreoffice.org>2018-04-16 13:17:35 +0200
commitd5ca87f12819b669646bb6f0978f79ebb5d3f035 (patch)
tree1c08e27ecc4c0e7b89fca2ffa37fe6f1d7c911c0
parentBetter TDF video for new help (diff)
downloadhelp-d5ca87f12819b669646bb6f0978f79ebb5d3f035.tar.gz
help-d5ca87f12819b669646bb6f0978f79ebb5d3f035.zip
tdf#116150 Review XHP <switch> style transform
implement <switch> and <switchinline> with HTML and Javascript, for 'sys' and 'appl'. Change-Id: I6056e787146bb92617c2ce639acab16d16d6f765 Reviewed-on: https://gerrit.libreoffice.org/52929 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org> Tested-by: Olivier Hallot <olivier.hallot@libreoffice.org>
-rw-r--r--help3xsl/help.js65
-rw-r--r--help3xsl/online_transform.xsl232
2 files changed, 185 insertions, 112 deletions
diff --git a/help3xsl/help.js b/help3xsl/help.js
index cd454e6fbe..585ff2ef80 100644
--- a/help3xsl/help.js
+++ b/help3xsl/help.js
@@ -7,42 +7,60 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Used to set Application in caseinline=APP
-function setModule(module) {
+function setApplSpan(SpanID) {
+ var module = getParameterByName("DbPAR");
if (module === null) {
module = "WRITER";
}
- var itemspan = document.getElementsByTagName("span");
- var n = itemspan.length;
- for (var i = 0; i < n; i++) {
- if (itemspan[i].getAttribute("value") == module) {
- itemspan[i].removeAttribute("hidden");
+ var y = document.getElementById(SpanID).getElementsByTagName("SPAN");
+ var n = y.length;
+ var foundSystem = false;
+ for (i = 0; i < n; i++) {
+ if (y[i].getAttribute("id") === null){
+ continue;
+ }
+ else if( y[i].getAttribute("id").startsWith(module)){
+ y[i].removeAttribute("hidden");
+ foundSystem=true;
+ }
+ }
+ for (i = 0; i < n; i++) {
+ if (y[i].getAttribute("id") === null){
+ continue;
+ }
+ else if( y[i].getAttribute("id").startsWith("default")){
+ if(!foundSystem){
+ y[i].removeAttribute("hidden");
+ }
}
}
}
// Used to set system in case, caseinline=SYSTEM
-function setSystem(system) {
- var hasSystem;
+function setSystemSpan(spanID) {
+ var system = getParameterByName("System");
// if no System in URL, get browser system
if (system === null) {
system = getSystem();
}
- // on loading page, DEFAULTSYS visible, sys is hidden
- // when hasSystem, show sys, hide DEFAULTSYS
- var itemspan = document.getElementsByTagName("span");
- var n = itemspan.length;
- //Show when system is found in page
- hasSystem = false;
- for (var i = 0; i < n; i++) {
- if (itemspan[i].getAttribute("value") == system) {
- itemspan[i].removeAttribute("hidden");
- hasSystem = true;
+ var y = document.getElementById(spanID).getElementsByTagName("SPAN");
+ var n = y.length;
+ var foundSystem = false;
+ for (i = 0; i < n; i++) {
+ if (y[i].getAttribute("id") === null){
+ continue;
+ }
+ else if( y[i].getAttribute("id").startsWith(system)){
+ y[i].removeAttribute("hidden");
+ foundSystem=true;
}
}
- //it hasSystem, then hide all DEFAULTSYS
- if (hasSystem){
- for (var i = 0; i < n; i++) {
- if (itemspan[i].getAttribute("value") == "DEFAULTSYS") {
- itemspan[i].setAttribute("hidden",true);
+ for (i = 0; i < n; i++) {
+ if (y[i].getAttribute("id") === null){
+ continue;
+ }
+ else if( y[i].getAttribute("id").startsWith("default")){
+ if(!foundSystem){
+ y[i].removeAttribute("hidden");
}
}
}
@@ -229,5 +247,4 @@ if (typeof linkIndex !== "undefined") {
}
current.classList.add('contents-current');
}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl
index 6127ca924c..6db51ccafd 100644
--- a/help3xsl/online_transform.xsl
+++ b/help3xsl/online_transform.xsl
@@ -138,6 +138,7 @@
<link rel="shortcut icon" href="{$target}media/navigation/favicon.ico" />
<link type="text/css" href="{$target}normalize.css" rel="Stylesheet" />
<link type="text/css" href="{$target}default.css" rel="Stylesheet" />
+ <script type="text/javascript" src="{$target}help.js"></script>
<script type="text/javascript" src="{$target}fuse.js"></script>
<script type="text/javascript" src="{$target}paginathing.js"></script>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
@@ -306,16 +307,12 @@
</div>
<script type="text/javascript" src="{$target}{$lang}/bookmarks.js"/>
<script type="text/javascript" src="{$target}{$lang}/contents.js"/>
- <script type="text/javascript" src="{$target}help.js"></script>
<xsl:choose>
<xsl:when test="$online">
<script type="text/javascript">
<![CDATA[
- var userLang = navigator.language || navigator.userLanguage;
var module = getParameterByName("DbPAR");
- setModule(module);
var system = getParameterByName("System");
- setSystem(system);
fixURL(module,system);
var dbg = getParameterByName("Debug");
if (dbg == null){dbg=0}
@@ -329,9 +326,7 @@
<script type="text/javascript">
<![CDATA[
var module = getParameterByName("DbPAR");
- setModule(module);
var system = getSystem();
- setSystem(system);
fixURL(module,system);
var dbg = getParameterByName("Debug");
if (dbg == null){dbg=0}
@@ -685,12 +680,96 @@
</xsl:template>
<!-- SWITCH -->
-<xsl:template match="switch"><xsl:apply-templates /></xsl:template>
-<xsl:template match="switch" mode="embedded"><xsl:apply-templates /></xsl:template>
+<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: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: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: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>
+</xsl:template>
<!-- SWITCHINLINE -->
-<xsl:template match="switchinline"><xsl:apply-templates /></xsl:template>
-<xsl:template match="switchinline" mode="embedded"><xsl:apply-templates mode="embedded"/></xsl:template>
+<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: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: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:template>
<!-- TABLE -->
<xsl:template match="table"><xsl:call-template name="inserttable"/></xsl:template>
@@ -739,75 +818,75 @@
<!-- Branding -->
<xsl:template name="brand" >
- <xsl:param name="string"/>
+ <xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string,$brand1)">
- <xsl:variable name="newstr">
+ <xsl:variable name="newstr">
<xsl:value-of select="substring-before($string,$brand1)"/>
<xsl:value-of select="$productname"/>
<xsl:value-of select="substring-after($string,$brand1)"/>
- </xsl:variable>
- <xsl:call-template name="brand">
- <xsl:with-param name="string" select="$newstr"/>
- </xsl:call-template>
- </xsl:when>
+ </xsl:variable>
+ <xsl:call-template name="brand">
+ <xsl:with-param name="string" select="$newstr"/>
+ </xsl:call-template>
+ </xsl:when>
- <xsl:when test="contains($string,$brand2)">
- <xsl:variable name="newstr">
+ <xsl:when test="contains($string,$brand2)">
+ <xsl:variable name="newstr">
<xsl:value-of select="substring-before($string,$brand2)"/>
<xsl:value-of select="$pversion"/>
<xsl:value-of select="substring-after($string,$brand2)"/>
- </xsl:variable>
- <xsl:call-template name="brand">
- <xsl:with-param name="string" select="$newstr"/>
- </xsl:call-template>
- </xsl:when>
+ </xsl:variable>
+ <xsl:call-template name="brand">
+ <xsl:with-param name="string" select="$newstr"/>
+ </xsl:call-template>
+ </xsl:when>
- <xsl:when test="contains($string,$brand3)">
- <xsl:variable name="newstr">
+ <xsl:when test="contains($string,$brand3)">
+ <xsl:variable name="newstr">
<xsl:value-of select="substring-before($string,$brand3)"/>
<xsl:value-of select="$productname"/>
<xsl:value-of select="substring-after($string,$brand3)"/>
- </xsl:variable>
- <xsl:call-template name="brand">
- <xsl:with-param name="string" select="$newstr"/>
- </xsl:call-template>
- </xsl:when>
+ </xsl:variable>
+ <xsl:call-template name="brand">
+ <xsl:with-param name="string" select="$newstr"/>
+ </xsl:call-template>
+ </xsl:when>
<xsl:when test="contains($string,$brand4)">
- <xsl:variable name="newstr">
+ <xsl:variable name="newstr">
<xsl:value-of select="substring-before($string,$brand4)"/>
<xsl:value-of select="$pversion"/>
<xsl:value-of select="substring-after($string,$brand4)"/>
- </xsl:variable>
- <xsl:call-template name="brand">
- <xsl:with-param name="string" select="$newstr"/>
- </xsl:call-template>
- </xsl:when>
+ </xsl:variable>
+ <xsl:call-template name="brand">
+ <xsl:with-param name="string" select="$newstr"/>
+ </xsl:call-template>
+ </xsl:when>
<xsl:otherwise>
- <xsl:value-of select="$string"/>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:value-of select="$string"/>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:template>
<!-- Insert Paragraph -->
<xsl:template name="insertpara">
- <xsl:variable name="role">
- <xsl:choose>
- <xsl:when test="ancestor::table">
- <xsl:value-of select="concat(@role,'intable')"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="@role"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <p id="{@id}" class="{$role}"><xsl:apply-templates /></p>
+ <xsl:variable name="role">
+ <xsl:choose>
+ <xsl:when test="ancestor::table">
+ <xsl:value-of select="concat(@role,'intable')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="@role"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <p id="{@id}" class="{$role}"><xsl:apply-templates /></p>
</xsl:template>
<xsl:template match="bascode">
@@ -816,12 +895,12 @@
<!-- Insert Basic code snippet -->
<xsl:template name="insertbascode">
- <pre><xsl:apply-templates /></pre>
+ <pre><code><xsl:apply-templates /></code></pre>
</xsl:template>
<!-- Insert Logo code snippet -->
<xsl:template name="insertlogocode">
- <pre><xsl:apply-templates /></pre>
+ <pre><xsl:apply-templates /></pre>
</xsl:template>
<!-- Insert "How to get Link" -->
@@ -926,37 +1005,14 @@
<!-- Evaluate a case or caseinline switch -->
<xsl:template name="insertcase">
<xsl:param name="embedded" />
+ <xsl:variable name="auxID" select="concat(@select,generate-id())"/>
<xsl:choose>
- <xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
- <xsl:choose>
- <xsl:when test="$embedded = 'yes'">
- <span hidden="true" itemprop="system" value="{@select}"><xsl:apply-templates mode="embedded"/></span>
- </xsl:when>
- <xsl:otherwise>
- <span hidden="true" itemprop="system" value="{@select}"><xsl:apply-templates /></span>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="parent::switch[@select='appl'] or parent::switchinline[@select='appl']">
- <xsl:choose>
- <xsl:when test="$embedded = 'yes'">
- <span hidden="true" itemprop="appl" value="{@select}"><xsl:apply-templates mode="embedded"/></span>
- </xsl:when>
- <xsl:otherwise>
- <span hidden="true" itemprop="appl" value="{@select}"><xsl:apply-templates /></span>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:when test="parent::switch[@select='distrib'] or parent::switchinline[@select='distrib']">
- <xsl:choose>
- <xsl:when test="$embedded = 'yes'">
- <span hidden="true" itemprop="distrib" value="{@select}"><xsl:apply-templates mode="embedded"/></span>
- </xsl:when>
- <xsl:otherwise>
- <span hidden="true" itemprop="distrib" value="{@select}"><xsl:apply-templates /></span>
- </xsl:otherwise>
- </xsl:choose>
+ <xsl:when test="$embedded = 'yes'">
+ <span hidden="true" id="{$auxID}"><xsl:apply-templates mode="embedded"/></span>
</xsl:when>
+ <xsl:otherwise>
+ <span hidden="true" id="{$auxID}"><xsl:apply-templates/></span>
+ </xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -966,24 +1022,26 @@
<xsl:choose>
<xsl:when test="parent::switch[@select='sys'] or parent::switchinline[@select='sys']">
<xsl:if test="not(../child::case[@select=$System]) and not(../child::caseinline[@select=$System])">
+ <xsl:variable name="auxID" select="concat('default',generate-id())"/>
<xsl:choose>
<xsl:when test="$embedded = 'yes'">
- <span itemprop="system" value="DEFAULTSYS"><xsl:apply-templates mode="embedded"/></span>
+ <span hidden="true" id="{$auxID}"><xsl:apply-templates mode="embedded"/></span>
</xsl:when>
<xsl:otherwise>
- <span itemprop="system" value="DEFAULTSYS"><xsl:apply-templates /></span>
+ <span hidden="true" id="{$auxID}"><xsl:apply-templates /></span>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:when>
<xsl:when test="parent::switch[@select='appl'] or parent::switchinline[@select='appl']">
<xsl:if test="not(../child::case[@select=$appl]) and not(../child::caseinline[@select=$appl])">
+ <xsl:variable name="auxID" select="concat('default',generate-id())"/>
<xsl:choose>
<xsl:when test="$embedded = 'yes'">
- <span hidden="true" itemprop="appl" value="SHARED"><xsl:apply-templates mode="embedded"/></span>
+ <span hidden="true" id="{$auxID}"><xsl:apply-templates mode="embedded"/></span>
</xsl:when>
<xsl:otherwise>
- <span hidden="true" itemprop="appl" value="SHARED"><xsl:apply-templates /></span>
+ <span hidden="true" id="{$auxID}"><xsl:apply-templates /></span>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
@@ -1191,12 +1249,10 @@
<xsl:variable name="href"><xsl:value-of select="concat($urlpre,substring-before(@href,'#'))"/></xsl:variable>
<xsl:variable name="anc"><xsl:value-of select="substring-after(@href,'#')"/></xsl:variable>
<xsl:variable name="docum" select="document($href)"/>
-
<xsl:call-template name="insertembed">
<xsl:with-param name="doc" select="$docum" />
<xsl:with-param name="anchor" select="$anc" />
</xsl:call-template>
-
</div>
</xsl:template>