Browse files

Fixed so some events gets fired in a logical order and fixed better h…

…andling of the error event in the events.html example.
  • Loading branch information...
1 parent 481d0c1 commit 23802f4230d8e3c45cfdaffb583e031b0645157c @spocke spocke committed Sep 29, 2010
Showing with 16 additions and 6 deletions.
  1. +7 −1 examples/events.html
  2. +9 −5 src/javascript/plupload.js
View
8 examples/events.html
@@ -149,7 +149,13 @@
Error: function(up, args) {
// Called when a error has occured
- log('[error] ', args);
+
+ // Handle file specific error and general error
+ if (args.file) {
+ log('[error]', args, "File:", args.file);
+ } else {
+ log('[error]', args);
+ }
}
}
});
View
14 src/javascript/plupload.js
@@ -14,7 +14,7 @@
(function() {
var count = 0, runtimes = [], i18n = {}, mimes = {},
xmlEncodeChars = {'<' : 'lt', '>' : 'gt', '&' : 'amp', '"' : 'quot', '\'' : '#39'},
- xmlEncodeRegExp = /[<>&\"\']/g, undef;
+ xmlEncodeRegExp = /[<>&\"\']/g, undef, delay = window.setTimeout;
// IE W3C like event funcs
function preventDefault() {
@@ -779,8 +779,12 @@
// Only trigger QueueChanged event if any files where added
if (count) {
- self.trigger("QueueChanged");
- self.refresh();
+ delay(function() {
+ self.trigger("QueueChanged");
+ self.refresh();
+ });
+ } else {
+ return false; // Stop the FilesAdded event from immediate propagation
}
});
@@ -823,7 +827,7 @@
// Upload next file but detach it from the error event
// since other custom listeners might want to stop the queue
- window.setTimeout(function() {
+ delay(function() {
uploadNext.call(self);
});
}
@@ -836,7 +840,7 @@
// Upload next file but detach it from the error event
// since other custom listeners might want to stop the queue
- window.setTimeout(function() {
+ delay(function() {
uploadNext.call(self);
});
});

0 comments on commit 23802f4

Please sign in to comment.