80 lines
2.3 KiB
JavaScript
80 lines
2.3 KiB
JavaScript
import './bootstrap';
|
|
import UserService from './services/UserService';
|
|
import StationService from './services/StationService';
|
|
import CardMemberService from './services/CardMemberService';
|
|
import ContentService from './services/ContentService';
|
|
|
|
// Initialize services
|
|
window.services = {
|
|
user: new UserService(),
|
|
station: new StationService(),
|
|
cardMember: new CardMemberService(),
|
|
content: new ContentService()
|
|
};
|
|
|
|
// Configure global AJAX settings
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
}
|
|
});
|
|
|
|
// Configure Toastr notifications
|
|
toastr.options = {
|
|
closeButton: true,
|
|
progressBar: true,
|
|
positionClass: 'toast-top-right',
|
|
timeOut: 3000
|
|
};
|
|
|
|
// Initialize Bootstrap components
|
|
$(function () {
|
|
$('[data-bs-toggle="tooltip"]').tooltip();
|
|
$('[data-bs-toggle="popover"]').popover();
|
|
});
|
|
|
|
// Sidebar toggle functionality
|
|
$(document).ready(function() {
|
|
$('#sidebarCollapse').on('click', function() {
|
|
$('#sidebar').toggleClass('active');
|
|
$('#content').toggleClass('active');
|
|
});
|
|
|
|
$('.more-button,.body-overlay').on('click', function() {
|
|
$('#sidebar,.body-overlay').toggleClass('show-nav');
|
|
});
|
|
});
|
|
|
|
// Handle file inputs
|
|
$(document).on('change', '.custom-file-input', function() {
|
|
let fileName = $(this).val().split('\\').pop();
|
|
$(this).next('.custom-file-label').addClass("selected").html(fileName);
|
|
});
|
|
|
|
// Handle form validation
|
|
$(document).on('submit', 'form.needs-validation', function(event) {
|
|
if (!this.checkValidity()) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
}
|
|
$(this).addClass('was-validated');
|
|
});
|
|
|
|
// Handle DataTables initialization
|
|
$.extend(true, $.fn.dataTable.defaults, {
|
|
language: {
|
|
search: "_INPUT_",
|
|
searchPlaceholder: "Search...",
|
|
lengthMenu: "_MENU_ records per page",
|
|
info: "Showing _START_ to _END_ of _TOTAL_ records",
|
|
infoEmpty: "Showing 0 to 0 of 0 records",
|
|
infoFiltered: "(filtered from _MAX_ total records)"
|
|
},
|
|
dom: '<"row"<"col-sm-12 col-md-6"l><"col-sm-12 col-md-6"f>>' +
|
|
'<"row"<"col-sm-12"tr>>' +
|
|
'<"row"<"col-sm-12 col-md-5"i><"col-sm-12 col-md-7"p>>',
|
|
pageLength: 10,
|
|
processing: true,
|
|
responsive: true,
|
|
stateSave: true
|
|
});
|