huge updates i donot track what updates i have made

This commit is contained in:
sankalp committed 2025-03-29 03:22:47 +05:45
1 parent d02b470ca0
commit 84dd5d0b2f
55 files changed
+11072 -1415

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
/* Target the specific logo image */
img[src*="/static/img/logo.png"] {
max-height: 100px !important;
width: auto !important;
}
/* Target login page logo */
.jazzmin-login-page .login-logo img {
max-height: 100px !important;
width: auto !important;
}
/* Target admin interface logo */
.brand-link img.img-circle {
max-height: 33px !important;
width: auto !important;
opacity: .8;
margin-left: .8rem;
margin-right: .5rem;
margin-top: -3px;
}
+712
View File
@@ -0,0 +1,712 @@
/* Reset body padding since we removed the sidebar */
body {
padding-left: 0 !important;
padding-top: 0 !important;
}
/* Material Design Color System */
:root {
--primary: #3F51B5; /* Indigo */
--primary-light: #7986CB;
--secondary: #9E9E9E; /* Grey */
--success: #4CAF50; /* Green */
--warning: #FFC107; /* Amber */
--danger: #F44336; /* Red */
--info: #2196F3; /* Blue */
--background: #F5F5F5; /* Grey 100 */
--card-bg: #FFFFFF;
--text-primary: #212121; /* Grey 900 */
--text-secondary: #757575; /* Grey 600 */
--border-color: #BDBDBD; /* Grey 400 */
--hover-bg: #E8EAF6; /* Indigo 50 */
--card-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
/* Base Layout Styles */
body {
background-color: var(--background);
min-height: 100vh;
padding-bottom: 80px;
position: relative;
color: var(--text-primary);
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
/* Modern Card Styles */
.content-card {
background-color: var(--card-bg);
border-radius: 8px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
padding: 20px;
margin-bottom: 20px;
transition: var(--transition);
}
.content-card:hover {
transform: translateY(-2px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}
/* Bottom Navigation */
.bottom-nav {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background-color: white;
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
z-index: 1000;
}
.nav-container {
display: flex;
overflow-x: auto;
padding: 10px;
justify-content: space-around;
}
.nav-item {
display: flex;
flex-direction: column;
align-items: center;
color: var(--secondary);
text-decoration: none;
padding: 8px;
font-size: 0.8rem;
transition: all 0.2s;
border-radius: 5px;
min-width: 60px;
}
.nav-item i {
font-size: 1.2rem;
margin-bottom: 4px;
}
.nav-item.active {
color: var(--primary);
background-color: var(--hover-bg);
transform: scale(1.1);
}
.nav-item:hover:not(.active) {
background-color: rgba(0, 0, 0, 0.04);
}
/* Content Section Styles */
.content-section {
display: none;
opacity: 0;
transform: translateY(20px);
transition: opacity 0.3s ease, transform 0.3s ease;
}
.content-section.active {
display: block;
opacity: 1;
transform: translateY(0);
}
/* Summary Cards */
.summary-card {
background-color: var(--card-bg);
border-radius: 8px;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
.summary-card .card-header {
background-color: var(--hover-bg);
padding: 12px 16px;
border-bottom: 1px solid var(--border-color);
}
.card-body {
padding: 1.5rem;
}
/* Progress Bars */
.progress {
height: 12px;
background-color: #E8EAF6;
border-radius: 24px;
overflow: hidden;
}
.progress-bar {
border-radius: 24px;
transition: var(--transition);
}
/* Add this to replace inline style attributes */
.progress-bar[style] {
width: var(--progress-width, 0%);
}
/* Tables */
.table {
background: #FFFFFF;
border-radius: 16px;
overflow: hidden;
box-shadow: var(--card-shadow);
border-collapse: separate;
border-spacing: 0;
}
.table thead th {
background: var(--hover-bg);
border: none;
padding: 1rem 1.5rem;
font-weight: 600;
color: var(--primary);
}
.table tbody td {
padding: 1rem 1.5rem;
border-top: 1px solid var(--border-color);
transition: var(--transition);
}
.table tbody tr:hover td {
background-color: var(--hover-bg);
}
/* Status Badges */
.status-badge {
padding: 4px 8px;
border-radius: 4px;
font-size: 0.75rem;
font-weight: 500;
display: inline-block;
}
.bg-success, .completed, .leave-approved {
background-color: var(--success) !important;
color: white;
}
.bg-warning, .ongoing, .leave-pending {
background-color: var(--warning) !important;
color: #212121; /* Material design suggests dark text on light colors like Amber */
}
.bg-danger, .leave-rejected {
background-color: var(--danger) !important;
color: white;
}
.bg-info, .upcoming {
background-color: var(--info) !important;
color: white;
}
/* Animations */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
/* Responsive Design */
@media (max-width: 768px) {
.container-fluid {
padding: 0.5rem;
}
.content-card {
padding: 16px;
}
.summary-card {
margin-bottom: 1rem;
}
.card-header {
padding: 1rem;
}
.card-body {
padding: 1rem;
}
.table {
font-size: 0.875rem;
}
.table th,
.table td {
padding: 0.75rem;
white-space: nowrap;
}
.table-responsive {
margin: 0 -0.5rem;
}
.row {
margin-left: -0.5rem;
margin-right: -0.5rem;
}
.col-12, .col-md-6 {
padding-left: 0.5rem;
padding-right: 0.5rem;
}
.bottom-nav {
padding: 0.5rem;
}
.nav-item {
padding: 0.375rem;
}
.nav-item i {
font-size: 1.25rem;
}
.nav-item span {
display: none;
}
.nav-item.active::after {
bottom: -0.5rem;
}
/* Welcome Section */
.welcome-section img {
width: 60px !important;
height: 60px !important;
}
.welcome-section h2 {
font-size: 1.5rem;
}
/* Course Cards */
.course-card {
margin-bottom: 1rem;
}
.course-card .card-title {
font-size: 1.1rem;
}
/* Subject Cards */
.subject-card {
margin-bottom: 1rem;
}
/* Feedback Cards */
.feedback-card {
margin-bottom: 1rem;
}
/* Notice Cards */
.notice-card {
margin-bottom: 1rem;
}
/* Profile Section */
.profile-image {
width: 120px !important;
height: 120px !important;
}
/* Modal Adjustments */
.modal-dialog {
margin: 0.5rem;
}
.modal-body {
padding: 1rem;
}
/* Form Elements */
.form-control,
.form-select {
font-size: 0.875rem;
}
.btn {
padding: 0.375rem 0.75rem;
font-size: 0.875rem;
}
/* Rating Stars */
.rating-container .fa-star {
font-size: 1.25rem;
}
.nav-item {
min-width: auto;
}
}
/* Small Mobile Devices */
@media (max-width: 480px) {
.nav-container {
padding: 0 0.5rem;
}
.nav-item {
padding: 0.25rem;
}
.nav-item i {
font-size: 1.1rem;
}
.nav-item span {
font-size: 0.65rem;
}
.content-card {
padding: 0.75rem;
}
.card-header {
padding: 0.75rem;
}
.card-body {
padding: 0.75rem;
}
.table th,
.table td {
padding: 0.5rem;
}
.status-badge {
padding: 0.2rem 0.5rem;
font-size: 0.75rem;
}
.btn {
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
}
}
/* Landscape Mode */
@media (max-height: 500px) and (orientation: landscape) {
.bottom-nav {
position: static;
margin-top: 1rem;
}
body {
padding-bottom: 0;
}
.content-card {
margin-bottom: 1rem;
}
}
/* High-DPI Screens */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
.content-card {
box-shadow: 0 5px 10px -3px rgba(0, 0, 0, 0.1);
}
}
/* Print Styles */
@media print {
.bottom-nav,
.btn-primary,
.modal,
.modal-backdrop {
display: none !important;
}
.content-card {
box-shadow: none;
border: 1px solid #ddd;
}
.table {
box-shadow: none;
}
}
/* Modal styles */
.modal {
z-index: 1050 !important;
}
.modal-backdrop {
z-index: 1040 !important;
}
.modal-content {
border-radius: 8px !important;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}
.modal-header {
border-bottom: 1px solid #e5e7eb;
padding: 1rem 1.5rem;
}
.modal-body {
padding: 1.5rem;
}
.modal-footer {
border-top: 1px solid #e5e7eb;
padding: 1rem 1.5rem;
}
/* Navigation enhanced styles */
.nav-item {
transition: transform 0.2s ease-in-out;
}
.content-section {
transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
opacity: 0;
transform: translateY(20px);
}
.content-section.active {
opacity: 1;
transform: translateY(0);
}
/* Improve active state visibility */
.nav-item.active {
color: var(--primary);
font-weight: 600;
}
.nav-item.active i {
transform: scale(1.1);
}
/* Add ripple effect for touch devices */
.nav-item {
position: relative;
overflow: hidden;
}
.nav-item::after {
content: '';
position: absolute;
top: 50%;
left: 50%;
width: 5px;
height: 5px;
background: rgba(79, 70, 229, 0.3);
opacity: 0;
border-radius: 100%;
transform: scale(1, 1) translate(-50%);
transform-origin: 50% 50%;
}
.nav-item:active::after {
animation: ripple 0.6s ease-out;
}
@keyframes ripple {
0% {
transform: scale(0, 0);
opacity: 0.5;
}
100% {
transform: scale(100, 100);
opacity: 0;
}
}
/* Star Rating Styles */
.rating-container .form-check-label {
cursor: pointer;
padding: 0.25rem;
}
.rating-container .fa-star,
.rating-container .fa-star-half-alt {
color: #f8d74c;
}
/* Profile Images */
.profile-image-small {
width: 80px;
height: 80px;
object-fit: cover;
}
.profile-image-large {
width: 200px;
height: 200px;
object-fit: cover;
}
/* Add notification toast styles if they don't already exist */
.notification-toast {
position: fixed;
top: 20px;
right: 20px;
z-index: 9999;
min-width: 250px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
border-radius: 4px;
}
/* Welcome Section */
.welcome-section {
background: linear-gradient(to right, #4338ca, #6366f1);
color: white;
padding: 20px;
}
/* Schedule styling */
.schedule-item {
padding: 12px;
border-radius: 6px;
margin-bottom: 10px;
background-color: #f8f9fa;
border-left: 4px solid var(--primary);
}
/* Rating stars styling */
.rating-stars {
color: #FFD700;
}
/* Custom tabs styling */
.feedback-tabs {
border-bottom: 2px solid #e9ecef;
margin-bottom: 1.5rem;
}
.feedback-tab-btn {
padding: 10px 20px;
cursor: pointer;
border-radius: 4px;
transition: var(--transition);
border: 1px solid var(--border-color);
background-color: white;
color: var(--text-primary);
text-align: center;
flex: 1;
}
.feedback-tab-btn.active {
background-color: var(--primary);
color: white;
border-color: var(--primary);
}
.feedback-tab-btn:hover:not(.active) {
background-color: var(--hover-bg);
}
.tab-pane {
display: none;
}
.tab-pane.active {
display: block;
}
/* Star rating styling */
.rating-container .form-check-label i.fas {
color: #FFD700;
}
/* Custom smaller scrollbar styling */
.activity-scroll::-webkit-scrollbar {
width: 4px;
}
.activity-scroll::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 10px;
}
.activity-scroll::-webkit-scrollbar-thumb {
background: #ccc;
border-radius: 10px;
}
.activity-scroll::-webkit-scrollbar-thumb:hover {
background: #999;
}
/* Firefox scrollbar */
.activity-scroll {
scrollbar-width: thin;
scrollbar-color: #ccc #f1f1f1;
}
@media (min-width: 992px) {
.container-fluid {
padding-bottom: 60px;
}
}
/* Custom Tab System */
.custom-tabs {
display: flex;
border-bottom: 1px solid #dee2e6;
margin-bottom: 1rem;
}
.custom-tab-btn {
padding: 0.5rem 1rem;
margin-bottom: -1px;
background: none;
border: 1px solid transparent;
border-top-left-radius: 0.25rem;
border-top-right-radius: 0.25rem;
cursor: pointer;
color: var(--secondary);
}
.custom-tab-btn.active {
color: var(--primary);
background-color: #fff;
border-color: #dee2e6 #dee2e6 #fff;
}
.custom-tab-content {
display: none;
}
.custom-tab-content.active {
display: block;
}
/* Fix for profile tab visibility */
#profileSection.active .tab-pane.active {
display: block !important;
}
#profileSection.active .nav-tabs .nav-link.active {
color: var(--primary);
border-color: var(--primary);
background-color: #fff;
}
/* Action buttons enhanced */
.action-button {
border-radius: 50px;
padding: 10px 20px;
font-weight: 500;
transition: var(--transition);
display: inline-flex;
align-items: center;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}
.action-button:hover {
transform: translateY(-3px);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}
.action-button i {
margin-right: 8px;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 317 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

+563
View File
@@ -0,0 +1,563 @@
document.addEventListener('DOMContentLoaded', function() {
console.log("Dashboard script loaded");
// Set default date to today for leave requests
const dateInput = document.getElementById('customLeaveDate');
if (dateInput) {
const today = new Date();
const year = today.getFullYear();
let month = today.getMonth() + 1;
let day = today.getDate();
month = month < 10 ? '0' + month : month;
day = day < 10 ? '0' + day : day;
dateInput.min = `${year}-${month}-${day}`;
dateInput.value = `${year}-${month}-${day}`;
}
// Close modals with Escape key
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') {
// Check each modal and close if visible
const modalIds = [
{ id: 'customLeaveModal', closeFn: closeLeaveModal },
{ id: 'profileModal', closeFn: closeProfileModal },
{ id: 'passwordModal', closeFn: closePasswordModal },
{ id: 'feedbackModal', closeFn: closeFeedbackModal },
{ id: 'pdfViewerModal', closeFn: closePdfViewerModal },
{ id: 'subjectFilesModal', closeFn: closeSubjectFilesModal }
];
modalIds.forEach(modal => {
const modalElement = document.getElementById(modal.id);
if (modalElement && modalElement.style.display === 'block') {
modal.closeFn();
}
});
}
});
// Navigation
const navItems = document.querySelectorAll('.nav-item');
const contentSections = document.querySelectorAll('.content-section');
// Function to scroll to section with smooth animation
function scrollToSection(sectionId) {
const section = document.getElementById(sectionId);
if (section) {
const offset = 20; // Offset from top
const sectionPosition = section.getBoundingClientRect().top + window.pageYOffset - offset;
window.scrollTo({
top: sectionPosition,
behavior: 'smooth'
});
}
}
// Function to update active state
function updateActiveState(clickedItem) {
// Remove active class from all nav items
navItems.forEach(nav => {
nav.classList.remove('active');
nav.style.transform = 'scale(1)';
});
// Add active class to clicked item
clickedItem.classList.add('active');
clickedItem.style.transform = 'scale(1.1)';
// Remove active class from all sections
contentSections.forEach(section => {
section.classList.remove('active');
section.style.opacity = '0';
section.style.transform = 'translateY(20px)';
});
// Add active class to target section
const sectionId = clickedItem.dataset.section + 'Section';
const targetSection = document.getElementById(sectionId);
if (targetSection) {
targetSection.classList.add('active');
targetSection.style.opacity = '1';
targetSection.style.transform = 'translateY(0)';
}
}
// Add click event listeners to nav items
navItems.forEach(item => {
item.addEventListener('click', function(e) {
e.preventDefault();
const sectionId = this.dataset.section + 'Section';
// Update active state
updateActiveState(this);
// Scroll to section
scrollToSection(sectionId);
});
});
// Add scroll event listener to update active state based on scroll position
let scrollTimeout;
window.addEventListener('scroll', function() {
clearTimeout(scrollTimeout);
scrollTimeout = setTimeout(function() {
const scrollPosition = window.scrollY + 100; // Offset for better detection
contentSections.forEach(section => {
const sectionTop = section.offsetTop - 100;
const sectionBottom = sectionTop + section.offsetHeight;
if (scrollPosition >= sectionTop && scrollPosition < sectionBottom) {
const sectionId = section.id;
const navItem = document.querySelector(`.nav-item[data-section="${sectionId.replace('Section', '')}"]`);
if (navItem) {
updateActiveState(navItem);
}
}
});
}, 100);
});
// Add touch feedback
navItems.forEach(item => {
item.addEventListener('touchstart', function() {
this.style.transform = 'scale(0.95)';
});
item.addEventListener('touchend', function() {
this.style.transform = this.classList.contains('active') ? 'scale(1.1)' : 'scale(1)';
});
});
// Initialize first section as active
const firstNavItem = navItems[0];
if (firstNavItem) {
updateActiveState(firstNavItem);
}
// Initialize rating functionality
setupStarRating();
// Set up subject files buttons
document.querySelectorAll('.view-subject-files').forEach(button => {
button.addEventListener('click', function() {
const subjectId = this.getAttribute('data-subject-id');
viewSubjectFiles(subjectId);
});
});
// Handle image loading errors
document.querySelectorAll('img[src*="student.image.url"]').forEach(img => {
img.addEventListener('error', function() {
this.onerror = null;
this.src = '/static/img/user.png';
});
});
// Handle feedback form tabs
setupFeedbackTabs();
// Initialize Bootstrap tooltip and popover components
initializeBootstrapComponents();
// Setup custom tabs
setupCustomTabs();
// Add form validation for rating form
setupRatingFormValidation();
});
// Modal Functions
function openLeaveModal() {
document.getElementById('customLeaveModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeLeaveModal() {
document.getElementById('customLeaveModal').style.display = 'none';
document.body.style.overflow = '';
}
function openProfileModal() {
document.getElementById('profileModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeProfileModal() {
document.getElementById('profileModal').style.display = 'none';
document.body.style.overflow = '';
}
function openPasswordModal() {
document.getElementById('passwordModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closePasswordModal() {
document.getElementById('passwordModal').style.display = 'none';
document.body.style.overflow = '';
}
function openFeedbackModal() {
document.getElementById('feedbackModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closeFeedbackModal() {
document.getElementById('feedbackModal').style.display = 'none';
document.body.style.overflow = '';
}
function openPdfViewerModal(url) {
document.getElementById('pdfViewer').src = url;
document.getElementById('pdfViewerModal').style.display = 'block';
document.body.style.overflow = 'hidden';
}
function closePdfViewerModal() {
document.getElementById('pdfViewerModal').style.display = 'none';
document.body.style.overflow = '';
}
function openSubjectFilesModal(subjectId) {
// Use the viewSubjectFiles function which fetches the files from the server
viewSubjectFiles(subjectId);
}
function closeSubjectFilesModal() {
document.getElementById('subjectFilesModal').style.display = 'none';
document.body.style.overflow = '';
}
// Setup custom tabs
function setupCustomTabs() {
const tabButtons = document.querySelectorAll('.custom-tab-btn');
if (tabButtons.length > 0) {
tabButtons.forEach(button => {
button.addEventListener('click', function() {
// Remove active class from all buttons
tabButtons.forEach(btn => btn.classList.remove('active'));
// Add active class to clicked button
this.classList.add('active');
// Hide all content
document.querySelectorAll('.custom-tab-content').forEach(content => {
content.classList.remove('active');
});
// Show target content
const target = this.getAttribute('data-target');
document.getElementById(target).classList.add('active');
});
});
}
}
// Setup feedback form validation
function setupRatingFormValidation() {
const ratingForm = document.querySelector('.feedback-form');
const ratingInput = document.getElementById('selected_rating');
const ratingError = document.getElementById('rating-error');
if (ratingForm && ratingInput && ratingError) {
// Add form validation before submission
ratingForm.addEventListener('submit', function(e) {
// Check if rating is selected
if (!ratingInput.value) {
e.preventDefault(); // Stop form submission
if (ratingError) {
ratingError.style.display = 'block';
ratingError.scrollIntoView({ behavior: 'smooth' });
}
return false;
}
return true;
});
}
}
// Implementation for subject files
function viewSubjectFiles(subjectId) {
// Show loading state
const filesList = document.getElementById('subjectFilesList');
if (!filesList) return;
filesList.innerHTML = `
<div class="text-center py-4">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<p class="mt-2 text-muted">Loading syllabus...</p>
</div>
`;
// Show modal
document.getElementById('subjectFilesModal').style.display = 'block';
document.body.style.overflow = 'hidden';
// Fetch syllabus
fetch(`/app/subject/${subjectId}/files/`)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
if (!data.files || data.files.length === 0) {
filesList.innerHTML = `
<div class="text-center py-4">
<i class="fas fa-file-pdf fa-2x text-muted mb-3"></i>
<p class="text-muted mb-0">No syllabus available for this subject</p>
</div>
`;
} else {
let html = '';
data.files.forEach(file => {
html += `
<div class="list-group-item">
<div class="d-flex w-100 justify-content-between align-items-center">
<div>
<h6 class="mb-1">
<i class="fas fa-file-pdf text-danger me-2"></i>
${file.title}
</h6>
<p class="mb-1 small text-muted">${file.description || 'No description'}</p>
</div>
<div class="text-end">
${file.file_url ? `
<a href="${file.file_url}" class="btn btn-sm btn-primary" download>
<i class="fas fa-download"></i> Download
</a>
` : `
<span class="text-danger">
<i class="fas fa-exclamation-circle"></i> File not available
</span>
`}
</div>
</div>
</div>
`;
});
filesList.innerHTML = html;
}
} else {
throw new Error(data.message || 'Failed to load syllabus');
}
})
.catch(error => {
console.error('Error:', error);
filesList.innerHTML = `
<div class="text-center py-4">
<i class="fas fa-exclamation-circle fa-2x text-danger mb-3"></i>
<p class="text-danger mb-0">Unable to load syllabus. Please try again later.</p>
<small class="text-muted">${error.message}</small>
</div>
`;
});
}
// Setup feedback tabs
function setupFeedbackTabs() {
const teacherTabBtn = document.getElementById('teacher-tab-btn');
const instituteTabBtn = document.getElementById('institute-tab-btn');
if (teacherTabBtn && instituteTabBtn) {
teacherTabBtn.addEventListener('click', function() {
switchFeedbackTab('teacher');
});
instituteTabBtn.addEventListener('click', function() {
switchFeedbackTab('institute');
});
}
}
// Tab switching function
function switchFeedbackTab(tabId) {
// Hide all tab contents
document.querySelectorAll('.tab-pane').forEach(tab => {
tab.classList.remove('active');
});
// Deactivate all tab buttons
document.querySelectorAll('.feedback-tab-btn').forEach(btn => {
btn.classList.remove('active');
});
// Show selected tab content and activate button
document.getElementById(`${tabId}-tab-content`).classList.add('active');
document.getElementById(`${tabId}-tab-btn`).classList.add('active');
}
// Initialize Bootstrap components
function initializeBootstrapComponents() {
// Initialize tooltips if available
if (typeof bootstrap !== 'undefined' && bootstrap.Tooltip) {
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
}
// Initialize popovers if available
if (typeof bootstrap !== 'undefined' && bootstrap.Popover) {
const popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'));
popoverTriggerList.map(function (popoverTriggerEl) {
return new bootstrap.Popover(popoverTriggerEl);
});
}
}
// Function to show notification toast
function showNotification(title, message, type = 'success') {
const toast = document.getElementById('notificationToast');
if (!toast) return;
const toastTitle = document.getElementById('toastTitle');
const toastMessage = document.getElementById('toastMessage');
toastTitle.innerText = title;
toastMessage.innerText = message;
// Set toast color based on type
toast.className = 'toast';
if (type === 'success') {
toast.classList.add('bg-success', 'text-white');
} else if (type === 'error') {
toast.classList.add('bg-danger', 'text-white');
} else if (type === 'warning') {
toast.classList.add('bg-warning');
} else if (type === 'info') {
toast.classList.add('bg-info', 'text-white');
}
const bsToast = new bootstrap.Toast(toast);
bsToast.show();
}
// Function to set up star rating
function setupStarRating() {
// Teacher feedback
setupStarRatingComponent('teacher-rating', 'teacherStar');
// Institute feedback
setupStarRatingComponent('institute-rating', 'instituteStar');
// Generic rating stars
setupGenericRatingStars();
}
function setupStarRatingComponent(containerId, inputPrefix) {
const container = document.getElementById(containerId);
if (!container) return;
const stars = container.querySelectorAll('.form-check-label');
const inputs = Array.from(container.querySelectorAll('input[type="radio"]'));
stars.forEach((star, index) => {
// Click event
star.addEventListener('click', function() {
// Update visual state
updateStars(stars, index);
// Update form input
inputs[index].checked = true;
});
// Hover effects
star.addEventListener('mouseenter', function() {
highlightStars(stars, index);
});
container.addEventListener('mouseleave', function() {
resetStars(stars, inputs);
});
});
}
function setupGenericRatingStars() {
const stars = document.querySelectorAll('.rating-star');
const ratingInput = document.getElementById('selected_rating');
const ratingError = document.getElementById('rating-error');
if (stars.length > 0 && ratingInput) {
stars.forEach(star => {
// Click event
star.addEventListener('click', function() {
const value = parseInt(this.getAttribute('data-value'));
ratingInput.value = value;
// Update the stars
stars.forEach((s, index) => {
if (index < value) {
s.className = 'fas fa-star fs-4 text-warning rating-star';
} else {
s.className = 'far fa-star fs-4 text-warning rating-star';
}
});
// Hide error message if displayed
if (ratingError) ratingError.style.display = 'none';
});
// Hover events
star.addEventListener('mouseenter', function() {
const value = parseInt(this.getAttribute('data-value'));
stars.forEach((s, index) => {
if (index < value) {
s.className = 'fas fa-star fs-4 text-warning rating-star';
}
});
});
star.addEventListener('mouseleave', function() {
const selectedValue = parseInt(ratingInput.value) || 0;
stars.forEach((s, index) => {
if (index < selectedValue) {
s.className = 'fas fa-star fs-4 text-warning rating-star';
} else {
s.className = 'far fa-star fs-4 text-warning rating-star';
}
});
});
});
}
}
function updateStars(stars, selectedIndex) {
stars.forEach((star, i) => {
const starIcon = star.querySelector('i');
if (i <= selectedIndex) {
starIcon.className = 'fas fa-star fs-4';
} else {
starIcon.className = 'far fa-star fs-4';
}
});
}
function highlightStars(stars, hoverIndex) {
stars.forEach((star, i) => {
const starIcon = star.querySelector('i');
if (i <= hoverIndex) {
starIcon.className = 'fas fa-star fs-4';
}
});
}
function resetStars(stars, inputs) {
const selectedIndex = inputs.findIndex(input => input.checked);
stars.forEach((star, i) => {
const starIcon = star.querySelector('i');
if (selectedIndex >= 0 && i <= selectedIndex) {
starIcon.className = 'fas fa-star fs-4';
} else {
starIcon.className = 'far fa-star fs-4';
}
});
}
+113
View File
@@ -0,0 +1,113 @@
document.addEventListener('DOMContentLoaded', function() {
// Handle star rating selection for teacher feedback
const teacherStars = document.querySelectorAll('[id^="teacherStar"]');
const teacherLabels = document.querySelectorAll('label[for^="teacherStar"]');
teacherLabels.forEach(label => {
label.addEventListener('click', function() {
const starId = this.getAttribute('for');
const starNumber = parseInt(starId.replace('teacherStar', ''));
// Update visual appearance
teacherLabels.forEach((lbl, index) => {
const star = lbl.querySelector('i');
if (index < starNumber) {
star.className = 'fas fa-star fs-4 text-warning';
} else {
star.className = 'far fa-star fs-4 text-warning';
}
});
// Set the correct radio button
document.getElementById(starId).checked = true;
});
// Add hover effects
label.addEventListener('mouseenter', function() {
const starId = this.getAttribute('for');
const starNumber = parseInt(starId.replace('teacherStar', ''));
teacherLabels.forEach((lbl, index) => {
const star = lbl.querySelector('i');
if (index < starNumber) {
star.className = 'fas fa-star fs-4 text-warning';
}
});
});
label.addEventListener('mouseleave', function() {
// Reset to selected state
let selectedValue = 0;
teacherStars.forEach((radio, index) => {
if (radio.checked) {
selectedValue = index + 1;
}
});
teacherLabels.forEach((lbl, index) => {
const star = lbl.querySelector('i');
if (index < selectedValue) {
star.className = 'fas fa-star fs-4 text-warning';
} else {
star.className = 'far fa-star fs-4 text-warning';
}
});
});
});
// Handle star rating selection for institute feedback
const instituteStars = document.querySelectorAll('[id^="instituteStar"]');
const instituteLabels = document.querySelectorAll('label[for^="instituteStar"]');
instituteLabels.forEach(label => {
label.addEventListener('click', function() {
const starId = this.getAttribute('for');
const starNumber = parseInt(starId.replace('instituteStar', ''));
// Update visual appearance
instituteLabels.forEach((lbl, index) => {
const star = lbl.querySelector('i');
if (index < starNumber) {
star.className = 'fas fa-star fs-4 text-warning';
} else {
star.className = 'far fa-star fs-4 text-warning';
}
});
// Set the correct radio button
document.getElementById(starId).checked = true;
});
// Add hover effects
label.addEventListener('mouseenter', function() {
const starId = this.getAttribute('for');
const starNumber = parseInt(starId.replace('instituteStar', ''));
instituteLabels.forEach((lbl, index) => {
const star = lbl.querySelector('i');
if (index < starNumber) {
star.className = 'fas fa-star fs-4 text-warning';
}
});
});
label.addEventListener('mouseleave', function() {
// Reset to selected state
let selectedValue = 0;
instituteStars.forEach((radio, index) => {
if (radio.checked) {
selectedValue = index + 1;
}
});
instituteLabels.forEach((lbl, index) => {
const star = lbl.querySelector('i');
if (index < selectedValue) {
star.className = 'fas fa-star fs-4 text-warning';
} else {
star.className = 'far fa-star fs-4 text-warning';
}
});
});
});
});