HEX
Server: LiteSpeed
System: Linux standart103.isimtescil.net 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: byildiz (11197)
PHP: 8.2.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/byildiz.com.tr/httpdocs/wp-content/themes/lumex/assets/js/main.js
/* -------------------------------------------

Name: 		 Lumex
Version:     1.0
Developer:   Nazar Miller (millerDigitalDesign)
Portfolio:   https://themeforest.net/user/millerdigitaldesign/portfolio?ref=MillerDigitalDesign

p.s. I am available for Freelance hire (UI design, web development). email: miller.themes@gmail.com
   
------------------------------------------- */

document.addEventListener("DOMContentLoaded", function () {

    "use strict";

    /* Elementor Editor */
    var elementor = 0;
    if ( window.location.href.indexOf('/?elementor-preview=') > -1 || window.location.href.indexOf('&action=elementor') > -1 ) {
        elementor = 1;
    }

    /* -------------------------------------------

    Register GSAP plugins

    ------------------------------------------- */
    gsap.registerPlugin(ScrollTrigger);

    /* -------------------------------------------

    mobile panel fix

    ------------------------------------------- */
    function setHeight() {
        var vh = window.innerHeight * 0.01;
        document.documentElement.style.setProperty('--vh', `${vh}px`);
    }
    setHeight();
    window.addEventListener('resize', setHeight);

    /* -------------------------------------------

    smooth scroll

    ------------------------------------------- */
    const lenis = new Lenis();

    lenis.on('scroll', ScrollTrigger.update);

    gsap.ticker.add((time) => {
        lenis.raf(time * 1000);
    });

    gsap.ticker.lagSmoothing(0);

    /* -------------------------------------------

    preloader

    ------------------------------------------- */
    const counterEl = document.querySelector('.mil-counter');
    const lineEl = document.querySelector('.mil-mil-preloader-line');
    const preloaderFrame = document.querySelector('.mil-preloader-frame');

    const startDelay = 400;
    const duration = 2000;

    if (preloaderFrame && counterEl && lineEl) {
        setTimeout(() => {
            preloaderFrame.classList.add('mil-loading');

            let start = null;

            function animate(timestamp) {
                if (!start) start = timestamp;
                const progress = Math.min((timestamp - start) / duration, 1);
                const value = Math.floor(progress * 100);

                counterEl.textContent = value.toString();
                lineEl.style.width = value + '%';

                if (progress < 1) {
                    requestAnimationFrame(animate);
                } else {
                    setTimeout(() => {
                        preloaderFrame.classList.remove('mil-loading');
                        setTimeout(() => {
                            preloaderFrame.classList.add('mil-ready');
                        }, 400);
                    }, 400);
                }
            }

            requestAnimationFrame(animate);
        }, startDelay);
    }

    /* -------------------------------------------

    top panel

    ------------------------------------------- */
    const openInfoBtn = document.querySelector('.mil-open-info');
    const infoWindowFrame = document.querySelector('.mil-info-window-frame');
    const infoWindow = document.querySelector('.mil-info-window');
    const menuBtn = document.querySelector('.mil-menu-btn');
    const mobileMenu = document.querySelector('.mil-mobile-menu');
    const topPanel = document.querySelector('.mil-top-panel');
    const links = document.querySelectorAll('a[href^="#"]:not([href="#"])');

    if (openInfoBtn && infoWindowFrame && infoWindow) {
        const toggleInfo = (show) => {
            openInfoBtn.classList.toggle('mil-active', show);
            infoWindowFrame.classList.toggle('mil-active', show);
            if (topPanel) topPanel.classList.toggle('mil-active', show);
        };

        openInfoBtn.addEventListener('click', (e) => {
            e.stopPropagation();
            e.preventDefault();
            const isActive = openInfoBtn.classList.contains('mil-active');
            toggleInfo(!isActive);
        });

        document.addEventListener('click', (e) => {
            const clickedInsideInfo = infoWindow.contains(e.target);
            const clickedButton = openInfoBtn.contains(e.target);
            if (!clickedInsideInfo && !clickedButton) {
                toggleInfo(false);
            }
        });

        infoWindow.addEventListener('click', (e) => {
            e.stopPropagation();
        });
    }

    function handleScroll() {
        const scrollY = window.scrollY || window.pageYOffset;
        const threshold = 10 * parseFloat(getComputedStyle(document.documentElement).fontSize);

        if (topPanel) {
            topPanel.classList.toggle('mil-scroll', scrollY >= threshold);
        }
        if (infoWindowFrame) {
            infoWindowFrame.classList.toggle('mil-scroll', scrollY >= threshold);
        }
    }

    if (topPanel || infoWindowFrame) {
        window.addEventListener('scroll', handleScroll);
    }

    if (menuBtn && mobileMenu) {
        menuBtn.addEventListener('click', (e) => {
            e.stopPropagation();
            menuBtn.classList.toggle('mil-active');
            mobileMenu.classList.toggle('mil-active');
        });

        if (topPanel) {
            topPanel.addEventListener('click', (e) => {
                e.stopPropagation();
            });
        }

        document.addEventListener('click', () => {
            menuBtn.classList.remove('mil-active');
            mobileMenu.classList.remove('mil-active');
        });
    }

    /* -------------------------------------------

    anchor smooth scroll

    ------------------------------------------- */
    if (links.length) {
        links.forEach(link => {
            link.addEventListener('click', function (e) {
                const targetId = this.getAttribute('href').slice(1);
                const targetEl = document.getElementById(targetId);

                if (targetEl) {
                    e.preventDefault();
                    const offsetPx = remOffset * getRemInPx();
                    const elementPosition = targetEl.getBoundingClientRect().top + window.pageYOffset;
                    const offsetPosition = elementPosition - offsetPx;

                    window.scrollTo({
                        top: offsetPosition,
                        behavior: 'smooth'
                    });
                }
            });
        });
    }

    /* -------------------------------------------
    
    order a call
    
    ------------------------------------------- */

    const openBtn = document.querySelector('.mil-open-window');
    const closeBtn = document.querySelector('.mil-close-popup');
    const orderCallFrame = document.querySelector('.mil-order-call-frame');
    const rightButtonsFrame = document.querySelector('.mil-right-buttons-frame');

    if (openBtn && closeBtn && orderCallFrame) {
        openBtn.addEventListener('click', () => {
            orderCallFrame.classList.add('mil-active');
        });

        closeBtn.addEventListener('click', () => {
            orderCallFrame.classList.remove('mil-active');
        });
    }

    window.addEventListener('scroll', () => {
        const rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
        const scrollThreshold = 20 * rem;
        const bottomOffset = 20 * rem;

        const scrollY = window.scrollY || window.pageYOffset;
        const windowHeight = window.innerHeight;
        const docHeight = document.documentElement.scrollHeight;

        // Додаємо/видаляємо mil-active
        if (scrollY >= scrollThreshold) {
            rightButtonsFrame?.classList.add('mil-active');
        } else {
            rightButtonsFrame?.classList.remove('mil-active');
        }

        // Додаємо/видаляємо mil-on-bottom з відступом
        if (scrollY + windowHeight >= docHeight - bottomOffset) {
            rightButtonsFrame?.classList.add('mil-on-bottom');
        } else {
            rightButtonsFrame?.classList.remove('mil-on-bottom');
        }
    });

    const remOffset = 12;
    const getRemInPx = () => {
        return parseFloat(getComputedStyle(document.documentElement).fontSize);
    };


    /* -------------------------------------------

    animation

    ------------------------------------------- */
    const initAnimations = () => {
        const scaleImage = document.querySelectorAll(".mil-scale-img");
        if (scaleImage.length) {
            scaleImage.forEach((section) => {
                var value1 = section.getAttribute("data-value-1");
                var value2 = section.getAttribute("data-value-2");
                if (!value1 || !value2) return;

                if (window.innerWidth < 1200) {
                    value1 = Math.max(.95, value1);
                }

                gsap.fromTo(section, {
                    ease: 'sine',
                    scale: value1,
                }, {
                    scale: value2,
                    scrollTrigger: {
                        trigger: section,
                        scrub: true,
                        toggleActions: 'play none none reverse',
                    }
                });
            });
        }

        const scaleImageTop = document.querySelectorAll(".mil-scale-img-top");
        if (scaleImageTop.length && window.innerWidth >= 1200) {
            scaleImageTop.forEach((section) => {
                var value1 = section.getAttribute("data-value-1");
                var value2 = section.getAttribute("data-value-2");
                if (!value1 || !value2) return;

                gsap.fromTo(section, {
                    ease: 'sine',
                    scale: value1,
                }, {
                    scale: value2,
                    scrollTrigger: {
                        trigger: section,
                        scrub: true,
                        start: "top top",
                        toggleActions: 'play none none reverse',
                    }
                });
            });
        }

        const scaleImageAlt = document.querySelectorAll(".mil-scale-img-alt");
        if (scaleImageAlt.length && window.innerWidth >= 1200) {
            scaleImageAlt.forEach((section) => {
                var value1 = section.getAttribute("data-value-1");
                var value2 = section.getAttribute("data-value-2");
                if (!value1 || !value2) return;

                gsap.fromTo(section, {
                    ease: 'sine',
                    scale: value1,
                }, {
                    scale: value2,
                    scrollTrigger: {
                        trigger: section,
                        scrub: true,
                        start: "top-=100%",
                        toggleActions: 'play none none reverse',
                    }
                });
            });
        }

        const rotate = document.querySelectorAll(".mil-rotate");
        if (rotate.length) {
            rotate.forEach((section) => {
                var value = section.getAttribute("data-value");
                if (!value) return;

                gsap.fromTo(section, {
                    ease: 'sine',
                    rotate: 0,
                }, {
                    rotate: value,
                    scrollTrigger: {
                        trigger: section,
                        scrub: true,
                        toggleActions: 'play none none reverse',
                    }
                });
            });
        }

        const numbers = document.querySelectorAll(".mil-counter");
        if (numbers.length) {
            numbers.forEach(element => {
                const numberAttr = element.dataset.number;
                if (!numberAttr) return;
                const num = parseFloat(numberAttr);
                const split = num.toString().split(".");
                const decimals = split.length > 1 ? split[1].length : 0;
                const zero = {
                    val: 0
                };

                gsap.to(zero, {
                    val: num,
                    duration: 1.8,
                    scrollTrigger: {
                        trigger: element,
                        toggleActions: 'play none none reverse',
                    },
                    onUpdate: function () {
                        element.textContent = zero.val.toFixed(decimals);
                    }
                });
            });
        }

        const prog = document.querySelectorAll(".mil-skill-prog");
        if (prog.length) {
            prog.forEach((section) => {
                var value = section.getAttribute("data-value");
                if (!value) return;

                gsap.fromTo(section, {
                    ease: 'sine',
                    width: 0,
                }, {
                    width: value,
                    scrollTrigger: {
                        trigger: section,
                        toggleActions: 'play none none reverse',
                    }
                });
            });
        }
    };

    initAnimations();

    /* -------------------------------------------

    sliders

    ------------------------------------------- */
    if (document.querySelector('.mil-slider-bg-img')) {
        new Swiper('.mil-slider-bg-img', {
            slidesPerView: 1,
            speed: 800,
            effect: 'fade',
            parallax: true,
            autoplay: {
                delay: 5000,
            },
            navigation: {
                nextEl: '.mil-hero-slider-next',
                prevEl: '.mil-hero-slider-prev',
            },
            pagination: {
                el: '.mil-hero-slider-pagination',
                clickable: true,
            },
        });
    }

    if (document.querySelector('.mil-slider-title')) {
        new Swiper('.mil-slider-title', {
            slidesPerView: 1,
            speed: 800,
            effect: 'fade',
            parallax: true,
            autoplay: {
                delay: 5000,
            },
            navigation: {
                nextEl: '.mil-hero-slider-next',
                prevEl: '.mil-hero-slider-prev',
            },
            pagination: {
                el: '.mil-hero-slider-pagination',
                clickable: true,
            },
        });
    }

    /* -------------------------------------------

    faq

    ------------------------------------------- */
    const faqButtons = document.querySelectorAll('.mil-faq-question');
    if (faqButtons.length) {
        faqButtons.forEach((btn) => {
            btn.addEventListener('click', () => {
                const item = btn.parentElement;
                item.classList.toggle('mil-active');

                document.querySelectorAll('.mil-faq-item').forEach((otherItem) => {
                    if (otherItem !== item) {
                        otherItem.classList.remove('mil-active');
                    }
                });
            });
        });
    }

});

