// intialization plugins
$(document).ready(function () {

    //animation icon toggler of navbar
    $(`.navbar-toggler`).click(function() {
        $(`.navbar-toggler`).toggleClass(`active`);
    });

    //Wow intit
    wow = new WOW({
        boxClass: 'wow',
        animateClass: 'animated',
        offset: 200,
        mobile: true,
        live: false
    });
    wow.init();

    //fancybox
    $("[data-fancybox]").fancybox({
        selector: '[data-fancybox="images"]',
        // loop: true
    });

    // share_links 
    $('.course_card .share_box .share_butn ').click(function() {
        $(this).parent('.share_box').find(`.share_links`).toggleClass(`active`);
    });

    // fav_butn
    $(`.course_card .img_box .fav_butn `).click(function() {
        $(this).toggleClass(`active`);
    });
    

    //editButton
    $(`#editButton`).click(function() {
        $(`.profile_pg .profile_tab .data_box`).hide();
        $(`.profile_pg .profile_tab .editData_box`).css("display", "block");
    });

    //  loader 
    // $(window).on("load", function() {
    //     $("#preloader").addClass("isdone");
    // });

});

// Swiper
$(document).ready(function () {

    //////////////////// feedback_swiper  ////////////////////
    // var swiper = new Swiper('.feedback_sec .feedback_swiper', {
    //     // loop: true,
    //     speed: 900,
    //     slidesPerView: 1,
    //     spaceBetween: 15,
    //     // autoplay: {
    //     //     delay: 2500,
    //     // },
    //     navigation: {
    //         nextEl: '.feedback_sec .swiper-button-next',
    //         prevEl: '.feedback_sec .swiper-button-prev',
    //     },
    //     pagination: {
    //         el: '.feedback_sec .swiper-pagination',
    //         clickable: true
    //     },

    // });

    
    //////////////////// features_swiper  ////////////////////
    var swiper = new Swiper('.testmonial_sec .feedback_swiper', {
        loop: true,
        speed: 1000,
        slidesPerView: 1,
        spaceBetween: 15,
        centeredSlides: true,
        autoplay: {
            delay: 3000,
        },
        navigation: {
            nextEl: '.testmonial_sec .swiper-button-next',
            prevEl: '.testmonial_sec .swiper-button-prev',
        },
        pagination: {
            el: '.testmonial_sec .swiper-pagination',
            clickable: true
        },
        breakpoints: {
            768: {
                slidesPerView: 2,
                spaceBetween: 20,
            },
            1024: {
                slidesPerView: 3,
                spaceBetween: 20,
            },
        }
    });

    //////////////////// courses_swiper  ////////////////////
    var swiper = new Swiper('.courses_sec .courses_swiper', {
        // loop: true,
        speed: 900,
        slidesPerView: 1,
        spaceBetween: 15,
        // autoplay: {
        //     delay: 2500,
        // },
        observer: true,
        observeParents: true,
        navigation: {
            nextEl: '.courses_sec .swiper-button-next',
            prevEl: '.courses_sec .swiper-button-prev',
        },
        pagination: {
            el: '.courses_sec .swiper-pagination',
            clickable: true
        },
        breakpoints: {
            640: {
                slidesPerView: 2,
                spaceBetween: 20,
            },
            768: {
                slidesPerView: 3,
                spaceBetween: 20,
            },
            1024: {
                slidesPerView: 4,
                spaceBetween: 20,
            },
        }
    });
    
    //////////////////// Swiper  ////////////////////
    // var swiper = new Swiper(' .swiper-container', {
    //     // loop: true,
    //     speed: 900,
    //     slidesPerView: 1,
    //     spaceBetween: 15,
    //     // autoplay: {
    //     //     delay: 2500,
    //     // },
    //     //In Tabs
    //     // observer: true,
    //     // observeParents: true,
    //     navigation: {
    //         nextEl: '.swiper-button-next',
    //         prevEl: '.swiper-button-prev',
    //     },
    //     pagination: {
    //         el: '.swiper-pagination',
    //         clickable: true
    //     },
    //     breakpoints: {
    //         640: {
    //             slidesPerView: 2,
    //             spaceBetween: 20,
    //         },
    //         768: {
    //             slidesPerView: 3,
    //             spaceBetween: 20,
    //         },
    //         1024: {
    //             slidesPerView: 5,
    //             spaceBetween: 20,
    //             // Prevent swiper in lg screens
    //             // allowTouchMove: false,
    //             // preventClicks: false
    //         },
    //     }
    // });

});



// ------------ SHOW HED PASS ----------
$(document).ready(function() {
    $(".show_hide_password .show_pass").on('click', function(event) {
        event.preventDefault();
        if($(this).siblings("input").attr("type") == "text"){
            $(this).siblings("input").attr('type', 'password');
            $(this).addClass( "fa-eye-slash" );
            $(this).removeClass( "fa-eye" );
        }else if($(this).siblings("input").attr("type") == "password"){
            $(this).siblings("input").attr('type', 'text');
            $(this).removeClass( "fa-eye-slash" );
            $(this).addClass( "fa-eye" );
        }
    });
});



// ------------ increase products -----------
var buttonPlus  = $(".qty-btn-plus");
var buttonMinus = $(".qty-btn-minus");

var incrementPlus = buttonPlus.click(function() {
    var $n = $(this)
    .parent(".qty-container")
    .find(".input-qty");
    $n.val(Number($n.val())+1 );
});

var incrementMinus = buttonMinus.click(function() {
    var $n = $(this)
    .parent(".qty-container")
    .find(".input-qty");
    var amount = Number($n.val());
    if (amount > 0) {
        $n.val(amount-1);
    }
});




// ------------ digitsOnly -----------
jQuery('.digitsOnly').keypress(function(event){
	if(event.which !=8 && isNaN(String.fromCharCode(event.which))){
		event.preventDefault();
	}
		console.log(event.which);

});


$('[data-toggle="datepicker"]').datepicker();
