<commit_before>Backbone.ImageableView = Backbone.View.extend({

  submitImage: function (options) {
    var image = options.image,
        param = options.param,
        model = options.model,
        formData = new FormData();

    if (!image) { return; }
    formData.append(param, image);
    $.ajax({
      url: _.result(model, "url"),
      type: "PATCH",
      data: formData,
      processData: false,
      contentType: false,
      success: function () {
        options.success && options.success();
      }
    });
  },

  triggerUpload: function (e) {
    e.preventDefault();
    $("#image-form").trigger("click");
  },

  replaceFormImage: function (e) {
    e.preventDefault();
    var files = e.currentTarget.files,
        reader = new FileReader();
    if (!files || !files.length) { return; }

    reader.onload = function (readerEvent) {
      $("#form-image").attr("src", readerEvent.target.result);<commit_msg>Prevent image forms from prematurely syncing mid-upload<commit_after>Backbone.ImageableView = Backbone.View.extend({

  submitImage: function (options) {
    this.stopListening();

    var view = this,
        image = options.image,
        param = options.param,
        model = options.model,
        formData = new FormData();

    if (!image) { return; }
    formData.append(param, image);
    $.ajax({
      url: _.result(model, "url"),
      type: "PATCH",
      data: formData,
      processData: false,
      contentType: false,
      success: function () {
        options.success && options.success();
      }
    });
  },

  triggerUpload: function (e) {
    e.preventDefault();
    $("#image-form").trigger("click");
  },

  replaceFormImage: function (e) {
    e.preventDefault();
    var files = e.currentTarget.files,
        reader = new FileReader();
    if (!files || !files.length) { return; }

    reader.onload = function (readerEvent) {
      $("#form-image").attr("src", readerEvent.target.result);
{'fraction_non_alphanumeric': 0.15317622950819673, 'fraction_numerical': 0.0, 'mean_word_length': 2.6710526315789473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '519032', 'n_tokens_mistral': 582, 'n_tokens_neox': 575, 'n_words': 128}