diff options
Diffstat (limited to 'haddock-api/resources/html/js-src')
-rw-r--r-- | haddock-api/resources/html/js-src/details-helper.tsx | 1 | ||||
-rw-r--r-- | haddock-api/resources/html/js-src/quick-jump.tsx | 23 |
2 files changed, 14 insertions, 10 deletions
diff --git a/haddock-api/resources/html/js-src/details-helper.tsx b/haddock-api/resources/html/js-src/details-helper.tsx index 871b5417..411d38d7 100644 --- a/haddock-api/resources/html/js-src/details-helper.tsx +++ b/haddock-api/resources/html/js-src/details-helper.tsx @@ -407,7 +407,6 @@ function restoreToggled() { // <details> element with id given by the 'data-details-id' property // of the "toggle" element. function onToggleClick(ev: MouseEvent) { - ev.preventDefault(); const toggle = ev.currentTarget as HTMLElement; toggleDetails(toggle); storeLocalConfig(); 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 |