|
|
@ -154,6 +154,73 @@ function addFile(inputEl, file, eagerUpload,btnId) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addFile.nextAttachmentId = 1;
|
|
|
|
addFile.nextAttachmentId = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addReviseFile(inputEl, file, eagerUpload,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var attachments_frame = '#attachments_fields';
|
|
|
|
|
|
|
|
if ($(attachments_frame).children().length < 30) {
|
|
|
|
|
|
|
|
deleteallfiles = $(inputEl).data('deleteAllFiles');
|
|
|
|
|
|
|
|
var attachmentId = addFile.nextAttachmentId++;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileSpan = $('<span>', {
|
|
|
|
|
|
|
|
'id': 'attachments_' + attachmentId,
|
|
|
|
|
|
|
|
'class': 'attachment'
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fileSpan.append(
|
|
|
|
|
|
|
|
$('<input>', {
|
|
|
|
|
|
|
|
'type': 'text',
|
|
|
|
|
|
|
|
'class': 'upload_filename readonly',
|
|
|
|
|
|
|
|
'name': 'attachments[' + attachmentId + '][filename]',
|
|
|
|
|
|
|
|
'readonly': 'readonly'
|
|
|
|
|
|
|
|
}).val(file.name),
|
|
|
|
|
|
|
|
// $('<input>', {
|
|
|
|
|
|
|
|
// 'type': 'text',
|
|
|
|
|
|
|
|
// 'class': 'description',
|
|
|
|
|
|
|
|
// 'name': 'attachments[' + attachmentId + '][description]',
|
|
|
|
|
|
|
|
// 'maxlength': 254,
|
|
|
|
|
|
|
|
// 'placeholder': $(inputEl).data('descriptionPlaceholder')
|
|
|
|
|
|
|
|
// }).toggle(!eagerUpload),
|
|
|
|
|
|
|
|
// $('<span >' + $(inputEl).data('fieldIsPublic') + ':</span>').attr({
|
|
|
|
|
|
|
|
// 'class': 'ispublic-label'
|
|
|
|
|
|
|
|
// }),
|
|
|
|
|
|
|
|
// $('<input>', {
|
|
|
|
|
|
|
|
// 'type': 'checkbox',
|
|
|
|
|
|
|
|
// 'class': 'is_public_checkbox',
|
|
|
|
|
|
|
|
// 'value': 1,
|
|
|
|
|
|
|
|
// 'name': 'attachments[' + attachmentId + '][is_public_checkbox]',
|
|
|
|
|
|
|
|
// checked: 'checked'
|
|
|
|
|
|
|
|
// }).toggle(!eagerUpload),
|
|
|
|
|
|
|
|
$('<a> </a>').attr({
|
|
|
|
|
|
|
|
'href': "#",
|
|
|
|
|
|
|
|
'class': 'remove-upload'
|
|
|
|
|
|
|
|
}).click(function() {
|
|
|
|
|
|
|
|
if (confirm($(inputEl).data('areYouSure'))) {
|
|
|
|
|
|
|
|
removeReviseFile();
|
|
|
|
|
|
|
|
if (!eagerUpload) {
|
|
|
|
|
|
|
|
(function(e) {
|
|
|
|
|
|
|
|
reload(e);
|
|
|
|
|
|
|
|
})(fileSpan);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).toggle(!eagerUpload),
|
|
|
|
|
|
|
|
$('<div>', {
|
|
|
|
|
|
|
|
'class': 'div_attachments',
|
|
|
|
|
|
|
|
'name': 'div_' + 'attachments_' + attachmentId
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
).appendTo('#attachments_fields');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$("#uploadReviseBox").addClass('disable_link');
|
|
|
|
|
|
|
|
$("#choose_revise_attach").attr("onclick","return false;");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (eagerUpload) {
|
|
|
|
|
|
|
|
ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return attachmentId;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
|
|
|
|
function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
|
|
|
|
//上传开始调用函数
|
|
|
|
//上传开始调用函数
|
|
|
|
function onLoadstart(e) {
|
|
|
|
function onLoadstart(e) {
|
|
|
@ -293,6 +360,13 @@ function removeFile() {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function removeReviseFile() {
|
|
|
|
|
|
|
|
$(this).parent('span').remove();
|
|
|
|
|
|
|
|
$("#uploadReviseBox").removeClass('disable_link');
|
|
|
|
|
|
|
|
$("#choose_revise_attach").attr("onclick","_file.click();");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//gcm delete all file
|
|
|
|
//gcm delete all file
|
|
|
|
//modify by yutao 2015-5-14 <20><>1<EFBFBD><31>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>ϴ<EFBFBD><CFB4>ؼ<EFBFBD>ʱ<EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>bug <20>ʸ<EFBFBD>֮ start
|
|
|
|
//modify by yutao 2015-5-14 <20><>1<EFBFBD><31>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>ڶ<EFBFBD><DAB6><EFBFBD>ϴ<EFBFBD><CFB4>ؼ<EFBFBD>ʱ<EFBFBD>˿<EFBFBD><CBBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>bug <20>ʸ<EFBFBD>֮ start
|
|
|
|
function removeAll(containerid) {
|
|
|
|
function removeAll(containerid) {
|
|
|
@ -346,6 +420,30 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addReviseInputFiles(inputEl,btnId) {
|
|
|
|
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
|
|
|
|
if (inputEl.files) {
|
|
|
|
|
|
|
|
uploadAndAttachReviseFiles(inputEl.files, inputEl,btnId);
|
|
|
|
|
|
|
|
// $(inputEl).remove();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// browser not supporting the file API, upload on form submission
|
|
|
|
|
|
|
|
var attachmentId;
|
|
|
|
|
|
|
|
var aFilename = inputEl.value.split(/\/|\\/);
|
|
|
|
|
|
|
|
var count = $('#attachments_fields>span').length;
|
|
|
|
|
|
|
|
attachmentId = addReviseFile(inputEl, {
|
|
|
|
|
|
|
|
name: aFilename[aFilename.length - 1]
|
|
|
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
if (attachmentId) {
|
|
|
|
|
|
|
|
$(inputEl).attr({
|
|
|
|
|
|
|
|
name: 'attachments[' + attachmentId + '][file]'
|
|
|
|
|
|
|
|
}).hide();
|
|
|
|
|
|
|
|
if (count <= 0) count = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function addInputFiles(inputEl,btnId) {
|
|
|
|
function addInputFiles(inputEl,btnId) {
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
if (inputEl.files) {
|
|
|
|
if (inputEl.files) {
|
|
|
@ -405,6 +503,26 @@ function addInputFiles_board(inputEl, id,btnId) {
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function uploadAndAttachReviseFiles(files, inputEl,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
|
|
|
|
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sizeExceeded = false;
|
|
|
|
|
|
|
|
$.each(files, function() {
|
|
|
|
|
|
|
|
if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {
|
|
|
|
|
|
|
|
sizeExceeded = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (sizeExceeded) {
|
|
|
|
|
|
|
|
window.alert(maxFileSizeExceeded);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$.each(files, function() {
|
|
|
|
|
|
|
|
addReviseFile(inputEl, this, true,btnId);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function uploadAndAttachFiles(files, inputEl,btnId) {
|
|
|
|
function uploadAndAttachFiles(files, inputEl,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|