<commit_before>(function(global) {
    'use strict';

    $(document).ready(function(){
        Dropzone.autoDiscover = false;
    });

    global.setupDropzone = function(element) {
        var $dz = $(element),
            $form = $dz.closest('form'),
            options = {
                clickable: element + ' .dropzone-inner',
                previewsContainer: element + ' .dropzone-previews',
                autoProcessQueue: false,

                init: function() {
                    var $button = $form.find('input[type="submit"], .js-dropzone-upload'),
                        self = this,
                        file = $dz.data('value');

                    if (file) {
                        var existingFile = {
                            name: file.file_name,
                            size: file.size,
                            accepted: true
                        };

                        self.emit('addedfile', existingFile);
                        $dz.find('.dz-progress').hide();
                        self.files[0] = existingFile;

                        /* Disable opening the upload dialog when clicking on the file's preview element */
                        $dz.find('.dz-preview').on('click', function(e) {
                            e.stopPropagation();
                        });

                        // Check if the existing file is an image and add the image preview.
                        if (file.content_type.match(/image\/.*/) && file.url) {
                            $dz.find('.dz-image > img').attr('src', file.url);
                            $dz.find('.dz-image > img').attr('width', '120px');
                            $dz.find('.dz-preview').removeClass('dz-file-preview').addClass('dz-image-preview');
                        }
                    }

                    $button.on('click', function(e) {
                        e.preventDefault();
                        e.stopPropagation();
                        $button.prop('disabled', true);

                        if (self.getQueuedFiles().length) {
                            $dz.find('.dz-progress').show();
                            self.processQueue();
                        }
                        else {
                            $form.submit();
                        }
                    });

                    self.on('addedfile', function(file) {
                        if (!options.uploadMultiple && self.files.length > 1) {
                            self.removeFile(self.files[0]);
                        }

                        // force change in form, so that we can process
                        // the 'change' event
                        $button.prop('disabled', false);
                        $form.find('.change-trigger').val(self.files.length);
                        $form.trigger('change');

                        $dz.find('.dz-message').hide();
                        $dz.find('.dz-progress').hide();
                        $(file.previewElement).on('click', function(e) {
                            e.stopPropagation();
                        });
                    });

                    self.on('removedfile', function(file) {

                        // force change in form, so that we can process
                        // the 'change' event
                        $form.find('.change-trigger').val(self.files.length);
                        $form.trigger('change');

                        if (self.files.length === 0) {
                            $dz.find('.dz-message').show();
                        }
                    });

                    self.on('sendingmultiple', function() {<commit_msg>Fix dropzone widget change trigger<commit_after>(function(global) {
    'use strict';

    $(document).ready(function(){
        Dropzone.autoDiscover = false;
    });

    global.setupDropzone = function(element) {
        var $dz = $(element),
            $form = $dz.closest('form'),
            options = {
                clickable: element + ' .dropzone-inner',
                previewsContainer: element + ' .dropzone-previews',
                autoProcessQueue: false,

                init: function() {
                    var $button = $form.find('input[type="submit"], .js-dropzone-upload'),
                        self = this,
                        file = $dz.data('value');

                    if (file) {
                        var existingFile = {
                            name: file.file_name,
                            size: file.size,
                            accepted: true
                        };

                        self.emit('addedfile', existingFile);
                        $dz.find('.dz-progress').hide();
                        self.files[0] = existingFile;

                        /* Disable opening the upload dialog when clicking on the file's preview element */
                        $dz.find('.dz-preview').on('click', function(e) {
                            e.stopPropagation();
                        });

                        // Check if the existing file is an image and add the image preview.
                        if (file.content_type.match(/image\/.*/) && file.url) {
                            $dz.find('.dz-image > img').attr('src', file.url);
                            $dz.find('.dz-image > img').attr('width', '120px');
                            $dz.find('.dz-preview').removeClass('dz-file-preview').addClass('dz-image-preview');
                        }
                    }

                    $button.on('click', function(e) {
                        e.preventDefault();
                        e.stopPropagation();
                        $button.prop('disabled', true);

                        if (self.getQueuedFiles().length) {
                            $dz.find('.dz-progress').show();
                            self.processQueue();
                        }
                        else {
                            $form.submit();
                        }
                    });

                    self.on('addedfile', function(file) {
                        if (!options.uploadMultiple && self.files.length > 1) {
                            self.removeFile(self.files[0]);
                        }

                        // force change in form, so that we can process
                        // the 'change' event
                        $button.prop('disabled', false);
                        $form.find('.change-trigger').val(Math.random());
                        $form.trigger('change');

                        $dz.find('.dz-message').hide();
                        $dz.find('.dz-progress').hide();
                        $(file.previewElement).on('click', function(e) {
                            e.stopPropagation();
                        });
                    });

                    self.on('removedfile', function(file) {

                        // force change in form, so that we can process
                        // the 'change' event
                        $form.find('.change-trigger').val(Math.random());
                        $form.trigger('change');

                        if (self.files.length === 0) {
                            $dz.find('.dz-message').show();
                        }
                    });

                    self.on('sendingmultiple', function() {
{'fraction_non_alphanumeric': 0.12773967997848595, 'fraction_numerical': 0.001882479494419793, 'mean_word_length': 0.947630269704111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4105310', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1591, 'n_words': 298}