Sha256: d6acfa1b3348c8173001c4cf6e61743868ad28d2f75fd43009f3be811af5d85e
Contents?: true
Size: 1.33 KB
Versions: 2
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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
georgia-0.8.0 | app/assets/javascripts/georgia/components/asset-uploader.js.coffee |
georgia-0.7.8 | app/assets/javascripts/georgia/components/asset-uploader.js.coffee |