ProgerXP / FileDrop

Self-contained cross-browser pure JavaScript class for Drag & Drop and AJAX (multi) file upload.
filedropjs.org
The Unlicense
264 stars 61 forks source link

jQuery event arguments #4

Closed nickmay closed 10 years ago

nickmay commented 10 years ago

Thanks for filedrop! Your hard work is very much appreciated!

The documentation here:

http://proger.i-forge.net/FileDrop_-_cross-browser_JavaScript_Drag-Drop_file_upload/7CC

has the parameters for "progress" as function (current, total,xhr,e)

I am using them with jquery,

.on(fileprogress)

and the parameters actually appear to be ordered (xhr,e,current,total)

... I am not sure about the order of the xhr and the e - but current and total are definitely the last two.

Is this just a documentation glitch, or a query thing, to have I misunderstood?

ProgerXP commented 10 years ago

jQuery puts its own event object in front of all arguments when it calls DOM listeners so you can add e before every argument of FileDrop's own events. Normally you'd just ignore it, it's not useful.

Right now FileDrop has been rewritten and expanded with HTML5 support. Here's the demo if you feel like taking a look.

nickmay commented 10 years ago

This is fabulous!

Many thanks… You really should put a tip box somewhere on your site. I have sweated blood trying to roll my own file upload system...

3 thoughts/questions.

1: I still can’t turn off logging when using the jQuery interface. I tried this...

var options = {logging:false, iframe: {url: 'upload.php'}};

but it doesn’t seem to work….

2: file.SendTo (old jQuery example on https://github.com/ProgerXP/FileDrop) has been re-capitalised to file.sendTo (your new code). That is a very minor thing, but it stops the new code from “just working” with existing implementations. It is going to generate support requests / confusion. If you add a note to your new page explaining the change, people will know to update their code.

3: Using a class and doing something like this isn’t going to cause problems is it?

$('.dropbox').each(function(){

var upload_parameter = something unique to this instance...
var el      =$(this);
el.filedrop({logging:log,iframe:{force:force_iframe,url:send_url}})
.on() …etc
.on() …etc

})

Many thanks!

Nick

ProgerXP commented 10 years ago

still can’t turn off logging when using the jQuery interface.

Logging is global, you have to set window.fd.logging = false before/after FileDrop.js has loaded.

That is a very minor thing, but it stops the new code from “just working” with existing implementations.

There are multiple changes that prevent new FileDrop from working seamlessly with old scripts. I'm planning on writing separate compatibility layer for v1 but if you're writing a new project/could update your old code this is the way to go. Overall I made properties more standardized (zone -> el, camelCase capitalization, etc.).

And I will surely update my page and write the migration guide, don't forget FD2 isn't yet released.

Using a class and doing something like this isn’t going to cause problems is it?

Yes, should be fine.

p.s: I've renamed your ticket to better match the thread. Please don't mind.

nickmay commented 10 years ago

Understood. I know the docs are not yet complete - if I can help with testing, on either Mac Safari or iOS, let me know.

ProgerXP commented 10 years ago

if I can help with testing, on either Mac Safari or iOS, let me know.

This would be awesome. For starter you can just run the new demo I've linked to above and see if all samples work. If not tell me which are failing, I will check them out. So far I've only tested FD2 in Firefox and Chrome; the latter fails on some uploads.

When I'm near release I will drop you a line to do more thorough testing. Thanks!