c0b9cf12f7
Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
function taskCreateOpen() {
|
|
var modal = document.getElementById('task-create-modal');
|
|
if (!modal) return;
|
|
modal.style.display = 'flex';
|
|
if (typeof initPeoplePickers === 'function') initPeoplePickers(modal);
|
|
var title = modal.querySelector('[name="title"]');
|
|
if (title) {
|
|
try { title.focus(); } catch (e) {}
|
|
}
|
|
}
|
|
|
|
function taskCreateClose() {
|
|
var modal = document.getElementById('task-create-modal');
|
|
if (modal) modal.style.display = 'none';
|
|
}
|
|
|
|
function taskCreateInit() {
|
|
var modal = document.getElementById('task-create-modal');
|
|
if (!modal) return;
|
|
if (typeof initPeoplePickers === 'function') initPeoplePickers(modal);
|
|
var root = document.querySelector('.page-content');
|
|
if (root && root.getAttribute('data-task-form-open') === '1') {
|
|
taskCreateOpen();
|
|
}
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', taskCreateInit);
|
|
} else {
|
|
taskCreateInit();
|
|
}
|
|
document.addEventListener('keydown', function (e) {
|
|
if (e.key !== 'Escape') return;
|
|
var modal = document.getElementById('task-create-modal');
|
|
if (modal && modal.style.display === 'flex') taskCreateClose();
|
|
});
|
|
document.addEventListener('htmx:afterSwap', function (ev) {
|
|
var target = ev.detail && ev.detail.target;
|
|
if (target && target.id === 'main-content') {
|
|
taskCreateInit();
|
|
}
|
|
});
|