blog, testimonal

This commit is contained in:
2026-11-18 15:40:30 +05:45
parent a41dfbe939
commit 7ea12b20ef
12 changed files with 4527 additions and 38 deletions
+2103 -3
View File
File diff suppressed because it is too large Load Diff
+507
View File
@@ -1612,3 +1612,510 @@
initApplicationForm();
}
})();
// ===== STUDENT WORK GALLERY FILTERS
(function () {
'use strict';
function initStudentWorkFilters() {
var page = document.querySelector('.student-work');
var grid = document.getElementById('student-work-grid');
if (!page || !grid) {
return;
}
if (grid.getAttribute('data-student-filters-init') === 'true') {
return;
}
grid.setAttribute('data-student-filters-init', 'true');
var cards = Array.prototype.slice.call(
grid.querySelectorAll('.student-card')
);
var courseSelect = page.querySelector('[data-filter="course"]');
var skillSelect = page.querySelector('[data-filter="skill"]');
var batchSelect = page.querySelector('[data-filter="batch"]');
var resetButton = page.querySelector('.student-work__reset');
var count = page.querySelector('.student-work__count');
var emptyState = page.querySelector('.student-work__empty');
if (!cards.length || !courseSelect || !skillSelect || !batchSelect) {
return;
}
function getSkills(card) {
var raw = card.getAttribute('data-skills') || '';
if (!raw) {
return [];
}
return raw.split('|').filter(function (skill) {
return skill !== '';
});
}
function populateSelect(select, values, allLabel) {
var selected = select.value || 'all';
select.innerHTML = '';
var allOption = document.createElement('option');
allOption.value = 'all';
allOption.textContent = allLabel;
select.appendChild(allOption);
values.forEach(function (value) {
var option = document.createElement('option');
option.value = value;
option.textContent = value;
select.appendChild(option);
});
if (values.indexOf(selected) !== -1) {
select.value = selected;
}
}
function collectValues() {
var courses = [];
var skills = [];
var batches = [];
cards.forEach(function (card) {
var course = card.getAttribute('data-course') || '';
var batch = card.getAttribute('data-batch') || '';
if (course && courses.indexOf(course) === -1) {
courses.push(course);
}
if (batch && batches.indexOf(batch) === -1) {
batches.push(batch);
}
getSkills(card).forEach(function (skill) {
if (skills.indexOf(skill) === -1) {
skills.push(skill);
}
});
});
courses.sort();
skills.sort();
batches.sort();
populateSelect(courseSelect, courses, 'All courses');
populateSelect(skillSelect, skills, 'All skills');
populateSelect(batchSelect, batches, 'All batches');
}
function updateCount(visible) {
if (count) {
count.textContent = 'Showing ' + visible + ' illustrative concept' + (visible === 1 ? '' : 's');
}
}
function applyFilters() {
var course = courseSelect.value;
var skill = skillSelect.value;
var batch = batchSelect.value;
var visible = 0;
cards.forEach(function (card) {
var cardCourse = card.getAttribute('data-course') || '';
var cardBatch = card.getAttribute('data-batch') || '';
var cardSkills = getSkills(card);
var matchesCourse = course === 'all' || cardCourse === course;
var matchesSkill = skill === 'all' || cardSkills.indexOf(skill) !== -1;
var matchesBatch = batch === 'all' || cardBatch === batch;
var show = matchesCourse && matchesSkill && matchesBatch;
card.classList.toggle('is-hidden', !show);
if (show) {
visible += 1;
}
});
updateCount(visible);
if (emptyState) {
emptyState.hidden = visible !== 0;
}
}
collectValues();
applyFilters();
[courseSelect, skillSelect, batchSelect].forEach(function (select) {
select.addEventListener('change', applyFilters);
});
if (resetButton) {
resetButton.addEventListener('click', function () {
courseSelect.value = 'all';
skillSelect.value = 'all';
batchSelect.value = 'all';
applyFilters();
});
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initStudentWorkFilters);
} else {
initStudentWorkFilters();
}
})();
// ===== BLOG DETAIL PAGE =====
(function () {
'use strict';
function initBlogDetail() {
var page = document.querySelector('.blog-detail');
if (!page || page.getAttribute('data-blog-detail-init') === 'true') {
return;
}
page.setAttribute('data-blog-detail-init', 'true');
var progressBar = page.querySelector('.reading-progress__bar');
function updateProgress() {
if (!progressBar) {
return;
}
var doc = document.documentElement;
var scrollTop = window.scrollY || doc.scrollTop || 0;
var scrollHeight = doc.scrollHeight - window.innerHeight;
var progress = scrollHeight > 0 ? (scrollTop / scrollHeight) * 100 : 0;
if (progress < 0) {
progress = 0;
}
if (progress > 100) {
progress = 100;
}
progressBar.style.width = progress + '%';
}
if (progressBar) {
updateProgress();
window.addEventListener('scroll', updateProgress, { passive: true });
window.addEventListener('resize', updateProgress);
}
var tocLinks = Array.prototype.slice.call(page.querySelectorAll('.blog-toc__link'));
var sections = [];
tocLinks.forEach(function (link) {
var href = link.getAttribute('href') || '';
if (href.charAt(0) !== '#') {
return;
}
var section = document.getElementById(href.slice(1));
if (section) {
sections.push({ link: link, section: section });
}
});
function setActiveLink(activeLink) {
tocLinks.forEach(function (link) {
link.classList.toggle('is-active', link === activeLink);
});
}
if (sections.length && 'IntersectionObserver' in window) {
var observer = new IntersectionObserver(function (entries) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
sections.forEach(function (item) {
if (item.section === entry.target) {
setActiveLink(item.link);
}
});
}
});
}, {
rootMargin: '-20% 0px -60% 0px',
threshold: 0.1
});
sections.forEach(function (item) {
observer.observe(item.section);
});
} else if (sections.length) {
setActiveLink(sections[0].link);
}
var form = page.querySelector('.blog-comment__form');
if (form) {
var status = form.querySelector('.blog-comment__status');
form.addEventListener('submit', function (event) {
event.preventDefault();
var requiredNames = ['comment', 'name', 'email'];
var isValid = true;
requiredNames.forEach(function (name) {
var field = form.querySelector('[name="' + name + '"]');
if (!field) {
return;
}
var value = (field.value || '').trim();
if (!value) {
isValid = false;
field.setAttribute('aria-invalid', 'true');
} else {
field.removeAttribute('aria-invalid');
}
});
if (status) {
status.textContent = isValid ? 'Comments are not enabled yet.' : 'Please fill in the required fields.';
}
});
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initBlogDetail);
} else {
initBlogDetail();
}
})();
// ===== TESTIMONIALS PAGE =====
(function () {
'use strict';
function initTestimonialsPage() {
var page = document.querySelector('.testimonials');
if (!page || page.getAttribute('data-testimonials-init') === 'true') {
return;
}
page.setAttribute('data-testimonials-init', 'true');
var searchInput = page.querySelector('.testimonials__search-input');
var tabs = Array.prototype.slice.call(page.querySelectorAll('.testimonials__tab'));
var textPanel = document.getElementById('testimonials-panel-text');
var videoPanel = document.getElementById('testimonials-panel-video');
var grid = page.querySelector('.testimonials__grid');
var cards = grid ? Array.prototype.slice.call(grid.querySelectorAll('.testimonial-card')) : [];
var emptyState = page.querySelector('.testimonials__empty:not(.testimonials__empty--video)');
var loadMoreButton = page.querySelector('.testimonials__more');
var modal = document.getElementById('testimonial-modal');
var batchSize = 12;
var visibleCount = 0;
var matchingCards = cards.slice();
var reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
function setActiveTab(tabName) {
tabs.forEach(function (tab) {
var isActive = (tab.getAttribute('data-tab') || '') === tabName;
tab.classList.toggle('is-active', isActive);
tab.setAttribute('aria-selected', String(isActive));
tab.tabIndex = isActive ? 0 : -1;
});
if (textPanel) {
textPanel.hidden = tabName !== 'text';
}
if (videoPanel) {
videoPanel.hidden = tabName !== 'video';
}
}
function renderCards(resetCount) {
if (resetCount) {
visibleCount = Math.min(batchSize, matchingCards.length);
}
cards.forEach(function (card) {
card.hidden = true;
});
matchingCards.forEach(function (card, index) {
card.hidden = index >= visibleCount;
});
if (emptyState) {
emptyState.hidden = matchingCards.length !== 0;
}
if (loadMoreButton) {
loadMoreButton.hidden = matchingCards.length <= visibleCount;
}
}
function applySearch() {
var query = searchInput ? (searchInput.value || '').trim().toLowerCase() : '';
matchingCards = cards.filter(function (card) {
var name = (card.getAttribute('data-name') || '').toLowerCase();
var course = (card.getAttribute('data-course') || '').toLowerCase();
return query === '' || name.indexOf(query) !== -1 || course.indexOf(query) !== -1;
});
renderCards(true);
}
tabs.forEach(function (tab) {
tab.addEventListener('click', function () {
setActiveTab(tab.getAttribute('data-tab') || 'text');
});
});
if (searchInput) {
searchInput.addEventListener('input', applySearch);
}
if (loadMoreButton) {
loadMoreButton.addEventListener('click', function () {
visibleCount = Math.min(visibleCount + batchSize, matchingCards.length);
renderCards(false);
});
}
applySearch();
setActiveTab('text');
if (!modal) {
return;
}
var panel = modal.querySelector('.testimonial-modal__panel');
var closeButtons = Array.prototype.slice.call(modal.querySelectorAll('[data-modal-close]'));
var modalText = modal.querySelector('.testimonial-modal__text');
var modalName = modal.querySelector('.testimonial-modal__name');
var modalCourse = modal.querySelector('.testimonial-modal__course');
var modalDate = modal.querySelector('.testimonial-modal__date');
var modalAvatar = modal.querySelector('.testimonial-modal__avatar');
var lastFocused = null;
function getFocusableElements() {
if (!panel) {
return [];
}
return Array.prototype.slice.call(panel.querySelectorAll(
'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])'
)).filter(function (el) {
return !el.hasAttribute('disabled') && el.getAttribute('aria-hidden') !== 'true';
});
}
function openModal(data, opener) {
lastFocused = opener || document.activeElement;
if (modalText) {
modalText.textContent = data.text || '';
}
if (modalName) {
modalName.textContent = data.name || '';
}
if (modalCourse) {
modalCourse.textContent = data.course || '';
}
if (modalDate) {
modalDate.textContent = data.date ? 'Posted on: ' + data.date : '';
}
if (modalAvatar) {
modalAvatar.textContent = data.initials || '';
}
modal.classList.add('is-open');
modal.setAttribute('aria-hidden', 'false');
document.body.classList.add('modal-open');
var focusables = getFocusableElements();
if (focusables.length) {
focusables[0].focus();
} else if (panel) {
panel.focus();
}
}
function closeModal() {
if (!modal.classList.contains('is-open')) {
return;
}
modal.classList.remove('is-open');
modal.setAttribute('aria-hidden', 'true');
document.body.classList.remove('modal-open');
if (lastFocused && typeof lastFocused.focus === 'function') {
lastFocused.focus();
}
}
cards.forEach(function (card) {
var button = card.querySelector('.testimonial-card__more');
if (!button) {
return;
}
button.addEventListener('click', function () {
openModal({
name: button.getAttribute('data-name') || '',
course: button.getAttribute('data-course') || '',
text: button.getAttribute('data-text') || '',
date: button.getAttribute('data-date') || '',
initials: button.getAttribute('data-initials') || ''
}, button);
});
});
closeButtons.forEach(function (button) {
button.addEventListener('click', closeModal);
});
modal.addEventListener('click', function (event) {
if (event.target && event.target.hasAttribute('data-modal-close')) {
closeModal();
}
});
document.addEventListener('keydown', function (event) {
if (!modal.classList.contains('is-open')) {
return;
}
if (event.key === 'Escape' || event.key === 'Esc') {
event.preventDefault();
closeModal();
return;
}
if (event.key === 'Tab') {
var focusables = getFocusableElements();
if (!focusables.length) {
event.preventDefault();
return;
}
var first = focusables[0];
var last = focusables[focusables.length - 1];
if (event.shiftKey && document.activeElement === first) {
event.preventDefault();
last.focus();
} else if (!event.shiftKey && document.activeElement === last) {
event.preventDefault();
first.focus();
}
}
});
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initTestimonialsPage);
} else {
initTestimonialsPage();
}
})();