Created
March 28, 2014 09:41
-
-
Save H1D/9828988 to your computer and use it in GitHub Desktop.
with file upload ember jquery-file-upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App.FileUploadComponent = Em.Component.extend({ | |
tagName: 'label', | |
classNames: ['fileupload__component'], | |
upload_progress: null, | |
disabled: Em.computed.bool('upload_progress'), | |
didInsertElement: function() { | |
Em.assert('should have an url', this.get('url')); | |
return this.$().fileupload({ | |
url: this.get('url'), | |
done: (function(_this) { | |
return function(e, data) { | |
return _this.sendAction('done', data.result); | |
}; | |
})(this), | |
fail: (function(_this) { | |
return function() { | |
return _this.sendAction('fail'); | |
}; | |
})(this), | |
start: (function(_this) { | |
return function() { | |
return _this.sendAction('start'); | |
}; | |
})(this), | |
progressall: (function(_this) { | |
return function(e, data) { | |
var progress; | |
progress = parseInt(data.loaded / data.total * 100, 10); | |
return _this.set('upload_progress', "" + progress + "%"); | |
}; | |
})(this) | |
}); | |
}, | |
willDestroyElement: function() { | |
return this.$().fileupload('destroy'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment