Skip to content

Commit 97427a7

Browse files
committed
Merge pull request tors#11 from tallica/master
Update JavaScript assets.
2 parents 23da13d + 8ba7230 commit 97427a7

File tree

5 files changed

+178
-54
lines changed

5 files changed

+178
-54
lines changed

vendor/assets/javascripts/jquery-fileupload/jquery.fileupload-ui.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload User Interface Plugin 6.9.3
2+
* jQuery File Upload User Interface Plugin 6.9.4
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -89,7 +89,7 @@
8989
files = data.files;
9090
$(this).fileupload('process', data).done(function () {
9191
that._adjustMaxNumberOfFiles(-files.length);
92-
data.isAdjusted = true;
92+
data.maxNumberOfFilesAdjusted = true;
9393
data.files.valid = data.isValidated = that._validate(files);
9494
data.context = that._renderUpload(files).data('data', data);
9595
options.filesContainer[
@@ -112,8 +112,9 @@
112112
send: function (e, data) {
113113
var that = $(this).data('fileupload');
114114
if (!data.isValidated) {
115-
if (!data.isAdjusted) {
115+
if (!data.maxNumberOfFilesAdjusted) {
116116
that._adjustMaxNumberOfFiles(-data.files.length);
117+
data.maxNumberOfFilesAdjusted = true;
117118
}
118119
if (!that._validate(data.files)) {
119120
return false;
@@ -163,6 +164,17 @@
163164
);
164165
});
165166
} else {
167+
if ($.isArray(data.result)) {
168+
$.each(data.result, function (index, file) {
169+
if (data.maxNumberOfFilesAdjusted && file.error) {
170+
that._adjustMaxNumberOfFiles(1);
171+
} else if (!data.maxNumberOfFilesAdjusted &&
172+
!file.error) {
173+
that._adjustMaxNumberOfFiles(-1);
174+
}
175+
});
176+
data.maxNumberOfFilesAdjusted = true;
177+
}
166178
template = that._renderDownload(data.result)
167179
.appendTo(that.options.filesContainer);
168180
that._forceReflow(template);
@@ -178,7 +190,9 @@
178190
fail: function (e, data) {
179191
var that = $(this).data('fileupload'),
180192
template;
181-
that._adjustMaxNumberOfFiles(data.files.length);
193+
if (data.maxNumberOfFilesAdjusted) {
194+
that._adjustMaxNumberOfFiles(data.files.length);
195+
}
182196
if (data.context) {
183197
data.context.each(function (index) {
184198
if (data.errorThrown !== 'abort') {
@@ -209,7 +223,6 @@
209223
}
210224
});
211225
} else if (data.errorThrown !== 'abort') {
212-
that._adjustMaxNumberOfFiles(-data.files.length);
213226
data.context = that._renderUpload(data.files)
214227
.appendTo(that.options.filesContainer)
215228
.data('data', data);

vendor/assets/javascripts/jquery-fileupload/jquery.fileupload.js

Lines changed: 141 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery File Upload Plugin 5.13
2+
* jQuery File Upload Plugin 5.16.1
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2010, Sebastian Tschan
@@ -447,6 +447,9 @@
447447
if (options.type !== 'POST' && options.type !== 'PUT') {
448448
options.type = 'POST';
449449
}
450+
if (!options.formAcceptCharset) {
451+
options.formAcceptCharset = options.form.attr('accept-charset');
452+
}
450453
},
451454

452455
_getAJAXSettings: function (data) {
@@ -663,9 +666,15 @@
663666
options.limitConcurrentUploads > that._sending) {
664667
// Start the next queued upload,
665668
// that has not been aborted:
666-
var nextSlot = that._slots.shift();
669+
var nextSlot = that._slots.shift(),
670+
isPending;
667671
while (nextSlot) {
668-
if (!nextSlot.isRejected()) {
672+
// jQuery 1.6 doesn't provide .state(),
673+
// while jQuery 1.8+ removed .isRejected():
674+
isPending = nextSlot.state ?
675+
nextSlot.state() === 'pending' :
676+
!nextSlot.isRejected();
677+
if (isPending) {
669678
nextSlot.resolve();
670679
break;
671680
}
@@ -693,7 +702,7 @@
693702
var args = [undefined, 'abort', 'abort'];
694703
if (!jqXHR) {
695704
if (slot) {
696-
slot.rejectWith(args);
705+
slot.rejectWith(pipe, args);
697706
}
698707
return send(false, args);
699708
}
@@ -748,14 +757,6 @@
748757
return result;
749758
},
750759

751-
// File Normalization for Gecko 1.9.1 (Firefox 3.5) support:
752-
_normalizeFile: function (index, file) {
753-
if (file.name === undefined && file.size === undefined) {
754-
file.name = file.fileName;
755-
file.size = file.fileSize;
756-
}
757-
},
758-
759760
_replaceFileInput: function (input) {
760761
var inputClone = input.clone(true);
761762
$('<form></form>').append(inputClone)[0].reset();
@@ -780,21 +781,90 @@
780781
}
781782
},
782783

784+
_handleFileTreeEntry: function (entry, path) {
785+
var that = this,
786+
dfd = $.Deferred(),
787+
errorHandler = function () {
788+
dfd.reject();
789+
},
790+
dirReader;
791+
path = path || '';
792+
if (entry.isFile) {
793+
entry.file(function (file) {
794+
file.relativePath = path;
795+
dfd.resolve(file);
796+
}, errorHandler);
797+
} else if (entry.isDirectory) {
798+
dirReader = entry.createReader();
799+
dirReader.readEntries(function (entries) {
800+
that._handleFileTreeEntries(
801+
entries,
802+
path + entry.name + '/'
803+
).done(function (files) {
804+
dfd.resolve(files);
805+
}).fail(errorHandler);
806+
}, errorHandler);
807+
} else {
808+
errorHandler();
809+
}
810+
return dfd.promise();
811+
},
812+
813+
_handleFileTreeEntries: function (entries, path) {
814+
var that = this;
815+
return $.when.apply(
816+
$,
817+
$.map(entries, function (entry) {
818+
return that._handleFileTreeEntry(entry, path);
819+
})
820+
).pipe(function () {
821+
return Array.prototype.concat.apply(
822+
[],
823+
arguments
824+
);
825+
});
826+
},
827+
828+
_getDroppedFiles: function (dataTransfer) {
829+
dataTransfer = dataTransfer || {};
830+
var items = dataTransfer.items;
831+
if (items && items.length && (items[0].webkitGetAsEntry ||
832+
items[0].getAsEntry)) {
833+
return this._handleFileTreeEntries(
834+
$.map(items, function (item) {
835+
if (item.webkitGetAsEntry) {
836+
return item.webkitGetAsEntry();
837+
}
838+
return item.getAsEntry();
839+
})
840+
);
841+
}
842+
return $.Deferred().resolve(
843+
$.makeArray(dataTransfer.files)
844+
).promise();
845+
},
846+
783847
_getFileInputFiles: function (fileInput) {
784848
fileInput = $(fileInput);
785-
var files = $.each($.makeArray(fileInput.prop('files')), this._normalizeFile),
849+
var entries = fileInput.prop('webkitEntries') ||
850+
fileInput.prop('entries'),
851+
files,
786852
value;
853+
if (entries) {
854+
return this._handleFileTreeEntries(entries);
855+
}
856+
files = $.makeArray(fileInput.prop('files'));
787857
if (!files.length) {
788858
value = fileInput.prop('value');
789859
if (!value) {
790-
return [];
860+
return $.Deferred().reject([]).promise();
791861
}
792862
// If the files property is not available, the browser does not
793863
// support the File API and we add a pseudo File object with
794864
// the input value as name with path information removed:
795865
files = [{name: value.replace(/^.*\\/, '')}];
796866
}
797-
return files;
867+
return $.Deferred().resolve(files).promise();
798868
},
799869

800870
_onChange: function (e) {
@@ -803,14 +873,15 @@
803873
fileInput: $(e.target),
804874
form: $(e.target.form)
805875
};
806-
data.files = that._getFileInputFiles(data.fileInput);
807-
if (that.options.replaceFileInput) {
808-
that._replaceFileInput(data.fileInput);
809-
}
810-
if (that._trigger('change', e, data) === false ||
811-
that._onAdd(e, data) === false) {
812-
return false;
813-
}
876+
that._getFileInputFiles(data.fileInput).always(function (files) {
877+
data.files = files;
878+
if (that.options.replaceFileInput) {
879+
that._replaceFileInput(data.fileInput);
880+
}
881+
if (that._trigger('change', e, data) !== false) {
882+
that._onAdd(e, data);
883+
}
884+
});
814885
},
815886

816887
_onPaste: function (e) {
@@ -831,19 +902,16 @@
831902
},
832903

833904
_onDrop: function (e) {
905+
e.preventDefault();
834906
var that = e.data.fileupload,
835907
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
836-
data = {
837-
files: $.each(
838-
$.makeArray(dataTransfer && dataTransfer.files),
839-
that._normalizeFile
840-
)
841-
};
842-
if (that._trigger('drop', e, data) === false ||
843-
that._onAdd(e, data) === false) {
844-
return false;
845-
}
846-
e.preventDefault();
908+
data = {};
909+
that._getDroppedFiles(dataTransfer).always(function (files) {
910+
data.files = files;
911+
if (that._trigger('drop', e, data) !== false) {
912+
that._onAdd(e, data);
913+
}
914+
});
847915
},
848916

849917
_onDragOver: function (e) {
@@ -937,29 +1005,61 @@
9371005
// must have a files property and can contain additional options:
9381006
// .fileupload('add', {files: filesList});
9391007
add: function (data) {
1008+
var that = this;
9401009
if (!data || this.options.disabled) {
9411010
return;
9421011
}
9431012
if (data.fileInput && !data.files) {
944-
data.files = this._getFileInputFiles(data.fileInput);
1013+
this._getFileInputFiles(data.fileInput).always(function (files) {
1014+
data.files = files;
1015+
that._onAdd(null, data);
1016+
});
9451017
} else {
946-
data.files = $.each($.makeArray(data.files), this._normalizeFile);
1018+
data.files = $.makeArray(data.files);
1019+
this._onAdd(null, data);
9471020
}
948-
this._onAdd(null, data);
9491021
},
9501022

9511023
// This method is exposed to the widget API and allows sending files
9521024
// using the fileupload API. The data parameter accepts an object which
953-
// must have a files property and can contain additional options:
1025+
// must have a files or fileInput property and can contain additional options:
9541026
// .fileupload('send', {files: filesList});
9551027
// The method returns a Promise object for the file upload call.
9561028
send: function (data) {
9571029
if (data && !this.options.disabled) {
9581030
if (data.fileInput && !data.files) {
959-
data.files = this._getFileInputFiles(data.fileInput);
960-
} else {
961-
data.files = $.each($.makeArray(data.files), this._normalizeFile);
1031+
var that = this,
1032+
dfd = $.Deferred(),
1033+
promise = dfd.promise(),
1034+
jqXHR,
1035+
aborted;
1036+
promise.abort = function () {
1037+
aborted = true;
1038+
if (jqXHR) {
1039+
return jqXHR.abort();
1040+
}
1041+
dfd.reject(null, 'abort', 'abort');
1042+
return promise;
1043+
};
1044+
this._getFileInputFiles(data.fileInput).always(
1045+
function (files) {
1046+
if (aborted) {
1047+
return;
1048+
}
1049+
data.files = files;
1050+
jqXHR = that._onSend(null, data).then(
1051+
function (result, textStatus, jqXHR) {
1052+
dfd.resolve(result, textStatus, jqXHR);
1053+
},
1054+
function (jqXHR, textStatus, errorThrown) {
1055+
dfd.reject(jqXHR, textStatus, errorThrown);
1056+
}
1057+
);
1058+
}
1059+
);
1060+
return this._enhancePromise(promise);
9621061
}
1062+
data.files = $.makeArray(data.files);
9631063
if (data.files.length) {
9641064
return this._onSend(null, data);
9651065
}

vendor/assets/javascripts/jquery-fileupload/jquery.iframe-transport.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* jQuery Iframe Transport Plugin 1.4
2+
* jQuery Iframe Transport Plugin 1.5
33
* https://github.com/blueimp/jQuery-File-Upload
44
*
55
* Copyright 2011, Sebastian Tschan
@@ -42,6 +42,7 @@
4242
return {
4343
send: function (_, completeCallback) {
4444
form = $('<form style="display:none;"></form>');
45+
form.attr('accept-charset', options.formAcceptCharset);
4546
// javascript:false as initial iframe src
4647
// prevents warning popups on HTTPS in IE6.
4748
// IE versions below IE8 cannot set the name property of

0 commit comments

Comments
 (0)