Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2f009f986 | ||
|
|
30904723d2 | ||
|
|
07fa69478f | ||
|
|
377d1ba2cf | ||
|
|
f674bb4c66 |
@@ -241,10 +241,13 @@
|
||||
|
||||
function buildData() {
|
||||
var morningItems = [];
|
||||
var mEls = document.querySelectorAll('#morning-list .item-row input');
|
||||
for (var i=0; i<mEls.length; i++) {
|
||||
var v = mEls[i].value.trim();
|
||||
if (v) morningItems.push(v);
|
||||
var mRows = document.querySelectorAll('#morning-list .item-row');
|
||||
for (var i=0; i<mRows.length; i++) {
|
||||
var input = mRows[i].querySelector('input[type="text"]');
|
||||
var noteEl = mRows[i].querySelector('.item-note-val');
|
||||
var v = input ? input.value.trim() : '';
|
||||
var n = noteEl ? noteEl.value.trim() : '';
|
||||
if (v) morningItems.push(n ? {text: v, note: n} : v);
|
||||
}
|
||||
// 收集日历日程
|
||||
var calEls = document.querySelectorAll('#morning-calendar-list .cal-task-item span:last-child');
|
||||
@@ -345,13 +348,22 @@
|
||||
var idx = container.children.length;
|
||||
var text = typeof val === 'string' ? val : (val && val.text ? val.text : '');
|
||||
text = text || '';
|
||||
var note = (val && val.note) ? val.note : '';
|
||||
var hasNote = !!note;
|
||||
var div = document.createElement('div');
|
||||
div.className = 'item-row';
|
||||
div.draggable = true;
|
||||
div.innerHTML = '<span class="drag-handle" title="拖动排序">⋮⋮</span>' +
|
||||
'<span class="idx">' + (idx+1) + '.</span>' +
|
||||
'<input type="text" value="' + esc(text) + '" placeholder="本周最重要的一件事…">' +
|
||||
'<button class="btn-note-toggle' + (hasNote ? ' has-note' : '') + '" onclick="openNoteModal(this)" title="备注">💬</button>' +
|
||||
'<button class="btn-del" onclick="this.parentElement.remove();renumberMorning()"><svg class="icon-sm"><use href="#icon-x"/></svg></button>';
|
||||
// 隐藏存储备注
|
||||
var noteHidden = document.createElement('input');
|
||||
noteHidden.type = 'hidden';
|
||||
noteHidden.className = 'item-note-val';
|
||||
noteHidden.value = note;
|
||||
div.appendChild(noteHidden);
|
||||
div.addEventListener('dragstart', dragStart);
|
||||
div.addEventListener('dragover', dragOver);
|
||||
div.addEventListener('drop', function(e){ dragDrop.call(this, e, 'morning-list'); });
|
||||
@@ -360,6 +372,36 @@
|
||||
renumberMorning();
|
||||
}
|
||||
|
||||
var noteModalRow = null;
|
||||
|
||||
window.openNoteModal = function(btn) {
|
||||
noteModalRow = btn.closest('.item-row');
|
||||
var noteEl = noteModalRow.querySelector('.item-note-val');
|
||||
var input = noteModalRow.querySelector('input[type="text"]');
|
||||
var title = input ? input.value.trim() || '未命名任务' : '备注';
|
||||
document.getElementById('note-modal-title').textContent = title;
|
||||
document.getElementById('note-modal-textarea').value = noteEl ? noteEl.value : '';
|
||||
document.getElementById('note-modal').style.display = 'flex';
|
||||
};
|
||||
|
||||
window.saveNoteModal = function() {
|
||||
var modal = document.getElementById('note-modal');
|
||||
if (!noteModalRow) return;
|
||||
var noteEl = noteModalRow.querySelector('.item-note-val');
|
||||
var btn = noteModalRow.querySelector('.btn-note-toggle');
|
||||
var val = document.getElementById('note-modal-textarea').value.trim();
|
||||
if (noteEl) noteEl.value = val;
|
||||
if (btn) { if (val) { btn.classList.add('has-note'); } else { btn.classList.remove('has-note'); } }
|
||||
modal.style.display = 'none';
|
||||
noteModalRow = null;
|
||||
triggerAutoSave();
|
||||
};
|
||||
|
||||
window.closeNoteModal = function() {
|
||||
document.getElementById('note-modal').style.display = 'none';
|
||||
noteModalRow = null;
|
||||
};
|
||||
|
||||
function renumberMorning() {
|
||||
var rows = document.querySelectorAll('#morning-list .item-row');
|
||||
for (var i=0; i<rows.length; i++) {
|
||||
|
||||
@@ -1817,3 +1817,11 @@ body {
|
||||
.item-row.dragging, .evening-row.dragging { opacity: 0.5; }
|
||||
.item-row.drag-over, .evening-row.drag-over { border-color: var(--primary) !important; background: var(--primary-light); }
|
||||
.evening-drag { position: absolute; left: 6px; top: 8px; }
|
||||
|
||||
/* 任务备注 */
|
||||
.btn-note-toggle { display: inline-flex; background: none; border: none; cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px; transition: all 0.15s; flex-shrink: 0; }
|
||||
.btn-note-toggle:hover { background: var(--bg); }
|
||||
.btn-note-toggle.has-note { color: var(--primary); }
|
||||
.item-note { display: none; width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; font-family: inherit; color: var(--text); background: var(--bg); resize: vertical; min-height: 28px; box-sizing: border-box; margin-top: 6px; }
|
||||
.item-note:focus { outline: none; border-color: var(--primary); }
|
||||
.item-row { flex-wrap: wrap; }
|
||||
|
||||
@@ -34,6 +34,23 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 备注编辑弹窗 -->
|
||||
<div class="sync-modal-overlay" id="note-modal" style="display:none">
|
||||
<div class="sync-modal" style="max-width:720px">
|
||||
<div class="sync-modal-header">
|
||||
<h3 id="note-modal-title">备注</h3>
|
||||
<button class="sync-modal-close" onclick="closeNoteModal()">×</button>
|
||||
</div>
|
||||
<div style="padding:16px">
|
||||
<textarea id="note-modal-textarea" style="width:100%; min-height:300px; padding:12px; border:1px solid var(--border); border-radius:8px; font-size:14px; font-family:inherit; line-height:1.6; resize:vertical; box-sizing:border-box" placeholder="写点备注…"></textarea>
|
||||
</div>
|
||||
<div class="sync-modal-footer">
|
||||
<button class="btn-wish-cancel" onclick="closeNoteModal()">取消</button>
|
||||
<button class="btn-wish-save" onclick="saveNoteModal()">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="app-layout">
|
||||
|
||||
<!-- ═══ 左侧边栏 ═══ -->
|
||||
|
||||
Reference in New Issue
Block a user