<commit_before>(($) ->

  $.attachinary =
    index: 0
    config:
      disableWith: 'Uploading...'
      invalidFormatMessage: 'Invalid file format'
      template: """
        <ul>
          <% for(var i=0; i<files.length; i++){ %>
            <li>
              <img
                src="<%= $.cloudinary.url(files[i].public_id, { "version": files[i].version, "format": 'jpg', "crop": 'fill', "width": 75, "height": 75 }) %>"
                alt="" width="75" height="75" />
              <a href="#" data-remove="<%= files[i].public_id %>">Remove</a>
            </li>
          <% } %>
        </ul>
      """
      render: (files) ->
        $.attachinary.Templating.template(@template, files: files)


  $.fn.attachinary = (options) ->
    settings = $.extend $.attachinary.config, options

    this.each ->
      $this = $(this)

      if !$this.data('attachinary-bond')
        $this.data 'attachinary-bond', new $.attachinary.Attachinary($this, settings)



  class $.attachinary.Attachinary
    constructor: (@$input, @config) ->
      @options = @$input.data('attachinary')
      @files = @options.files

      @$form = @$input.closest('form')
      @$submit = @$form.find('input[type=submit]')
      @initFileUpload()
      @addFilesContainer()
      @bindEventHandlers()
      @redraw()
      @checkMaximum()

    initFileUpload: ->
      @options.field_name = @$input.attr('name')

      options =
        dataType: 'json'
        paramName: 'file'
        headers: {"X-Requested-With": "XMLHttpRequest"}
        dropZone: @$input

      if @$input.attr('accept')
        options.acceptFileTypes = new RegExp("^#{@$input.attr('accept').split(",").join("|")}$", "i")

      @$input.fileupload(options)


    bindEventHandlers: ->
      @$input.bind 'fileuploaddone', (event, data) =>
        setTimeout (=> @addFile(data.result)), 0 # let 'fileuploadalways' finish

      @$input.bind 'fileuploadstart', (event) =>
        @$input = $(event.target)  # important! changed on every file upload
        $form = @$input.closest('form')
        $submit = $form.find('input[type=submit]')

        @$input.addClass 'uploading'
        $form.addClass  'uploading'
<commit_msg>allowing multiple files to be uploaded at once<commit_after>(($) ->

  $.attachinary =
    index: 0
    config:
      disableWith: 'Uploading...'
      invalidFormatMessage: 'Invalid file format'
      template: """
        <ul>
          <% for(var i=0; i<files.length; i++){ %>
            <li>
              <img
                src="<%= $.cloudinary.url(files[i].public_id, { "version": files[i].version, "format": 'jpg', "crop": 'fill', "width": 75, "height": 75 }) %>"
                alt="" width="75" height="75" />
              <a href="#" data-remove="<%= files[i].public_id %>">Remove</a>
            </li>
          <% } %>
        </ul>
      """
      render: (files) ->
        $.attachinary.Templating.template(@template, files: files)


  $.fn.attachinary = (options) ->
    settings = $.extend $.attachinary.config, options

    this.each ->
      $this = $(this)

      if !$this.data('attachinary-bond')
        $this.data 'attachinary-bond', new $.attachinary.Attachinary($this, settings)



  class $.attachinary.Attachinary
    constructor: (@$input, @config) ->
      @options = @$input.data('attachinary')
      @files = @options.files

      @$form = @$input.closest('form')
      @$submit = @$form.find('input[type=submit]')
      @initFileUpload()
      @addFilesContainer()
      @bindEventHandlers()
      @redraw()
      @checkMaximum()

    initFileUpload: ->
      @options.field_name = @$input.attr('name')

      options =
        dataType: 'json'
        paramName: 'file'
        headers: {"X-Requested-With": "XMLHttpRequest"}
        dropZone: @$input

      if @$input.attr('accept')
        options.acceptFileTypes = new RegExp("^#{@$input.attr('accept').split(",").join("|")}$", "i")

      @$input.attr('multiple', true) if @options.maximum > 1
      @$input.fileupload(options)


    bindEventHandlers: ->
      @$input.bind 'fileuploaddone', (event, data) =>
        setTimeout (=> @addFile(data.result)), 0 # let 'fileuploadalways' finish

      @$input.bind 'fileuploadstart', (event) =>
        @$input = $(event.target)  # important! changed on every file upload
        $form = @$input.closest('form')
        $submit = $form.find('input[type=submit]')

        @$input.addClass 'uploading'
        $form.addClass  'uploading'

{'fraction_non_alphanumeric': 0.18623935454952936, 'fraction_numerical': 0.005154639175257732, 'mean_word_length': 2.443672839506173, 'pattern_counts': {'":': 12, '<': 27, '<?xml version=': 0, '>': 46, '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': '7049229', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1385, 'n_words': 272}