打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

Widget:GFLMail:修订间差异

来自OGAS数据中枢
弃权者留言 | 贡献
无编辑摘要
弃权者留言 | 贡献
无编辑摘要
 
(未显示同一用户的11个中间版本)
第1行: 第1行:
<script>
<script>
(function() {
(function () {
     var widgetId = '<!--{$id|escape:'html'}-->';
  if (window._gflMailInit) return;
      
  window._gflMailInit = true;
     function initMail() {
 
        var rootEl = document.getElementById('gflRoot-' + widgetId);
  function openDetail(item) {
        if (!rootEl || rootEl.classList.contains('gfl-initialized')) {
     var idx  = item.getAttribute('data-gfl-index');
            return;
    var root = item.closest('.gfl-mail');
        }
    if (!root) return;
       
 
        rootEl.classList.add('gfl-initialized');
    // 先撑开外壳到固定高度,再做过渡
       
    var fixedH = getComputedStyle(root).getPropertyValue('--gfl-height').trim() || '450px';
        var mailsData;
    // 先把当前自然高度设为起点,避免从0跳变
        try {
    root.style.height = root.offsetHeight + 'px';
            mailsData = JSON.parse(rootEl.getAttribute('data-mails') || '[]');
    // 强制重排后过渡到目标高度
        } catch(e) {
    root.offsetHeight;
            console.error('GFLMail: Failed to parse mail data', e);
    root.style.transition = 'height .3s cubic-bezier(.4,0,.2,1)';
            return;
     root.style.height = fixedH;
        }
 
       
     root.querySelectorAll('.gfl-detail.is-open').forEach(function (d) {
        var wrapperEl = document.getElementById('gflWrapper-' + widgetId);
      d.classList.remove('is-open');
        var detailEl = wrapperEl.querySelector('.gfl-detail');
    });
        var listEl = wrapperEl.querySelector('.gfl-list');
    var target = root.querySelector('#gflDetail-' + idx);
       
    if (!target) return;
        if (!wrapperEl || !detailEl || !listEl) {
 
            return;
    root.classList.add('view-detail');
        }
    requestAnimationFrame(function () {
       
      target.classList.add('is-open');
        var items = listEl.querySelectorAll('.gfl-item');
    });
        for (var i = 0; i < items.length; i++) {
  }
            (function(index) {
 
                var item = items[index];
function closeDetail(btn) {
               
  var root = btn.closest('.gfl-mail');
                item.addEventListener('click', function() {
  if (!root) return;
                    openMail(index);
 
                });
  root.querySelectorAll('.gfl-detail.is-open').forEach(function (d) {
               
    d.classList.remove('is-open');
                item.addEventListener('keypress', function(e) {
  });
                    if (e.key === 'Enter' || e.key === ' ') {
  root.classList.remove('view-detail');
                        e.preventDefault();
 
                        openMail(index);
  // 过渡回列表自然高度
                    }
  var list = root.querySelector('.gfl-list');
                });
  // 列表隐藏时 visibility:hidden 但仍占布局,scrollHeight 可读
            })(i);
  var listH = list.scrollHeight;
        }
  root.style.transition = 'height .3s cubic-bezier(.4,0,.2,1)';
       
  root.style.height = listH + 'px';
        var backBtn = detailEl.querySelector('.gfl-back-btn');
 
        if (backBtn) {
  root.addEventListener('transitionend', function onEnd(e) {
            backBtn.addEventListener('click', function() {
    if (e.propertyName !== 'height') return;
                wrapperEl.classList.remove('detail-open');
    root.removeEventListener('transitionend', onEnd);
            });
    root.style.height = '';
        }
    root.style.transition = '';
       
  });
        function openMail(idx) {
}
            var mail = mailsData[idx];
 
            if (!mail) return;
  document.querySelectorAll('.gfl-item').forEach(function (item) {
           
    item.addEventListener('click', function () { openDetail(item); });
            var subjectEl = detailEl.querySelector('.gfl-detail-subject');
    item.addEventListener('keydown', function (e) {
            var dateEl = detailEl.querySelector('.gfl-date-row');
      if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); openDetail(item); }
            var contentEl = detailEl.querySelector('.gfl-content');
    });
            var charEl = detailEl.querySelector('.gfl-char');
  });
           
 
            if (subjectEl) subjectEl.textContent = mail.subject;
  document.querySelectorAll('.gfl-back-btn').forEach(function (btn) {
            if (dateEl) dateEl.textContent = mail.date;
    btn.addEventListener('click', function () { closeDetail(btn); });
            if (contentEl) contentEl.innerHTML = mail.content;
    btn.addEventListener('keydown', function (e) {
           
      if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); closeDetail(btn); }
            if (charEl) {
     });
                if (mail.charImg) {
  });
                    charEl.innerHTML = '<img src="' + mail.charImg + '" alt="人形立绘" />';
                } else {
                    charEl.innerHTML = '<div class="gfl-char-placeholder">立绘区域<br>(传入图片后显示)</div>';
                }
            }
           
            wrapperEl.classList.add('detail-open');
        }
     }
   
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', initMail);
    } else {
        initMail();
    }
})();
})();
</script>
</script>
<includeonly><!--{$id|validate:'id'}--></includeonly>

2026年5月21日 (四) 07:44的最新版本

<script> (function () {

 if (window._gflMailInit) return;
 window._gflMailInit = true;
 function openDetail(item) {
   var idx  = item.getAttribute('data-gfl-index');
   var root = item.closest('.gfl-mail');
   if (!root) return;
   // 先撑开外壳到固定高度,再做过渡
   var fixedH = getComputedStyle(root).getPropertyValue('--gfl-height').trim() || '450px';
   // 先把当前自然高度设为起点,避免从0跳变
   root.style.height = root.offsetHeight + 'px';
   // 强制重排后过渡到目标高度
   root.offsetHeight;
   root.style.transition = 'height .3s cubic-bezier(.4,0,.2,1)';
   root.style.height = fixedH;
   root.querySelectorAll('.gfl-detail.is-open').forEach(function (d) {
     d.classList.remove('is-open');
   });
   var target = root.querySelector('#gflDetail-' + idx);
   if (!target) return;
   root.classList.add('view-detail');
   requestAnimationFrame(function () {
     target.classList.add('is-open');
   });
 }

function closeDetail(btn) {

 var root = btn.closest('.gfl-mail');
 if (!root) return;
 root.querySelectorAll('.gfl-detail.is-open').forEach(function (d) {
   d.classList.remove('is-open');
 });
 root.classList.remove('view-detail');
 // 过渡回列表自然高度
 var list = root.querySelector('.gfl-list');
 // 列表隐藏时 visibility:hidden 但仍占布局,scrollHeight 可读
 var listH = list.scrollHeight;
 root.style.transition = 'height .3s cubic-bezier(.4,0,.2,1)';
 root.style.height = listH + 'px';
 root.addEventListener('transitionend', function onEnd(e) {
   if (e.propertyName !== 'height') return;
   root.removeEventListener('transitionend', onEnd);
   root.style.height = ;
   root.style.transition = ;
 });

}

 document.querySelectorAll('.gfl-item').forEach(function (item) {
   item.addEventListener('click', function () { openDetail(item); });
   item.addEventListener('keydown', function (e) {
     if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); openDetail(item); }
   });
 });
 document.querySelectorAll('.gfl-back-btn').forEach(function (btn) {
   btn.addEventListener('click', function () { closeDetail(btn); });
   btn.addEventListener('keydown', function (e) {
     if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); closeDetail(btn); }
   });
 });

})(); </script>