document.addEventListener("DOMContentLoaded", function () {
    "use strict";

    /* -------------------------------------------

    highlight words

    ------------------------------------------- */
    const words = document.querySelectorAll('[data-whighlight]');

    words.forEach(word => {
        let word_color = word.dataset.whighlightColor;
        const word_color_m = word.dataset.whighlightColor;
        const value = word.dataset.whighlight;
        const currentStr = word.innerHTML;
        let newCurrentStr = currentStr;
        let valueArr = value.split(', ');
        valueArr.forEach(function(item_value, index){
            if ( word_color_m == 'a21' ) {
                if ( (index+1) % 2 == 0 ) {
                    word_color = 'a2';
                } else {
                    word_color = 'a1';
                }
            } else if ( word_color_m == 'a12' ) {
                if ( (index+1) % 2 == 0 ) {
                    word_color = 'a1';
                } else {
                    word_color = 'a2';
                }
            } else {}

            newCurrentStr = newCurrentStr.replaceAll(item_value, '<span class="mil-'+word_color+'">'+item_value+'</span>');
        });
        word.innerHTML = newCurrentStr;
    });

});

( function( $ ) {
  'use strict';
    
    /***************************

    color variables

    ***************************/
    var variables = {
        "accentColor": 'rgba(255, 152, 0, 1)',
        "darkColor": '#000',
        "lightColor" : '#fff'
    }

    /* Custom Colors */
    if ( $('.mil-wrapper').data('dark-color') ) {
        variables.darkColor = $('.mil-wrapper').data('dark-color');
    }
    if ( $('.mil-wrapper').data('accent-color') ) {
        variables.accentColor = $('.mil-wrapper').data('accent-color');
    }
    if ( $('.mil-wrapper').data('light-color') ) {
        variables.lightColor = $('.mil-wrapper').data('light-color');
    }

    /* Elementor Editor */
    var elementor = 0;
    if ( window.location.href.indexOf('/?elementor-preview=') > -1 || window.location.href.indexOf('&action=elementor') > -1 ) {
        elementor = 1;
    }

    /***************************

    portfolio slider

    ***************************/
    var p_mousewheel = true;
    var p_mousewheel_param = $('.mil-portfolio-slider').data('mousewheel');
    if (p_mousewheel_param == 'false') {
        p_mousewheel = false;
    }
    var swiper = new Swiper('.mil-portfolio-slider', {
        slidesPerView: 1,
        spaceBetween: 0,
        speed: 800,
        parallax: true,
        mousewheel: {
            enable: p_mousewheel
        },
        navigation: {
            nextEl: '.mil-portfolio-next',
            prevEl: '.mil-portfolio-prev',
        },
        pagination: {
            el: '.swiper-portfolio-pagination',
            type: 'fraction',
        },
    });

    /***************************

    Magnific Popups

    ***************************/
    if(/\.(?:jpg|jpeg|gif|png)$/i.test($('.wp-block-gallery .blocks-gallery-item:first a').attr('href'))){
    $('.wp-block-gallery a').magnificPopup({
        gallery: {
            enabled: true
        },
        type: 'image',
        closeOnContentClick: false,
        fixedContentPos: false,
        closeBtnInside: false,
        callbacks: {
        beforeOpen: function() {
            // just a hack that adds mfp-anim class to markup
            this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
            this.st.mainClass = 'mfp-zoom-in';
        }
        },
    });
    }
    $('[data-magnific-inline]').magnificPopup({
    type: 'inline',
    overflowY: 'auto',
    preloader: false,
    callbacks: {
        beforeOpen: function() {
            this.st.mainClass = 'mfp-zoom-in';
        }
    },
    });
    $('[data-magnific-image]').magnificPopup({
    type: 'image',
    closeOnContentClick: true,
    fixedContentPos: false,
    closeBtnInside: false,
    callbacks: {
        beforeOpen: function() {
        // just a hack that adds mfp-anim class to markup
            this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
            this.st.mainClass = 'mfp-zoom-in';
        }
    },
    });
    if (!$('body').hasClass('elementor-page')) {
    $("a").each(function(i, el) {
        var href_value = el.href;
        if (/\.(jpg|png|gif)$/.test(href_value)) {
            $(el).magnificPopup({
            type: 'image',
            closeOnContentClick: true,
            fixedContentPos: false,
            closeBtnInside: false,
            callbacks: {
                beforeOpen: function() {
                // just a hack that adds mfp-anim class to markup
                    this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
                    this.st.mainClass = 'mfp-zoom-in';
                }
            },
            });
        }
    });
    }
    $('[data-magnific-video]').magnificPopup({
    type: 'iframe',
    iframe: {
        patterns: {
            youtube_short: {
                index: 'youtu.be/',
                id: 'youtu.be/',
                src: 'https://www.youtube.com/embed/%id%?autoplay=1'
            }
        }
    },
    preloader: false,
    fixedContentPos: false,
    callbacks: {
        markupParse: function(template, values, item) {
        template.find('iframe').attr('allow', 'autoplay');
        },
        beforeOpen: function() {
        // just a hack that adds mfp-anim class to markup
            this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
            this.st.mainClass = 'mfp-zoom-in';
        }
    },
    });
    $('[data-magnific-music]').magnificPopup({
    type: 'iframe',
    preloader: false,
    fixedContentPos: false,
    closeBtnInside: true,
    callbacks: {
        beforeOpen: function() {
        // just a hack that adds mfp-anim class to markup
            this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
            this.st.mainClass = 'mfp-zoom-in';
        }
    },
    });
    $('[data-magnific-gallery]').magnificPopup({
    gallery: {
        enabled: true
    },
    type: 'image',
    closeOnContentClick: false,
    fixedContentPos: false,
    closeBtnInside: false,
    callbacks: {
        beforeOpen: function() {
        // just a hack that adds mfp-anim class to markup
            this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
            this.st.mainClass = 'mfp-zoom-in';
        }
    },
    });

    /* Generate Random Title Markup */
    if ( $('.mil-thin-gen').length ) {
        var mtg_words = $('.mil-thin-gen').text().split(' ');
        var mtg_num = mtg_words.length;
        var mtg_count = parseInt(mtg_num/2);
        var mtg_indexes = [];
        var mtg_res = '';
        for (var i = 0; i<mtg_count; i++){
            mtg_indexes.push(Math.floor(Math.random() * mtg_num));
        }
        for (var i=0; i<mtg_num; i++) {
            if ( mtg_indexes.includes(i) ) {
                mtg_res += ' ' + '<span class="mil-thin">' + mtg_words[i] + '</span>';
            } else {
                mtg_res += ' ' + mtg_words[i];
            }
        }
        if ( mtg_res ) {
            $('.mil-thin-gen').html(mtg_res);
        }
    }

    /* 
		X Icon
	*/
	if($('footer .mil-social-icons .fab.fa-twitter').length){
		$('footer .mil-social-icons .fab.fa-twitter').addClass('x-icon');
		$('footer .mil-social-icons .fab.fa-twitter').append('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="#ffffff" d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"/></svg>');
	}

    /*
        Portfolio
    */

	var $container = $('.portfolio-grid');
	$container.imagesLoaded(function() {
		$container.isotope({
			itemSelector: '.portfolio-grid-item',
			percentPosition: true,
		});
	});

    /* Mobile Menu Parent Container */
    $('.elementor-widget-lumex-header-menu').css({'position': 'initial'});
    $('.elementor-widget-lumex-header-menu').closest('.e-child').css({'position': 'initial'});
    $('.elementor-widget-lumex-header-menu').closest('.e-parent').css({'position': 'initial'});
    $('.elementor-widget-lumex-header-menu .elementor-widget-container').css({'position': 'initial'});

} )( jQuery );