From 863b926ed16b372800f75e8ac467afbf3443f61e Mon Sep 17 00:00:00 2001 From: Ilmari Lauhakangas Date: Fri, 9 Feb 2018 13:42:21 +0200 Subject: Tweaked contents expansion Stopped excluding main items. Highlighted current item. Harmonised the help.js indentation. Change-Id: I6b8f22940d077d008662a387071a5d5db04409f7 Reviewed-on: https://gerrit.libreoffice.org/49488 Reviewed-by: Olivier Hallot Tested-by: Olivier Hallot --- help3xsl/default.css | 8 +- help3xsl/help.js | 216 ++++++++++++++++++++++++--------------------------- 2 files changed, 108 insertions(+), 116 deletions(-) (limited to 'help3xsl') diff --git a/help3xsl/default.css b/help3xsl/default.css index dc2a19972a..e797cd68c7 100644 --- a/help3xsl/default.css +++ b/help3xsl/default.css @@ -579,9 +579,6 @@ li.disabled a { line-height: 16px; vertical-align: middle; } -.contents-treeview label { - background-position: 18px 0; -} .contents-treeview label:before { content: "⊞"; color: #18A303; @@ -592,6 +589,11 @@ li.disabled a { .contents-treeview input:checked + label::before { content: "⊟"; } +.contents-current { + background-color: #18A303; + color: #FFF; + padding-right: 1px; +} /* webkit adjacent element selector bugfix */ @media screen and (-webkit-min-device-pixel-ratio: 0) { diff --git a/help3xsl/help.js b/help3xsl/help.js index 53d9cda4c3..9329f2d0fb 100644 --- a/help3xsl/help.js +++ b/help3xsl/help.js @@ -6,179 +6,172 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - // Used to set Application in caseinline=APP -function setModule(module){ - if (module === null){module="WRITER";} +function setModule(module) { + 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){ + for (var i = 0; i < n; i++) { + if (itemspan[i].getAttribute("value") == module) { itemspan[i].removeAttribute("hidden"); } } } - // Used to set system in caseinline=SYSTEM -function setSystem(system){ +function setSystem(system) { var itemspan = document.getElementsByTagName("span"); - if (system=== null){system="WIN";} + if (system === null) { + system = "WIN"; + } var n = itemspan.length; - for (var i = 0; i < n; i++){ - if (itemspan[i].getAttribute("value") == system){ + for (var i = 0; i < n; i++) { + if (itemspan[i].getAttribute("value") == system) { itemspan[i].removeAttribute("hidden"); } } } /* add &DbPAR= and &System= to the links in DisplayArea div */ -function fixURL(module, system){ +function fixURL(module, system) { var itemlink = document.getElementById("DisplayArea").getElementsByTagName("a"); - var pSystem = (system=== null) ? "WIN" : system; - var pAppl = (module=== null) ? "WRITER" : module; + var pSystem = (system === null) ? "WIN" : system; + var pAppl = (module === null) ? "WRITER" : module; var n = itemlink.length; - - for (var i = 0; i input'); - document.getElementById(input[0].id).checked = true; +var contentMatch = pathname.match(pathRegex); +function linksMatch(content) { + var linkMatch = new RegExp(content); + var links = document.getElementById("Contents").getElementsByTagName("a"); + for (var i = 0, len = links.length; i < len; i++) { + if (links[i].href.match(linkMatch)) { + return i; } } } +linkIndex = linksMatch(contentMatch); +if (typeof linkIndex !== "undefined") { + var current = document.getElementById("Contents").getElementsByTagName("a")[linkIndex]; + var cItem = current.parentElement; + var parents = []; + while (cItem.parentElement && !cItem.parentElement.matches("#Contents") && parents.indexOf(cItem.parentElement) == -1) { + parents.push(cItem = cItem.parentElement); + } + var liParents = [].filter.call(parents, function(item) { + return item.matches("li"); + }); + for (var i = 0, len = liParents.length; i < len; i++) { + var input = liParents[i].querySelectorAll(':scope > input'); + document.getElementById(input[0].id).checked = true; + } + current.classList.add('contents-current'); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ -- cgit