aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/resources/html/js-src
diff options
context:
space:
mode:
authorMike Pilgrem <mpilgrem@users.noreply.github.com>2019-11-13 21:43:03 +0000
committerMike Pilgrem <mpilgrem@users.noreply.github.com>2022-06-12 21:57:19 +0100
commit3ab18cf06ae9392eab1349675dab8a177f1412da (patch)
treea17da33db62ce591a05c2132c094913b371a41e0 /haddock-api/resources/html/js-src
parentc5a83df91b97f85d995599c5ae7beacabe2ff040 (diff)
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