Sha256: d2dc673e967e7fd349d9ff6a0cedb6686573f65886d503e4f19a753c1469fe3d
Contents?: true
Size: 1.33 KB
Versions: 8
Compression:
Stored size: 1.33 KB
Contents
# We use fileuploadalways callback because the response from the server is not accepted as successful # See other callbacks here: https://github.com/blueimp/jQuery-File-Upload/wiki/Options#callback-options class @AssetUploader constructor: (element, options={}) -> @el = $(element) @btn = @el.prev() @progress = $('#progress') @progressBar = $('#progress .progress-bar') @bindEvents() bindEvents: () => @el.fileupload(dataType: 'jsonp') # @el.on('fileuploadadd', @fileuploadadd) @el.on('fileuploadsend', @fileuploadsend) @el.on('fileuploadalways', @fileuploadalways) @el.on('fileuploadprogressall', @fileuploadprogressall) fileuploadadd: (e, data) -> data.submit() fileuploadsend: (e, data) => @btn.html("<i class='fa fa-spinner fa-spin'></i> Uploading...") @progress.modal('show') fileuploadalways: (e, data) => @progress.modal('hide') @btn.html("<i class='fa fa-check'></i> Uploaded") setTimeout( -> @btn.html("<i class='fa fa-plus'></i> Select files...") 1500 ) fileuploadprogressall: (e, data) => progress = parseInt(data.loaded / data.total * 100, 10) @progressBar .css('width', "#{progress}%") .attr('aria-valuenow', "#{progress}%") $.fn.uploadable = -> @each -> new AssetUploader(this) jQuery -> $('.js-file-upload').uploadable()
Version data entries
8 entries across 8 versions & 1 rubygems