{"size": 1434, "ext": "js", "max_stars_repo_path": "web/modules/contrib/dropzonejs/modules/eb_widget/js/dropzonejs_eb_widget.ief_edit.js", "max_stars_repo_name": "rc100/awfd8-migrate", "max_stars_repo_stars_event_min_datetime": "2017-06-05T18:55:28.000Z", "max_stars_repo_stars_event_max_datetime": "2018-03-01T22:27:35.000Z", "max_issues_repo_path": "web/modules/contrib/dropzonejs/modules/eb_widget/js/dropzonejs_eb_widget.ief_edit.js", "max_issues_repo_name": "rc100/awfd8-migrate", "max_issues_repo_issues_event_min_datetime": "2017-06-18T19:48:52.000Z", "max_issues_repo_issues_event_max_datetime": "2019-10-14T17:45:31.000Z", "max_forks_repo_path": "web/modules/contrib/dropzonejs/modules/eb_widget/js/dropzonejs_eb_widget.ief_edit.js", "max_forks_repo_name": "rc100/awfd8-migrate", "max_forks_repo_forks_event_min_datetime": "2017-07-05T23:30:07.000Z", "max_forks_repo_forks_event_max_datetime": "2017-12-13T02:48:19.000Z"}
{"max_stars_count": 4, "max_issues_count": 8, "max_forks_count": 3, "avg_line_length": 30.5106382979, "max_line_length": 113, "alphanum_fraction": 0.5641562064}
/**
 * @file
 * dropzonejs_eb_widget.ief_edit.js
 *
 * Bundles various dropzone eb widget behaviours.
 */

(function ($, Drupal, drupalSettings) {
  'use strict';

  Drupal.behaviors.dropzonejsPostIntegrationEbWidgetEditJs = {
    attach: function (context) {
      if (typeof drupalSettings.dropzonejs.instances !== 'undefined') {
        _.each(drupalSettings.dropzonejs.instances, function (item) {
          var $form = $(item.instance.element).parents('form');

          if ($form.hasClass('dropzonejs-disable-submit')) {
            var $submit = $form.find('.is-entity-browser-submit');
            $submit.prop('disabled', false);

            var autoSubmitDropzone = function () {
              var $form = this;

              // Trigger generation of IEF form only, when there are new
              // accepted files and there are no rejected files.
              if (item.instance.getAcceptedFiles().length > 0 && item.instance.getRejectedFiles().length === 0) {
                $('#edit-edit', $form).trigger('mousedown');

                item.instance.removeAllFiles();
              }
            }.bind($form);

            item.instance.on('queuecomplete', function () {
              autoSubmitDropzone();
            });

            item.instance.on('removedfile', function () {
              autoSubmitDropzone();
            });
          }
        });
      }
    }
  };

}(jQuery, Drupal, drupalSettings));
