Author card uses configurable limit/orderby/style and self CTAs. Tip is per-user weixin/alipay QR modal (no site-global image). Comment action permissions honor user_caps matrix. Free points tasks expose done_today/passive status + better comment deep link. audit-admin-contracts errors=0.
59 lines
1.6 KiB
JavaScript
59 lines
1.6 KiB
JavaScript
/**
|
|
* Reward (打赏) — per-user QR modal openers.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
;(function () {
|
|
'use strict';
|
|
|
|
function initReward() {
|
|
function closeAll() {
|
|
document.querySelectorAll('.reward-modal.is-open').forEach(function (m) {
|
|
m.classList.remove('is-open');
|
|
m.setAttribute('aria-hidden', 'true');
|
|
});
|
|
document.body.style.overflow = '';
|
|
}
|
|
|
|
function openForUser(userId) {
|
|
var id = String(userId || '');
|
|
var modal = id
|
|
? document.getElementById('reward-modal-' + id)
|
|
: document.querySelector('.reward-modal');
|
|
if (!modal) return;
|
|
closeAll();
|
|
modal.classList.add('is-open');
|
|
modal.setAttribute('aria-hidden', 'false');
|
|
document.body.style.overflow = 'hidden';
|
|
}
|
|
|
|
document.querySelectorAll('[data-aksrt-reward-open]').forEach(function (el) {
|
|
el.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
openForUser(el.getAttribute('data-user-id') || '');
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('[data-aksrt-reward-close]').forEach(function (el) {
|
|
el.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
closeAll();
|
|
});
|
|
});
|
|
|
|
document.addEventListener('keydown', function (e) {
|
|
if (e.key === 'Escape') closeAll();
|
|
});
|
|
}
|
|
|
|
if (window.AksrtFrontend && typeof window.AksrtFrontend.register === 'function') {
|
|
window.AksrtFrontend.register('aksrt-reward', function () {
|
|
initReward();
|
|
});
|
|
} else if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', initReward);
|
|
} else {
|
|
initReward();
|
|
}
|
|
})();
|