Skip to content

Commit

Permalink
Renamed the finished event to success, and added a complete event.
Browse files Browse the repository at this point in the history
For backwords compatibilty the old finished event is also called.
  • Loading branch information
enyo committed Feb 6, 2013
1 parent 0c5aea6 commit dd04c4f
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 10 deletions.
8 changes: 6 additions & 2 deletions downloads/dropzone-amd-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Emitter.prototype.hasListeners = function(event){
*/


Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "thumbnail", "error", "processingfile", "uploadprogress", "finished"];
Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "thumbnail", "error", "processingfile", "uploadprogress", "success", "complete"];

Dropzone.prototype.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];

Expand Down Expand Up @@ -283,9 +283,10 @@ Emitter.prototype.hasListeners = function(event){
width: "" + progress + "%"
});
},
finished: function(file) {
success: function(file) {
return file.previewTemplate.addClass("success");
},
complete: function(file) {},
previewTemplate: "<div class=\"preview file-preview\">\n <div class=\"details\">\n <div class=\"filename\"><span></span></div>\n </div>\n <div class=\"progress\"><span class=\"upload\"></span></div>\n <div class=\"success-mark\"><span>✔</span></div>\n <div class=\"error-mark\"><span>✘</span></div>\n <div class=\"error-message\"><span></span></div>\n</div>"
};

Expand Down Expand Up @@ -607,13 +608,16 @@ Emitter.prototype.hasListeners = function(event){

Dropzone.prototype.finished = function(file, responseText, e) {
this.files.processing = without(this.files.processing, file);
this.emit("success", file, responseText, e);
this.emit("finished", file, responseText, e);
this.emit("complete", file);
return this.processQueue();
};

Dropzone.prototype.errorProcessing = function(file, message) {
this.files.processing = without(this.files.processing, file);
this.emit("error", file, message);
this.emit("complete", file);
return this.processQueue();
};

Expand Down
8 changes: 6 additions & 2 deletions downloads/dropzone.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
*/


Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "thumbnail", "error", "processingfile", "uploadprogress", "finished"];
Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "thumbnail", "error", "processingfile", "uploadprogress", "success", "complete"];

Dropzone.prototype.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i];

Expand Down Expand Up @@ -493,9 +493,10 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){
width: "" + progress + "%"
});
},
finished: function(file) {
success: function(file) {
return file.previewTemplate.addClass("success");
},
complete: function(file) {},
previewTemplate: "<div class=\"preview file-preview\">\n <div class=\"details\">\n <div class=\"filename\"><span></span></div>\n </div>\n <div class=\"progress\"><span class=\"upload\"></span></div>\n <div class=\"success-mark\"><span>✔</span></div>\n <div class=\"error-mark\"><span>✘</span></div>\n <div class=\"error-message\"><span></span></div>\n</div>"
};

Expand Down Expand Up @@ -817,13 +818,16 @@ require.register("dropzone/lib/dropzone.js", function(exports, require, module){

Dropzone.prototype.finished = function(file, responseText, e) {
this.files.processing = without(this.files.processing, file);
this.emit("success", file, responseText, e);
this.emit("finished", file, responseText, e);
this.emit("complete", file);
return this.processQueue();
};

Dropzone.prototype.errorProcessing = function(file, message) {
this.files.processing = without(this.files.processing, file);
this.emit("error", file, message);
this.emit("complete", file);
return this.processQueue();
};

Expand Down
8 changes: 6 additions & 2 deletions lib/dropzone.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions src/dropzone.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class Dropzone extends Em
"error"
"processingfile"
"uploadprogress"
"finished"
"success"
"complete"
]


Expand Down Expand Up @@ -170,11 +171,15 @@ class Dropzone extends Em
uploadprogress: (file, progress) ->
file.previewTemplate.find(".progress .upload").css { width: "#{progress}%" }

# When the complete upload is finished
# When the complete upload is finished and successfull
# Receives `file`
finished: (file) ->
success: (file) ->
file.previewTemplate.addClass "success"

# When the upload is finished, either with success or an error.
# Receives `file`
complete: (file) ->


# This template will be chosen when a new file is dropped.
previewTemplate: """
Expand Down Expand Up @@ -480,7 +485,9 @@ class Dropzone extends Em
# Individual callbacks have to be called in the appropriate sections.
finished: (file, responseText, e) ->
@files.processing = without(@files.processing, file)
@emit "finished", file, responseText, e
@emit "success", file, responseText, e
@emit "finished", file, responseText, e # For backwards compatibility
@emit "complete", file
@processQueue()


Expand All @@ -489,6 +496,7 @@ class Dropzone extends Em
errorProcessing: (file, message) ->
@files.processing = without(@files.processing, file)
@emit "error", file, message
@emit "complete", file
@processQueue()


Expand Down

0 comments on commit dd04c4f

Please sign in to comment.