diff options
author | Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> | 2019-03-10 10:57:34 +0200 |
---|---|---|
committer | Olivier Hallot <olivier.hallot@libreoffice.org> | 2019-03-10 19:22:22 +0100 |
commit | 54e3236790baca8a55d0bea3b1dd3e8de5ec5dd5 (patch) | |
tree | 09b8aac4732136f114a20b3304154eb4d384d9a7 | |
parent | 3013fcc8dd2ca6407c6bf17a36a34741d0c9c968 (diff) |
Show module & lang navigation on mobile
Module & languages menus were not shown on screen widths < 960.
Changed module & languages menu background to span the whole
width, when on mobile.
An arrow function was used in help2.js, which means it was broken
on IE.
Moved all src .js files to head and used defer for all.
Moved inline Piwik & system info JS into help2.js and added a
test for onlineness targeting the first meta element in the body.
Change-Id: Ic1a928b53ce9029f9f655117977cd511b7e3246d
Reviewed-on: https://gerrit.libreoffice.org/69005
Tested-by: Jenkins
Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org>
-rw-r--r-- | help3xsl/default.css | 6 | ||||
-rw-r--r-- | help3xsl/help2.js | 42 | ||||
-rw-r--r-- | help3xsl/online_transform.xsl | 67 |
3 files changed, 60 insertions, 55 deletions
diff --git a/help3xsl/default.css b/help3xsl/default.css index 75798d2db0..5c68d41185 100644 --- a/help3xsl/default.css +++ b/help3xsl/default.css @@ -600,12 +600,16 @@ li.disabled a { } .modules { border-bottom: 2px solid #f3f3f3; + background-color: #233336; } .modules label:after, .lang label:after { font-size: 30px; color: #fff; content:"⌄"; } +.lang { + background-color: #233336; +} .lang label, .modules label { display: none; } @@ -796,6 +800,7 @@ li.disabled a { position: absolute; top: 0; left: 200px; + background-color: transparent; } .modules { width: 120px; @@ -803,6 +808,7 @@ li.disabled a { top: 0; left: 80px; border: none; + background-color: transparent; } #DisplayArea { box-shadow: 0 2px 8px 0 rgba(0,0,0,.05); diff --git a/help3xsl/help2.js b/help3xsl/help2.js index 505dcaf8ec..5a48c394fe 100644 --- a/help3xsl/help2.js +++ b/help3xsl/help2.js @@ -75,7 +75,7 @@ function fixURL(module, system) { for (var i = 0; i < n; i++) { if (itemlink[i].getAttribute("class") != "objectfiles"){ setURLParam(itemlink[i], pSystem, pAppl); - }; + } } } //Set the params inside URL @@ -159,11 +159,49 @@ function setupLanguages(target, page) { var langNav = document.getElementById('langs-nav'); if (!langNav.classList.contains('loaded')) { var html = ''; - languagesSet.forEach(lang => { + languagesSet.forEach(function(lang) { html += '<a href="' + target + lang + page + '">' + ((lang in languageNames)? languageNames[lang]: lang) + '</a>'; }); langNav.innerHTML = html; langNav.classList.add('loaded'); } } + +// Test, if we are online +if (document.body.getElementsByTagName('meta')[0].getAttribute('itemprop') === 'version') { + var _paq = _paq || []; + /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ + _paq.push(['disableCookies']); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="//piwik.documentfoundation.org/"; + _paq.push(['setTrackerUrl', u+'piwik.php']); + _paq.push(['setSiteId', '68']); + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); + })(); + var system = getParameterByName("System"); +} else { + var system = getSystem(); +} + +var module = getParameterByName("DbPAR"); +var helpID = getParameterByName("HID"); +fixURL(module,system); +var dbg = getParameterByName("Debug"); +if (dbg == null) { dbg=0; } +document.getElementById("DEBUG").style.display = (dbg == 0) ? "none":"block"; +document.getElementById("bm_module").innerHTML ="Module is: "+module; +document.getElementById("bm_system").innerHTML ="System is: "+system; +document.getElementById("bm_HID").innerHTML ="HID is: "+helpID; + +// Mobile devices need the modules and langs on page load +if (Math.max(document.documentElement.clientWidth, window.innerWidth || 0) < 960) { + var e = new Event('change'); + var modules = document.getElementById('modules'); + var langs = document.getElementById('langs'); + modules.dispatchEvent(e); + langs.dispatchEvent(e); +} /* 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 02a669a56f..33a9537d34 100644 --- a/help3xsl/online_transform.xsl +++ b/help3xsl/online_transform.xsl @@ -145,21 +145,24 @@ <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval' piwik.documentfoundation.org *.google.com *.googleapis.com"/> </xsl:if> <title><xsl:value-of select="$titleL10N"/></title> - <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" /> - <link type="text/css" href="{$target}prism.css" rel="Stylesheet" /> - <script type="text/javascript" src="{$target}help2.js"></script> - <script type="text/javascript" src="{$target}languages.js"></script> - <script type="text/javascript" src="{$target}{$lang}/langnames.js"></script> - <script type="text/javascript" src="{$target}fuzzysort.js"></script> - <script type="text/javascript" src="{$target}paginathing.js"></script> - <script type="text/javascript" src="{$target}prism.js"></script> + <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"/> + <link type="text/css" href="{$target}prism.css" rel="Stylesheet"/> + <script type="text/javascript" src="{$target}help2.js" defer=""/> + <script type="text/javascript" src="{$target}languages.js" defer=""/> + <script type="text/javascript" src="{$target}{$lang}/langnames.js" defer=""/> + <script type="text/javascript" src="{$target}fuzzysort.js" defer=""/> + <script type="text/javascript" src="{$target}paginathing.js" defer=""/> + <script type="text/javascript" src="{$target}prism.js" defer=""/> + <script type="text/javascript" src="{$target}{$lang}/bookmarks.js" defer=""/> + <script type="text/javascript" src="{$target}{$lang}/contents.js" defer=""/> + <script type="text/javascript" src="{$target}help.js" defer=""/> <meta name="viewport" content="width=device-width,initial-scale=1"/> </head> <body itemscope="true" itemtype="http://schema.org/TechArticle"> <xsl:if test="$online"> - <meta itemprop="version" content="{$productversion}"/> + <meta itemprop="version" content="{$productversion}"/><!-- This is used by help2.js to test, if we are online --> <meta itemprop="inLanguage" content="{$lang}"/> <meta itemprop="datePublished" content="2017"/> <meta itemprop="headline" content="{$titleL10N}"/> @@ -252,48 +255,6 @@ <p id="bm_HID"></p> </div> </footer> - <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 type="text/javascript"> - <![CDATA[ - var module = getParameterByName("DbPAR"); - var helpID = getParameterByName("HID"); - ]]> - <xsl:choose> - <xsl:when test="$online"><![CDATA[var system = getParameterByName("System");]]></xsl:when> - <xsl:otherwise><![CDATA[var system = getSystem();]]></xsl:otherwise> - </xsl:choose> - <![CDATA[ - fixURL(module,system); - var dbg = getParameterByName("Debug"); - if (dbg == null){dbg=0} - document.getElementById("DEBUG").style.display = (dbg == 0) ? "none":"block"; - document.getElementById("bm_module").innerHTML ="Module is: "+module; - document.getElementById("bm_system").innerHTML ="System is: "+system; - document.getElementById("bm_HID").innerHTML ="HID is: "+helpID; - ]]> - </script> - <xsl:if test="$online"> - <!-- Piwik --> - <script type="text/javascript"> - <![CDATA[ - var _paq = _paq || []; - /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ - _paq.push(['disableCookies']); - _paq.push(['trackPageView']); - _paq.push(['enableLinkTracking']); - (function() { - var u="//piwik.documentfoundation.org/"; - _paq.push(['setTrackerUrl', u+'piwik.php']); - _paq.push(['setSiteId', '68']); - var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); - })(); - ]]> - </script> - <!-- End Piwik Code --> - </xsl:if> </body> </html> </xsl:template> |