-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
shiny-mode-tab
and shinylive
links in code block site-wide f…
…eatures
- Loading branch information
Showing
5 changed files
with
99 additions
and
91 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,6 @@ | ||
<script type="text/javascript"> | ||
|
||
document.querySelectorAll('.tab-pane:first-of-type').forEach((x) => x.classList.add("show")) | ||
|
||
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]') | ||
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl)) | ||
|
||
function addShinyliveEditLinks() { | ||
const codeWithLink = document.querySelectorAll('.sourceCode[data-shinylive]') | ||
codeWithLink.forEach(el => { | ||
el.classList.add("code-with-shinylive-link") | ||
const url = el.dataset.shinylive | ||
|
||
// <a class="edit-shinylive-button btn btn-link" href="<%= app.shinylive %>" data-bs-toggle="tooltip" data-bs-title="Edit in Shinylive" data-bs-placement="bottom"> | ||
// <i class="bi bi-lightning-fill"></i> <span class="visually-hidden">Edit in Shinylive</span> | ||
// </a> | ||
|
||
const link = document.createElement('a') | ||
link.classList.add('edit-shinylive-button', 'btn', 'btn-link') | ||
link.href = url | ||
link.dataset.bsToggle = 'tooltip' | ||
link.dataset.bsTitle = 'Edit in Shinylive' | ||
link.dataset.bsPlacement = 'bottom' | ||
|
||
const icon = document.createElement('i') | ||
icon.classList.add('bi', 'bi-lightning-fill') | ||
link.appendChild(icon) | ||
|
||
const span = document.createElement('span') | ||
span.classList.add('visually-hidden') | ||
span.innerText = 'Edit in Shinylive' | ||
link.appendChild(span) | ||
|
||
const btnCopy = el.querySelector('.code-copy-button') | ||
if (btnCopy) { | ||
btnCopy.parentElement.insertBefore(link, btnCopy) | ||
} else { | ||
if (el.matches('pre')) { | ||
el.appendChild(link) | ||
} else { | ||
el.querySelector('pre').appendChild(link) | ||
} | ||
} | ||
|
||
if (window.bootstrap?.Tooltip) { | ||
new bootstrap.Tooltip(link) | ||
} | ||
el.removeAttribute('data-shinylive') | ||
}) | ||
} | ||
|
||
addShinyliveEditLinks() | ||
</script> |
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,3 +1,3 @@ | ||
<!-- Google Tag Manager (noscript) --> | ||
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KHBDBW7" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> | ||
<!-- End Google Tag Manager (noscript) --> | ||
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KHBDBW7" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> | ||
<!-- End Google Tag Manager (noscript) --> |
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