1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-12 13:24:52 +00:00

[fileupload] fix for Firefox 50

This commit is contained in:
llj
2016-11-25 16:59:21 +08:00
parent ad67cc22f4
commit 3534b5836e
3 changed files with 31 additions and 22 deletions

View File

@@ -124,12 +124,17 @@ form.fileupload({
data.files.shift();
return;
}
if (file.webkitRelativePath) { // for 'upload folder'
// set 'file.relative_path' when upload a folder
if (data.fileInput) { // clicking
if (file.webkitRelativePath) {
file.relative_path = file.webkitRelativePath;
}
if (file.relativePath) { // for 'folder drag & drop'
} else { // drag & drop
if (file.relativePath) {
file.relative_path = file.relativePath + file.name;
}
}
})
.bind('fileuploadsubmit', function(e, data) {
if (data.files.length == 0) {
@@ -221,13 +226,13 @@ form.fileupload({
{% if enable_upload_folder %}
if ('webkitdirectory' in $('input[type="file"]', $('#add-file'))[0]) {
$('#add-folder').show();
$('#add-file, #add-folder').click(function() {
form.fileupload(
'option',
'fileInput',
$('input[type="file"]', $(this))
'option', {
fileInput: $('input[type="file"]', $('#add-file, #add-folder')),
// set 'replaceFileInput: false' for Firefox(v50)
replaceFileInput: navigator.userAgent.indexOf('Firefox') == -1 ? true : false
}
);
});
}
{% endif %}

View File

@@ -216,16 +216,17 @@ define([
if (app.pageOptions.enable_upload_folder) {
if ('webkitdirectory' in $('#basic-upload-input')[0]) {
// if enable_upload_folder and is chrome
this.$("#basic-upload").remove();
this.$("#advanced-upload").show();
this.upload_dropdown = new DropdownView({
el: this.$("#advanced-upload")
});
$popup.fileupload(
'option',
'fileInput',
this.$('#advanced-upload input[type="file"]'));
'option', {
fileInput: this.$('#advanced-upload input[type="file"]'),
// set 'replaceFileInput: false' for Firefox(v50)
replaceFileInput: navigator.userAgent.indexOf('Firefox') == -1 ? true : false
});
} else {
this.$("#advanced-upload").remove();
$popup.fileupload(

View File

@@ -108,14 +108,17 @@ define([
data.files.shift();
return;
}
// set 'file.relative_path' when upload a folder
if (data.fileInput) { // clicking
if (file.webkitRelativePath) {
file.relative_path = file.webkitRelativePath;
}
// add folder by drag & drop
} else { // drag & drop
if (file.relativePath) {
file.relative_path = file.relativePath + file.name;
}
}
})
.bind('fileuploadstart', function() {
$fu_status.html(fu_status.uploading);