diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index 546792d5..f34a0e4e 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -12,11 +12,14 @@ <% end %> "+count+""+"个文件"); +} \ No newline at end of file diff --git a/app/views/attachments/upload.js.erb b/app/views/attachments/upload.js.erb index 4761f463..82b79bb6 100644 --- a/app/views/attachments/upload.js.erb +++ b/app/views/attachments/upload.js.erb @@ -8,7 +8,7 @@ fileSpan.find('a.remove-upload') .attr({ "data-remote": true, "data-method": 'delete', - href: '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' + "href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>' }) .off('click'); <% end %> diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb index 6c4483d5..0c1867a9 100644 --- a/app/views/layouts/_base_footer.html.erb +++ b/app/views/layouts/_base_footer.html.erb @@ -29,15 +29,3 @@ -<%= debug(params) if Rails.env.development? %> - - \ No newline at end of file diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 7260a9c4..496f5641 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -244,7 +244,6 @@ -
diff --git a/app/views/attachments/destroy.js.erb b/app/views/attachments/destroy.js.erb index 3cfb5845..04cd4e02 100644 --- a/app/views/attachments/destroy.js.erb +++ b/app/views/attachments/destroy.js.erb @@ -1 +1,8 @@ $('#attachments_<%= j params[:attachment_id] %>').remove(); +var count=$('#attachments_fields>span').length; +if(count<=0){ + $("#upload_file_count").text("未上传文件"); + $(".remove_all").remove(); +}else{ + $("#upload_file_count").html("已上传"+" diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 2256ed86..2423b848 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -741,6 +741,7 @@ zh: label_latest_revision_plural: 最近的修订版本 label_view_revisions: 查看修订 label_view_all_revisions: 查看所有修订 + label_no_file_uploaded: 未上传文件 label_max_size: 最大文件大小 label_sort_highest: 置顶 label_sort_higher: 上移 diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index 7b8394fe..3d1520f8 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -7,14 +7,14 @@ function addFile(inputEl, file, eagerUpload) { var attachmentId = addFile.nextAttachmentId++; - var fileSpan = $('', { id: 'attachments_' + attachmentId }); + var fileSpan = $('', { 'id': 'attachments_' + attachmentId, 'class':'attachment' }); fileSpan.append( - $('', { type: 'text', 'class': 'filename readonly', name: 'attachments[' + attachmentId + '][filename]', readonly: 'readonly'} ).val(file.name), - $('', { type: 'text', 'class': 'description', name: 'attachments[' + attachmentId + '][description]', maxlength: 255, placeholder: $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), - $(' ').attr({ href: "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload) + $('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name), + $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload), + $(' ').attr({ 'href': "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload) ).appendTo('#attachments_fields'); - + if(eagerUpload) { ajaxUpload(file, attachmentId, fileSpan, inputEl); } @@ -63,6 +63,22 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) { } form.dequeue('upload'); }); + + //gcm files count and add delete_all link + + var count=$('#attachments_fields>span').length; + $('#upload_file_count').html("已上传"+""+count+""+"个文件"); + + if(count>=1){ + var add_attachs=$('.add_attachment'); + var delete_all=$('.remove_all'); + if(delete_all.length<1){ + add_attachs.append($(" ").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"})); + } + } + + //gcm + } var progressSpan = $('