<?php $__env->startSection('title',$category->name.' Haberleri - '.config('settings.site_title_devam', 'Varsayılan Başlık')); ?>
<?php $__env->startSection('description',$category->name.' Haberleri, Son Dakika '.$category->name. ' Haber ve Gelişmeleri Ogaste Haber Sitesinde Yer Almaktadır' ); ?>



<?php $__env->startSection('content'); ?>
<div class="container-page-custom"  id="site-content">
     
        <div class="col-md-12">
    <div class="ads-1">
        <div class="container">
            <div class="d-flex align-items-center">
                <?php echo $category->category_top_banner; ?>

            </div>
        </div>
    </div>
     <div class="container Category">
          <div class="container mt-5">
        <div class="section-header">
            <h2><?php echo e($category->name); ?></h2>
            <div class="line" style="background-color:#<?php echo e($category->color); ?>"></div>
        </div>
    </div>
    <div class="row">
      

    </div>
      <div class="container newsSlider">
    <div class="row">
        
        <div class="col-md-9">
        <div class="sliderConr">
        <div class="slider slider-2">
             <?php $__currentLoopData = $ekonomikhaberlerSlider; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ekonomikhaberSlider): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

           <?php echo getNewsLink($ekonomikhaberSlider); ?>


                <div class="sliderIn">
                    <div class="slideTit">
                          <span class="badge bg-primary" style="background-color:#<?php echo e($ekonomikhaberSlider->category->color); ?> !important;"><?php echo e($ekonomikhaberSlider->category->name); ?></span>
                        <span>
                            <h2><?php echo e($ekonomikhaberSlider->name); ?></h2>
                        </span>
                    </div>

                    <img src="http://panel.nxoran.com/uploads/images/<?php echo e($ekonomikhaberSlider->news_image); ?>"
                        alt="1">
                </div>
             </a>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
             
        </div>
        <div class="nav">
            <button id="left-2" style="display: none;"></button>
            <ul id="uli-2" class="uld">
                <li class="lim active">1</li>
                <li class="lim">2</li>
                <li class="lim">3</li>
                <li class="lim">4</li>
                <li class="lim">5</li>
                <li class="lim">6</li>
                <li class="lim">7</li>
                <li class="lim">8</li>
                <li class="lim">9</li>
                 <li class="lim">10</li>
                <li class="lim">11</li>
                <li class="lim">12</li>
                <li class="lim">13</li>
                <li class="lim">14</li>
                <li class="lim">15</li>
            </ul>
            <button id="right-2" style="display: none;"> </button>
        </div>
    </div>
    </div>
     <div class="col-md-3 mobile-mt-50">
        <div class="row">
            <div class="col-md-12 ads"><?php echo $category->headline_side_one; ?></div>
            <div class="col-md-12 ads"><?php echo $category->headline_side_two; ?></div>
</div>
        </div>
    </div>
   
    </div>

    </div>
    <div style="clear: both;"></div>
    <div class="container newseight" style="margin-top:50px">
        <div class="row">
           <?php $__currentLoopData = $ekonomikhaberlerNews; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ekonomikhaberNews): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            <div class="col-6 col-md-3 col-lg-3">
                 <div class="news-card">
             <?php echo getNewsLink($ekonomikhaberNews); ?><img src="http://panel.nxoran.com/uploads/images/<?php echo e($ekonomikhaberNews->news_image); ?>" alt="Yıkım"  style="height:165px"></a>
            <div class="news-badge"style="background-color:#<?php echo e($ekonomikhaberNews->category->color); ?> !important;"><?php echo e($ekonomikhaberNews->category->name); ?></div>
             <div class="card-body">
                <h5 class="card-title">  <?php echo getNewsLink($ekonomikhaberNews); ?><div class="news-title"><?php echo e($ekonomikhaberNews->name); ?></div></a></h5></div>
        </div>
            </div>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            
           
        </div>
        <div id="loading" style="display:none;" class="text-center mt-5">
    <img src="/output-onlinegiftools.gif" alt="Loading..." style="width: 150px;">

</div>
    </div>
    </div>
 </div>
              
    </div>
