Template:Theme-HJ: Difference between revisions
From HUIJIA FUN
PlurimodSU (talk | contribs) Beautification |
PlurimodSU (talk | contribs) m Beautification |
||
| Line 259: | Line 259: | ||
<script> | <script> | ||
/** | /** | ||
* HUIJIA FUN - | * HUIJIA FUN - UI ENHANCEMENTS (v4.1) | ||
* Features: | * Fix: Moved Reading Progress Bar to bottom to prevent header overlap. | ||
* Features: Bottom Progress Bar, Code Copy Buttons, Smooth Reveal. | |||
*/ | */ | ||
| Line 267: | Line 267: | ||
"use strict"; | "use strict"; | ||
const injectStyles = () => { | const injectStyles = () => { | ||
const style = document.createElement('style'); | const style = document.createElement('style'); | ||
style.innerHTML = ` | style.innerHTML = ` | ||
/* Reading Progress Bar */ | /* Reading Progress Bar - Moved to Bottom */ | ||
#reading-progress-container { | #reading-progress-container { | ||
position: fixed; | position: fixed; | ||
top: 0 | bottom: 0; /* Changed from top: 0 */ | ||
left: 0; | left: 0; | ||
width: 100%; | width: 100%; | ||
height: | height: 5px; | ||
background: | background: rgba(255, 255, 255, 0.2); | ||
z-index: | backdrop-filter: blur(2px); | ||
z-index: 9999; | |||
border-top: 1px solid rgba(0,0,0,0.05); | |||
} | } | ||
#reading-progress-bar { | #reading-progress-bar { | ||
| Line 285: | Line 286: | ||
width: 0%; | width: 0%; | ||
background: var(--mw-primary, #025F32); | background: var(--mw-primary, #025F32); | ||
transition: width 0. | box-shadow: 0 0 10px var(--mw-accent, #227F52); | ||
transition: width 0.15s ease-out; | |||
} | } | ||
/* Copy Button | /* Code Block Copy Button Fix */ | ||
.code-copy-btn { | .code-copy-btn { | ||
position: absolute; | position: absolute; | ||
top: | top: 10px; | ||
right: | right: 10px; | ||
background: var(--mw-primary, #025F32); | background: var(--mw-primary, #025F32); | ||
color: white; | color: white; | ||
border: none; | border: none; | ||
border-radius: | border-radius: 6px; | ||
padding: | padding: 5px 10px; | ||
font-size: 11px; | font-size: 11px; | ||
font-family: | font-family: var(--font-heading); | ||
font-weight: bold; | |||
cursor: pointer; | cursor: pointer; | ||
opacity: 0; | opacity: 0; | ||
transition: | transition: all 0.2s ease; | ||
z-index: | z-index: 50; | ||
} | } | ||
pre:hover .code-copy-btn { | pre:hover .code-copy-btn { | ||
| Line 310: | Line 313: | ||
.code-copy-btn:hover { | .code-copy-btn:hover { | ||
background: var(--mw-accent, #227F52); | background: var(--mw-accent, #227F52); | ||
transform: scale(1.05); | |||
} | } | ||
pre { position: relative; } | pre { position: relative; overflow: visible !important; } | ||
/* | /* Entrance Animations */ | ||
.reveal-on-scroll { | .reveal-on-scroll { | ||
opacity: 0; | opacity: 0; | ||
transform: translateY( | transform: translateY(15px); | ||
transition: | transition: opacity 0.6s ease-out, transform 0.6s ease-out; | ||
} | } | ||
.reveal-on-scroll.is-visible { | .reveal-on-scroll.is-visible { | ||
opacity: 1; | opacity: 1; | ||
transform: translateY(0); | transform: translateY(0); | ||
} | } | ||
`; | `; | ||
| Line 348: | Line 331: | ||
}; | }; | ||
const initProgressBar = () => { | const initProgressBar = () => { | ||
const container = document.createElement('div'); | const container = document.createElement('div'); | ||
| Line 358: | Line 340: | ||
window.addEventListener('scroll', () => { | window.addEventListener('scroll', () => { | ||
const winScroll = | const winScroll = window.pageYOffset || document.documentElement.scrollTop; | ||
const height = document.documentElement.scrollHeight - document.documentElement.clientHeight; | const height = document.documentElement.scrollHeight - document.documentElement.clientHeight; | ||
const scrolled = (winScroll / height) * 100; | const scrolled = (winScroll / height) * 100; | ||
| Line 365: | Line 347: | ||
}; | }; | ||
const initCopyButtons = () => { | const initCopyButtons = () => { | ||
const codeBlocks = document.querySelectorAll('pre'); | const codeBlocks = document.querySelectorAll('pre'); | ||
codeBlocks.forEach((block) => { | codeBlocks.forEach((block) => { | ||
if (block.querySelector('.code-copy-btn')) return; // Prevent duplicates | |||
const btn = document.createElement('button'); | const btn = document.createElement('button'); | ||
btn.className = 'code-copy-btn'; | btn.className = 'code-copy-btn'; | ||
| Line 384: | Line 366: | ||
}; | }; | ||
const initScrollReveal = () => { | const initScrollReveal = () => { | ||
const observer = new IntersectionObserver((entries) => { | const observer = new IntersectionObserver((entries) => { | ||
entries.forEach(entry => { | entries.forEach(entry => { | ||
| Line 393: | Line 373: | ||
} | } | ||
}); | }); | ||
}, | }, { threshold: 0.05 }); | ||
const items = document.querySelectorAll('#mw-content h2, #mw-content h3, .thumbinner, table.wikitable'); | |||
const | items.forEach(item => { | ||
item.classList.add('reveal-on-scroll'); | |||
observer.observe(item); | |||
observer.observe( | |||
}); | }); | ||
}; | }; | ||
// | // Execution | ||
document.addEventListener("DOMContentLoaded", () => { | |||
injectStyles(); | injectStyles(); | ||
initProgressBar(); | initProgressBar(); | ||
initCopyButtons(); | initCopyButtons(); | ||
initScrollReveal(); | initScrollReveal(); | ||
}); | }); | ||
})(); | })(); | ||
</script> | </script> | ||
Revision as of 00:33, 31 March 2026
Description
Origin
Author: PlurimodSU
Note
To use this theme on a page, simply add the following code directly to the page's source code:
{{Theme-HJ}}
