26 lines
835 B
JavaScript
26 lines
835 B
JavaScript
import $ from 'jquery';
|
|
window.$ = window.jQuery = $;
|
|
|
|
import * as bootstrap from 'bootstrap';
|
|
window.bootstrap = bootstrap;
|
|
|
|
// Aktifkan tooltip & auto-dismiss alert
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach((el) => new bootstrap.Tooltip(el));
|
|
|
|
setTimeout(() => {
|
|
document.querySelectorAll('.alert-auto-dismiss').forEach((el) => {
|
|
bootstrap.Alert.getOrCreateInstance(el).close();
|
|
});
|
|
}, 5000);
|
|
|
|
// Pengesahan ringkas sebelum hantar borang berbahaya
|
|
document.querySelectorAll('form[data-confirm]').forEach((form) => {
|
|
form.addEventListener('submit', (e) => {
|
|
if (!window.confirm(form.getAttribute('data-confirm'))) {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
});
|
|
});
|