|
|
@ -22,7 +22,7 @@ function reload(fileSpan) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function addFile_board(inputEl, file, eagerUpload, id) {
|
|
|
|
function addFile_board(inputEl, file, eagerUpload, id,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
var attachments_frame = '#attachments_fields' + id;
|
|
|
|
var attachments_frame = '#attachments_fields' + id;
|
|
|
|
if ($(attachments_frame).children().length < 30) {
|
|
|
|
if ($(attachments_frame).children().length < 30) {
|
|
|
@ -80,7 +80,7 @@ function addFile_board(inputEl, file, eagerUpload, id) {
|
|
|
|
).appendTo(attachments_frame);
|
|
|
|
).appendTo(attachments_frame);
|
|
|
|
|
|
|
|
|
|
|
|
if (eagerUpload) {
|
|
|
|
if (eagerUpload) {
|
|
|
|
ajaxUpload(file, attachmentId, fileSpan, inputEl);
|
|
|
|
ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return attachmentId;
|
|
|
|
return attachmentId;
|
|
|
@ -88,7 +88,7 @@ function addFile_board(inputEl, file, eagerUpload, id) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function addFile(inputEl, file, eagerUpload) {
|
|
|
|
function addFile(inputEl, file, eagerUpload,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
var attachments_frame = '#attachments_fields';
|
|
|
|
var attachments_frame = '#attachments_fields';
|
|
|
|
if ($(attachments_frame).children().length < 30) {
|
|
|
|
if ($(attachments_frame).children().length < 30) {
|
|
|
@ -145,7 +145,7 @@ function addFile(inputEl, file, eagerUpload) {
|
|
|
|
).appendTo('#attachments_fields');
|
|
|
|
).appendTo('#attachments_fields');
|
|
|
|
|
|
|
|
|
|
|
|
if (eagerUpload) {
|
|
|
|
if (eagerUpload) {
|
|
|
|
ajaxUpload(file, attachmentId, fileSpan, inputEl);
|
|
|
|
ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return attachmentId;
|
|
|
|
return attachmentId;
|
|
|
@ -154,7 +154,7 @@ function addFile(inputEl, file, eagerUpload) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
addFile.nextAttachmentId = 1;
|
|
|
|
addFile.nextAttachmentId = 1;
|
|
|
|
|
|
|
|
|
|
|
|
function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
function ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
function onLoadstart(e) {
|
|
|
|
function onLoadstart(e) {
|
|
|
|
fileSpan.removeClass('ajax-waiting');
|
|
|
|
fileSpan.removeClass('ajax-waiting');
|
|
|
@ -168,7 +168,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function actualUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
function actualUpload(file, attachmentId, fileSpan, inputEl,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
ajaxUpload.uploading++;
|
|
|
|
ajaxUpload.uploading++;
|
|
|
|
|
|
|
|
|
|
|
@ -178,6 +178,23 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.done(function(result) {
|
|
|
|
.done(function(result) {
|
|
|
|
progressSpan.progressbar('value', 100).remove();
|
|
|
|
progressSpan.progressbar('value', 100).remove();
|
|
|
|
|
|
|
|
var containerid = $(inputEl).data('containerid');
|
|
|
|
|
|
|
|
console.log($(inputEl))
|
|
|
|
|
|
|
|
if(containerid == undefined ){
|
|
|
|
|
|
|
|
var count = $('#attachments_fields>span').length;
|
|
|
|
|
|
|
|
$('#'+btnId).removeAttr("disabled");
|
|
|
|
|
|
|
|
$('#'+btnId).val('确定')
|
|
|
|
|
|
|
|
$('#'+btnId).css('background-color','#269ac9')
|
|
|
|
|
|
|
|
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
$('#'+btnId).removeAttr("disabled");
|
|
|
|
|
|
|
|
$('#'+btnId).val('确定')
|
|
|
|
|
|
|
|
$('#'+btnId).css('background-color','#269ac9')
|
|
|
|
|
|
|
|
var count = $('#attachments_fields' + containerid + '>span').length;
|
|
|
|
|
|
|
|
$('#upload_file_count' + containerid).html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fileSpan.find('input.description, a').css('display', 'inline-block');
|
|
|
|
fileSpan.find('input.description, a').css('display', 'inline-block');
|
|
|
|
fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
|
|
|
|
fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -202,7 +219,10 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
var containerid = $(inputEl).data('containerid');
|
|
|
|
var containerid = $(inputEl).data('containerid');
|
|
|
|
if (containerid == undefined) {
|
|
|
|
if (containerid == undefined) {
|
|
|
|
var count = $('#attachments_fields>span').length;
|
|
|
|
var count = $('#attachments_fields>span').length;
|
|
|
|
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
|
|
|
|
$('#'+btnId).attr("disabled",true);
|
|
|
|
|
|
|
|
$('#'+btnId).val('提交中');
|
|
|
|
|
|
|
|
$('#'+btnId).css('background-color','#c1c1c1')
|
|
|
|
|
|
|
|
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('lebelFileUploding'));
|
|
|
|
if (count >= 1) {
|
|
|
|
if (count >= 1) {
|
|
|
|
var add_attachs = $('.add_attachment');
|
|
|
|
var add_attachs = $('.add_attachment');
|
|
|
|
var delete_all = $('.remove_all');
|
|
|
|
var delete_all = $('.remove_all');
|
|
|
@ -216,7 +236,10 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
var count = $('#attachments_fields' + containerid + '>span').length;
|
|
|
|
var count = $('#attachments_fields' + containerid + '>span').length;
|
|
|
|
$('#upload_file_count' + containerid).html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
|
|
|
|
$('#'+btnId).attr("disabled",true);
|
|
|
|
|
|
|
|
$('#'+btnId).val('提交中');
|
|
|
|
|
|
|
|
$('#'+btnId).css('background-color','#c1c1c1')
|
|
|
|
|
|
|
|
$('#upload_file_count' + containerid).html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('lebelFileUploding'));
|
|
|
|
if (count >= 1) {
|
|
|
|
if (count >= 1) {
|
|
|
|
var add_attachs = $('.add_attachment').filter(function(index) {
|
|
|
|
var add_attachs = $('.add_attachment').filter(function(index) {
|
|
|
|
return $(this).data('containerid') == containerid;
|
|
|
|
return $(this).data('containerid') == containerid;
|
|
|
@ -240,14 +263,14 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var progressSpan = $('<div>').insertAfter(fileSpan.find('input.filename'));
|
|
|
|
var progressSpan = $('<div>').insertAfter(fileSpan.find('input.upload_filename'));
|
|
|
|
progressSpan.progressbar();
|
|
|
|
progressSpan.progressbar();
|
|
|
|
fileSpan.addClass('ajax-waiting');
|
|
|
|
fileSpan.addClass('ajax-waiting');
|
|
|
|
|
|
|
|
|
|
|
|
var maxSyncUpload = $(inputEl).data('max-concurrent-uploads');
|
|
|
|
var maxSyncUpload = $(inputEl).data('max-concurrent-uploads');
|
|
|
|
|
|
|
|
|
|
|
|
if (maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload)
|
|
|
|
if (maxSyncUpload == null || maxSyncUpload <= 0 || ajaxUpload.uploading < maxSyncUpload)
|
|
|
|
actualUpload(file, attachmentId, fileSpan, inputEl);
|
|
|
|
actualUpload(file, attachmentId, fileSpan, inputEl,btnId);
|
|
|
|
else
|
|
|
|
else
|
|
|
|
$(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl));
|
|
|
|
$(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -312,11 +335,11 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function addInputFiles(inputEl) {
|
|
|
|
function addInputFiles(inputEl,btnId) {
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
if (inputEl.files) {
|
|
|
|
if (inputEl.files) {
|
|
|
|
// upload files using ajax
|
|
|
|
// upload files using ajax
|
|
|
|
uploadAndAttachFiles(inputEl.files, inputEl);
|
|
|
|
uploadAndAttachFiles(inputEl.files, inputEl,btnId);
|
|
|
|
// $(inputEl).remove();
|
|
|
|
// $(inputEl).remove();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// browser not supporting the file API, upload on form submission
|
|
|
|
// browser not supporting the file API, upload on form submission
|
|
|
@ -338,12 +361,12 @@ function addInputFiles(inputEl) {
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function addInputFiles_board(inputEl, id) {
|
|
|
|
function addInputFiles_board(inputEl, id,btnId) {
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
|
|
|
|
|
|
|
|
if (inputEl.files) {
|
|
|
|
if (inputEl.files) {
|
|
|
|
// upload files using ajax
|
|
|
|
// upload files using ajax
|
|
|
|
uploadAndAttachFiles_board(inputEl.files, inputEl, id);
|
|
|
|
uploadAndAttachFiles_board(inputEl.files, inputEl, id,btnId);
|
|
|
|
// $(inputEl).remove();
|
|
|
|
// $(inputEl).remove();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// browser not supporting the file API, upload on form submission
|
|
|
|
// browser not supporting the file API, upload on form submission
|
|
|
@ -363,7 +386,7 @@ function addInputFiles_board(inputEl, id) {
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function uploadAndAttachFiles(files, inputEl) {
|
|
|
|
function uploadAndAttachFiles(files, inputEl,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
|
|
|
|
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
|
|
|
@ -378,12 +401,12 @@ function uploadAndAttachFiles(files, inputEl) {
|
|
|
|
window.alert(maxFileSizeExceeded);
|
|
|
|
window.alert(maxFileSizeExceeded);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$.each(files, function() {
|
|
|
|
$.each(files, function() {
|
|
|
|
addFile(inputEl, this, true);
|
|
|
|
addFile(inputEl, this, true,btnId);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function uploadAndAttachFiles_board(files, inputEl, id) {
|
|
|
|
function uploadAndAttachFiles_board(files, inputEl, id,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
|
|
|
|
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
|
|
|
@ -398,7 +421,7 @@ function uploadAndAttachFiles_board(files, inputEl, id) {
|
|
|
|
window.alert(maxFileSizeExceeded);
|
|
|
|
window.alert(maxFileSizeExceeded);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$.each(files, function() {
|
|
|
|
$.each(files, function() {
|
|
|
|
addFile_board(inputEl, this, true, id);
|
|
|
|
addFile_board(inputEl, this, true, id,btnId);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -471,10 +494,11 @@ $(function() {
|
|
|
|
//课程课件
|
|
|
|
//课程课件
|
|
|
|
function addInputFilesCourseSource(inputEl) {
|
|
|
|
function addInputFilesCourseSource(inputEl) {
|
|
|
|
checkBox = arguments[1] == 'public' ? false : true;
|
|
|
|
checkBox = arguments[1] == 'public' ? false : true;
|
|
|
|
|
|
|
|
btnId = arguments[2];
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
if (inputEl.files) {
|
|
|
|
if (inputEl.files) {
|
|
|
|
// upload files using ajax
|
|
|
|
// upload files using ajax
|
|
|
|
uploadAndAttachFilesCourseSource(inputEl.files, inputEl,checkBox);
|
|
|
|
uploadAndAttachFilesCourseSource(inputEl.files, inputEl,checkBox,btnId);
|
|
|
|
// $(inputEl).remove();
|
|
|
|
// $(inputEl).remove();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// browser not supporting the file API, upload on form submission
|
|
|
|
// browser not supporting the file API, upload on form submission
|
|
|
@ -496,7 +520,7 @@ function addInputFilesCourseSource(inputEl) {
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function uploadAndAttachFilesCourseSource(files, inputEl,checkBox) {
|
|
|
|
function uploadAndAttachFilesCourseSource(files, inputEl,checkBox,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
|
|
|
|
var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
|
|
|
@ -511,12 +535,12 @@ function uploadAndAttachFilesCourseSource(files, inputEl,checkBox) {
|
|
|
|
window.alert(maxFileSizeExceeded);
|
|
|
|
window.alert(maxFileSizeExceeded);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$.each(files, function() {
|
|
|
|
$.each(files, function() {
|
|
|
|
addFileCourseSource(inputEl, this, true,checkBox);
|
|
|
|
addFileCourseSource(inputEl, this, true,checkBox,btnId);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function addFileCourseSource(inputEl, file, eagerUpload,checkBox) {
|
|
|
|
function addFileCourseSource(inputEl, file, eagerUpload,checkBox,btnId) {
|
|
|
|
|
|
|
|
|
|
|
|
var attachments_frame = '#attachments_fields';
|
|
|
|
var attachments_frame = '#attachments_fields';
|
|
|
|
if ($(attachments_frame).children().length < 30) {
|
|
|
|
if ($(attachments_frame).children().length < 30) {
|
|
|
@ -595,7 +619,7 @@ function addFileCourseSource(inputEl, file, eagerUpload,checkBox) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (eagerUpload) {
|
|
|
|
if (eagerUpload) {
|
|
|
|
ajaxUpload(file, attachmentId, fileSpan, inputEl);
|
|
|
|
ajaxUpload(file, attachmentId, fileSpan, inputEl,btnId);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return attachmentId;
|
|
|
|
return attachmentId;
|
|
|
|