|
|
|
@ -234,7 +234,7 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
var buttons = document.createElement("div");
|
|
|
|
|
buttons.className = "buttons";
|
|
|
|
|
buttons.innerHTML =
|
|
|
|
|
'<button class="fa fa-eye" title="Show hidden lines" aria-label="Show hidden lines"></button>';
|
|
|
|
|
"<button class=\"fa fa-eye\" title=\"Show hidden lines\" aria-label=\"Show hidden lines\"></button>";
|
|
|
|
|
|
|
|
|
|
// add expand button
|
|
|
|
|
var pre_block = block.parentNode;
|
|
|
|
@ -274,7 +274,7 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
clipButton.className = "fa fa-copy clip-button";
|
|
|
|
|
clipButton.title = "Copy to clipboard";
|
|
|
|
|
clipButton.setAttribute("aria-label", clipButton.title);
|
|
|
|
|
clipButton.innerHTML = '<i class="tooltiptext"></i>';
|
|
|
|
|
clipButton.innerHTML = "<i class=\"tooltiptext\"></i>";
|
|
|
|
|
|
|
|
|
|
buttons.insertBefore(clipButton, buttons.firstChild);
|
|
|
|
|
}
|
|
|
|
@ -283,7 +283,7 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
|
|
|
|
|
// Process playground code blocks
|
|
|
|
|
Array.from(document.querySelectorAll(".playground")).forEach(function(
|
|
|
|
|
pre_block
|
|
|
|
|
pre_block,
|
|
|
|
|
) {
|
|
|
|
|
// Add play button
|
|
|
|
|
var buttons = pre_block.querySelector(".buttons");
|
|
|
|
@ -307,11 +307,11 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
if (window.playground_copyable) {
|
|
|
|
|
var copyCodeClipboardButton = document.createElement("button");
|
|
|
|
|
copyCodeClipboardButton.className = "fa fa-copy clip-button";
|
|
|
|
|
copyCodeClipboardButton.innerHTML = '<i class="tooltiptext"></i>';
|
|
|
|
|
copyCodeClipboardButton.innerHTML = "<i class=\"tooltiptext\"></i>";
|
|
|
|
|
copyCodeClipboardButton.title = "Copy to clipboard";
|
|
|
|
|
copyCodeClipboardButton.setAttribute(
|
|
|
|
|
"aria-label",
|
|
|
|
|
copyCodeClipboardButton.title
|
|
|
|
|
copyCodeClipboardButton.title,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
buttons.insertBefore(copyCodeClipboardButton, buttons.firstChild);
|
|
|
|
@ -339,7 +339,7 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
var html = document.querySelector("html");
|
|
|
|
|
var themeToggleButton = document.getElementById("theme-toggle");
|
|
|
|
|
var themePopup = document.getElementById("theme-list");
|
|
|
|
|
var themeColorMetaTag = document.querySelector('meta[name="theme-color"]');
|
|
|
|
|
var themeColorMetaTag = document.querySelector("meta[name=\"theme-color\"]");
|
|
|
|
|
var stylesheets = {
|
|
|
|
|
ayuHighlight: document.querySelector("[href$='ayu-highlight.css']"),
|
|
|
|
|
tomorrowNight: document.querySelector("[href$='tomorrow-night.css']"),
|
|
|
|
@ -402,7 +402,7 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
themeColorMetaTag.content = getComputedStyle(
|
|
|
|
|
document.documentElement
|
|
|
|
|
document.documentElement,
|
|
|
|
|
).backgroundColor;
|
|
|
|
|
}, 1);
|
|
|
|
|
|
|
|
|
@ -453,9 +453,9 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
themePopup.addEventListener("focusout", function(e) {
|
|
|
|
|
// e.relatedTarget is null in Safari and Firefox on macOS (see workaround below)
|
|
|
|
|
if (
|
|
|
|
|
!!e.relatedTarget &&
|
|
|
|
|
!themeToggleButton.contains(e.relatedTarget) &&
|
|
|
|
|
!themePopup.contains(e.relatedTarget)
|
|
|
|
|
!!e.relatedTarget
|
|
|
|
|
&& !themeToggleButton.contains(e.relatedTarget)
|
|
|
|
|
&& !themePopup.contains(e.relatedTarget)
|
|
|
|
|
) {
|
|
|
|
|
hideThemes();
|
|
|
|
|
}
|
|
|
|
@ -464,9 +464,9 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
// Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang/mdBook/issues/628
|
|
|
|
|
document.addEventListener("click", function(e) {
|
|
|
|
|
if (
|
|
|
|
|
themePopup.style.display === "block" &&
|
|
|
|
|
!themeToggleButton.contains(e.target) &&
|
|
|
|
|
!themePopup.contains(e.target)
|
|
|
|
|
themePopup.style.display === "block"
|
|
|
|
|
&& !themeToggleButton.contains(e.target)
|
|
|
|
|
&& !themePopup.contains(e.target)
|
|
|
|
|
) {
|
|
|
|
|
hideThemes();
|
|
|
|
|
}
|
|
|
|
@ -560,7 +560,7 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
if (html.classList.contains("sidebar-hidden")) {
|
|
|
|
|
var current_width = parseInt(
|
|
|
|
|
document.documentElement.style.getPropertyValue("--sidebar-width"),
|
|
|
|
|
10
|
|
|
|
|
10,
|
|
|
|
|
);
|
|
|
|
|
if (current_width < 150) {
|
|
|
|
|
document.documentElement.style.setProperty("--sidebar-width", "150px");
|
|
|
|
@ -611,7 +611,7 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
time: Date.now(),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
{ passive: true }
|
|
|
|
|
{ passive: true },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
document.addEventListener(
|
|
|
|
@ -625,16 +625,16 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
|
|
|
|
|
if (tDiff < 250 && Math.abs(xDiff) >= 150) {
|
|
|
|
|
if (
|
|
|
|
|
xDiff >= 0 &&
|
|
|
|
|
firstContact.x < Math.min(document.body.clientWidth * 0.25, 300)
|
|
|
|
|
)
|
|
|
|
|
xDiff >= 0
|
|
|
|
|
&& firstContact.x < Math.min(document.body.clientWidth * 0.25, 300)
|
|
|
|
|
) {
|
|
|
|
|
showSidebar();
|
|
|
|
|
else if (xDiff < 0 && curX < 300) hideSidebar();
|
|
|
|
|
} else if (xDiff < 0 && curX < 300) hideSidebar();
|
|
|
|
|
|
|
|
|
|
firstContact = null;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{ passive: true }
|
|
|
|
|
{ passive: true },
|
|
|
|
|
);
|
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
@ -758,7 +758,7 @@ function playground_text(playground, hidden = true) {
|
|
|
|
|
}
|
|
|
|
|
prevScrollTop = scrollTop;
|
|
|
|
|
},
|
|
|
|
|
{ passive: true }
|
|
|
|
|
{ passive: true },
|
|
|
|
|
);
|
|
|
|
|
})();
|
|
|
|
|
(function controllBorder() {
|
|
|
|
|