@@ -2574,32 +2574,39 @@ <h3>More</h3>
25742574
25752575 <!-- Custom JavaScript -->
25762576 < script >
2577- document . addEventListener ( 'DOMContentLoaded' , function ( ) {
2577+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
25782578 // Preloader
25792579 window . addEventListener ( 'load' , function ( ) {
25802580 const preloader = document . querySelector ( '.preloader' ) ;
25812581 preloader . classList . add ( 'fade-out' ) ;
2582+
2583+ // Remove preloader from DOM after animation finishes
2584+ setTimeout ( ( ) => {
2585+ preloader . style . display = 'none' ;
2586+ } , 500 ) ;
25822587 } ) ;
25832588
25842589 // Mobile Navigation
25852590 const hamburger = document . getElementById ( 'hamburger' ) ;
25862591 const navList = document . getElementById ( 'nav-list' ) ;
25872592
2588- hamburger . addEventListener ( 'click' , function ( ) {
2589- navList . classList . toggle ( 'active' ) ;
2590- hamburger . innerHTML = navList . classList . contains ( 'active' )
2591- ? '<i class="fas fa-times"></i>'
2592- : '<i class="fas fa-bars"></i>' ;
2593- } ) ;
2593+ if ( hamburger && navList ) {
2594+ hamburger . addEventListener ( 'click' , function ( ) {
2595+ navList . classList . toggle ( 'active' ) ;
2596+ hamburger . innerHTML = navList . classList . contains ( 'active' )
2597+ ? '<i class="fas fa-times"></i>'
2598+ : '<i class="fas fa-bars"></i>' ;
2599+ } ) ;
25942600
2595- // Close mobile nav when clicking on a nav link
2596- const navLinks = document . querySelectorAll ( '.nav-link' ) ;
2597- navLinks . forEach ( link => {
2598- link . addEventListener ( 'click' , function ( ) {
2599- navList . classList . remove ( 'active' ) ;
2600- hamburger . innerHTML = '<i class="fas fa-bars"></i>' ;
2601+ // Close mobile nav when clicking on a nav link
2602+ const navLinks = document . querySelectorAll ( '.nav-link' ) ;
2603+ navLinks . forEach ( link => {
2604+ link . addEventListener ( 'click' , function ( ) {
2605+ navList . classList . remove ( 'active' ) ;
2606+ hamburger . innerHTML = '<i class="fas fa-bars"></i>' ;
2607+ } ) ;
26012608 } ) ;
2602- } ) ;
2609+ }
26032610
26042611 // Smooth scrolling for anchor links
26052612 document . querySelectorAll ( 'a[href^="#"]' ) . forEach ( anchor => {
@@ -2611,8 +2618,9 @@ <h3>More</h3>
26112618
26122619 const targetElement = document . querySelector ( targetId ) ;
26132620 if ( targetElement ) {
2621+ const headerHeight = document . querySelector ( '.header' ) . offsetHeight ;
26142622 window . scrollTo ( {
2615- top : targetElement . offsetTop - 70 ,
2623+ top : targetElement . offsetTop - headerHeight ,
26162624 behavior : 'smooth'
26172625 } ) ;
26182626 }
@@ -2622,21 +2630,39 @@ <h3>More</h3>
26222630 // Back to top button
26232631 const backToTop = document . getElementById ( 'back-to-top' ) ;
26242632
2625- window . addEventListener ( 'scroll' , function ( ) {
2626- if ( window . pageYOffset > 300 ) {
2627- backToTop . classList . add ( 'active' ) ;
2628- } else {
2629- backToTop . classList . remove ( 'active' ) ;
2630- }
2631- } ) ;
2633+ if ( backToTop ) {
2634+ window . addEventListener ( 'scroll' , function ( ) {
2635+ if ( window . pageYOffset > 300 ) {
2636+ backToTop . classList . add ( 'active' ) ;
2637+ } else {
2638+ backToTop . classList . remove ( 'active' ) ;
2639+ }
2640+ } ) ;
26322641
2633- backToTop . addEventListener ( 'click' , function ( e ) {
2634- e . preventDefault ( ) ;
2635- window . scrollTo ( {
2636- top : 0 ,
2637- behavior : 'smooth'
2642+ backToTop . addEventListener ( 'click' , function ( e ) {
2643+ e . preventDefault ( ) ;
2644+ window . scrollTo ( {
2645+ top : 0 ,
2646+ behavior : 'smooth'
2647+ } ) ;
26382648 } ) ;
2639- } ) ;
2649+ }
2650+
2651+ // Certifications View More/Less functionality
2652+ const viewMoreCertsBtn = document . getElementById ( 'view-more-certs' ) ;
2653+ const moreCerts = document . getElementById ( 'more-certs' ) ;
2654+
2655+ if ( viewMoreCertsBtn && moreCerts ) {
2656+ viewMoreCertsBtn . addEventListener ( 'click' , function ( ) {
2657+ if ( moreCerts . style . display === 'none' ) {
2658+ moreCerts . style . display = 'grid' ;
2659+ viewMoreCertsBtn . textContent = 'View Less Certifications' ;
2660+ } else {
2661+ moreCerts . style . display = 'none' ;
2662+ viewMoreCertsBtn . textContent = 'View More Certifications' ;
2663+ }
2664+ } ) ;
2665+ }
26402666
26412667 // Animation on scroll
26422668 const animateElements = document . querySelectorAll ( '.animate' ) ;
@@ -2664,18 +2690,63 @@ <h3>More</h3>
26642690 window . addEventListener ( 'resize' , checkIfInView ) ;
26652691 window . addEventListener ( 'load' , checkIfInView ) ;
26662692
2667- // Form submission (if you decide to implement it)
2693+ // Form submission
26682694 const contactForm = document . getElementById ( 'contact-form' ) ;
26692695 if ( contactForm ) {
26702696 contactForm . addEventListener ( 'submit' , function ( e ) {
26712697 e . preventDefault ( ) ;
2672- // Form submission logic would go here
26732698
2674- // For demonstration purposes, show a success message
2675- alert ( 'Form submitted successfully! This is a demo, so no actual submission occurred.' ) ;
2699+ // Get form values
2700+ const name = document . getElementById ( 'name' ) . value . trim ( ) ;
2701+ const email = document . getElementById ( 'email' ) . value . trim ( ) ;
2702+ const subject = document . getElementById ( 'subject' ) . value . trim ( ) ;
2703+ const message = document . getElementById ( 'message' ) . value . trim ( ) ;
2704+
2705+ // Basic validation
2706+ if ( ! name || ! email || ! subject || ! message ) {
2707+ alert ( 'Please fill in all fields' ) ;
2708+ return ;
2709+ }
2710+
2711+ // For demonstration purposes - in a real implementation,
2712+ // you would send the form data to a server
2713+ alert ( 'Thank you for your message! This is a demo form, so no actual submission occurred. In a live implementation, your message would have been sent.' ) ;
26762714 contactForm . reset ( ) ;
26772715 } ) ;
26782716 }
2717+
2718+ // Active navigation highlighting
2719+ const sections = document . querySelectorAll ( 'section[id]' ) ;
2720+
2721+ function highlightNavigation ( ) {
2722+ const scrollY = window . pageYOffset ;
2723+
2724+ sections . forEach ( section => {
2725+ const sectionHeight = section . offsetHeight ;
2726+ const sectionTop = section . offsetTop - 100 ;
2727+ const sectionId = section . getAttribute ( 'id' ) ;
2728+
2729+ if ( scrollY > sectionTop && scrollY <= sectionTop + sectionHeight ) {
2730+ document . querySelector ( '.nav-link[href="#' + sectionId + '"]' ) ?. classList . add ( 'active' ) ;
2731+ } else {
2732+ document . querySelector ( '.nav-link[href="#' + sectionId + '"]' ) ?. classList . remove ( 'active' ) ;
2733+ }
2734+ } ) ;
2735+ }
2736+
2737+ window . addEventListener ( 'scroll' , highlightNavigation ) ;
2738+
2739+ // Add .active class style to nav-link
2740+ const style = document . createElement ( 'style' ) ;
2741+ style . textContent = `
2742+ .nav-link.active {
2743+ color: var(--primary-color);
2744+ }
2745+ .nav-link.active::after {
2746+ width: 100%;
2747+ }
2748+ ` ;
2749+ document . head . appendChild ( style ) ;
26792750} ) ;
26802751 </ script >
26812752</ body >
0 commit comments