added 打赏效果

This commit is contained in:
Vaica committed 2026-02-02 21:36:53 +08:00
1 parent 93e7f21444
commit 6047ab7eef
7 files changed
+329 -8

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
/**
* Reward System Module
*/
(function() {
function initReward() {
const btn = document.getElementById('reward-btn');
const modal = document.getElementById('reward-modal');
const close = document.getElementById('reward-close');
if (!btn || !modal) return;
// Helper to show modal
const showModal = (e) => {
if(e) {
e.preventDefault();
e.stopPropagation();
}
modal.classList.add('show');
document.body.style.overflow = 'hidden'; // Prevent scrolling
};
// Helper to hide modal
const hideModal = () => {
modal.classList.remove('show');
document.body.style.overflow = '';
};
// Button click
btn.addEventListener('click', showModal);
// Close button click
if (close) {
close.addEventListener('click', hideModal);
}
// Click outside modal content
modal.addEventListener('click', (e) => {
if (e.target === modal) {
hideModal();
}
});
// Escape key to close
if (!window.rewardKeyHandlerAttached) {
document.addEventListener('keydown', function(e) {
const activeModal = document.getElementById('reward-modal');
if (e.key === 'Escape' && activeModal && activeModal.classList.contains('show')) {
activeModal.classList.remove('show');
document.body.style.overflow = '';
}
});
window.rewardKeyHandlerAttached = true;
}
}
// Initialize on load
document.addEventListener('DOMContentLoaded', initReward);
// Initialize on Pjax complete
document.addEventListener('pjax:complete', initReward);
// Export
window.initReward = initReward;
})();