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 %> +<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()" %> + <%= file_field_tag 'attachments[dummy][file]', - :id => nil, + :id => '_file', :class => 'file_selector', :multiple => true, :onchange => 'addInputFiles(this);', + :style => '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)), @@ -24,6 +27,7 @@ :upload_path => uploads_path(:format => 'js'), :description_placeholder => l(:label_optional_description) } %> +<%= l(:label_no_file_uploaded)%> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) 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("已上传"+""+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/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 = $('
').insertAfter(fileSpan.find('input.filename')); @@ -84,6 +100,16 @@ function removeFile() { return false; } +//gcm delete all file +function removeAll(){ + if(confirm("您确定要删除所有文件吗?")){ + $(".remove-upload").removeAttr("data-confirm"); + $(".remove-upload").click(); + } +// return false; +} +//gcm + function uploadBlob(blob, uploadUrl, attachmentId, options) { var actualOptions = $.extend({ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index e5a203a6..c3572f93 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1821,6 +1821,11 @@ span.required {color: #bb0000;} a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block; padding-left:16px;} a.remove-upload:hover {text-decoration:none !important;} +/*gcm upload file count and deleteall*/ +#upload_file_count #count {color:red; font-size:1.5em;} +span.add_attachment .remove_all {background:none;background: url(../images/delete.png) no-repeat 1px 50%; width:1px; display:inline-block;position:absolute;right:21px;text-decoration:none;} + + div.fileover { background-color: lavender; } div.attachments { margin-top: 12px; } diff --git a/public/themes/redpenny-master/stylesheets/application.css b/public/themes/redpenny-master/stylesheets/application.css index 51a41fea..cc321a42 100644 --- a/public/themes/redpenny-master/stylesheets/application.css +++ b/public/themes/redpenny-master/stylesheets/application.css @@ -982,7 +982,8 @@ hr } p { - font-size: 13px + font-size: 13px; + position:relative;/*gcm*/ } /*end*/ div.issue