</div>

<style>
    #loading {
    display: none; /* Başlangıçta gizli */
    text-align: center;
    margin-top: 20px;
}

#loading img {
    width: 150px;

</style>

<script type="text/javascript">
    
    
       
     function initializeSlider(sliderClass, leftBtnId, rightBtnId, indicatorUlId, interval) {
    let sliderCont = document.querySelector(sliderClass);
    let sliderI = sliderCont.querySelectorAll(".sliderIn");
    let sliderItem = [...sliderI];
    let sliderD = sliderCont.parentElement.querySelectorAll(".lim");
    let sliderDods = [...sliderD];
    let dodsUl = sliderCont.parentElement.querySelector(indicatorUlId);
    let btnLeft = document.getElementById(leftBtnId);
    let btnRight = document.getElementById(rightBtnId);
    let limit = 0;
    let startX = 0;
    let moveX = 0;

    btnLeft.addEventListener("click", prev);
    btnRight.addEventListener("click", next);

    sliderCont.addEventListener("touchstart", touchStart);
    sliderCont.addEventListener("touchmove", touchMove);
    sliderCont.addEventListener("touchend", touchEnd);

    nexts();

    function prev() {
        limit--;
        if (limit < 0) {
            limit = sliderItem.length - 1;
        }
        nexts();
    }

    function next() {
        limit++;
        if (limit >= sliderItem.length) {
            limit = 0;
        }
        nexts();
    }

    let replay = setInterval(next, interval);

    dodsUl.addEventListener("mouseover", (e, index) => {
        if (!e.target.classList.contains("tumu")) {
            sliderDods.forEach((em, ind) => {
                em.classList.remove("active");
            });
            e.target.classList.add("active");
            limit = Number(e.target.innerText - 1);
            nexts();
        }
    });

    function nexts() {
        sliderItem.forEach((it, index) => {
            if (index == limit) {
                it.classList.add("sliderInActive");
            } else {
                it.classList.remove("sliderInActive");
            }
        });
        sliderDods.forEach((im, index) => {
            if (index == limit) {
                im.classList.add("active");
            } else {
                im.classList.remove("active");
            }
        });
    }

    function touchStart(e) {
        startX = e.touches[0].clientX;
        clearInterval(replay);
    }

    function touchMove(e) {
        moveX = e.touches[0].clientX;
    }

    function touchEnd() {
        const sensitivity = 100; // Kaydırma hassasiyetini artırmak için bu değeri artırabilirsiniz.
        if (startX > moveX + sensitivity) {
            next();
        } else if (startX < moveX - sensitivity) {
            prev();
        }
        replay = setInterval(next, interval);
    }
}

        // Initialize sliders
        initializeSlider(".slider-2", "left-2", "right-2", "#uli-2", 4000);

</script>

<?php $__env->startSection('script'); ?>

<script type="text/javascript">
    let offset = 35; // İlk 20 haber zaten yüklü.
let categoryId = <?php echo e($category->id); ?>;
let loading = false;

// CSRF token'ını almak için jQuery'yi kullanıyoruz
$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});

$(window).scroll(function() {
    if ($(window).scrollTop() + $(window).height() >= $(document).height() - 100 && !loading) {
        loading = true; // Aynı anda birden fazla istek yapmayı engelle
        $('#loading').show(); // Loading div'i göster

        $.ajax({
            url: '<?php echo e(route('load.more.news')); ?>',
            method: 'POST',
            data: {
                offset: offset,
                category_id: categoryId
            },
            success: function(response) {
                if (response) {
                    $('.newseight .row').append(response);
                    offset += 20; // Yeni offset değeri
                    loading = false;
                        $('#loading').hide();
                }
            },
            error: function() {
                loading = false; // Hata durumunda tekrar yüklemeye izin ver
                 $('#loading').hide();
            }
        });
    }
});
</script>

<?php $__env->stopSection(); ?>


<?php $__env->stopSection(); ?>


<?php echo $__env->make('layout.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/nxoranco/public_html/resources/views/categories/category.blade.php ENDPATH**/ ?>