@extends('admin.layouts.container')

@section('content')
    <div class="side-title">
        <h3>{{ $head ?? ''}}</h3>
    </div>

    <div class="border-item">
        <form class="form-row" method="post" onsubmit="saveForm(this)" action="{{ $action }}" enctype="multipart/form-data">
            @if($gallery ?? ''  && $gallery->id)
                @method('PUT')
            @endif
            @csrf

            <div class="border-item photos col-md-12 other_image_container">
                <div class="row">
                    @if ($galleries ?? false)
                        @foreach ($galleries as $photo)
                            <div class="col-md-4">
                                <div class="items">
                                    <div class="img">
                                        <a href="{{ asset($photo->image ?? '')}}" data-fancybox="gallery"><img src="{{ asset($photo->image ?? '')}}" alt=""></a>
                                    </div>
                                    <input type="hidden" name="images[]" value="{{ $photo->image ?? "" }}">
                                    <a href="#" onclick="DeleteImg(this)" class="close"><i class="fas fa-times"></i></a>
                                </div>
                            </div>
                        @endforeach
                    @endif
                </div>
                <div class="text-center">
                    <input id="other_image_thumbnail" class="other_image_thumbnail" type="hidden"/>
                    <div class="clearfix"></div>
                    <span id="add">
                                <a id="lfm" data-width="" data-cache="article_gallery" data-input=".other_image_thumbnail" data-preview="" data-show="" data-hide="" class="lfm add">
                                    Add New Item
                                </a>
                            </span>
                </div>
            </div>

            <div class="text-center mt-5 col-12">
                <button class="butn"><span>{{ __('dashboard.save') }}</span></button>
            </div>
        </form>
    </div>

@endsection

@section('inner_js')
    <!-- Editor JS orders -->
    <script src="{{ asset('/assets/admin/js/lib/tinymce.min.js') }}"></script>

    <script>
        function DeleteImg(elem)
        {
            $(elem).closest('.col-md-4').remove();
        }
    </script>
    <script>
        let route_prefix = "{{ url(config('lfm.prefix')) }}",
            url = "{{url('/')}}/",
            currentLanguage = "{{getCurrentLocale()}}",
            imagePath = "{{asset('')}}";
    </script>
    <script src="{{ asset('assets/admin/js/editor.js') }}"></script>
    <script src="{{ asset('assets/admin/js/lfm.js') }}"></script>
    <script src="{{ asset('assets/admin/js/articles.js') }}"></script>
@endsection



