aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/resources/html/js-src
diff options
context:
space:
mode:
authormergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-06-13 11:49:37 +0000
committerGitHub <noreply@github.com>2022-06-13 11:49:37 +0000
commit118dd4ed0c901f56070052405f533d9deff5bb22 (patch)
treea17da33db62ce591a05c2132c094913b371a41e0 /haddock-api/resources/html/js-src
parentc5a83df91b97f85d995599c5ae7beacabe2ff040 (diff)
parent3ab18cf06ae9392eab1349675dab8a177f1412da (diff)
Merge pull request #1108 from mpilgrem/fix783
Fix #783 Don't show button if --quickjump not present
Diffstat (limited to 'haddock-api/resources/html/js-src')
-rw-r--r--haddock-api/resources/html/js-src/quick-jump.tsx23
1 files changed, 14 insertions, 9 deletions
diff --git a/haddock-api/resources/html/js-src/quick-jump.tsx b/haddock-api/resources/html/js-src/quick-jump.tsx
index 20ff8e15..ef02cbd2 100644
--- a/haddock-api/resources/html/js-src/quick-jump.tsx
+++ b/haddock-api/resources/html/js-src/quick-jump.tsx
@@ -45,11 +45,12 @@ class PageMenuButton extends Component<any, any> {
}
-function addSearchPageMenuButton(action: () => void) {
- const pageMenu = document.querySelector('#page-menu') as HTMLUListElement;
- const dummy = document.createElement('li');
- pageMenu.insertBefore(dummy, pageMenu.firstChild);
- preact.render(<PageMenuButton onClick={action} title="Quick Jump" />, pageMenu, dummy);
+function addSearchPageMenuButton(quickJumpButton: HTMLLIElement) {
+ const showHide = function(action: () => void) {
+ const pageMenu = document.querySelector('#page-menu') as HTMLUListElement;
+ preact.render(<PageMenuButton onClick={action} title="Quick Jump" />, pageMenu, quickJumpButton);
+ };
+ return showHide;
}
// -------------------------------------------------------------------------- //
@@ -410,10 +411,14 @@ function NoResultsMsg(props: { searchString: string }) {
}
export function init(docBaseUrl?: string, showHide?: (action: () => void) => void) {
- preact.render(
- <QuickJump baseUrl={docBaseUrl || "."} showHideTrigger={showHide || addSearchPageMenuButton} />,
- document.body
- );
+ // A <li> element with this id should exist if --quickjump was set
+ const quickJumpButton = document.getElementById('quick-jump-button');
+ if (quickJumpButton)
+ preact.render(
+ <QuickJump baseUrl={docBaseUrl || "."} showHideTrigger={showHide ||
+ addSearchPageMenuButton(quickJumpButton as HTMLLIElement)} />,
+ document.body
+ );
}
// export to global object