1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-13 05:39:59 +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(); data.files.shift();
return; 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; 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; file.relative_path = file.relativePath + file.name;
} }
}
}) })
.bind('fileuploadsubmit', function(e, data) { .bind('fileuploadsubmit', function(e, data) {
if (data.files.length == 0) { if (data.files.length == 0) {
@@ -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', fileInput: $('input[type="file"]', $('#add-file, #add-folder')),
$('input[type="file"]', $(this)) // set 'replaceFileInput: false' for Firefox(v50)
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,14 +108,17 @@ define([
data.files.shift(); data.files.shift();
return; return;
} }
// set 'file.relative_path' when upload a folder
if (data.fileInput) { // clicking
if (file.webkitRelativePath) { if (file.webkitRelativePath) {
file.relative_path = file.webkitRelativePath; file.relative_path = file.webkitRelativePath;
} }
} else { // drag & drop
// add folder by drag & drop
if (file.relativePath) { if (file.relativePath) {
file.relative_path = file.relativePath + file.name; file.relative_path = file.relativePath + file.name;
} }
}
}) })
.bind('fileuploadstart', function() { .bind('fileuploadstart', function() {
$fu_status.html(fu_status.uploading); $fu_status.html(fu_status.uploading);