From a01de011ca2fbdfc17c345b14050b78014cc33fe Mon Sep 17 00:00:00 2001
From: lizanle <491823689@qq.com>
Date: Wed, 11 Nov 2015 16:02:37 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E7=9A=84?=
=?UTF-8?q?=20=E7=A1=AE=E5=AE=9A=E6=8C=89=E9=92=AE=E7=9A=84=E8=81=94?=
=?UTF-8?q?=E5=8A=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/files/_attachement_list.html.erb | 2 +-
.../files/_new_style_attachment_list.html.erb | 2 +-
app/views/files/_upload_course_files.erb | 5 +-
app/views/files/_upload_show.html.erb | 3 +-
app/views/student_work/new.html.erb | 8 ++-
app/views/users/_attachment_list.html.erb | 2 +-
..._special_user_homework_attachment.html.erb | 61 +++++++++++++++++++
app/views/users/_upload_resource.html.erb | 4 +-
public/javascripts/attachments.js | 53 ++++++++++------
public/stylesheets/courses.css | 12 ++++
10 files changed, 121 insertions(+), 31 deletions(-)
create mode 100644 app/views/users/_special_user_homework_attachment.html.erb
diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb
index c5a3b9af0..25cc7f68a 100644
--- a/app/views/files/_attachement_list.html.erb
+++ b/app/views/files/_attachement_list.html.erb
@@ -6,7 +6,7 @@
:id => '_file',
:class => ie8? ? '':'file_selector',
:multiple => true,
- :onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'");',
+ :onchange => 'addInputFilesCourseSource(this,"'+ checkBox.to_s+'","'+'submit_resource'+'");',
:style => ie8? ? '': 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
diff --git a/app/views/files/_new_style_attachment_list.html.erb b/app/views/files/_new_style_attachment_list.html.erb
index 174a05047..cd33b6507 100644
--- a/app/views/files/_new_style_attachment_list.html.erb
+++ b/app/views/files/_new_style_attachment_list.html.erb
@@ -5,7 +5,7 @@
:id => "_file#{container.id}",
:class => ie8? ? '':'file_selector',
:multiple => true,
- :onchange => "addInputFiles_board(this, '#{container.id}');",
+ :onchange => "addInputFiles_board(this, '#{container.id}','"+"submit_resource"+"');",
:style => ie8? ? '': 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb
index 9c7021383..f023e8413 100644
--- a/app/views/files/_upload_course_files.erb
+++ b/app/views/files/_upload_course_files.erb
@@ -22,9 +22,10 @@
<%= render :partial => 'files/new_style_attachment_list',:locals => {:container => course} %>
- <%= l(:button_cancel)%>
- <%= l(:button_confirm)%>
+ <%= l(:button_cancel)%>
+
+ <%= submit_tag '确定',:onclick=>'submit_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %>
<% end %>
diff --git a/app/views/files/_upload_show.html.erb b/app/views/files/_upload_show.html.erb
index 21cd94d8d..dbd0277d7 100644
--- a/app/views/files/_upload_show.html.erb
+++ b/app/views/files/_upload_show.html.erb
@@ -11,7 +11,8 @@
<%= render :partial => 'attachement_list',:locals => {:course => course} %>
<%= l(:button_cancel)%>
- <%= l(:button_confirm)%>
+
+ <%= submit_tag '确定',:onclick=>'submit_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %>
<% end %>
diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb
index fdf1e31a3..b71d36f97 100644
--- a/app/views/student_work/new.html.erb
+++ b/app/views/student_work/new.html.erb
@@ -95,7 +95,7 @@
- <%= render :partial => 'users/user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %>
+ <%= render :partial => 'users/special_user_homework_attachment', :locals => {:container => @student_work, :has_program=>false} %>
@@ -111,9 +111,11 @@
-
确定
+
+ <%= submit_tag '确定',:onclick=>'popupRegex();new_student_work();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText fr' %>
或
- <%= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%>
+ <%#= link_to "取消", user_homeworks_user_path(User.current.id), :class => "fr mr10 mt3"%>
+
<%= l(:button_cancel)%>
<% end%>
diff --git a/app/views/users/_attachment_list.html.erb b/app/views/users/_attachment_list.html.erb
index 3d44fa267..939513627 100644
--- a/app/views/users/_attachment_list.html.erb
+++ b/app/views/users/_attachment_list.html.erb
@@ -7,7 +7,7 @@
:id => '_file',
:class => ie8? ? '':'file_selector',
:multiple => true,
- :onchange => 'addInputFiles(this);',
+ :onchange => 'addInputFiles(this,"'+'upload_files_submit_btn'+'");',
:style => ie8? ? '': 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
diff --git a/app/views/users/_special_user_homework_attachment.html.erb b/app/views/users/_special_user_homework_attachment.html.erb
new file mode 100644
index 000000000..2f5a4e8e3
--- /dev/null
+++ b/app/views/users/_special_user_homework_attachment.html.erb
@@ -0,0 +1,61 @@
+
+
+ <% if defined?(container) && container && container.saved_attachments %>
+ <% container.attachments.each_with_index do |attachment, i| %>
+
+ <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename link_file', :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')%>
+ <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
+ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
+
+
+ <% end %>
+ <% container.saved_attachments.each_with_index do |attachment, i| %>
+
+ <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :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')%>
+ <%= link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') unless attachment.id.nil? %>
+ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
+
+
+ <% end %>
+ <% end %>
+
+ <%= file_field_tag 'attachments[dummy][file]',
+ :id => '_file',
+ :class => ie8? ? '' : 'file_selector',
+ :multiple => true,
+ :onchange => 'addInputFiles(this,"'+'upload_files_submit_btn'+'");',
+ :style => ie8? ? '' : 'display:none',
+ :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_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
+ :upload_path => uploads_path(:format => 'js',:project =>nil),
+ :description_placeholder => l(:label_optional_description),
+ :field_is_public => l(:field_is_public),
+ :are_you_sure => l(:text_are_you_sure),
+ :file_count => l(:label_file_count),
+ :lebel_file_uploding => l(:lebel_file_uploding),
+ :delete_all_files => l(:text_are_you_sure_all)
+ } %>
+
+
+
+
+
+
上传附件
+ <%= link_to "资源库",{:controller => 'users',:action=>'user_import_resource',:id=>User.current.id,:homework_id=>container.id},:class => "FilesBtn fl mt3 mr20",:remote => true%>
+ <% if defined?(has_program) && has_program %>
+
编程
+
+ <% end %>
+
+
+<% content_for :header_tags do %>
+ <%= javascript_include_tag 'attachments' %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/_upload_resource.html.erb b/app/views/users/_upload_resource.html.erb
index d73b2986a..c973217f6 100644
--- a/app/views/users/_upload_resource.html.erb
+++ b/app/views/users/_upload_resource.html.erb
@@ -45,9 +45,9 @@
- <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:class=>'sendSourceText' %>
+ <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %>
-
+
<% end %>
diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js
index 5718983fa..20e845424 100644
--- a/public/javascripts/attachments.js
+++ b/public/javascripts/attachments.js
@@ -22,7 +22,7 @@ function reload(fileSpan) {
}
-function addFile_board(inputEl, file, eagerUpload, id) {
+function addFile_board(inputEl, file, eagerUpload, id,btnId) {
var attachments_frame = '#attachments_fields' + id;
if ($(attachments_frame).children().length < 30) {
@@ -80,7 +80,7 @@ function addFile_board(inputEl, file, eagerUpload, id) {
).appendTo(attachments_frame);
if (eagerUpload) {
- ajaxUpload(file, attachmentId, fileSpan, inputEl);
+ ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId);
}
return attachmentId;
@@ -88,7 +88,7 @@ function addFile_board(inputEl, file, eagerUpload, id) {
return null;
}
-function addFile(inputEl, file, eagerUpload) {
+function addFile(inputEl, file, eagerUpload,btnId) {
var attachments_frame = '#attachments_fields';
if ($(attachments_frame).children().length < 30) {
@@ -145,7 +145,7 @@ function addFile(inputEl, file, eagerUpload) {
).appendTo('#attachments_fields');
if (eagerUpload) {
- ajaxUpload(file, attachmentId, fileSpan, inputEl);
+ ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId);
}
return attachmentId;
@@ -154,7 +154,7 @@ function addFile(inputEl, file, eagerUpload) {
}
addFile.nextAttachmentId = 1;
-function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
+function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
function onLoadstart(e) {
fileSpan.removeClass('ajax-waiting');
@@ -168,7 +168,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
}
}
- function actualUpload(file, attachmentId, fileSpan, inputEl) {
+ function actualUpload(file, attachmentId, fileSpan, inputEl,btnId) {
ajaxUpload.uploading++;
@@ -182,9 +182,15 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
console.log($(inputEl))
if(containerid == undefined ){
var count = $('#attachments_fields>span').length;
+ $('#'+btnId).removeAttr("disabled");
+ $('#'+btnId).val('确定')
+ $('#'+btnId).css('background-color','#269ac9')
$('#upload_file_count').html("" + count + "" + $(inputEl).data('fileCount'));
}
else{
+ $('#'+btnId).removeAttr("disabled");
+ $('#'+btnId).val('确定')
+ $('#'+btnId).css('background-color','#269ac9')
var count = $('#attachments_fields' + containerid + '>span').length;
$('#upload_file_count' + containerid).html("" + count + "" + $(inputEl).data('fileCount'));
}
@@ -213,6 +219,9 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
var containerid = $(inputEl).data('containerid');
if (containerid == undefined) {
var count = $('#attachments_fields>span').length;
+ $('#'+btnId).attr("disabled",true);
+ $('#'+btnId).val('提交中');
+ $('#'+btnId).css('background-color','#c1c1c1')
$('#upload_file_count').html("" + count + "" + $(inputEl).data('lebelFileUploding'));
if (count >= 1) {
var add_attachs = $('.add_attachment');
@@ -227,6 +236,9 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
}
} else {
var count = $('#attachments_fields' + containerid + '>span').length;
+ $('#'+btnId).attr("disabled",true);
+ $('#'+btnId).val('提交中');
+ $('#'+btnId).css('background-color','#c1c1c1')
$('#upload_file_count' + containerid).html("" + count + "" + $(inputEl).data('lebelFileUploding'));
if (count >= 1) {
var add_attachs = $('.add_attachment').filter(function(index) {
@@ -258,7 +270,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
var maxSyncUpload = $(inputEl).data('max-concurrent-uploads');
if (maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload)
- actualUpload(file, attachmentId, fileSpan, inputEl);
+ actualUpload(file, attachmentId, fileSpan, inputEl,btnId);
else
$(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl));
}
@@ -323,11 +335,11 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
});
}
-function addInputFiles(inputEl) {
+function addInputFiles(inputEl,btnId) {
// var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) {
// upload files using ajax
- uploadAndAttachFiles(inputEl.files, inputEl);
+ uploadAndAttachFiles(inputEl.files, inputEl,btnId);
// $(inputEl).remove();
} else {
// browser not supporting the file API, upload on form submission
@@ -349,12 +361,12 @@ function addInputFiles(inputEl) {
//clearedFileInput.insertAfter('#attachments_fields');
}
-function addInputFiles_board(inputEl, id) {
+function addInputFiles_board(inputEl, id,btnId) {
// var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) {
// upload files using ajax
- uploadAndAttachFiles_board(inputEl.files, inputEl, id);
+ uploadAndAttachFiles_board(inputEl.files, inputEl, id,btnId);
// $(inputEl).remove();
} else {
// browser not supporting the file API, upload on form submission
@@ -374,7 +386,7 @@ function addInputFiles_board(inputEl, id) {
//clearedFileInput.insertAfter('#attachments_fields');
}
-function uploadAndAttachFiles(files, inputEl) {
+function uploadAndAttachFiles(files, inputEl,btnId) {
var maxFileSize = $(inputEl).data('max-file-size');
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
@@ -389,12 +401,12 @@ function uploadAndAttachFiles(files, inputEl) {
window.alert(maxFileSizeExceeded);
} else {
$.each(files, function() {
- addFile(inputEl, this, true);
+ addFile(inputEl, this, true,btnId);
});
}
}
-function uploadAndAttachFiles_board(files, inputEl, id) {
+function uploadAndAttachFiles_board(files, inputEl, id,btnId) {
var maxFileSize = $(inputEl).data('max-file-size');
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
@@ -409,7 +421,7 @@ function uploadAndAttachFiles_board(files, inputEl, id) {
window.alert(maxFileSizeExceeded);
} else {
$.each(files, function() {
- addFile_board(inputEl, this, true, id);
+ addFile_board(inputEl, this, true, id,btnId);
});
}
}
@@ -482,10 +494,11 @@ $(function() {
//课程课件
function addInputFilesCourseSource(inputEl) {
checkBox = arguments[1] == 'public' ? false : true;
+ btnId = arguments[2];
// var clearedFileInput = $(inputEl).clone().val('');
if (inputEl.files) {
// upload files using ajax
- uploadAndAttachFilesCourseSource(inputEl.files, inputEl,checkBox);
+ uploadAndAttachFilesCourseSource(inputEl.files, inputEl,checkBox,btnId);
// $(inputEl).remove();
} else {
// browser not supporting the file API, upload on form submission
@@ -507,7 +520,7 @@ function addInputFilesCourseSource(inputEl) {
//clearedFileInput.insertAfter('#attachments_fields');
}
-function uploadAndAttachFilesCourseSource(files, inputEl,checkBox) {
+function uploadAndAttachFilesCourseSource(files, inputEl,checkBox,btnId) {
var maxFileSize = $(inputEl).data('max-file-size');
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
@@ -522,12 +535,12 @@ function uploadAndAttachFilesCourseSource(files, inputEl,checkBox) {
window.alert(maxFileSizeExceeded);
} else {
$.each(files, function() {
- addFileCourseSource(inputEl, this, true,checkBox);
+ addFileCourseSource(inputEl, this, true,checkBox,btnId);
});
}
}
-function addFileCourseSource(inputEl, file, eagerUpload,checkBox) {
+function addFileCourseSource(inputEl, file, eagerUpload,checkBox,btnId) {
var attachments_frame = '#attachments_fields';
if ($(attachments_frame).children().length < 30) {
@@ -606,7 +619,7 @@ function addFileCourseSource(inputEl, file, eagerUpload,checkBox) {
}
if (eagerUpload) {
- ajaxUpload(file, attachmentId, fileSpan, inputEl);
+ ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId);
}
return attachmentId;
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index 71b473abe..0cb6e203f 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -1128,3 +1128,15 @@ a.postRouteLink:hover {text-decoration:underline;}
.syllabusSettingIcon:hover {cursor: pointer}
.pic_files{display:block; background:url(../images/public_icon.png) 0px -578px no-repeat; width:20px; height:15px;}
+
+/*确定按钮*/
+input.sendSourceText {
+ font-size: 14px;
+ color: #ffffff;
+ background-color: #269ac9;
+ cursor: pointer;
+ outline: none;
+ border: none;
+ width: 50px;
+ height: 25px;
+}