Initial commit - Zhangmenu Django project
A menu management application built with Django, featuring: - Dish management with cover images - Order system with party dates and participants - REST API with Django REST Framework - Bootstrap-styled frontend Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
// 弹窗组件
|
||||
|
||||
const Modal = {
|
||||
// 显示弹窗
|
||||
show(modalId) {
|
||||
const modal = document.getElementById(modalId);
|
||||
if (modal) {
|
||||
modal.style.display = 'block';
|
||||
document.body.style.overflow = 'hidden';
|
||||
}
|
||||
},
|
||||
|
||||
// 隐藏弹窗
|
||||
hide(modalId) {
|
||||
const modal = document.getElementById(modalId);
|
||||
if (modal) {
|
||||
modal.style.display = 'none';
|
||||
document.body.style.overflow = '';
|
||||
}
|
||||
},
|
||||
|
||||
// 切换弹窗
|
||||
toggle(modalId) {
|
||||
const modal = document.getElementById(modalId);
|
||||
if (modal) {
|
||||
if (modal.style.display === 'none') {
|
||||
this.show(modalId);
|
||||
} else {
|
||||
this.hide(modalId);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 显示确认对话框
|
||||
confirm(message) {
|
||||
return confirm(message);
|
||||
},
|
||||
|
||||
// 显示加载状态
|
||||
showLoading(modalId) {
|
||||
const modal = document.getElementById(modalId);
|
||||
if (modal) {
|
||||
const footer = modal.querySelector('.modal-footer');
|
||||
if (footer) {
|
||||
footer.dataset.originalContent = footer.innerHTML;
|
||||
footer.innerHTML = '<span class="loading-text">加载中...</span>';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 隐藏加载状态
|
||||
hideLoading(modalId) {
|
||||
const modal = document.getElementById(modalId);
|
||||
if (modal) {
|
||||
const footer = modal.querySelector('.modal-footer');
|
||||
if (footer && footer.dataset.originalContent) {
|
||||
footer.innerHTML = footer.dataset.originalContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Bootstrap 模态框包装
|
||||
const BootstrapModal = {
|
||||
init(modalId) {
|
||||
return new bootstrap.Modal(document.getElementById(modalId));
|
||||
},
|
||||
|
||||
show(modalId) {
|
||||
const modal = bootstrap.Modal.getOrCreateInstance(document.getElementById(modalId));
|
||||
modal.show();
|
||||
},
|
||||
|
||||
hide(modalId) {
|
||||
const modal = bootstrap.Modal.getOrCreateInstance(document.getElementById(modalId));
|
||||
modal.hide();
|
||||
}
|
||||
};
|
||||
|
||||
// 导出
|
||||
window.Modal = Modal;
|
||||
window.BootstrapModal = BootstrapModal;
|
||||
Reference in New Issue
Block a user