Spaces:
Running
Running
File size: 7,854 Bytes
23b7352 09d7236 23b7352 09d7236 23b7352 09d7236 23b7352 09d7236 23b7352 6576277 23b7352 09d7236 6576277 09d7236 23b7352 09d7236 23b7352 09d7236 23b7352 09d7236 23b7352 09d7236 23b7352 09d7236 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
// Loading screen with animated entrance
document.body.insertAdjacentHTML('afterbegin', '<loading-screen></loading-screen>');
// Add VIP badges to all product cards
document.querySelectorAll('.bg-gray-800').forEach(card => {
card.insertAdjacentHTML('afterbegin', '<vip-badge></vip-badge>');
});
// Luxury animations
const animateOnScroll = () => {
const elements = document.querySelectorAll('.animate-scroll');
elements.forEach(el => {
const rect = el.getBoundingClientRect();
if (rect.top < window.innerHeight * 0.8) {
el.classList.add('animate-fadeInUp');
}
});
};
// Shared JavaScript across all pages
document.addEventListener('DOMContentLoaded', function() {
// Initialize floating elements
gsap.to(".floating-element", {
y: 20,
duration: 3,
repeat: -1,
yoyo: true,
ease: "sine.inOut"
});
// Parallax effect for hero section
gsap.to("#hero-content", {
y: -50,
scrollTrigger: {
trigger: "#hero",
start: "top top",
end: "bottom top",
scrub: true
}
});
// Initialize scroll animations
window.addEventListener('scroll', animateOnScroll);
animateOnScroll();
// Initialize Vanta.js background
if (document.getElementById('vanta-bg')) {
VANTA.GLOBE({
el: "#vanta-bg",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0xd946ef,
color2: 0x8b5cf6,
backgroundColor: 0x111827,
size: 1.00,
lineHeight: 18.00,
spacing: 17.00,
speed: 0.50
});
}
// Add to cart functionality
const addToCartButtons = document.querySelectorAll('button:contains("ADD TO CART")');
addToCartButtons.forEach(button => {
button.addEventListener('click', function() {
const productCard = this.closest('.bg-gray-800');
const productName = productCard.querySelector('h3').textContent;
// Luxury feedback
const originalText = this.textContent;
this.textContent = 'MEDLEMSKAP AKTIVERT!';
this.classList.add('bg-amber-600', 'text-gray-900');
// Show VIP modal after adding to cart
setTimeout(() => {
showVIPModal();
}, 1000);
// Confetti effect
confetti({
particleCount: 100,
spread: 70,
origin: { y: 0.6 },
colors: ['#f59e0b', '#fbbf24', '#ffffff']
});
setTimeout(() => {
this.textContent = originalText;
this.classList.remove('bg-green-600');
}, 1500);
console.log(`Added ${productName} to cart`);
});
});
// Smooth scrolling for anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
window.scrollTo({
top: target.offsetTop - 80,
behavior: 'smooth'
});
}
});
});
// Newsletter form submission
const newsletterForm = document.querySelector('input[type="email"]').closest('div').parentElement;
if (newsletterForm) {
const submitButton = newsletterForm.querySelector('button');
submitButton.addEventListener('click', function() {
const emailInput = newsletterForm.querySelector('input[type="email"]');
const email = emailInput.value.trim();
if (email && validateEmail(email)) {
// Luxury feedback
const originalText = this.textContent;
this.textContent = 'TUSEN TAKK!';
this.classList.add('bg-amber-600');
// Golden particles animation
const particles = [];
for (let i = 0; i < 30; i++) {
particles.push({
x: newsletterForm.getBoundingClientRect().left + Math.random() * newsletterForm.offsetWidth,
y: newsletterForm.getBoundingClientRect().top + Math.random() * newsletterForm.offsetHeight,
size: Math.random() * 3 + 2,
speed: Math.random() * 2 + 1
});
}
particles.forEach(p => {
const particle = document.createElement('div');
particle.style.position = 'absolute';
particle.style.width = `${p.size}px`;
particle.style.height = `${p.size}px`;
particle.style.backgroundColor = '#fbbf24';
particle.style.borderRadius = '50%';
particle.style.left = `${p.x}px`;
particle.style.top = `${p.y}px`;
document.body.appendChild(particle);
gsap.to(particle, {
y: `-=${p.speed * 50}`,
x: `+=${(Math.random() - 0.5) * 50}`,
opacity: 0,
duration: 1.5,
ease: "power1.out",
onComplete: () => particle.remove()
});
});
emailInput.value = '';
setTimeout(() => {
this.textContent = originalText;
this.classList.remove('bg-green-600');
}, 2000);
console.log(`Subscribed with email: ${email}`);
} else {
emailInput.classList.add('border-red-500');
setTimeout(() => {
emailInput.classList.remove('border-red-500');
}, 2000);
}
});
}
// VIP Membership modal
function showVIPModal() {
const modal = document.createElement('div');
modal.className = 'fixed inset-0 bg-black bg-opacity-80 z-50 flex items-center justify-center p-4';
modal.innerHTML = `
<div class="bg-gray-900 border border-amber-500 rounded-xl max-w-md w-full p-8 relative animate-scaleIn">
<button class="absolute top-4 right-4 text-amber-500 hover:text-amber-300">
<i data-feather="x"></i>
</button>
<h3 class="text-2xl font-bold text-amber-500 mb-4">Bli En Del Av Familien</h3>
<p class="text-gray-300 mb-6">
Ved å kjøpe denne eksklusive kolleksjonen blir du en del av OG ENCRO-familien.
Få tilgang til tidlig utgivelse av albumet, VIP-arrangementer og muligheten til
å tjene penger på begrensede utgaver.
</p>
<div class="flex justify-end">
<button class="px-6 py-3 bg-amber-600 hover:bg-amber-700 rounded-lg font-bold transition-colors">
Jeg Er Med
</button>
</div>
</div>
`;
document.body.appendChild(modal);
feather.replace();
modal.querySelector('button').addEventListener('click', () => {
gsap.to(modal.querySelector('div'), {
scale: 0.9,
opacity: 0,
duration: 0.3,
ease: "power1.in",
onComplete: () => modal.remove()
});
});
}
// Email validation helper
function validateEmail(email) {
const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return re.test(email);
}
// Navbar scroll effect
window.addEventListener('scroll', function() {
const navbar = document.querySelector('custom-navbar');
if (window.scrollY > 50) {
navbar.classList.add('scrolled');
} else {
navbar.classList.remove('scrolled');
}
});
}); |