Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Fix #783 Don't show button if --quickjump not present #1108

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion haddock-api/resources/html/haddock-bundle.min.js

Large diffs are not rendered by default.

23 changes: 14 additions & 9 deletions haddock-api/resources/html/js-src/quick-jump.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

// -------------------------------------------------------------------------- //
Expand Down Expand Up @@ -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
Expand Down
Loading