<commit_before>{% extends 'form_div_layout.html.twig' %}

{% block media_widget %}

    {% set dropzoneId = "dropzone_"~form.vars.id %}


    {% block media_javascripts %}
        {% javascripts
            '@MediaBundle/Resources/public/js/dropzone.js'
        %}
            <script type="text/javascript" src="{{ asset_url }}"></script>
        {% endjavascripts %}
        <script type="text/javascript">
            (function($) {

                function showHideDropzoneButton(nb,max) {
                    if(nb < max)
                        $('div#{{dropzoneId}}').parent().find('.dz-clickable').show();
                    else
                        $('div#{{dropzoneId}}').parent().find('.dz-clickable').hide();
                }



                $(function(){

                    Dropzone.autoDiscover = false;

                    var mediaDropzone = new Dropzone("div#{{dropzoneId}}", {
                        url: "{{app.request.getSchemeAndHttpHost()}}{{ app.request.baseUrl }}/media/upload",
                        maxFiles: 1,
                        parallelUploads: 1,
                        //autoQueue: false, // Make sure the files aren't queued until manually added
                        maxFilesize: 10,
                        clickable : 'p.add-{{dropzoneId}}',
                        acceptedFiles: '.jpg, .png, .jpeg, .pdf',
                        addRemoveLinks : true,
                        dictDefaultMessage : '',
                        previewTemplate : $('div#{{dropzoneId}}').parent().find('.previewTemplateFileDrop').html(),
                        thumbnailWidth : "200",
                        thumbnailHeight : "135",
                        dictInvalidFileType : 'Mauvais type de fichier',
                        dictRemoveFile : '',
                        dictCancelUpload : '',
                        dictCancelUploadConfirmation : 'Confirmer',
                        dictMaxFilesExceeded : 'Limite de photo atteinte.',
                        dictFileTooBig : 'Le fichier est trop volumineux (max 10 Mo)',
                        init : function(){

                            /* DropZone */
                            var $this = this;

                            /* set MaxFiles to 1 by default */
                            $this.options.maxFiles = 1;

                            /* Load existing images for this okaz */
                            var backup_folder = $('div#{{dropzoneId}}').parent().find('.dropzone-backup');

                            if(backup_folder.length && backup_folder.has('img')) {
                                backup_folder.find('img').each(function(i,el){
                                    var mockFile = { name: "Filename", size: 12345 };
                                    var key = $(this).data('key');
                                    Dropzone.forElement('div#{{dropzoneId}}').emit("addedfile", mockFile);
                                    Dropzone.forElement('div#{{dropzoneId}}').emit("thumbnail", mockFile, $(this).attr('src'));

                                    // Set $this.files.length right
                                    $this.files.push(mockFile);

                                    // set data-nb attr for remove link and remove associated hidden input */
                                    mockFile.previewTemplate.setAttribute('data-rel',key);
                                });

                                $('.dz-remove').show();
                            }


                            /* Show clickable button if limit upload */
                            if($this.files.length < $this.options.maxFiles)
                                $('div#{{dropzoneId}}').parent().find('.dz-clickable').show();
                            else {
                                $('div#{{dropzoneId}}').parent().find('.dz-clickable').hide();
                            }

                            /* Show clickable button only if file length < to the maxFile limit */
                            showHideDropzoneButton($this.files.length,$this.options.maxFiles);


                            /* Create Waiting message */
                            if($('#pictureLoader').length == 0) {
                                var loader = $('<p />',{
                                    'id' : 'pictureLoader',
                                    'html' : 'Merci de patienter pendant l\'uplaod de votre fichier/image'
                                }).insertAfter($('form .form-actions button')).hide();
                            }
                        }
                    });

                    mediaDropzone
                    .on("success", function(file, response)
                    {
                        file.previewElement.setAttribute('data-rel',response[0].id);

                        $('#{{form.vars.id}}').val(response[0].id);

                        $('.dz-progress').hide();
                        $('.dz-remove').show();

                        /* Show clickable button only if file length < to the maxFile limit */
                        showHideDropzoneButton(mediaDropzone.files.length,mediaDropzone.options.maxFiles);
                    });<commit_msg>correction orthographe faute de frappe<commit_after>{% extends 'form_div_layout.html.twig' %}

{% block media_widget %}

    {% set dropzoneId = "dropzone_"~form.vars.id %}


    {% block media_javascripts %}
        {% javascripts
            '@MediaBundle/Resources/public/js/dropzone.js'
        %}
            <script type="text/javascript" src="{{ asset_url }}"></script>
        {% endjavascripts %}
        <script type="text/javascript">
            (function($) {

                function showHideDropzoneButton(nb,max) {
                    if(nb < max)
                        $('div#{{dropzoneId}}').parent().find('.dz-clickable').show();
                    else
                        $('div#{{dropzoneId}}').parent().find('.dz-clickable').hide();
                }



                $(function(){

                    Dropzone.autoDiscover = false;

                    var mediaDropzone = new Dropzone("div#{{dropzoneId}}", {
                        url: "{{app.request.getSchemeAndHttpHost()}}{{ app.request.baseUrl }}/media/upload",
                        maxFiles: 1,
                        parallelUploads: 1,
                        //autoQueue: false, // Make sure the files aren't queued until manually added
                        maxFilesize: 10,
                        clickable : 'p.add-{{dropzoneId}}',
                        acceptedFiles: '.jpg, .png, .jpeg, .pdf',
                        addRemoveLinks : true,
                        dictDefaultMessage : '',
                        previewTemplate : $('div#{{dropzoneId}}').parent().find('.previewTemplateFileDrop').html(),
                        thumbnailWidth : "200",
                        thumbnailHeight : "135",
                        dictInvalidFileType : 'Mauvais type de fichier',
                        dictRemoveFile : '',
                        dictCancelUpload : '',
                        dictCancelUploadConfirmation : 'Confirmer',
                        dictMaxFilesExceeded : 'Limite de photo atteinte.',
                        dictFileTooBig : 'Le fichier est trop volumineux (max 10 Mo)',
                        init : function(){

                            /* DropZone */
                            var $this = this;

                            /* set MaxFiles to 1 by default */
                            $this.options.maxFiles = 1;

                            /* Load existing images for this okaz */
                            var backup_folder = $('div#{{dropzoneId}}').parent().find('.dropzone-backup');

                            if(backup_folder.length && backup_folder.has('img')) {
                                backup_folder.find('img').each(function(i,el){
                                    var mockFile = { name: "Filename", size: 12345 };
                                    var key = $(this).data('key');
                                    Dropzone.forElement('div#{{dropzoneId}}').emit("addedfile", mockFile);
                                    Dropzone.forElement('div#{{dropzoneId}}').emit("thumbnail", mockFile, $(this).attr('src'));

                                    // Set $this.files.length right
                                    $this.files.push(mockFile);

                                    // set data-nb attr for remove link and remove associated hidden input */
                                    mockFile.previewTemplate.setAttribute('data-rel',key);
                                });

                                $('.dz-remove').show();
                            }


                            /* Show clickable button if limit upload */
                            if($this.files.length < $this.options.maxFiles)
                                $('div#{{dropzoneId}}').parent().find('.dz-clickable').show();
                            else {
                                $('div#{{dropzoneId}}').parent().find('.dz-clickable').hide();
                            }

                            /* Show clickable button only if file length < to the maxFile limit */
                            showHideDropzoneButton($this.files.length,$this.options.maxFiles);


                            /* Create Waiting message */
                            if($('#pictureLoader').length == 0) {
                                var loader = $('<p />',{
                                    'id' : 'pictureLoader',
                                    'html' : 'Merci de patienter pendant l\'upload de votre fichier/image'
                                }).insertAfter($('form .form-actions button')).hide();
                            }
                        }
                    });

                    mediaDropzone
                    .on("success", function(file, response)
                    {
                        file.previewElement.setAttribute('data-rel',response[0].id);

                        $('#{{form.vars.id}}').val(response[0].id);

                        $('.dz-progress').hide();
                        $('.dz-remove').show();

                        /* Show clickable button only if file length < to the maxFile limit */
                        showHideDropzoneButton(mediaDropzone.files.length,mediaDropzone.options.maxFiles);
                    });
{'fraction_non_alphanumeric': 0.1244402096236303, 'fraction_numerical': 0.004192472606002858, 'mean_word_length': 1.1029853736726107, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4370517', 'n_tokens_mistral': 2509, 'n_tokens_neox': 2285, 'n_words': 438}