-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
132 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
body.preview { | ||
--sidebarWidth: 0px; | ||
} | ||
|
||
body.preview .content { | ||
height: auto; | ||
} | ||
|
||
body.preview .content-inner { | ||
padding: 0; | ||
} | ||
|
||
body.preview .sidebar, body.preview #sidebar-menu { | ||
display: none; | ||
} | ||
|
||
body.preview .hover-link, body.preview .detail-link { | ||
display: none; | ||
} | ||
|
||
body.preview :is(h1, h2, h3):first-of-type { | ||
margin-top: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@media print { | ||
.main { | ||
.body-wrapper { | ||
display: block; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,35 @@ | ||
import { getLocationHash, descriptionElementFromHash } from './helpers' | ||
|
||
|
||
export function initialize () { | ||
const previewing = getPreviewing() | ||
const previewing = descriptionElementFromHash(getLocationHash(), true) | ||
|
||
if (previewing) { | ||
preview(previewing) | ||
} | ||
} | ||
|
||
function preview (previewing) { | ||
cleanUpPreviewing(previewing) | ||
replaceContents(previewing) | ||
removeNonPreviewContents() | ||
makeLinksOpenInParent() | ||
scrollToTop() | ||
} | ||
|
||
function makeLinksOpenInParent () { | ||
const links = document.getElementsByTagName('a') | ||
for (let element of links) { | ||
for (const element of links) { | ||
console.log(element) | ||
if(element.getAttribute('target') !== '_blank') { | ||
if (element.getAttribute('target') !== '_blank') { | ||
element.setAttribute('target', '_parent') | ||
} | ||
} | ||
} | ||
|
||
function cleanUpPreviewing(previewing) { | ||
const detailHeader = previewing.querySelector('.detail-header') | ||
if (detailHeader) { | ||
detailHeader.classList.add('detail-header-preview') | ||
} | ||
} | ||
|
||
function scrollToTop() { | ||
function scrollToTop () { | ||
window.scrollTo(0, 0) | ||
} | ||
|
||
function removeNonPreviewContents () { | ||
document.getElementById('sidebar').remove() | ||
document.getElementById('sidebar-menu').remove() | ||
document.getElementById('background-layer').remove() | ||
const bottomActions = document.getElementById('bottom-actions') | ||
bottomActions && bottomActions.remove() | ||
const footer = document.getElementById('footer') | ||
footer && footer.remove() | ||
Array.from(document.getElementsByTagName('a')) | ||
.filter((element) => element.getAttribute('href').startsWith('#')) | ||
.forEach(element => element.remove()) | ||
} | ||
|
||
function replaceContents (previewing) { | ||
const contentContainer = document.getElementById('main') | ||
contentContainer.classList.add("content-preview") | ||
document.body.classList.add('preview') | ||
const content = document.getElementById('content') | ||
content.innerHTML = previewing.innerHTML | ||
} | ||
|
||
function getPreviewing () { | ||
const params = new URLSearchParams(window.location.search) | ||
if (params.has('preview')) { | ||
return descriptionElementFromHash(getLocationHash(), true) | ||
} | ||
} |
Oops, something went wrong.