Skip to content

Commit

Permalink
Initialize more content
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Dec 24, 2024
1 parent 3cd4e32 commit 93caabf
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
27 changes: 20 additions & 7 deletions assets/js/entry/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,23 @@ import SwupProgressPlugin from '@swup/progress-plugin'

onDocumentReady(() => {
const params = new URLSearchParams(window.location.search)
const isEmbedded = window.self !== window.parent
const isPreview = params.has('preview')
const isHint = params.has('hint')

initTabsets() // alters content HTML, so is run early
initTheme(params.get('theme'))
initStyling()

initTabsets()
initContent(isPreview)
initMakeup()
initTooltips()
initHintsPage()
initCopyButton()
initStyling()

if (isPreview) {
if (isPreview && isEmbedded) {
initPreview()
} if (isHint && isEmbedded) {
initHintsPage()
} else {
if (window.location.protocol !== 'file:') {
new Swup({
Expand All @@ -52,9 +56,17 @@ onDocumentReady(() => {
},
hooks: {
'page:view': () => {
initTabsets()
initContent(false)
initMakeup()
initTooltips()
initCopyButton()

updateSidebarDrawer()
updateSidebarContent()
initSearch()
initSearchPage()
initSettings()
}
},
linkSelector: 'a[href]:not([href^="/"]):not([href^="http"])',
Expand All @@ -63,13 +75,14 @@ onDocumentReady(() => {
}

initVersions()
initSidebarDrawer()
initSidebarContent()
initSearch()
initModal()
initKeyboardShortcuts()
initQuickSwitch()
initToast()

initSidebarDrawer()
initSidebarContent()
initSearch()
initSearchPage()
initSettings()
}
Expand Down
13 changes: 3 additions & 10 deletions assets/js/tooltips/hint-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@ const CONTENT_INNER_SELECTOR = '.content-inner'
* and sends to the parent window as an event.
*/
export function initialize () {
if (shouldSendHint()) {
const hint = buildHint()
if (hint) {
sendHintToParentWindow(hint)
}
const hint = buildHint()
if (hint) {
sendHintToParentWindow(hint)
}
}

function shouldSendHint () {
const params = new URLSearchParams(window.location.search)
return params.has('hint') && window.self !== window.parent
}

function sendHintToParentWindow (hint) {
const href = window.location.href
const message = { hint, href }
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/ex_doc/formatter/html/templates/sidebar_template.eex
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
<% end %>
</nav>

<main class="content page-<%= type %>" id="main" data-type="<%= sidebar_type(type) %>">
<output role="status" id="toast"></output>
<output role="status" id="toast"></output>

<main class="content page-<%= type %>" id="main" data-type="<%= sidebar_type(type) %>">
<div id="content" class="content-inner">
<div class="top-search">
<div class="search-settings">
Expand Down

0 comments on commit 93caabf

Please sign in to comment.