Current File : /home/tradevaly/www/resources/views/backend/pages/setting/home/video_banner/index.blade.php
@extends('backend.ayaan.master')
@push('title','Vedio ')
@push('style')
<style>
    #short_video_link{
        display:none;
    }
    #short_video{
        display:none;
    }
    #videoUrl {
    border: 1px solid;
    }
    #videoFile {
    border: 1px solid;
    }
</style>
@endpush

@section('content')
    <div class="container-fluid">
        <div class="container-fluid">
            <div class="row">
                <div class="col-12 col">
                    <div class="page-title-box d-sm-flex align-items-center justify-content-between">
                        <h4 class="mb-sm-0 font-size-18">Inbox</h4>
                        <div class="page-title-right">
                            <ol class="breadcrumb m-0">
                                <li class="breadcrumb-item"><a href="/email-inbox">Email</a></li>
                                <li class="active breadcrumb-item" aria-current="page"><a href="/email-inbox">Inbox</a></li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-12">
                   @include('backend.pages.setting.home.side_bar');
                    <div class="email-rightbar mb-3">
                        <div class="card">
                            <div class="card-header">
                                <h4>Short Video</h4>
                            </div>
                            <div class="card-body">
                                <ul class="nav nav-pills mb-3" id="pills-tab" role="tablist">
                                  <li class="nav-item" role="presentation">
                                    <button class="nav-link {{ site_setting('sort_video_type') == 'video_file'? 'active':'' }}" id="pills-home-tab" data-bs-toggle="pill" data-bs-target="#pills-home" type="button" role="tab" aria-controls="pills-home" aria-selected="false">Upload File</button>
                                  </li>
                                  <li class="nav-item" role="presentation">
                                    <button class="nav-link {{ site_setting('sort_video_type') == 'video_url'? 'active':'' }}" id="pills-profile-tab" data-bs-toggle="pill" data-bs-target="#pills-profile" type="button" role="tab" aria-controls="pills-profile" aria-selected="false">Upload Url</button>
                                  </li>
                                </ul>
                                <div class="tab-content" id="pills-tabContent">
                                  <div class="tab-pane fade  {{ site_setting('sort_video_type') == 'video_file'? ' show active':'' }}" id="pills-home" role="tabpanel" aria-labelledby="pills-home-tab">
                                    <form action="{{route('admin.setting.video_banner.sortVedio','video_file')}}" method="post" class="form-control" enctype="multipart/form-data">
                                      @csrf
                                      <video width="320" height="240" controls>
                                          <source src="{{ asset('storage/setting/'.site_setting('sort_video_file')) }}" type="video/mp4">
                                          <source src="{{ asset('storage/setting/'.site_setting('sort_video_file')) }}" type="video/ogg">
                                        </video>
                                      <input type="file" id="videoFile" name="sort_video_file" class="form-control mb-3">
                                      <input type="submit" class="btn btn-success">
                                    </form>
                                  </div>
                                  <div class="tab-pane fade {{ site_setting('sort_video_type') == 'video_url'? 'show active':'' }}" id="pills-profile" role="tabpanel" aria-labelledby="pills-profile-tab">
                                    <form action="{{route('admin.setting.video_banner.sortVedio','video_url')}}" method="post" class="form-control">
                                      @csrf
                                      <iframe width="700" height="315" src="{{ site_setting('sort_video_url') }}"></iframe>
                                      <input type="text" id="videoUrl" name="sort_video_url" class="form-control mb-3 boder" placeholder="Enter Your video url" value="{{ site_setting('sort_video_url') }}">
                                      <input type="submit" class="btn btn-success">
                                    </form>
                                  </div>
                                </div>
                            </div>
                        </div>
                        <div class="card">
                            <div class="card-header">
                                <h4>Video Banner</h4>
                            </div>
                            <div class="card-body">

                                <form action="{{ route('admin.setting.video_banner.update')}}" method="POST"
                                    enctype="multipart/form-data">
                                    @csrf
                                    @method('put')
                                    <div class="row">




                                        <div class="col-sm-12">
                                            <div class="mb-3">
                                                <label for="metadescription">Enter Your Video Link</label>
                                                <input id="metatitle" name="video_banner_link" type="text" class="form-control"
                                                    value="{{ site_setting('video_banner_link') }}" required>
                                            </div>
                                        </div>
                                        <div class="col-md-12">
                                            <div class="mb-3">
                                                <div class="fallback">
                                                    <input name="image" type="file"
                                                        oninput="preview_image(this, '.image_preview_container')" />
                                                </div>

                                                <div class="dz-message needsclick">
                                                    <div class="image_preview_container">
                                                        <img
                                                            src="{{ asset('storage/setting/'.site_setting('video_banner_photo')) }}"
                                                            alt="Image Not Found" class="img-fluid w-75 pt-3">
                                                        </div>
                                                </div>

                                            </div>
                                        </div>




                                    </div>

                                    <div class="d-flex flex-wrap gap-2">
                                        <button type="submit" class="btn btn-primary waves-effect waves-light">Save
                                            Changes</button>
                                        <button type="submit"
                                            class="btn btn-secondary waves-effect waves-light">Cancel</button>
                                    </div>
                                </form>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    @stop

    @push('script')
        <script>
            function preview_image(F, image_container) {
                let my_container = document.querySelector(image_container);

                let new_container = document.createElement('div');
                new_container.className = 'image_preview_container';

                F = F.files;
                F = Array.from(F);

                F.forEach(file => {
                    let my_url = URL.createObjectURL(file);

                    let my_image = getImage(my_url);
                    new_container.append(my_image);
                });

                my_container.replaceWith(new_container);
            }

            function getImage(url) {
                let img = document.createElement('img');
                img.src = url;
                img.alt = "Image Not Found";

                return img;
            }

            $(document).on('change', '[name=parent_id]', function() {
                var child_id = $(this).val();
                get_child(child_id);
            });


            function get_child(child_id) {
                $('[name="sub_id"]').html("");
                $.ajax({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    },
                    url: "{{ route('ajax.cat') }}",
                    type: 'POST',
                    data: {
                        sub_id: child_id
                    },
                    success: function(response) {
                        var obj = JSON.parse(response);
                        if (obj != '') {
                            $('[name="sub_id"]').html(obj);
                        }
                    }
                });
            }
        </script>
        <script>
            let shor_video_type = document.querySelector('#shor_video_type');
            let short_video_link = document.querySelector('#short_video_link');
            let short_video = document.querySelector('#short_video');
            
            shor_video_type.addEventListener('change', function() {
            if (shor_video_type.value === 'short_video_link') {
                short_video_link.style.display = 'block';
            } else {
                short_video_link.style.display = 'none';
            }
            if (short_video.value === 'short_video') {
                short_video.style.display = 'block';
            } else {
                short_video.style.display = 'none';
            }
        });
        </script>
    @endpush