first load
This commit is contained in:
65
custom/script.js.template
Normal file
65
custom/script.js.template
Normal file
@@ -0,0 +1,65 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.querySelectorAll('pre').forEach(function(pre) {
|
||||
// Evita duplicar o botão copiar
|
||||
if (pre.querySelector('.copy-btn')) return;
|
||||
|
||||
pre.style.position = 'relative'; // importante para posicionamento absoluto do botão
|
||||
|
||||
// Criar botão copiar com ícone SVG
|
||||
const copyBtn = document.createElement('button');
|
||||
copyBtn.className = 'copy-btn';
|
||||
copyBtn.type = 'button';
|
||||
copyBtn.setAttribute('aria-label', 'Copiar código');
|
||||
|
||||
// Ícone clipboard SVG inline
|
||||
copyBtn.innerHTML = `
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
||||
<path d="M16 1H4a2 2 0 0 0-2 2v14h2V3h12V1zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2zm0 16H8V7h11v14z" />
|
||||
</svg>
|
||||
`;
|
||||
|
||||
copyBtn.addEventListener('click', function() {
|
||||
const codeElement = pre.querySelector('code');
|
||||
let textToCopy = '';
|
||||
|
||||
if (codeElement) {
|
||||
textToCopy = codeElement.innerText;
|
||||
} else {
|
||||
// Copiar apenas texto puro do <pre> ignorando o botão
|
||||
textToCopy = Array.from(pre.childNodes)
|
||||
.filter(node => node.nodeType === Node.TEXT_NODE)
|
||||
.map(node => node.textContent)
|
||||
.join('');
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(textToCopy).then(() => {
|
||||
// Feedback visual simples
|
||||
copyBtn.innerHTML = `
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" >
|
||||
<path fill="green" d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/>
|
||||
</svg>`;
|
||||
setTimeout(() => {
|
||||
copyBtn.innerHTML = `
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
||||
<path d="M16 1H4a2 2 0 0 0-2 2v14h2V3h12V1zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2zm0 16H8V7h11v14z" />
|
||||
</svg>
|
||||
`;
|
||||
}, 1500);
|
||||
}).catch(() => {
|
||||
// Se erro, exibe ícone de erro (vermelho)
|
||||
copyBtn.innerHTML = `
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false" >
|
||||
<path fill="red" d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.29 13.29-1.41 1.41L12 13.41l-2.88 2.88-1.41-1.41L10.59 12 7.71 9.12l1.41-1.41L12 10.59l2.88-2.88 1.41 1.41L13.41 12l2.88 2.88z"/>
|
||||
</svg>`;
|
||||
setTimeout(() => {
|
||||
copyBtn.innerHTML = `
|
||||
<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
|
||||
<path d="M16 1H4a2 2 0 0 0-2 2v14h2V3h12V1zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2zm0 16H8V7h11v14z" />
|
||||
</svg>`;
|
||||
}, 1500);
|
||||
});
|
||||
});
|
||||
|
||||
pre.appendChild(copyBtn);
|
||||
});
|
||||
});
|
||||
268
custom/style.css.template
Normal file
268
custom/style.css.template
Normal file
@@ -0,0 +1,268 @@
|
||||
/* ===== Hiding social content ===== */
|
||||
.recent-activity-item-comment {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.article-votes {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.share {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.comment-overview {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.comment-callout {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ===== Collumns size ===== */
|
||||
.container {
|
||||
max-width: 1300px !important;
|
||||
}
|
||||
|
||||
.header {
|
||||
max-width: 1300px !important;
|
||||
}
|
||||
|
||||
#main-content.article, .article, .article-body, #article-body {
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
.article-container a:hover,
|
||||
#article-container a:hover {
|
||||
text-decoration: underline !important;
|
||||
}
|
||||
|
||||
/* ===== Article page container ===== */
|
||||
.article-container,
|
||||
#article-container {
|
||||
display: flex !important;
|
||||
flex-wrap: wrap !important;
|
||||
justify-content: center !important;
|
||||
align-items: flex-start !important;
|
||||
max-width: 1300px !important;
|
||||
margin: 0 auto !important;
|
||||
box-sizing: border-box !important;
|
||||
background: transparent !important;
|
||||
gap: 40px !important;
|
||||
width: 100% !important;
|
||||
overflow-x: hidden !important;
|
||||
}
|
||||
|
||||
/* ===== Main article ===== */
|
||||
#main-content.article,
|
||||
.article,
|
||||
.article-body,
|
||||
#article-body {
|
||||
flex: 1 1 700px !important;
|
||||
max-width: 100% !important;
|
||||
min-width: 300px !important;
|
||||
width: 100% !important;
|
||||
background: #fff !important;
|
||||
border-radius: 12px !important;
|
||||
margin: 40px 0 !important;
|
||||
font-size: 15px !important;
|
||||
line-height: 1.7 !important;
|
||||
box-sizing: border-box !important;
|
||||
overflow-wrap: break-word !important;
|
||||
}
|
||||
|
||||
/* ===== Sidebar ===== */
|
||||
.zd-sidebar,
|
||||
.article-sidebar {
|
||||
max-width: 260px !important;
|
||||
width: 100% !important;
|
||||
background: #f1f5f9 !important;
|
||||
padding: 20px !important;
|
||||
border-radius: 10px !important;
|
||||
font-size: 15px !important;
|
||||
line-height: 1.5 !important;
|
||||
margin: 40px 0 !important;
|
||||
box-sizing: border-box !important;
|
||||
overflow-wrap: break-word !important;
|
||||
}
|
||||
|
||||
/* ===== Responsiveness ===== */
|
||||
@media (max-width: 1150px) {
|
||||
.article-container,
|
||||
#article-container {
|
||||
flex-direction: column !important;
|
||||
gap: 0 !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
#main-content.article,
|
||||
.article,
|
||||
.article-body,
|
||||
#article-body {
|
||||
max-width: 100% !important;
|
||||
padding: 18px 1vw !important;
|
||||
margin: 10px 0 !important;
|
||||
border-radius: 8px !important;
|
||||
font-size: 16px !important;
|
||||
}
|
||||
.zd-sidebar,
|
||||
.article-sidebar {
|
||||
max-width: 100% !important;
|
||||
margin: 0 0 24px 0 !important;
|
||||
border-radius: 8px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Prevent horizontal page scroll ===== */
|
||||
html,
|
||||
body {
|
||||
overflow-x: hidden !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
|
||||
/* ===== General styles ===== */
|
||||
body {
|
||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
|
||||
background: #fafafa !important;
|
||||
color: #222 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4 {
|
||||
color: #004080 !important;
|
||||
font-weight: 700 !important;
|
||||
margin-top: 0.5em !important;
|
||||
margin-bottom: 0.5em !important;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #007acc !important;
|
||||
text-decoration: none !important;
|
||||
transition: color 0.3s ease !important;
|
||||
}
|
||||
|
||||
a:hover,
|
||||
a:focus {
|
||||
color: #005a99 !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-bottom: 1.15em !important;
|
||||
font-size: 15px !important;
|
||||
word-break: break-word !important;
|
||||
}
|
||||
|
||||
ul,
|
||||
ol {
|
||||
margin-left: 0.5em !important;
|
||||
margin-bottom: 1.1em !important;
|
||||
font-size: 15px !important;
|
||||
}
|
||||
|
||||
ul li strong {
|
||||
color: #d9534f !important;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse !important;
|
||||
width: 100% !important;
|
||||
margin-bottom: 1.5em !important;
|
||||
table-layout: fixed !important;
|
||||
word-wrap: break-word !important;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
border: 1px solid #ddd !important;
|
||||
padding: 10px !important;
|
||||
text-align: left !important;
|
||||
}
|
||||
|
||||
th {
|
||||
background-color: #007acc !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
img,
|
||||
.article-body img {
|
||||
max-width: 100% !important;
|
||||
height: auto !important;
|
||||
border-radius: 7px !important;
|
||||
box-shadow: 0 2px 10px rgb(0 0 0 / 0.1) !important;
|
||||
margin: 1.5em 0 !important;
|
||||
}
|
||||
|
||||
/* ===== Styles for <pre> blocks with copy button ===== */
|
||||
pre {
|
||||
position: relative !important;
|
||||
background: #f7f9fc !important;
|
||||
border-left: 5px solid #007acc !important;
|
||||
padding: 17px 20px 17px 20px !important;
|
||||
border-radius: 5px !important;
|
||||
margin-bottom: 2em !important;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
|
||||
font-family: Consolas, Monaco, 'Courier New', monospace !important;
|
||||
font-size: 14px !important;
|
||||
line-height: 1.6 !important;
|
||||
overflow-x: auto !important;
|
||||
white-space: pre !important;
|
||||
word-break: break-word !important;
|
||||
}
|
||||
|
||||
/* Copy button inside <pre> */
|
||||
pre .copy-btn {
|
||||
position: absolute !important;
|
||||
top: 12px !important;
|
||||
right: 12px !important;
|
||||
background: none !important;
|
||||
border: none !important;
|
||||
padding: 6px !important;
|
||||
cursor: pointer !important;
|
||||
z-index: 2 !important;
|
||||
transition: background-color 0.3s ease !important;
|
||||
color: #007acc !important;
|
||||
border-radius: 4px !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
font-size: 16px !important;
|
||||
}
|
||||
|
||||
pre .copy-btn:hover,
|
||||
pre .copy-btn:focus {
|
||||
background-color: rgba(0, 122, 204, 0.2) !important;
|
||||
outline: none !important;
|
||||
color: #005a99 !important;
|
||||
}
|
||||
|
||||
/* SVG icon inside the button, size and color */
|
||||
pre .copy-btn svg {
|
||||
width: 20px !important;
|
||||
height: 20px !important;
|
||||
fill: currentColor !important;
|
||||
}
|
||||
|
||||
/* ===== Responsiveness for small devices ===== */
|
||||
@media (max-width: 900px) {
|
||||
#main-content.article,
|
||||
.article,
|
||||
.article-body,
|
||||
#article-body {
|
||||
padding: 10px 2vw !important;
|
||||
font-size: 16px !important;
|
||||
}
|
||||
pre {
|
||||
padding: 14px 14px 14px 14px !important;
|
||||
font-size: 14px !important;
|
||||
}
|
||||
pre .copy-btn {
|
||||
top: 8px !important;
|
||||
right: 8px !important;
|
||||
padding: 5px !important;
|
||||
font-size: 14px !important;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user