From be5ba44a5a293a4a06a7555c5e8e66ea3614fc38 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 7 Jun 2017 15:24:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8F=AD=E7=BA=A7=E8=B5=84=E6=BA=90=E7=9A=84?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E8=B5=84=E6=BA=90=E5=BC=B9=E6=A1=86=E6=94=B9?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../files/_new_style_attachment_list.html.erb | 8 +-- app/views/files/_upload_course_files.erb | 69 +++++++++++-------- public/javascripts/attachments.js | 15 ++-- 3 files changed, 53 insertions(+), 39 deletions(-) diff --git a/app/views/files/_new_style_attachment_list.html.erb b/app/views/files/_new_style_attachment_list.html.erb index 80e41d55a..818c6c24f 100644 --- a/app/views/files/_new_style_attachment_list.html.erb +++ b/app/views/files/_new_style_attachment_list.html.erb @@ -23,12 +23,8 @@ - - <%= l(:label_no_file_uploaded)%> - -单个文件最大限制:<%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %> +单个文件最大限制:<%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>
- - +
\ No newline at end of file diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb index f7cab96b3..943ba8f51 100644 --- a/app/views/files/_upload_course_files.erb +++ b/app/views/files/_upload_course_files.erb @@ -1,47 +1,46 @@ -
-
-

上传资源

- -
+
+
+

上传资源

+
-
-
+
+
<%= error_messages_for 'attachment' %> - <%= form_tag(course_files_path(course), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %> + <%= form_tag(course_files_path(course), :multipart => true,:remote => !ie8?,:id=>"upload_course_file_form") do %>
  • - - + +
  • - - + +
  • - - + +
  • - - + +
  • - - + +
  • - - + +
-
+
<%= render :partial => 'files/new_style_attachment_list',:locals => {:container => course} %>
@@ -62,13 +61,13 @@
- +
- - 确定 - 取消 + + 确定 + 取消
<% end %>
@@ -103,11 +102,25 @@ function submit_course_resource() { <% if User.current.allowed_to?(:as_teacher,course) %> - if(regex_publish_time()) { - $('#submit_resource').parent().submit(); + if($("#upload_course_file_form").find('.upload_filename').length == 0){ + $("#upload_file_count_notice").html('请至少上传一个资源').show(); + event.preventDefault(); + return false; + }else{ + $("#upload_file_count_notice").hide(); + if(regex_publish_time()) { + $('#submit_resource').parent().submit(); + } } <% else %> - $('#submit_resource').parent().submit(); + if($("#upload_course_file_form").find('.upload_filename').length == 0){ + $("#upload_file_count_notice").html('请至少上传一个资源').show(); + event.preventDefault(); + return false; + }else { + $("#upload_file_count_notice").hide(); + $('#submit_resource').parent().submit(); + } <% end %> } function reset_publish_time(){ diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 883c8d306..117dff04a 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -35,11 +35,16 @@ function addFile_board(inputEl, file, eagerUpload, id,btnId) { }); fileSpan.append( + $('').attr({ + 'class': 'fa fa-folder mr5 color-light-grey', + 'aria-hidden': true + }), $('', { 'type': 'text', - 'class': 'upload_filename readonly', + 'class': 'upload_filename readonly hidden', 'name': 'attachments[' + attachmentId + '][filename]', - 'readonly': 'readonly' + 'readonly': 'readonly', + 'style': 'border:none; max-width:300px;white-space: nowrap; text-overflow:ellipsis;' }).val(file.name), // $('', { // 'type': 'text', @@ -58,10 +63,10 @@ function addFile_board(inputEl, file, eagerUpload, id,btnId) { // 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', // checked: 'checked' // }).toggle(!eagerUpload), - $(' ').attr({ + $('').attr({ 'href': "#", 'class': 'remove-upload', - 'data-containerid': id + 'style': 'vertical-align:top;' }).click(function() { if (confirm($(inputEl).data('areYouSure'))) { removeFile(); @@ -123,7 +128,7 @@ function addFile(inputEl, file, eagerUpload,btnId) { 'class': 'upload_filename readonly hidden', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly', - 'style': 'border:none; max-width:980px;white-space: nowrap; text-overflow:ellipsis;', + 'style': 'border:none; max-width:980px;white-space: nowrap; text-overflow:ellipsis;' }).val(file.name), // $('', { // 'type': 'text',