孕期小知识四张小卡精简:收起只露一句重点(宝宝=大小比喻,其余取首个分句),点开看全文,标题加小箭头 (v26100130)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 13:05:33 +00:00
parent eb1c1b51f1
commit 19e0167df0
3 changed files with 35 additions and 8 deletions

View File

@@ -3,7 +3,7 @@
(function () {
'use strict';
/* 页面版本号(YYMMDD+序号):显示在「关于兜爸心选」页底部;bump 时同步 head 注释与 ?v= */
var VER = '26100129';
var VER = '26100130';
const $ = (s, c) => (c || document).querySelector(s);
const $$ = (s, c) => Array.from((c || document).querySelectorAll(s));
@@ -3784,10 +3784,11 @@
$('#ptWhen').textContent = '本周第 ' + (today + 1) + ' 天';
$('#ptFloat').textContent = size.emoji;
$('#ptBabyIco').textContent = size.emoji;
$('#ptBaby').textContent = '像' + size.name + '那么大。' + (wk.baby || '');
$('#ptMom').textContent = wk.mom || '';
$('#ptEat').textContent = wk.eat || '';
$('#ptCare').textContent = wk.care || '';
/* 2026-10-01 用户反馈「四张小卡文字太多」:卡上只露一句重点,点开再看全文(全文存 data-full) */
setTipCard('#ptBaby', '像' + size.name + '那么大', '像' + size.name + '那么大。' + (wk.baby || ''));
setTipCard('#ptMom', tipGist(wk.mom), wk.mom);
setTipCard('#ptEat', tipGist(wk.eat), wk.eat);
setTipCard('#ptCare', tipGist(wk.care), wk.care);
/* 一周 7 个圆点:以前可回看,今天实心,以后锁着 */
const box = $('#ptDays');
box.textContent = '';
@@ -3825,10 +3826,31 @@
const body = $('#ptBody');
body.classList.remove('is-in'); void body.offsetWidth; body.classList.add('is-in'); // 重播进场动画
}
/* 四张小卡压成横滑后正文只露 3 行,点一下展开全文、再点收起 */
/* 一句重点 = 全文的第一个分句;太短(如「从这周末起」)就再带上下一句 */
function tipGist(txt) {
const parts = String(txt || '').split(/[,。;!]/).filter(Boolean);
let g = parts[0] || '';
if (g.length < 7 && parts[1]) g += ',' + parts[1];
return g;
}
function setTipCard(sel, gist, full) {
const p = $(sel);
if (!p) return;
p.dataset.gist = gist || '';
p.dataset.full = full || '';
const open = p.closest('.pt-card').classList.contains('is-open');
p.textContent = open ? p.dataset.full : p.dataset.gist;
}
/* 四张小卡只露一句重点,点一下展开全文、再点收回一句 */
(function () {
const g = $('#ptGrid');
if (g) g.addEventListener('click', e => { const c = e.target.closest('.pt-card'); if (c) c.classList.toggle('is-open'); });
if (g) g.addEventListener('click', e => {
const c = e.target.closest('.pt-card');
if (!c) return;
const open = c.classList.toggle('is-open');
const p = $('p', c);
if (p && p.dataset.full) p.textContent = open ? p.dataset.full : p.dataset.gist;
});
})();
function revealTipsGrid() {
const g = $('#ptGrid');