s3_direct_upload icon indicating copy to clipboard operation
s3_direct_upload copied to clipboard

[ToDiscuss] Using $.widget ?

Open lacco opened this issue 12 years ago • 6 comments

I started today using this awesome gem, it is much nicer than copying the Railscast code into each project. Additionally, the provided Javascript callbacks make it easy to adjust the plugin to some special needs.

Nevertheless, I felt that the callbacks were quite difficult to use (e.g. before_add in options while others using bind, and they have different names than the events from fileupload widget), so I started refactoring the client code into a $.widget. Do you have any thoughts on this? Of course it isn't backwards-compatible, but I think the API is much easier to use.

List of changes:

  • Plugin is initialized thorugh $("#myS3Uploader").s3upload instead of $("#myS3Uploader").S3Uploader
  • Renamed events: s3_upload_complete => s3uploaddone, s3_upload_failed => s3uploadfail
  • Introduce progress event that passes loaded, total and percentage properties
  • Pass additional filekey property to done callback

lacco avatar Dec 15 '12 13:12 lacco

I generally like this idea a lot. It makes things more modular and using the $.widget syntax is what the jquery file upload ui uses so it provides a more consistant syntax in this small eco-system.

Have you tested this code on all browsers?

waynehoover avatar Dec 17 '12 14:12 waynehoover

I only tested the code on IE9, FF and Chrome, but we will do some more testing as soon we ship our code to production (I don't expect any problems since fileupload is also based on $.widget).

lacco avatar Dec 19 '12 08:12 lacco

Okay, tI encountered no bugs on my refactoring. Shall I start working on rebasing my code on your current master so that we can merge it very soon, are you still interested in my changes?

lacco avatar Mar 16 '13 14:03 lacco

Yes, that sounds great, I will merge it in when you rebase on master.

waynehoover avatar Mar 16 '13 20:03 waynehoover

Out of curiosity, will this change facilitate usage of the standard jquery file upload UI? I actually prefer the load then start style UI with completion indicators.

uberllama avatar Mar 16 '13 22:03 uberllama

I had a quick look at rebasing this but it's diverged pretty far from master by now.

DanielHeath avatar Jun 30 '13 11:06 DanielHeath