|
|
|
@ -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> </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> </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> </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({
|
|
|
|
|