@extends('admin/layouts/contentLayoutMaster')

@section('title', $title)

@php
//$configData = Helper::applClasses();
@endphp

@section('vendor-style')
<!-- Vendor css files -->
<link rel="stylesheet" href="{{ asset(mix('vendors/css/extensions/nouislider.min.css')) }}">
<link rel="stylesheet" href="{{ asset(mix('vendors/css/ui/prism.min.css')) }}">
<link rel="stylesheet" href="{{ asset(mix('vendors/css/forms/select/select2.min.css')) }}">
<link rel="stylesheet" href="{{ asset(mix('admin/css/plugins/extensions/noui-slider.css')) }}">
<link rel="stylesheet" href="{{ asset(mix('admin/css/pages/app-ecommerce-shop.css')) }}">

@endsection

@section('content')

<div >
    <div class="content-body">
        <!-- Ecommerce Content Section Starts -->

        <section id="ecommerce-header">
            <div class="row">
                <div class="col-sm-12">
                    <a href="{{url("admin/media/create")}}" class="btn btn-primary mb-2 float-right"><i class="feather icon-plus "></i></a>

                    <div class="ecommerce-header-items">
                        <div class="result-toggler">
                            <button class="navbar-toggler shop-sidebar-toggler" type="button" data-toggle="collapse">
                                <span class="navbar-toggler-icon d-block d-lg-none"><i class="feather icon-menu"></i></span>
                            </button>
                            <div class="search-results">

                                Showing {{ $model->firstItem() }} to {{ $model->lastItem() }}
                                of total {{$model->total()}} entries
                            </div>
                        </div>
                        <div class="view-options">

                            <div class="view-btn-option">
                                <button class=" btn btn-white view-btn grid-view-btn
                                <?php
                                if ($activeClass == 'grid-view') {
                                    echo 'active';
                                }
                                ?>
                                        ">

                                    <i class="feather icon-grid"></i>
                                </button>
                                <button class=" btn btn-white list-view-btn view-btn 
                                <?php
                                if ($activeClass == 'list-view') {
                                    echo 'active';
                                }
                                ?>
                                        ">
                                    <i class="feather icon-list"></i>
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        <!-- Ecommerce Content Section Starts -->
        <!-- background Overlay when sidebar is shown  starts-->
        <div class="shop-content-overlay"></div>
        <!-- background Overlay when sidebar is shown  ends-->

        <!-- Ecommerce Search Bar Starts -->
        <section id="ecommerce-searchbar">
            <div class="row mt-1">
                <div class="col-sm-12">
                    <fieldset class="form-group position-relative">

                        @include("messages")
                        <form action="{{url("admin/media/search")}}">
                            <div class="">
                                <div class="row">
                                    <div class="col-sm-10">
                                        <input type="text" name="search" class="form-control search-product" id="iconLeft5" placeholder="Search here">
                                        <div id="test">
                                            <input type='hidden' value='grid-view' name='activeClass'>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <input type="submit"  class="search btn btn-primary mr-1 mb-1 waves-effect waves-light" value="search"/>
                                    </div>
                                </div>  
                            </div>

                        </form> 


                    </fieldset>
                </div>
            </div>
        </section>

        <!-- Ecommerce Search Bar Ends -->

        <!-- Ecommerce Products Starts -->
        <section id="ecommerce-products" class="{{$activeClass}}">

            @foreach($model as $row)
            <div class="card ecommerce-card line-content">
                <div class="card-content">
                    <div class="item-img text-center">
                        <a href="{{url('admin/media/'.$row->id)}}">
                            <img class="img-fluid"

                                 <?php if ($row->type == 'svg') { ?>
                                     src="{{asset("/uploads/$folder")."/".$row->file}}" alt="{{$row->file}}" 
                                 <?php } else { ?> src="{{asset("/uploads/$folder/thumbnails")."/".$row->file}}" alt="{{$row->file}}" 
                                 <?php } ?> width="150px" height="150px" />


                    </div>
                    <div class="card-body">
                        <div class="item-wrapper">
                            <div class="item-rating">
                                <div class="badge badge-primary badge-md">
                                    <span>{{$row->category}}</span>
                                </div>
                            </div>
                            <div>
                                <h6 class="item-price">
                                    {{$row->file}}
                                </h6>
                            </div>
                        </div>
                        <br>
<!--                        <div class="item-name">
                            <a href="{{url('admin/media/'.$row->id)}}">{{$row->title}}</a>
                            <p class="item-company">By <span class="company-name">Google</span></p>
                        </div>
                        <div>
                            <p class="item-description">
                               
                            </p>
                        </div>-->
                    </div>
                    <div class="item-options text-center">
                        <div class="item-wrapper">
                            <div class="item-rating">
                                <div class="badge badge-primary badge-md">
                                    <span>{{$row->category}}</span>
                                </div>
                            </div>
                            <div class="item-cost">
                                <h6 class="item-price">
                                    {{$row->file}}
                                </h6>
                            </div>
                        </div>
                        <div class="wishlist" data-href="{{url('admin/media/'.$row->id)}}">
                            <i class="fa fa-eye mr-25"></i> View
                        </div>
                        <div class="cart" >
                            <i class="fa fa-edit mr-25"></i><a id="cart" href="{{url('admin/media/edit/'.$row->id)}}" 
                                                               class="view-in-cart">Edit
                            </a>

                        </div>


                    </div>
                </div>
            </div>
            @endforeach


        </section>
        <div class="row">
            {!! $model->appends(Request::all())->links();!!}

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

<section id="ecommerce-pagination">
    <div class="row">
        <div class="col-sm-12">
            <nav aria-label="Page navigation example">
                <ul class="pagination justify-content-center mt-2"  id="pagin">

                </ul>
            </nav>
        </div>
    </div>
</section>

@endsection
@include('vendor_script')
@section('myscript')

<script src="{{ asset(mix('vendors/js/ui/prism.min.js')) }}"></script>
<script src="{{ asset(mix('vendors/js/extensions/wNumb.js')) }}"></script>
<script src="{{ asset(mix('vendors/js/extensions/nouislider.min.js')) }}"></script>
<script src="{{ asset(mix('vendors/js/forms/select/select2.full.min.js')) }}"></script>
<script src="{{ asset(mix('admin/js/scripts/pages/app-ecommerce-shop.js')) }}"></script>

{{-- Page js files --}}
<script>

$(document).ready(function () {

    $(document).on("click", ".wishlist", function () {

        var url = $(this).data("href");
        window.top.location.href = url;
//alert(url);
//$("#" + $("#targetControl").val()).val($("#selectFileName").val());
    });

    $(document).on("click", ".grid-view-btn", function () {
        var html = "<input type='hidden' value='grid-view' name='activeClass'>";
        $("#test").append(html);
    });
    $(document).on("click", ".list-view-btn", function () {
        var html = "<input type='hidden' value='list-view' name='activeClass'>";
        $("#test").append(html);

    });
});


</script>
@endsection


