From 659ff254e1683180b16df7f9b8b0c5f87c1abe73 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 15 May 2015 17:12:01 +0800 Subject: [PATCH 1/4] =?UTF-8?q?background=E8=83=8C=E6=99=AF=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E6=8B=89=E4=BC=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/application.css | 5 +++-- public/stylesheets/courses.css | 1 + public/stylesheets/project.css | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 35e41453e..edde12527 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1598,7 +1598,8 @@ blockquote { margin-right: 0.4em; border-radius: 4px; font-family: "Microsoft YaHei"; - background: url('../images/requirements/reference.jpg') + background: url('../images/requirements/reference.jpg'); + background-size: 100% 100%; } blockquote blockquote { margin-left: 0;} @@ -2780,4 +2781,4 @@ div.repos_explain{ padding-top: 20px; padding-bottom: 20px; } -.upload_img img{max-width: 580px;width: 100%;} +.upload_img img{max-width: 100%;} diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 132cddadc..5333b91a7 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -487,6 +487,7 @@ blockquote { border-radius: 4px; font-family: "Microsoft YaHei"; background: url('../images/requirements/reference.jpg'); + background-size: 100% 100%; } a.member_search_edit {width: 43px;background: #15bccf;color: #fff;text-align: center;text-decoration: none;padding: 2px;} .min_search_edit {width: 150px;height: 20px;border: 1px solid #d0d0d0 !important;color: #666;} diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 74d7c58b3..d6bef6524 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -388,6 +388,7 @@ blockquote { border-radius: 4px; font-family: "Microsoft YaHei"; background: url(http://test.forge.trustie.net/images/requirements/xreference.jpg.pagespeed.ic.h4inUJNyH0.jpg); + background-size: 100% 100%; } /*上传项目图片*/ .upload_file{margin-left: -60px;margin-top: 40px;width: 50px;position: absolute;height: 24px;opacity: 0;cursor: pointer} From b84f6280c259d76dc815f065170a360976b9cc74 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 15 May 2015 17:29:25 +0800 Subject: [PATCH 2/4] =?UTF-8?q?wiki=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_form_project.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/attachments/_form_project.html.erb b/app/views/attachments/_form_project.html.erb index 998766b27..d1cdf8cc9 100644 --- a/app/views/attachments/_form_project.html.erb +++ b/app/views/attachments/_form_project.html.erb @@ -125,9 +125,9 @@ :file_count => l(:label_file_count), :delete_all_files => l(:text_are_you_sure_all) } %> - <% if container.nil? %> - <%= l(:label_no_file_uploaded)%> - <% end %> + <% if defined?(container) %> + <%= l(:label_no_file_uploaded)%> + <% end %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) From d2a7d4196353ec7d16bfbdb3246b80d74ce83657 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Fri, 15 May 2015 17:35:24 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=A4=B4=E5=83=8F=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/avatar/_new_avatar_form.html.erb | 4 +- config/locales/en.yml | 2 + config/locales/zh.yml | 1 + config/settings.yml | 4 +- public/javascripts/jq-upload/upload.js | 46 +++++++++++++++------- 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/app/views/avatar/_new_avatar_form.html.erb b/app/views/avatar/_new_avatar_form.html.erb index 793252d3a..64abfbc30 100644 --- a/app/views/avatar/_new_avatar_form.html.erb +++ b/app/views/avatar/_new_avatar_form.html.erb @@ -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), diff --git a/config/locales/en.yml b/config/locales/en.yml index 9cf572830..8989ae36a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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})" + diff --git a/config/locales/zh.yml b/config/locales/zh.yml index de3ae4d53..5fcb1fb5c 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1983,3 +1983,4 @@ zh: label_media: 媒体 label_code: 代码 + error_upload_avatar_to_large: "超过大小限制 (%{max_size})" diff --git a/config/settings.yml b/config/settings.yml index 1dc3c7151..cf98025e0 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -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 diff --git a/public/javascripts/jq-upload/upload.js b/public/javascripts/jq-upload/upload.js index 59ed96882..985450648 100644 --- a/public/javascripts/jq-upload/upload.js +++ b/public/javascripts/jq-upload/upload.js @@ -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]; }, From 0e6c15c160ebb408d7bf6bed7c0f1f26b5159c7a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 15 May 2015 17:36:18 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E5=A4=B4=E5=83=8Flogo=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/avatar/_avatar_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/avatar/_avatar_form.html.erb b/app/views/avatar/_avatar_form.html.erb index 43aaf9132..632ea5d4d 100644 --- a/app/views/avatar/_avatar_form.html.erb +++ b/app/views/avatar/_avatar_form.html.erb @@ -43,7 +43,7 @@
-<%= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %> +<%#= link_to l(:button_delete_file),{:controller => :avatar,:action => :delete_image,:remote=>true,:source_type=> source.class,:source_id=>source.id},:confirm => l(:text_are_you_sure), :method => :post, :class => "btn_addPic", :style => "text-decoration:none;" %> <%= l(:button_upload_photo) %>