1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-12 21:30:39 +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,11 +124,16 @@ form.fileupload({
data.files.shift(); data.files.shift();
return; return;
} }
if (file.webkitRelativePath) { // for 'upload folder'
file.relative_path = file.webkitRelativePath; // set 'file.relative_path' when upload a folder
} if (data.fileInput) { // clicking
if (file.relativePath) { // for 'folder drag & drop' if (file.webkitRelativePath) {
file.relative_path = file.relativePath + file.name; file.relative_path = file.webkitRelativePath;
}
} else { // drag & drop
if (file.relativePath) {
file.relative_path = file.relativePath + file.name;
}
} }
}) })
.bind('fileuploadsubmit', function(e, data) { .bind('fileuploadsubmit', function(e, data) {
@@ -221,13 +226,13 @@ form.fileupload({
{% if enable_upload_folder %} {% if enable_upload_folder %}
if ('webkitdirectory' in $('input[type="file"]', $('#add-file'))[0]) { if ('webkitdirectory' in $('input[type="file"]', $('#add-file'))[0]) {
$('#add-folder').show(); $('#add-folder').show();
$('#add-file, #add-folder').click(function() { form.fileupload(
form.fileupload( 'option', {
'option', fileInput: $('input[type="file"]', $('#add-file, #add-folder')),
'fileInput', // set 'replaceFileInput: false' for Firefox(v50)
$('input[type="file"]', $(this)) replaceFileInput: navigator.userAgent.indexOf('Firefox') == -1 ? true : false
); }
}); );
} }
{% endif %} {% endif %}

View File

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

View File

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