Update Resumable from github, fixes some problems with setting et2_file value to a list of files in firefox.

This commit is contained in:
Nathan Gray 2014-07-07 20:26:48 +00:00
parent b9e6983643
commit 08c10a70aa
2 changed files with 23 additions and 6 deletions

View File

@ -258,8 +258,10 @@ var et2_file = et2_inputWidget.extend(
* If you pass a FileList or list of files, it will trigger the async upload * If you pass a FileList or list of files, it will trigger the async upload
* *
* @param {FileList|File[]|false} value List of files to be uploaded, or false to reset. * @param {FileList|File[]|false} value List of files to be uploaded, or false to reset.
* @param {Event} event Most browsers require the user to initiate file transfers in some way.
* Pass the event in, if you have it.
*/ */
set_value: function(value) { set_value: function(value, event) {
if(!value || typeof value == "undefined") if(!value || typeof value == "undefined")
{ {
value = {}; value = {};
@ -277,9 +279,18 @@ var et2_file = et2_inputWidget.extend(
} }
if(typeof value == 'object' && value.length && typeof value[0] == 'object' && value[0].name) if(typeof value == 'object' && value.length && typeof value[0] == 'object' && value[0].name)
{
try
{ {
this.input[0].files = value; this.input[0].files = value;
} }
catch (e)
{
var self = this;
var args = arguments;
jQuery.each(value, function(i,file) {self.resumable.addFile(this,event);});
}
}
}, },
/** /**
@ -349,6 +360,11 @@ var et2_file = et2_inputWidget.extend(
}, },
_fileAdded: function(file,event) { _fileAdded: function(file,event) {
// Manual additions have no event
if(typeof event == 'undefined')
{
event = {};
}
// Trigger start of uploading, calls callback // Trigger start of uploading, calls callback
if(!this.resumable.isUploading()) if(!this.resumable.isUploading())
{ {

View File

@ -230,7 +230,7 @@
window.setTimeout(function(){ window.setTimeout(function(){
$.files.push(f); $.files.push(f);
files.push(f); files.push(f);
f.container = event.srcElement; f.container = (typeof event != 'undefined' ? event.srcElement : null);
$.fire('fileAdded', f, event) $.fire('fileAdded', f, event)
},0); },0);
})()}; })()};
@ -450,6 +450,7 @@
params.push(['resumableIdentifier', encodeURIComponent($.fileObj.uniqueIdentifier)].join('=')); params.push(['resumableIdentifier', encodeURIComponent($.fileObj.uniqueIdentifier)].join('='));
params.push(['resumableFilename', encodeURIComponent($.fileObj.fileName)].join('=')); params.push(['resumableFilename', encodeURIComponent($.fileObj.fileName)].join('='));
params.push(['resumableRelativePath', encodeURIComponent($.fileObj.relativePath)].join('=')); params.push(['resumableRelativePath', encodeURIComponent($.fileObj.relativePath)].join('='));
params.push(['resumableTotalChunks', encodeURIComponent($.fileObj.chunks.length)].join('='));
// Append the relevant chunk and send it // Append the relevant chunk and send it
$.xhr.open('GET', $h.getTarget(params)); $.xhr.open('GET', $h.getTarget(params));
$.xhr.timeout = $.getOpt('xhrTimeout'); $.xhr.timeout = $.getOpt('xhrTimeout');
@ -578,7 +579,7 @@
if($.pendingRetry) { if($.pendingRetry) {
// if pending retry then that's effectively the same as actively uploading, // if pending retry then that's effectively the same as actively uploading,
// there might just be a slight delay before the retry starts // there might just be a slight delay before the retry starts
return('uploading') return('uploading');
} else if(!$.xhr) { } else if(!$.xhr) {
return('pending'); return('pending');
} else if($.xhr.readyState<4) { } else if($.xhr.readyState<4) {
@ -771,8 +772,8 @@
}); });
return(totalSize>0 ? totalDone/totalSize : 0); return(totalSize>0 ? totalDone/totalSize : 0);
}; };
$.addFile = function(file){ $.addFile = function(file, event){
appendFilesFromFileList([file]); appendFilesFromFileList([file], event);
}; };
$.removeFile = function(file){ $.removeFile = function(file){
for(var i = $.files.length - 1; i >= 0; i--) { for(var i = $.files.length - 1; i >= 0; i--) {