From 03fb1e86aa1942d5559f0599e92803b62b2bec24 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 23 Dec 2020 16:38:36 +0100 Subject: [PATCH] removed forced focus --- Client/WebServer/index.html | 3 +-- .../UI/Spaces/Docs-Space/DocsSpace.js | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Client/WebServer/index.html b/Client/WebServer/index.html index 9d70c869d..5e57190e2 100644 --- a/Client/WebServer/index.html +++ b/Client/WebServer/index.html @@ -70,8 +70,7 @@
-
-
+
diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index f8ad1f6e2..dd1a6d9e5 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -842,9 +842,10 @@ function newSuperalgosDocSpace() { HTML = HTML + '
' HTML = HTML + '
' HTML = HTML + '' - let docsSpaceDiv = document.getElementById('docs-space-div') - docsSpaceDiv.innerHTML = HTML + addFooter() + let docsContentDiv = document.getElementById('docs-content-div') + docsContentDiv.innerHTML = HTML + addFooter() detectEnterOnSearchBox() + setFocusOnSearchBox() } function detectCommands() { @@ -1268,10 +1269,11 @@ function newSuperalgosDocSpace() { // End Section HTML = HTML + '' - let docsSpaceDiv = document.getElementById('docs-space-div') - docsSpaceDiv.innerHTML = HTML + addFooter() + let docsContentDiv = document.getElementById('docs-content-div') + docsContentDiv.innerHTML = HTML + addFooter() detectEnterOnSearchBox() + setFocusOnSearchBox() } } @@ -1517,10 +1519,11 @@ function newSuperalgosDocSpace() { HTML = HTML.replace(tab.toUpperCase() + '_TOTAL_RESULTS', resultCounter) } - let docsSpaceDiv = document.getElementById('docs-space-div') - docsSpaceDiv.innerHTML = HTML + addFooter() + let docsContentDiv = document.getElementById('docs-content-div') + docsContentDiv.innerHTML = HTML + addFooter() detectEnterOnSearchBox() + setFocusOnSearchBox() } } @@ -1529,7 +1532,6 @@ function newSuperalgosDocSpace() { if (command !== undefined) { element.value = command } - element.focus() element.addEventListener("keyup", function (event) { if (event.key === "Enter" || event.keyCode === 13) { command = element.value @@ -1538,6 +1540,11 @@ function newSuperalgosDocSpace() { }); } + function setFocusOnSearchBox() { + const element = document.getElementsByClassName("docs-search-input")[0] + element.focus() + } + function scrollToElement(htmlElementId) { let myElement = document.getElementById(htmlElementId) let topPos = myElement.offsetTop @@ -1717,8 +1724,8 @@ function newSuperalgosDocSpace() { /* Here we inject the HTML we built into the DOM at the Docs Space Div. */ - let docsSpaceDiv = document.getElementById('docs-space-div') - docsSpaceDiv.innerHTML = HTML + addFooter() + let docsContentDiv = document.getElementById('docs-content-div') + docsContentDiv.innerHTML = HTML + addFooter() hightlightEmbeddedCode() detectEnterOnSearchBox() @@ -2788,7 +2795,7 @@ function newSuperalgosDocSpace() { } function hightlightEmbeddedCode() { - _self.Prism.highlightAllUnder(docsSpaceDiv, true, onHighlighted) + _self.Prism.highlightAllUnder(docsContentDiv, true, onHighlighted) function onHighlighted() { // nothing to do here }