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

Widget:GFLMail:修订间差异

来自OGAS数据中枢
弃权者留言 | 贡献
无编辑摘要
弃权者留言 | 贡献
无编辑摘要
第1行: 第1行:
<script>document.querySelectorAll('.gfl-item').forEach(item => {
<script>
   item.addEventListener('click', () => {
(function () {
     const idx = item.getAttribute('data-gfl-index');
  // 防止重复绑定(MW 可能多次执行)
     const root = item.closest('.gfl-mail');
  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;
     if (!root) return;


     root.querySelectorAll('.gfl-detail').forEach(d => d.classList.remove('is-open'));
    // 先关掉所有其他 detail
     root.querySelectorAll('.gfl-detail.is-open').forEach(function (d) {
      d.classList.remove('is-open');
    });


     const targetDetail = root.querySelector(`#gflDetail-${idx}`);
     var target = root.querySelector('#gflDetail-' + idx);
     if (!targetDetail) return;
     if (!target) return;


     targetDetail.style.visibility = 'hidden';
     // grid 布局下两面板共占同一单元格,高度自动由内容决定,无需手动设置
    targetDetail.style.opacity = '0';
    targetDetail.style.transform = 'translateX(30px)';
    targetDetail.classList.add('is-open');
   
    targetDetail.offsetHeight;
   
    const bodyEl = targetDetail.querySelector('.gfl-detail-body');
    const contentHeight = bodyEl ? bodyEl.scrollHeight : targetDetail.scrollHeight;
    const headerHeight = targetDetail.querySelector('.gfl-detail-header').offsetHeight;
    const totalHeight = contentHeight + headerHeight + 40; // 40px 是 padding 等
   
    const minHeight = 400;
    const finalHeight = Math.max(totalHeight, minHeight);
   
    root.style.height = finalHeight + 'px';
   
    targetDetail.style.visibility = '';
    targetDetail.style.opacity = '';
    targetDetail.style.transform = '';
   
     root.classList.add('view-detail');
     root.classList.add('view-detail');
  });
    // 下一帧再加 is-open,确保浏览器先完成布局,transition 才能正常触发
});
    requestAnimationFrame(function () {
      target.classList.add('is-open');
    });
  }


document.querySelectorAll('.gfl-back-btn').forEach(btn => {
  function closeDetail(btn) {
  btn.addEventListener('click', () => {
     var root = btn.closest('.gfl-mail');
     const root = btn.closest('.gfl-mail');
     if (!root) return;
     if (!root) return;
    root.querySelectorAll('.gfl-detail.is-open').forEach(function (d) {
      d.classList.remove('is-open');
    });
    root.classList.remove('view-detail');
  }


     root.classList.remove('view-detail');
  document.querySelectorAll('.gfl-item').forEach(function (item) {
     root.querySelectorAll('.gfl-detail').forEach(d => d.classList.remove('is-open'));
     item.addEventListener('click', function () { openDetail(item); });
     item.addEventListener('keydown', function (e) {
      if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); openDetail(item); }
    });
  });


     root.style.height = '';
  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>
</script>

2026年5月21日 (四) 07:32的版本

<script> (function () {

 // 防止重复绑定(MW 可能多次执行)
 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;
   // 先关掉所有其他 detail
   root.querySelectorAll('.gfl-detail.is-open').forEach(function (d) {
     d.classList.remove('is-open');
   });
   var target = root.querySelector('#gflDetail-' + idx);
   if (!target) return;
   // grid 布局下两面板共占同一单元格,高度自动由内容决定,无需手动设置
   root.classList.add('view-detail');
   // 下一帧再加 is-open,确保浏览器先完成布局,transition 才能正常触发
   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');
 }
 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>