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