{% extends 'base.html.twig' %}

{% block localstyle %}
    #page-wrapper {
        padding: 0px;
        min-height:0px !important;
    }
{% endblock %}

{% block pagewrapper %}
    <a class="btn btn-secondary" onClick="closeModal();">Annuler</a>

    <form action="{{ oneup_uploader_endpoint('slide') }}" name="formfile" class="dropzone" id="MyDropZone" style="margin-top:10px">
    </form>
{% endblock %}



{% block localjavascript %}
    Dropzone.options.MyDropZone = {
        acceptedMimeTypes: 'image/*',
        maxFiles: 1,
        resizeWidth:2500,

        success: function( file, response ){
            parent.$("#slide_image").val("uploads/slide/"+response["file"]);
            
            url = "{{ asset('uploads/slide/xxxxxxx')}}";
            url=url.replace("xxxxxxx",response["file"]);

            parent.$("#slide_image_img").attr("src",url);
            closeModal();
        }
    }

    function closeModal() {
        window.parent.$("#mymodal").modal('hide');
    }

    $(window).on("load",function () {
        // On vérifie que l'execution se fait bien dans le cadre d'une modal
        if(!window.parent.$("#mymodal #framemodal").length) {
             $(location).attr('href',"{{ path('app_core_home') }}");
        }
    });
{% endblock %}
