diff options
author | Olivier Hallot <olivier.hallot@libreoffice.org> | 2019-11-08 07:28:03 -0300 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2019-11-08 19:42:27 +0100 |
commit | d034a998ce691d67778bc5f499c04de7544e0af9 (patch) | |
tree | dab1ab312133f3199803dd2a54d73934dcfb3a3d | |
parent | 6f107ecda99e339d61517de33c0d452c18dfac3e (diff) |
Fix switch selection when embedded in other pages
Emebed exerpts with switch tags were unable to perform
the correct switch because of the use of the same id= in
several places in the page. The new logic fixes that.
Change-Id: I1e1084170e023c89f3c695c3d1c5a6c7deee7374
Reviewed-on: https://gerrit.libreoffice.org/82277
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
-rw-r--r-- | help3xsl/help2.js | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/help3xsl/help2.js b/help3xsl/help2.js index 54dd195ab3..a1739eeaf0 100644 --- a/help3xsl/help2.js +++ b/help3xsl/help2.js @@ -7,21 +7,21 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // Used to set Application in caseinline=APP -function setApplSpan(SpanID) { +function setApplSpan(spanZ) { var module = getParameterByName("DbPAR"); if (module === null) { module = "WRITER"; } - var y = document.getElementById(SpanID).getElementsByTagName("SPAN"); + var y = spanZ.getElementsByTagName("SPAN"); var n = y.length; - var foundSystem = false; + var foundAppl = 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; + foundAppl=true; } } for (i = 0; i < n; i++) { @@ -29,20 +29,20 @@ function setApplSpan(SpanID) { continue; } else if( y[i].getAttribute("id").startsWith("default")){ - if(!foundSystem){ + if(!foundAppl){ y[i].removeAttribute("hidden"); } } } } // Used to set system in case, caseinline=SYSTEM -function setSystemSpan(spanID) { - var system = getParameterByName("System"); +function setSystemSpan(spanZ) { // if no System in URL, get browser system + var system = getParameterByName("System"); if (system === null) { system = getSystem(); } - var y = document.getElementById(spanID).getElementsByTagName("SPAN"); + var y = spanZ.getElementsByTagName("SPAN"); var n = y.length; var foundSystem = false; for (i = 0; i < n; i++) { @@ -65,6 +65,7 @@ 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; @@ -74,9 +75,9 @@ for (z = 0; z < n; z++) { continue; } else if (id.startsWith("swlnsys")) { - setSystemSpan(id); + setSystemSpan(spans[z]); } else { - setApplSpan(id); + setApplSpan(spans[z]); } } /* add &DbPAR= and &System= to the links in DisplayArea div */ |