




















/* ----------------- Start Document ----------------- */
(function($){
    "use strict";
    

    
    // ------------------ End Document ------------------ //







        $('.fotkygal .bg-red-500').on('click', function(){
            //$('.fotka_detail').css('opacity','0');
            //$('.fotka_detail').css('display','none');

            $('#story-modal').show();

            if ($(this).children('img').attr('cislo') == '14'){
                
                $('.story-modal-media__img').hide();
                $('.story-modal-media__mp4').show();

                //$('.video_pop').play();
                $('.video_pop').trigger('play');

            } else {
                
                $('.story-modal-media__img').show();
                $('.story-modal-media__mp4').hide();


                let obraz = $(this).children('img').attr('src');
                console.log(obraz);
                $('.obr__big').attr('src',obraz);                
                
                

            }

            

        });


        $('.klik__zavri').on('click', function(){
            //$('.fotka_detail').css('opacity','0');
            //$('.fotka_detail').css('display','none');

            $('.video_pop').trigger('pause');
            $('#story-modal').hide();

        });

        let liked = false;

        /* $('.klik__like').on('click', function(){

            if (liked){
                $('.klik__like').css('color', '#666');
                $('.klik__like').html(' <i class="uil-heart mr-1"> </i> Like');
                $('.liked__avatar1').attr('src', 'assets/images/avatar-1.jpg');
                $('.liked__avatar2').attr('src', 'assets/images/avatar-4.jpg');
                $('.liked__avatar3').attr('src', 'assets/images/avatar-2.jpg');
                $('.liked__jmeno').html(' Martin');
                $('.liked__pocet').html(' 41 dalším ');
                liked = false;                
                
            } else{
                $('.klik__like').css('color', 'rgb(236 72 153)');
                $('.klik__like').html(' <i class="uil-heart mr-1"> </i> Líbí se ti');
                $('.liked__avatar1').attr('src', 'assets/images/avatar-4.jpg');
                $('.liked__avatar2').attr('src', 'assets/images/avatar-2.jpg');
                $('.liked__avatar3').attr('src', 'assets/images/avatar-7.jpg');
                $('.liked__jmeno').html(' Matěj');
                $('.liked__pocet').html(' 42 dalším ');
                liked = true;

            }
            
        }); */







const data = [
    { name:'Robert', likes:37, reactions:98, comments:17, photo:'1.jpeg' },
    { name:'Robert', likes:63, reactions:346, comments:41, photo:'2.jpeg' },       
    { name:'Robert', likes:54, reactions:142, comments:29, photo:'3.jpeg' },
    { name:'Robert', likes:87, reactions:311, comments:42, photo:'4.jpeg' },
    { name:'Robert', likes:82, reactions:191, comments:42, photo:'5.jpeg' },
    { name:'Robert', likes:87, reactions:311, comments:46, photo:'6.jpeg' },   
    { name:'Robert', likes:154, reactions:215, comments:71, photo:'7.jpeg' }, 
    { name:'Robert', likes:126, reactions:98, comments:17, photo:'8.jpeg' },
    { name:'Robert', likes:203, reactions:356, comments:71, photo:'9.jpeg' },
    { name:'Robert', likes:39, reactions:124, comments:8, photo:'10.jpeg' },
    { name:'Robert', likes:82, reactions:191, comments:42, photo:'11.jpeg' },
    { name:'Robert', likes:87, reactions:311, comments:46, photo:'12.jpeg' },       
    /* { name:'Robert', likes:172, reactions:287, comments:53, photo:'13.jpeg' },
    { name:'Robert', likes:103, reactions:255, comments:39, photo:'14.jpeg' },
    { name:'Robert', likes:82, reactions:191, comments:42, photo:'15.jpeg' },
    { name:'Robert', likes:87, reactions:311, comments:46, photo:'16.jpeg' },   
    { name:'Robert', likes:154, reactions:215, comments:71, photo:'17.jpeg' }, 
    { name:'Robert', likes:37, reactions:98, comments:17, photo:'18.jpeg' },
    { name:'Robert', likes:63, reactions:346, comments:41, photo:'19.jpeg' },  */   
];


    const template = document.querySelector('.bg-white.rounded-md');
    const container = template.parentNode;



for(let i = 1; i < data.length; i++) {
    const clone = template.cloneNode(true);

    clone.querySelector('.block.capitalize').textContent = data[i].name;

    const counters = clone.querySelectorAll('.ikony__text');
    counters[0].textContent = data[i].likes;
    counters[1].textContent = data[i].reactions;
    counters[2].textContent = data[i].comments;

    const img = clone.querySelector('img[src^="assets/photos/"]');
    const link = clone.querySelector('a[href^="assets/photos/"]');

    img.src = `assets/photos/${data[i].photo}`;
    img.alt = i+1;
    link.href = `assets/photos/${data[i].photo}`;
    //link.no = i;
    



    container.appendChild(clone);
}



$(document).on('click', '.klik__srdce', function(e){
    e.preventDefault();

    const $likeBtn = $(this);
    const $srdce = $likeBtn.find('svg');
    const $counter = $likeBtn.find('.ikony__text').first();

    let likes = parseInt($counter.text().trim(), 10) || 0;

    $srdce.removeClass('like-pop unlike-pop');

    if ($srdce.length) {
        $srdce[0].offsetHeight;
    }

    if ($likeBtn.hasClass('is-liked')) {
        $counter.text(Math.max(0, likes - 1));
        $likeBtn.removeClass('is-liked');
        $srdce.addClass('unlike-pop');
    } else {
        $counter.text(likes + 1);
        $likeBtn.addClass('is-liked');
        $srdce.addClass('like-pop');
    }
});






    let modrak = 1;

    $('.ikona__wrap').on('click', function(){
        //$('.fotka_detail').css('opacity','0');

        if (modrak == 1){

             $('.fotka__img').attr('src','assets/photos/modra.jpg');
            $('.fotka__odkaz').attr('href','assets/photos/modra.jpg');    

            
        } else if (modrak == 2) {

            
            $('.ikona__avatar').attr('src','assets/images/modra2.png');  
            
        } else {

            for(let i = 1; i < data.length+1; i++) {

                $('[alt="'+i+'"]').attr('src','assets/photos/'+i+'.jpeg');

                $('[alt="'+i+'"]').parent().attr('href','assets/photos/'+i+'.jpeg');

            } 
            
            $('.ikona__avatar').attr('src','assets/images/modra.png');   
            
            modrak = 0;
            
        }


        modrak++;


    });        






    
    })(jQuery);



    
    