Sha256: b28bdcbfca8795d2f629e541cabce7b646f03735f0317d93674aae6033b060a1

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

#= require jquery-fileupload

$.fn.ouvragesFileUpload = ->
  this.each ->
    $(this).find('.ofu-input').fileupload(
      autoUpload: true
      url: $(this).closest('.ofu-field').data('url')
      uploadTemplateId: null
      downloadTemplateId: null
      paramName: 'files[]'
      progressall: (e, data) ->
        progress = parseInt(data.loaded / data.total * 100, 10)
        $(this).closest('.ofu-field').find('.ofu-progress-bar').css('width', progress + "%").text(progress + "%")
    ).bind('fileuploadstart', (e, data) ->
      window.ofuFileCount++
      $(this).closest('.ofu-field').find('.ofu-files-container').empty()
      $(this).closest('.ofu-field').find('.ofu-files-container').append("<div class='progress'><div class='ofu-progress-bar bar' style='width: 0;'></div></div>")
      return
    ).bind('fileuploaddone', (e, data) ->
      $(this).closest('.ofu-field').find('input[type=hidden]').val(data.result.files[0].id)

      window.ofuFileCount--
      return
    ).bind('fileuploadfail', (e, data) ->
      window.ofuFileCount--
      return
    ).bind('fileuploadadd', (e, data) ->
      $(this).closest('.ofu-field').find('.ofu-files-container').empty()
      return
    )

window.ofuFileCount = 0

$(document).ready ->
  $('.ofu-field[data-auto=true]').ouvragesFileUpload()

$(window).bind 'beforeunload', ->
  if window.ofuFileCount > 0
    console.log("PREVENT")

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ouvrages_file_uploader-0.0.1 app/assets/javascripts/uploaded_files.js.coffee