footer , footer of base_course,upload files count and delete all upload

This commit is contained in:
kg 2014-04-17 08:33:44 +08:00
parent c9b92b4197
commit d450da9df8
9 changed files with 52 additions and 21 deletions

View File

@ -12,11 +12,14 @@
<% end %>
</span>
<span class="add_attachment">
<%= button_tag "浏览", :type=>"button", :onclick=>"_file.click()" %>
<!--%= link_to image_tag(),"javascript:void(0)", :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)
} %>
<span id="upload_file_count"><%= l(:label_no_file_uploaded)%></span>
(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)
</span>

View File

@ -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("已上传"+"<span id=\"count\">"+count+"</span>"+"个文件");
}

View File

@ -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 %>

View File

@ -29,15 +29,3 @@
</div>
</div>
</div>
<%= debug(params) if Rails.env.development? %>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-46523987-1', 'trustie.net');
ga('send', 'pageview');
</script>

View File

@ -244,7 +244,6 @@
</div>
<!--gcm move render down-->
</div>
<div id="ajax-indicator" style="display:none;">
<span><%= l(:label_loading) %></span>
</div>

View File

@ -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: 上移

View File

@ -7,14 +7,14 @@ function addFile(inputEl, file, eagerUpload) {
var attachmentId = addFile.nextAttachmentId++;
var fileSpan = $('<span>', { id: 'attachments_' + attachmentId });
var fileSpan = $('<span>', { 'id': 'attachments_' + attachmentId, 'class':'attachment' });
fileSpan.append(
$('<input>', { type: 'text', 'class': 'filename readonly', name: 'attachments[' + attachmentId + '][filename]', readonly: 'readonly'} ).val(file.name),
$('<input>', { type: 'text', 'class': 'description', name: 'attachments[' + attachmentId + '][description]', maxlength: 255, placeholder: $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').attr({ href: "#", 'class': 'remove-upload', 'data-confirm' : "您确定要删除吗?" }).click(removeFile).toggle(!eagerUpload)
$('<input>', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name),
$('<input>', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 255, 'placeholder': $(inputEl).data('description-placeholder') } ).toggle(!eagerUpload),
$('<a>&nbsp</a>').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("已上传"+"<span id=\"count\">"+count+"</span>"+"个文件");
if(count>=1){
var add_attachs=$('.add_attachment');
var delete_all=$('.remove_all');
if(delete_all.length<1){
add_attachs.append($("<a>&nbsp</a>").attr({"href":"javascript:void(0)", 'class': 'remove_all',"onclick": "removeAll()"}));
}
}
//gcm
}
var progressSpan = $('<div>').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({

View File

@ -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; }

View File

@ -982,7 +982,8 @@ hr
}
p
{
font-size: 13px
font-size: 13px;
position:relative;/*gcm*/
}
/*end*/
div.issue