Merge branch 'szzh' into develop
This commit is contained in:
commit
18bd667726
|
@ -9,8 +9,8 @@
|
|||
:size => "1",
|
||||
:multiple => true,
|
||||
:data => {
|
||||
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||
:max_file_size => Setting.upload_avatar_max_size,
|
||||
:max_file_size_message => l(:error_upload_avatar_to_large, :max_size => number_to_human_size(Setting.upload_avatar_max_size.to_i)),
|
||||
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||
:file_type => Redmine::Configuration['pic_types'].to_s,
|
||||
:type_support_message => l(:error_pic_type),
|
||||
|
|
|
@ -1520,3 +1520,5 @@ en:
|
|||
label_no_courses: You do not participate in any course, please search the curriculum, course, or create a course!
|
||||
label_commit_failed: commit failed
|
||||
#api end
|
||||
error_upload_avatar_to_large: "too big (%{max_size})"
|
||||
|
||||
|
|
|
@ -1983,3 +1983,4 @@ zh:
|
|||
label_media: 媒体
|
||||
label_code: 代码
|
||||
|
||||
error_upload_avatar_to_large: "超过大小限制 (%{max_size})"
|
||||
|
|
|
@ -60,7 +60,9 @@ per_page_options:
|
|||
default: '25,50,100'
|
||||
mail_from:
|
||||
default: trustieforge@gmail.com
|
||||
|
||||
upload_avatar_max_size:
|
||||
format: int
|
||||
default: 5242880
|
||||
### delayjob for send email.
|
||||
delayjob_enabled:
|
||||
default: 1
|
||||
|
|
|
@ -1,28 +1,44 @@
|
|||
$(function() {
|
||||
var $upload_file = $('.upload_file');
|
||||
var validateImage = function(file){
|
||||
if(!/^image\//.test(file.type)){
|
||||
alert($upload_file.attr("data-type-support-message") + $upload_file.attr("data-file-type"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
function endsWith(str, suffix) {
|
||||
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
||||
}
|
||||
var validateImage = function(file) {
|
||||
var types = $upload_file.attr('data-file-type').split(",");
|
||||
var check = false;
|
||||
$.each(types, function(n, e) {
|
||||
if (endsWith(file.name, e)) {
|
||||
check = true;
|
||||
}
|
||||
});
|
||||
if (!check) {
|
||||
alert($upload_file.attr("data-type-support-message") + $upload_file.attr("data-file-type"));
|
||||
return false;
|
||||
}
|
||||
if (file.size && file.size > parseInt($upload_file.attr('data-max-file-size'))) {
|
||||
alert($upload_file.attr("data-max-file-size-message"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
$('.upload_file').fileupload({
|
||||
url: '/upload_avatar.json?source_type=' + $('.upload_file').attr('data-source-type') +
|
||||
'&source_id=' + $('.upload_file').attr('data-source-id'),
|
||||
add: function(e,data){
|
||||
if(!validateImage(data.files[0])){
|
||||
return false;
|
||||
}
|
||||
data.submit();
|
||||
add: function(e, data) {
|
||||
if (!validateImage(data.files[0])) {
|
||||
return false;
|
||||
}
|
||||
data.submit();
|
||||
},
|
||||
formData: function(form) {
|
||||
var data = form.serializeArray();
|
||||
var auth = null;
|
||||
for(var key in data){
|
||||
if(data[key].name == "authenticity_token"){
|
||||
auth = data[key];break;
|
||||
}
|
||||
for (var key in data) {
|
||||
if (data[key].name == "authenticity_token") {
|
||||
auth = data[key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return [auth];
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue