108 lines
3.8 KiB
JavaScript
108 lines
3.8 KiB
JavaScript
// Modern Scripts for SmartSolTech Website
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
console.log('SmartSolTech: DOM loaded, initializing...');
|
|
|
|
// Hide loading screen
|
|
const loadingScreen = document.getElementById('loading-screen');
|
|
if (loadingScreen) {
|
|
console.log('SmartSolTech: Loading screen found, hiding...');
|
|
setTimeout(() => {
|
|
loadingScreen.style.opacity = '0';
|
|
loadingScreen.style.pointerEvents = 'none';
|
|
setTimeout(() => {
|
|
loadingScreen.style.display = 'none';
|
|
loadingScreen.remove(); // Полностью удаляем элемент
|
|
console.log('SmartSolTech: Loading screen removed');
|
|
}, 300);
|
|
}, 500); // Уменьшили время ожидания
|
|
} else {
|
|
console.log('SmartSolTech: Loading screen not found');
|
|
}
|
|
|
|
// Theme Toggle Functionality
|
|
const themeToggle = document.getElementById('theme-toggle');
|
|
const html = document.documentElement;
|
|
|
|
if (themeToggle) {
|
|
// Check for saved theme preference
|
|
const currentTheme = localStorage.getItem('theme') || 'light';
|
|
html.setAttribute('data-theme', currentTheme);
|
|
updateThemeIcon(currentTheme);
|
|
|
|
themeToggle.addEventListener('click', function() {
|
|
const currentTheme = html.getAttribute('data-theme');
|
|
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
|
|
|
|
html.setAttribute('data-theme', newTheme);
|
|
localStorage.setItem('theme', newTheme);
|
|
updateThemeIcon(newTheme);
|
|
|
|
// Add animation
|
|
this.style.transform = 'scale(0.8)';
|
|
setTimeout(() => {
|
|
this.style.transform = 'scale(1)';
|
|
}, 150);
|
|
});
|
|
}
|
|
|
|
function updateThemeIcon(theme) {
|
|
if (!themeToggle) return;
|
|
const icon = themeToggle.querySelector('i');
|
|
if (icon) {
|
|
if (theme === 'dark') {
|
|
icon.className = 'fas fa-sun';
|
|
themeToggle.setAttribute('aria-label', 'Переключить на светлую тему');
|
|
} else {
|
|
icon.className = 'fas fa-moon';
|
|
themeToggle.setAttribute('aria-label', 'Переключить на темную тему');
|
|
}
|
|
}
|
|
}
|
|
|
|
// Navbar scroll behavior
|
|
const navbar = document.querySelector('.navbar-modern');
|
|
if (navbar) {
|
|
window.addEventListener('scroll', function() {
|
|
if (window.scrollY > 50) {
|
|
navbar.classList.add('scrolled');
|
|
} else {
|
|
navbar.classList.remove('scrolled');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Smooth scrolling for anchor links
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
|
anchor.addEventListener('click', function (e) {
|
|
const target = document.querySelector(this.getAttribute('href'));
|
|
if (target) {
|
|
e.preventDefault();
|
|
target.scrollIntoView({
|
|
behavior: 'smooth'
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// Intersection Observer for animations
|
|
const observerOptions = {
|
|
threshold: 0.1,
|
|
rootMargin: '0px 0px -50px 0px'
|
|
};
|
|
|
|
const observer = new IntersectionObserver((entries) => {
|
|
entries.forEach(entry => {
|
|
if (entry.isIntersecting) {
|
|
entry.target.style.opacity = '1';
|
|
entry.target.style.transform = 'translateY(0)';
|
|
}
|
|
});
|
|
}, observerOptions);
|
|
|
|
// Observe cards and service items
|
|
document.querySelectorAll('.card-modern, .service-card, .step-card').forEach(card => {
|
|
observer.observe(card);
|
|
});
|
|
|
|
console.log('SmartSolTech: All scripts loaded successfully');
|
|
}); |