From ef0da2ebf695d7e985526dbd4a50d19cbe0c4bc8 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Fri, 25 Aug 2017 19:56:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE=E7=9A=84=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 7 +++++++ app/views/users/_user_homework_attachment.html.erb | 3 ++- public/javascripts/attachments.js | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 88e013250..f07415888 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -450,6 +450,13 @@ module ApplicationHelper return time end + def judge_Chinese_num str + cn_reg = /[\u4e00-\u9fa5]{1}/ + cn_number = str.scan(cn_reg).size + en_number = str.size - cn_number + size = 1.9* cn_number + en_number + end + # homework_common状态 # 0:挂起;1:提交中;2:匿评中;3:评阅中 def new_homework_common_status status diff --git a/app/views/users/_user_homework_attachment.html.erb b/app/views/users/_user_homework_attachment.html.erb index b76a96fff..34c6e2a49 100644 --- a/app/views/users/_user_homework_attachment.html.erb +++ b/app/views/users/_user_homework_attachment.html.erb @@ -5,7 +5,8 @@ - <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'readonly hidden atta_input', :style => 'border:none; max-width:980px;', :readonly=>'readonly')%> + <% size = judge_Chinese_num attachment.filename %> + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly hidden', :size => size, :style => 'border:none; max-width:980px;white-space: nowrap; text-overflow:ellipsis;font-family: Consolas;', :readonly=>'readonly')%> <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> <%= l(:field_is_public)%>: <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 746c2b96a..3ddd686ff 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -177,7 +177,7 @@ function addFile(inputEl, file, eagerUpload,btnId) { var ch = file.name[i]; var judge = regex.test(ch); if(regex.test(ch)){ - iSize += 1.8; + iSize += 1.9; }else{ iSize += 1; }