87 lines
2.8 KiB
HTML
87 lines
2.8 KiB
HTML
{% if demo_mode_enabled %}
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css">
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"></script>
|
|
<script>
|
|
// Initialize Toastr
|
|
toastr.options = {
|
|
"closeButton": true,
|
|
"debug": false,
|
|
"newestOnTop": false,
|
|
"progressBar": true,
|
|
"positionClass": "toast-top-right",
|
|
"preventDuplicates": false,
|
|
"onclick": null,
|
|
"showDuration": "300",
|
|
"hideDuration": "1000",
|
|
"timeOut": "5000",
|
|
"extendedTimeOut": "1000",
|
|
"showEasing": "swing",
|
|
"hideEasing": "linear",
|
|
"showMethod": "fadeIn",
|
|
"hideMethod": "fadeOut",
|
|
"toastContainerId": "toastr-container"
|
|
};
|
|
|
|
// This function will be called when the page loads
|
|
$(document).ready(function() {
|
|
// Intercept the form submission
|
|
$("form").submit(function(event) {
|
|
event.preventDefault(); // Prevent the default form submission
|
|
|
|
// Simulate an AJAX request here
|
|
// In your actual code, replace this with your AJAX call
|
|
setTimeout(function() {
|
|
var response = {
|
|
status: 'error',
|
|
message: 'Modifications are not allowed in demo mode.'
|
|
};
|
|
|
|
// Check if the response contains an error message
|
|
if (response.status === 'error') {
|
|
// Display the error message using Toastr
|
|
toastr.error(response.message);
|
|
} else {
|
|
// Continue with the normal form submission if no error
|
|
$(event.target).unbind('submit').submit();
|
|
}
|
|
}, 1000); // Simulated delay for demonstration
|
|
});
|
|
});
|
|
</script>
|
|
<script>
|
|
// Initialize Toastr
|
|
toastr.options = {
|
|
"closeButton": true,
|
|
"debug": false,
|
|
"newestOnTop": false,
|
|
"progressBar": true,
|
|
"positionClass": "toast-top-right",
|
|
"preventDuplicates": false,
|
|
"onclick": null,
|
|
"showDuration": "300",
|
|
"hideDuration": "1000",
|
|
"timeOut": "5000",
|
|
"extendedTimeOut": "1000",
|
|
"showEasing": "swing",
|
|
"hideEasing": "linear",
|
|
"showMethod": "fadeIn",
|
|
"hideMethod": "fadeOut",
|
|
"toastContainerId": "toastr-container"
|
|
};
|
|
|
|
// This function will be called when the page loads
|
|
$(document).ready(function() {
|
|
// Intercept clicks on links
|
|
$("a").click(function(event) {
|
|
// Check if the link's href contains "delete"
|
|
if ($(this).attr("href").includes("delete")) {
|
|
// Prevent the default behavior (navigating to the link)
|
|
event.preventDefault();
|
|
|
|
// Display a Toastr error message
|
|
toastr.error('Deletion is not allowed in demo mode');
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
{% endif %} |