[gi-docgen/ebassi/devhelp] template: Detect DevHelp




commit 38607884636c93ed3901d276b4339be14bc5f2e5
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Wed Apr 7 13:25:47 2021 +0100

    template: Detect DevHelp
    
    We can change the exposed UI depending on whether the documentation is
    browsed through DevHelp, and avoid duplication of existing
    functionality.

 gidocgen/templates/basic/main.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/gidocgen/templates/basic/main.js b/gidocgen/templates/basic/main.js
index 46f03fb..40bf6cf 100644
--- a/gidocgen/templates/basic/main.js
+++ b/gidocgen/templates/basic/main.js
@@ -68,6 +68,10 @@ function getSearchInput() {
     return document.getElementsByClassName("search-input")[0];
 }
 
+function getSidebar() {
+    return document.getElementsByClassName("sidebar")[0];
+}
+
 function getQueryStringParams() {
     var params = {};
     window.location.search.substring(1).split('&').
@@ -438,6 +442,7 @@ window.addEventListener("load", function() {
     var main = document.getElementById("main");
     var btnToTop = document.getElementById("btn-to-top");
 
+    var sidebar = getSidebar();
     var searchInput = getSearchInput();
 
     function labelForToggleButton(isCollapsed) {
@@ -553,6 +558,13 @@ window.addEventListener("load", function() {
         });
     }
 
+    // Hide the side bar when running under DevHelp; DevHelp has its own
+    // side bar and search function, so there's no reason to duplicate
+    // its functionality
+    if (navigator.userAgent.indexOf("DevHelp") !== -1) {
+        sidebar.addClass("hidden");
+    }
+
     if (window.buildIndex) {
         window.buildIndex('index.json');
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]