mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 16:31:13 +00:00
[lib] added fileupload
This commit is contained in:
@@ -5,11 +5,12 @@ define([
|
|||||||
'backbone',
|
'backbone',
|
||||||
'common',
|
'common',
|
||||||
'file-tree',
|
'file-tree',
|
||||||
|
'jquery.fileupload-ui',
|
||||||
'app/collections/dirents',
|
'app/collections/dirents',
|
||||||
'app/views/dirent',
|
'app/views/dirent',
|
||||||
'text!' + app.config._tmplRoot + 'dir-op-bar.html',
|
'text!' + app.config._tmplRoot + 'dir-op-bar.html',
|
||||||
'text!' + app.config._tmplRoot + 'path-bar.html',
|
'text!' + app.config._tmplRoot + 'path-bar.html',
|
||||||
], function($, simplemodal, _, Backbone, Common, FileTree, DirentCollection, DirentView,
|
], function($, simplemodal, _, Backbone, Common, FileTree, FileUpload, DirentCollection, DirentView,
|
||||||
DirOpBarTemplate, PathBarTemplate) {
|
DirOpBarTemplate, PathBarTemplate) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ define([
|
|||||||
dir_op_bar_template: _.template(DirOpBarTemplate),
|
dir_op_bar_template: _.template(DirOpBarTemplate),
|
||||||
newDirTemplate: _.template($("#add-new-dir-form-template").html()),
|
newDirTemplate: _.template($("#add-new-dir-form-template").html()),
|
||||||
newFileTemplate: _.template($("#add-new-file-form-template").html()),
|
newFileTemplate: _.template($("#add-new-file-form-template").html()),
|
||||||
|
//uploadFileDialogTemplate: _.template($("#upload-file-dialog-template").html()),
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
this.$dirent_list = this.$('.repo-file-list tbody');
|
this.$dirent_list = this.$('.repo-file-list tbody');
|
||||||
@@ -62,6 +64,297 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
window.locale = {
|
||||||
|
"fileupload": {
|
||||||
|
"errors": {
|
||||||
|
"maxFileSize": gettext("File is too big"),
|
||||||
|
"minFileSize": gettext("File is too small"),
|
||||||
|
"acceptFileTypes": gettext("Filetype not allowed"),
|
||||||
|
"maxNumberOfFiles": gettext("Max number of files exceeded"),
|
||||||
|
"uploadedBytes": gettext("Uploaded bytes exceed file size"),
|
||||||
|
"emptyResult": gettext("Empty file upload result")
|
||||||
|
},
|
||||||
|
"error": gettext("Error"),
|
||||||
|
"uploaded": gettext("uploaded"),
|
||||||
|
"canceled": gettext("canceled"),
|
||||||
|
"start": gettext("Start"),
|
||||||
|
"cancel": gettext("Cancel"),
|
||||||
|
"destroy": gettext("Delete")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var dirents = _this.dir;
|
||||||
|
var libview = _this;
|
||||||
|
//var popup = $(libview.uploadFileDialogTemplate()).addClass('fixed-upload-file-dialog');
|
||||||
|
var popup = $('#upload-file-dialog').addClass('fixed-upload-file-dialog');
|
||||||
|
var popup_height = '200px';
|
||||||
|
popup.css({'height': popup_height}).data('height', popup_height);
|
||||||
|
var fu_status = $('.status', popup),
|
||||||
|
total_progress = $('.total-progress', popup),
|
||||||
|
cancel_all_btn = $('.fileupload-buttonbar .cancel', popup),
|
||||||
|
close_icon = $('.close', popup),
|
||||||
|
saving_tip = $('.saving-tip', popup);
|
||||||
|
var fu_status_ = {
|
||||||
|
'uploading': gettext("File Uploading..."),
|
||||||
|
'complete': gettext("File Upload complete"),
|
||||||
|
'canceled': gettext("File Upload canceled"),
|
||||||
|
'failed': gettext("File Upload failed")
|
||||||
|
};
|
||||||
|
|
||||||
|
var uploaded_files = [];
|
||||||
|
|
||||||
|
var enable_upload_folder = app.pageOptions.enable_upload_folder;
|
||||||
|
var new_dir_names = [];
|
||||||
|
var dirs_to_update = [];
|
||||||
|
|
||||||
|
popup.fileupload({
|
||||||
|
paramName: 'file',
|
||||||
|
// customize it for 'done'
|
||||||
|
getFilesFromResponse: function (data) {
|
||||||
|
if (data.result) {
|
||||||
|
return data.result;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
autoUpload:true,
|
||||||
|
maxNumberOfFiles: 500,
|
||||||
|
sequentialUploads: true
|
||||||
|
})
|
||||||
|
.bind('fileuploadadd', function(e, data) {
|
||||||
|
// for drag & drop
|
||||||
|
if (!libview.$el.is(':visible')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (dirents.user_perm && dirents.user_perm != 'rw') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
popup.removeClass('hide');
|
||||||
|
cancel_all_btn.removeClass('hide');
|
||||||
|
close_icon.addClass('hide');
|
||||||
|
var path = dirents.path;
|
||||||
|
popup.fileupload('option', 'formData', {
|
||||||
|
'parent_dir': path == '/' ? path : path + '/'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!enable_upload_folder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// hide the upload menu
|
||||||
|
var menu = libview.$('#upload-menu');
|
||||||
|
if (!menu.hasClass('hide')) {
|
||||||
|
menu.find('.item').removeAttr('style')
|
||||||
|
.end().addClass('hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
// when add folder, a subdirectory will be shown as '.'. rm it.
|
||||||
|
var file = data.files[0];
|
||||||
|
if (file.name == '.') {
|
||||||
|
data.files.shift();
|
||||||
|
}
|
||||||
|
if (file.webkitRelativePath) { // for 'upload folder'
|
||||||
|
file.relative_path = file.webkitRelativePath;
|
||||||
|
}
|
||||||
|
if (file.relativePath) { // for 'folder drag & drop'
|
||||||
|
file.relative_path = file.relativePath + file.name;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.bind('fileuploadstart', function() {
|
||||||
|
fu_status.html(fu_status_.uploading);
|
||||||
|
})
|
||||||
|
.bind('fileuploadsubmit', function(e, data) {
|
||||||
|
var file = data.files[0];
|
||||||
|
// get url(token) for every file
|
||||||
|
if (!file.error) {
|
||||||
|
$.ajax({
|
||||||
|
url: Common.getUrl({name:'get_file_op_url', repo_id:dirents.repo_id}) + '?op_type=upload',
|
||||||
|
cache: false,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(ret) {
|
||||||
|
if (enable_upload_folder) {
|
||||||
|
var file_path = file.relative_path,
|
||||||
|
r_path;
|
||||||
|
if (file_path) { // 'add folder'
|
||||||
|
r_path = file_path.substring(0, file_path.lastIndexOf('/') + 1);
|
||||||
|
}
|
||||||
|
var formData = popup.fileupload('option', 'formData');
|
||||||
|
formData.relative_path = r_path || '';
|
||||||
|
popup.fileupload('option', 'formData', formData);
|
||||||
|
}
|
||||||
|
data.url = ret['url'];
|
||||||
|
data.jqXHR = popup.fileupload('send', data);
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
file.error = gettext("Failed to get upload url");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.bind('fileuploadprogressall', function (e, data) {
|
||||||
|
total_progress.html(parseInt(data.loaded / data.total * 100, 10) + '% ' + '<span style="font-size:14px;color:#555;">(' + $(this).data('blueimp-fileupload')._formatBitrate(data.bitrate) + ')</span>').removeClass('hide');
|
||||||
|
if (data.loaded > 0 && data.loaded == data.total) {
|
||||||
|
saving_tip.show();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.bind('fileuploaddone', function(e, data) {
|
||||||
|
if (data.textStatus != 'success') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var file = data.files[0];
|
||||||
|
var file_path = file.relative_path;
|
||||||
|
var file_uploaded = data.result[0]; // 'id', 'name', 'size'
|
||||||
|
// for 'template_download' render
|
||||||
|
file_uploaded.uploaded = true;
|
||||||
|
if (file_path) {
|
||||||
|
file_uploaded.relative_path = file_path.substring(0, file_path.lastIndexOf('/') + 1) + file_uploaded.name;
|
||||||
|
}
|
||||||
|
var path = dirents.path;
|
||||||
|
path = path == '/' ? path : path + '/';
|
||||||
|
if (data.formData.parent_dir != path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!file_path) {
|
||||||
|
uploaded_files.push(file_uploaded);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!enable_upload_folder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// for 'add folder'
|
||||||
|
var dir_name = file_path.substring(0, file_path.indexOf('/'));
|
||||||
|
var dir = dirents.where({'is_dir': true, 'obj_name': dir_name});
|
||||||
|
if (dir.length > 0) { // 0 or 1
|
||||||
|
if (dirs_to_update.indexOf(dir_name) == -1) {
|
||||||
|
dirs_to_update.push(dir_name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (new_dir_names.indexOf(dir_name) == -1) {
|
||||||
|
new_dir_names.push(dir_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.bind('fileuploadstop', function () {
|
||||||
|
cancel_all_btn.addClass('hide');
|
||||||
|
close_icon.removeClass('hide');
|
||||||
|
var path = dirents.path;
|
||||||
|
path = path == '/' ? path : path + '/';
|
||||||
|
if (popup.fileupload('option','formData').parent_dir != path) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var now = parseInt(new Date().getTime()/1000);
|
||||||
|
if (uploaded_files.length > 0) {
|
||||||
|
$(uploaded_files).each(function(index, file) {
|
||||||
|
var new_dirent = dirents.add({
|
||||||
|
'is_file': true,
|
||||||
|
'obj_name': file.name,
|
||||||
|
'last_modified': now,
|
||||||
|
'file_size': Common.fileSizeFormat(file.size, 1),
|
||||||
|
'obj_id': file.id,
|
||||||
|
'file_icon': 'file.png',
|
||||||
|
'last_update': gettext("Just now"),
|
||||||
|
'starred': false,
|
||||||
|
'sharelink': '',
|
||||||
|
'sharetoken': ''
|
||||||
|
}, {silent: true});
|
||||||
|
libview.addNewFile(new_dirent);
|
||||||
|
});
|
||||||
|
uploaded_files = [];
|
||||||
|
}
|
||||||
|
if (new_dir_names.length > 0) {
|
||||||
|
$(new_dir_names).each(function(index, new_name) {
|
||||||
|
var new_dirent = dirents.add({
|
||||||
|
'is_dir': true,
|
||||||
|
'obj_name': new_name,
|
||||||
|
'last_modified': now,
|
||||||
|
'last_update': gettext("Just now"),
|
||||||
|
'p_dpath': path + new_name,
|
||||||
|
'sharelink': '',
|
||||||
|
'sharetoken': '',
|
||||||
|
'uploadlink': '',
|
||||||
|
'uploadtoken': ''
|
||||||
|
}, {silent: true});
|
||||||
|
var view = new DirentView({model: new_dirent, dirView: libview});
|
||||||
|
libview.$dirent_list.prepend(view.render().el); // put the new dir as the first one
|
||||||
|
});
|
||||||
|
new_dir_names = [];
|
||||||
|
}
|
||||||
|
if (dirs_to_update.length > 0) {
|
||||||
|
$(dirs_to_update).each(function(index, dir_name) {
|
||||||
|
var dir = dirents.where({'is_dir':true, 'obj_name':dir_name});
|
||||||
|
dir[0].set({
|
||||||
|
'last_modified': now,
|
||||||
|
'last_update': gettext("Just now")
|
||||||
|
});
|
||||||
|
});
|
||||||
|
dirs_to_update = [];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// after tpl has rendered
|
||||||
|
.bind('fileuploadcompleted', function() { // 'done'
|
||||||
|
if ($('.files .cancel', popup).length == 0) {
|
||||||
|
saving_tip.hide();
|
||||||
|
total_progress.addClass('hide');
|
||||||
|
fu_status.html(fu_status_.complete);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.bind('fileuploadfailed', function(e, data) { // 'fail'
|
||||||
|
if ($('.files .cancel', popup).length == 0) {
|
||||||
|
cancel_all_btn.addClass('hide');
|
||||||
|
close_icon.removeClass('hide');
|
||||||
|
total_progress.addClass('hide');
|
||||||
|
saving_tip.hide();
|
||||||
|
if (data.errorThrown == 'abort') { // 'cancel'
|
||||||
|
fu_status.html(fu_status_.canceled);
|
||||||
|
} else { // 'error'
|
||||||
|
fu_status.html(fu_status_.failed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var max_upload_file_size = app.pageOptions.max_upload_file_size;
|
||||||
|
if (max_upload_file_size) {
|
||||||
|
popup.fileupload(
|
||||||
|
'option',
|
||||||
|
'maxFileSize',
|
||||||
|
max_upload_file_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable iframe cross-domain access via redirect option:
|
||||||
|
popup.fileupload(
|
||||||
|
'option',
|
||||||
|
'redirect',
|
||||||
|
window.location.href.replace(/\/repo\/[-a-z0-9]{36}\/.*/, app.config.mediaUrl + 'cors/result.html?%s')
|
||||||
|
);
|
||||||
|
|
||||||
|
// fold/unfold the dialog
|
||||||
|
$('.fold-switch', popup).click(function() {
|
||||||
|
var full_ht = parseInt(popup.data('height'));
|
||||||
|
var main_con = $('.fileupload-buttonbar, .table', popup);
|
||||||
|
if (popup.height() == full_ht) {
|
||||||
|
popup.height($('.hd', popup).outerHeight(true));
|
||||||
|
main_con.addClass('hide');
|
||||||
|
} else {
|
||||||
|
popup.height(full_ht);
|
||||||
|
main_con.removeClass('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.close', popup).click(function() {
|
||||||
|
popup.addClass('hide');
|
||||||
|
$('.files', popup).empty();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).click(function(e) {
|
||||||
|
var target = e.target || event.srcElement;
|
||||||
|
var closePopup = function(popup, popup_switch) {
|
||||||
|
if (!popup.hasClass('hide') && !popup.is(target) && !popup.find('*').is(target) && !popup_switch.is(target) && !popup_switch.find('*').is(target) ) {
|
||||||
|
popup.addClass('hide');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var libview = _this;
|
||||||
|
closePopup(libview.$('#upload-menu'), libview.$('#upload-file'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
showDir: function(category, repo_id, path) {
|
showDir: function(category, repo_id, path) {
|
||||||
@@ -99,6 +392,46 @@ define([
|
|||||||
this.dir.each(this.addOne, this);
|
this.dir.each(this.addOne, this);
|
||||||
this.renderPath();
|
this.renderPath();
|
||||||
this.renderDirOpBar();
|
this.renderDirOpBar();
|
||||||
|
|
||||||
|
var dir = this.dir;
|
||||||
|
var upload_popup = $('#upload-file-dialog');
|
||||||
|
if (dir.user_perm && dir.user_perm == 'rw') {
|
||||||
|
upload_popup.fileupload(
|
||||||
|
'option',
|
||||||
|
'fileInput',
|
||||||
|
this.$('#upload-file input'));
|
||||||
|
}
|
||||||
|
if (!app.pageOptions.enable_upload_folder) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var upload_btn = this.$('#upload-file'),
|
||||||
|
upload_menu = this.$('#upload-menu');
|
||||||
|
if (dir.user_perm && dir.user_perm == 'rw' &&
|
||||||
|
'webkitdirectory' in $('input[type="file"]', upload_btn)[0]) {
|
||||||
|
upload_btn.find('input').remove().end().addClass('cspt');
|
||||||
|
$('.item', upload_menu).click(function() {
|
||||||
|
upload_popup.fileupload(
|
||||||
|
'option',
|
||||||
|
'fileInput',
|
||||||
|
$('input[type="file"]', $(this)));
|
||||||
|
})
|
||||||
|
.hover(
|
||||||
|
function() {
|
||||||
|
$(this).css({'background':'#f3f3f3'});
|
||||||
|
},
|
||||||
|
function() {
|
||||||
|
$(this).css({'background':'transparent'});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.$('.repo-op').css({'position': 'relative'});
|
||||||
|
upload_menu.css({
|
||||||
|
'left': upload_btn.position().left,
|
||||||
|
'top': parseInt(this.$('.repo-op').css('padding-top')) + upload_btn.outerHeight(true)
|
||||||
|
});
|
||||||
|
upload_btn.click(function () {
|
||||||
|
upload_menu.toggleClass('hide');
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
renderPath: function() {
|
renderPath: function() {
|
||||||
@@ -125,7 +458,7 @@ define([
|
|||||||
encrypted: dir.encrypted,
|
encrypted: dir.encrypted,
|
||||||
path: dir.path,
|
path: dir.path,
|
||||||
repo_id: dir.repo_id,
|
repo_id: dir.repo_id,
|
||||||
enable_upload_folder: app.globalState.enable_upload_folder
|
enable_upload_folder: app.pageOptions.enable_upload_folder
|
||||||
})));
|
})));
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -242,20 +575,7 @@ define([
|
|||||||
'sharelink': '',
|
'sharelink': '',
|
||||||
'sharetoken': ''
|
'sharetoken': ''
|
||||||
}, {silent: true});
|
}, {silent: true});
|
||||||
var view = new DirentView({model: new_dirent, dirView: dirView});
|
dirView.addNewFile(new_dirent);
|
||||||
var new_file = view.render().el;
|
|
||||||
// put the new file as the first file
|
|
||||||
if ($('tr', dirView.$dirent_list).length == 0) {
|
|
||||||
dirView.$dirent_list.append(new_file);
|
|
||||||
} else {
|
|
||||||
var dirs = dir.where({'is_dir':true});
|
|
||||||
if (dirs.length == 0) {
|
|
||||||
dirView.$dirent_list.prepend(new_file);
|
|
||||||
} else {
|
|
||||||
// put the new file after the last dir
|
|
||||||
$($('tr', dirView.$dirent_list)[dirs.length - 1]).after(new_file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Common.ajaxPost({
|
Common.ajaxPost({
|
||||||
@@ -270,6 +590,25 @@ define([
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
addNewFile: function(new_dirent) {
|
||||||
|
var dirView = this,
|
||||||
|
dir = this.dir;
|
||||||
|
var view = new DirentView({model: new_dirent, dirView: dirView});
|
||||||
|
var new_file = view.render().el;
|
||||||
|
// put the new file as the first file
|
||||||
|
if ($('tr', dirView.$dirent_list).length == 0) {
|
||||||
|
dirView.$dirent_list.append(new_file);
|
||||||
|
} else {
|
||||||
|
var dirs = dir.where({'is_dir':true});
|
||||||
|
if (dirs.length == 0) {
|
||||||
|
dirView.$dirent_list.prepend(new_file);
|
||||||
|
} else {
|
||||||
|
// put the new file after the last dir
|
||||||
|
$($('tr', dirView.$dirent_list)[dirs.length - 1]).after(new_file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
sortByName: function() {
|
sortByName: function() {
|
||||||
var dirents = this.dir;
|
var dirents = this.dir;
|
||||||
var el = $('#by-name');
|
var el = $('#by-name');
|
||||||
@@ -290,7 +629,6 @@ define([
|
|||||||
},
|
},
|
||||||
|
|
||||||
sortByTime: function () {
|
sortByTime: function () {
|
||||||
console.log("sortByTime: " + this.dir.repo_id + " " + this.dir.path);
|
|
||||||
var dirents = this.dir;
|
var dirents = this.dir;
|
||||||
var el = $('#by-time');
|
var el = $('#by-time');
|
||||||
dirents.comparator = function(a, b) {
|
dirents.comparator = function(a, b) {
|
||||||
|
@@ -22,9 +22,16 @@ require.config({
|
|||||||
},
|
},
|
||||||
paths: {
|
paths: {
|
||||||
jquery: 'lib/jquery',
|
jquery: 'lib/jquery',
|
||||||
|
'jquery.ui.widget': 'lib/jquery.ui.widget.1.11.1',
|
||||||
|
'tmpl': 'lib/tmpl.min',
|
||||||
|
'jquery.iframe-transport': 'lib/jquery.iframe-transport.1.4',
|
||||||
|
'jquery.fileupload': 'lib/jquery.fileupload.5.42.1',
|
||||||
|
'jquery.fileupload-process': 'lib/jquery.fileupload.file-processing.1.3.0',
|
||||||
|
'jquery.fileupload-validate': 'lib/jquery.fileupload.validation.1.1.2',
|
||||||
|
'jquery.fileupload-ui': 'lib/jquery.fileupload.ui.9.6.0',
|
||||||
|
|
||||||
simplemodal: 'lib/jquery.simplemodal.1.4.4.min',
|
simplemodal: 'lib/jquery.simplemodal.1.4.4.min',
|
||||||
jstree: 'lib/jstree.1.0',
|
jstree: 'lib/jstree.1.0',
|
||||||
|
|
||||||
underscore: 'lib/underscore',
|
underscore: 'lib/underscore',
|
||||||
backbone: 'lib/backbone',
|
backbone: 'lib/backbone',
|
||||||
text: 'lib/text'
|
text: 'lib/text'
|
||||||
|
11
media/scripts/lib/jquery.fileupload.5.42.1.js
Normal file
11
media/scripts/lib/jquery.fileupload.5.42.1.js
Normal file
File diff suppressed because one or more lines are too long
11
media/scripts/lib/jquery.fileupload.file-processing.1.3.0.js
Normal file
11
media/scripts/lib/jquery.fileupload.file-processing.1.3.0.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* jQuery File Upload File Processing Plugin 1.3.0
|
||||||
|
* https://github.com/blueimp/jQuery-File-Upload
|
||||||
|
*
|
||||||
|
* Copyright 2012, Sebastian Tschan
|
||||||
|
* https://blueimp.net
|
||||||
|
*
|
||||||
|
* Licensed under the MIT license:
|
||||||
|
* http://www.opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery","jquery.fileupload"],factory);}else{factory(window.jQuery);}}(function($){var originalAdd=$.blueimp.fileupload.prototype.options.add;$.widget("blueimp.fileupload",$.blueimp.fileupload,{options:{processQueue:[],add:function(e,data){var $this=$(this);data.process(function(){return $this.fileupload("process",data);});originalAdd.call(this,e,data);}},processActions:{},_processFile:function(data,originalData){var that=this,dfd=$.Deferred().resolveWith(that,[data]),chain=dfd.promise();this._trigger("process",null,data);$.each(data.processQueue,function(i,settings){var func=function(data){if(originalData.errorThrown){return $.Deferred().rejectWith(that,[originalData]).promise();}return that.processActions[settings.action].call(that,data,settings);};chain=chain.pipe(func,settings.always&&func);});chain.done(function(){that._trigger("processdone",null,data);that._trigger("processalways",null,data);}).fail(function(){that._trigger("processfail",null,data);that._trigger("processalways",null,data);});return chain;},_transformProcessQueue:function(options){var processQueue=[];$.each(options.processQueue,function(){var settings={},action=this.action,prefix=this.prefix===true?action:this.prefix;$.each(this,function(key,value){if($.type(value)==="string"&&value.charAt(0)==="@"){settings[key]=options[value.slice(1)||(prefix?prefix+key.charAt(0).toUpperCase()+key.slice(1):key)];}else{settings[key]=value;}});processQueue.push(settings);});options.processQueue=processQueue;},processing:function(){return this._processing;},process:function(data){var that=this,options=$.extend({},this.options,data);if(options.processQueue&&options.processQueue.length){this._transformProcessQueue(options);if(this._processing===0){this._trigger("processstart");}$.each(data.files,function(index){var opts=index?$.extend({},options):options,func=function(){if(data.errorThrown){return $.Deferred().rejectWith(that,[data]).promise();}return that._processFile(opts,data);};opts.index=index;that._processing+=1;that._processingQueue=that._processingQueue.pipe(func,func).always(function(){that._processing-=1;if(that._processing===0){that._trigger("processstop");}});});}return this._processingQueue;},_create:function(){this._super();this._processing=0;this._processingQueue=$.Deferred().resolveWith(this).promise();}});}));
|
15
media/scripts/lib/jquery.fileupload.ui.9.6.0.js
Normal file
15
media/scripts/lib/jquery.fileupload.ui.9.6.0.js
Normal file
File diff suppressed because one or more lines are too long
13
media/scripts/lib/jquery.fileupload.validation.1.1.2.js
Normal file
13
media/scripts/lib/jquery.fileupload.validation.1.1.2.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/*
|
||||||
|
* jQuery File Upload Validation Plugin 1.1.2
|
||||||
|
* https://github.com/blueimp/jQuery-File-Upload
|
||||||
|
*
|
||||||
|
* Copyright 2013, Sebastian Tschan
|
||||||
|
* https://blueimp.net
|
||||||
|
*
|
||||||
|
* Licensed under the MIT license:
|
||||||
|
* http://www.opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* global define, window */
|
||||||
|
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery","jquery.fileupload-process"],factory);}else{factory(window.jQuery);}}(function($){$.blueimp.fileupload.prototype.options.processQueue.push({action:"validate",always:true,acceptFileTypes:"@",maxFileSize:"@",minFileSize:"@",maxNumberOfFiles:"@",disabled:"@disableValidation"});$.widget("blueimp.fileupload",$.blueimp.fileupload,{options:{getNumberOfFiles:$.noop,messages:{maxNumberOfFiles:"Maximum number of files exceeded",acceptFileTypes:"File type not allowed",maxFileSize:"File is too large",minFileSize:"File is too small"}},processActions:{validate:function(data,options){if(options.disabled){return data;}var dfd=$.Deferred(),settings=this.options,file=data.files[data.index],fileSize;if(options.minFileSize||options.maxFileSize){fileSize=file.size;}if($.type(options.maxNumberOfFiles)==="number"&&(settings.getNumberOfFiles()||0)+data.files.length>options.maxNumberOfFiles){file.error=settings.i18n("maxNumberOfFiles");}else{if(options.acceptFileTypes&&!(options.acceptFileTypes.test(file.type)||options.acceptFileTypes.test(file.name))){file.error=settings.i18n("acceptFileTypes");}else{if(fileSize>options.maxFileSize){file.error=settings.i18n("maxFileSize");}else{if($.type(fileSize)==="number"&&fileSize<options.minFileSize){file.error=settings.i18n("minFileSize");}else{delete file.error;}}}}if(file.error||data.files.error){data.files.error=true;dfd.rejectWith(this,[data]);}else{dfd.resolveWith(this,[data]);}return dfd.promise();}}});}));
|
11
media/scripts/lib/jquery.iframe-transport.1.4.js
Normal file
11
media/scripts/lib/jquery.iframe-transport.1.4.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* jQuery Iframe Transport Plugin 1.4
|
||||||
|
* https://github.com/blueimp/jQuery-File-Upload
|
||||||
|
*
|
||||||
|
* Copyright 2011, Sebastian Tschan
|
||||||
|
* https://blueimp.net
|
||||||
|
*
|
||||||
|
* Licensed under the MIT license:
|
||||||
|
* http://www.opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory);}else{factory(window.jQuery);}}(function($){var counter=0;$.ajaxTransport("iframe",function(options){if(options.async&&(options.type==="POST"||options.type==="GET")){var form,iframe;return{send:function(_,completeCallback){form=$('<form style="display:none;"></form>');iframe=$('<iframe src="javascript:false;" name="iframe-transport-'+(counter+=1)+'"></iframe>').bind("load",function(){var fileInputClones,paramNames=$.isArray(options.paramName)?options.paramName:[options.paramName];iframe.unbind("load").bind("load",function(){var response;try{response=iframe.contents();if(!response.length||!response[0].firstChild){throw new Error();}}catch(e){response=undefined;}completeCallback(200,"success",{"iframe":response});$('<iframe src="javascript:false;"></iframe>').appendTo(form);form.remove();});form.prop("target",iframe.prop("name")).prop("action",options.url).prop("method",options.type);if(options.formData){$.each(options.formData,function(index,field){$('<input type="hidden"/>').prop("name",field.name).val(field.value).appendTo(form);});}if(options.fileInput&&options.fileInput.length&&options.type==="POST"){fileInputClones=options.fileInput.clone();options.fileInput.after(function(index){return fileInputClones[index];});if(options.paramName){options.fileInput.each(function(index){$(this).prop("name",paramNames[index]||options.paramName);});}form.append(options.fileInput).prop("enctype","multipart/form-data").prop("encoding","multipart/form-data");}form.submit();if(fileInputClones&&fileInputClones.length){options.fileInput.each(function(index,input){var clone=$(fileInputClones[index]);$(input).prop("name",clone.prop("name"));clone.replaceWith(input);});}});form.append(iframe).appendTo(document.body);},abort:function(){if(iframe){iframe.unbind("load").prop("src","javascript".concat(":false;"));}if(form){form.remove();}}};}});$.ajaxSetup({converters:{"iframe text":function(iframe){return $(iframe[0].body).text();},"iframe json":function(iframe){return $.parseJSON($(iframe[0].body).text());},"iframe html":function(iframe){return $(iframe[0].body).html();},"iframe script":function(iframe){return $.globalEval($(iframe[0].body).text());}}});}));
|
16
media/scripts/lib/jquery.ui.widget.1.11.1.js
Normal file
16
media/scripts/lib/jquery.ui.widget.1.11.1.js
Normal file
File diff suppressed because one or more lines are too long
2
media/scripts/lib/tmpl.min.js
vendored
Normal file
2
media/scripts/lib/tmpl.min.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// tmpl.min.js
|
||||||
|
(function(a){"use strict";var b=function(a,c){var d=/[^\w\-\.:]/.test(a)?new Function(b.arg+",tmpl","var _e=tmpl.encode"+b.helper+",_s='"+a.replace(b.regexp,b.func)+"';return _s;"):b.cache[a]=b.cache[a]||b(b.load(a));return c?d(c,b):function(a){return d(a,b)}};b.cache={},b.load=function(a){return document.getElementById(a).innerHTML},b.regexp=/([\s'\\])(?![^%]*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g,b.func=function(a,b,c,d,e,f){if(b)return{"\n":"\\n","\r":"\\r","\t":"\\t"," ":" "}[a]||"\\"+a;if(c)return c==="="?"'+_e("+d+")+'":"'+("+d+"||'')+'";if(e)return"';";if(f)return"_s+='"},b.encReg=/[<>&"'\x00]/g,b.encMap={"<":"<",">":">","&":"&",'"':""","'":"'"},b.encode=function(a){return String(a||"").replace(b.encReg,function(a){return b.encMap[a]||""})},b.arg="o",b.helper=",print=function(s,e){_s+=e&&(s||'')||_e(s);},include=function(s,d){_s+=tmpl(s,d);}",typeof define=="function"&&define.amd?define(function(){return b}):a.tmpl=b})(this);
|
@@ -1,4 +1,4 @@
|
|||||||
{% load i18n %}
|
{% load i18n upload_tags %}
|
||||||
|
|
||||||
<script type="text/template" id="add-new-dir-form-template">
|
<script type="text/template" id="add-new-dir-form-template">
|
||||||
<form id="add-new-dir-form" action="" method="post" class="hide">{% csrf_token %}
|
<form id="add-new-dir-form" action="" method="post" class="hide">{% csrf_token %}
|
||||||
@@ -84,6 +84,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{% upload_js %}
|
||||||
|
|
||||||
|
<!--script type="text/template" id="upload-file-dialog-template"-->
|
||||||
<div id="upload-file-dialog" class="hide">
|
<div id="upload-file-dialog" class="hide">
|
||||||
<h3 class="hd"><span class="status">{% trans "File Upload" %}</span> <span class="total-progress hide"></span></h3>
|
<h3 class="hd"><span class="status">{% trans "File Upload" %}</span> <span class="total-progress hide"></span></h3>
|
||||||
<div class="ops">
|
<div class="ops">
|
||||||
@@ -98,6 +101,7 @@
|
|||||||
<table class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
|
<table class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!--/script-->
|
||||||
|
|
||||||
<div id="update-file-dialog" class="hide">
|
<div id="update-file-dialog" class="hide">
|
||||||
<h3 class="hd">{% trans "Update %(file_name)s" %}</h3>
|
<h3 class="hd">{% trans "Update %(file_name)s" %}</h3>
|
||||||
|
@@ -224,10 +224,9 @@
|
|||||||
app["pageOptions"] = {
|
app["pageOptions"] = {
|
||||||
base_url: "{{ SITE_ROOT }}" + "home/my/",
|
base_url: "{{ SITE_ROOT }}" + "home/my/",
|
||||||
csrfToken: "{{ csrf_token }}",
|
csrfToken: "{{ csrf_token }}",
|
||||||
reposUrl: "{% url 'api2-repos' %}"
|
reposUrl: "{% url 'api2-repos' %}",
|
||||||
};
|
enable_upload_folder: {% if enable_upload_folder %} true {% else %} false {% endif %},
|
||||||
app.globalState = {
|
max_upload_file_size: {% if max_upload_file_size %} {{ max_upload_file_size }} {% else %} '' {% endif %}
|
||||||
enable_upload_folder: {% if enable_upload_folder %} true {% else %} false {% endif %}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
{% if debug %}
|
{% if debug %}
|
||||||
|
@@ -53,7 +53,8 @@ from seahub.utils import render_permission_error, render_error, list_to_string,
|
|||||||
gen_file_get_url, string2list, MAX_INT, IS_EMAIL_CONFIGURED, \
|
gen_file_get_url, string2list, MAX_INT, IS_EMAIL_CONFIGURED, \
|
||||||
EVENTS_ENABLED, get_user_events, get_org_user_events, show_delete_days, \
|
EVENTS_ENABLED, get_user_events, get_org_user_events, show_delete_days, \
|
||||||
TRAFFIC_STATS_ENABLED, get_user_traffic_stat, new_merge_with_no_conflict, \
|
TRAFFIC_STATS_ENABLED, get_user_traffic_stat, new_merge_with_no_conflict, \
|
||||||
user_traffic_over_limit, send_perm_audit_msg, get_origin_repo_info
|
user_traffic_over_limit, send_perm_audit_msg, get_origin_repo_info, \
|
||||||
|
is_org_context, get_max_upload_file_size
|
||||||
from seahub.utils.paginator import get_page_range
|
from seahub.utils.paginator import get_page_range
|
||||||
from seahub.utils.star import get_dir_starred_files
|
from seahub.utils.star import get_dir_starred_files
|
||||||
from seahub.utils.timeutils import utc_to_local
|
from seahub.utils.timeutils import utc_to_local
|
||||||
@@ -1166,6 +1167,8 @@ def myhome(request):
|
|||||||
|
|
||||||
repo_create_url = reverse("repo_create")
|
repo_create_url = reverse("repo_create")
|
||||||
|
|
||||||
|
max_upload_file_size = get_max_upload_file_size()
|
||||||
|
|
||||||
return render_to_response('myhome.html', {
|
return render_to_response('myhome.html', {
|
||||||
"owned_repos": owned_repos,
|
"owned_repos": owned_repos,
|
||||||
"create_shared_repo": False,
|
"create_shared_repo": False,
|
||||||
@@ -1176,6 +1179,7 @@ def myhome(request):
|
|||||||
"sub_repos": sub_repos,
|
"sub_repos": sub_repos,
|
||||||
"repo_create_url": repo_create_url,
|
"repo_create_url": repo_create_url,
|
||||||
'enable_upload_folder': settings.ENABLE_UPLOAD_FOLDER,
|
'enable_upload_folder': settings.ENABLE_UPLOAD_FOLDER,
|
||||||
|
'max_upload_file_size': max_upload_file_size,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
Reference in New Issue
Block a user