|
|
|
@ -1,8 +1,7 @@
|
|
|
|
|
/* Redmine - project management software
|
|
|
|
|
Copyright (C) 2006-2013 Jean-Philippe Lang */
|
|
|
|
|
|
|
|
|
|
function postUpMsg(attachmentId)
|
|
|
|
|
{
|
|
|
|
|
function postUpMsg(attachmentId) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: '/attachments/renderTag',
|
|
|
|
|
type: "GET",
|
|
|
|
@ -30,28 +29,57 @@ function addFile_board(inputEl, file, eagerUpload, id) {
|
|
|
|
|
deleteallfiles = $(inputEl).data('deleteAllFiles');
|
|
|
|
|
var attachmentId = addFile.nextAttachmentId++;
|
|
|
|
|
|
|
|
|
|
var fileSpan = $('<span>', { 'id': 'attachments_' + attachmentId, 'class':'attachment' });
|
|
|
|
|
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': 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', 'data-containerid':id }).click(function(){
|
|
|
|
|
if(confirm($(inputEl).data('areYouSure'))){
|
|
|
|
|
$('<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': 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',
|
|
|
|
|
'data-containerid': id
|
|
|
|
|
}).click(function() {
|
|
|
|
|
if (confirm($(inputEl).data('areYouSure'))) {
|
|
|
|
|
removeFile();
|
|
|
|
|
if(!eagerUpload){
|
|
|
|
|
(function(e){
|
|
|
|
|
if (!eagerUpload) {
|
|
|
|
|
(function(e) {
|
|
|
|
|
reload(e);
|
|
|
|
|
})(fileSpan);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).toggle(!eagerUpload),
|
|
|
|
|
$('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
|
|
|
|
|
$('<div>', {
|
|
|
|
|
'class': 'div_attachments',
|
|
|
|
|
'name': 'div_' + 'attachments_' + attachmentId
|
|
|
|
|
})
|
|
|
|
|
).appendTo(attachments_frame);
|
|
|
|
|
|
|
|
|
|
if(eagerUpload) {
|
|
|
|
|
if (eagerUpload) {
|
|
|
|
|
ajaxUpload(file, attachmentId, fileSpan, inputEl);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -59,6 +87,7 @@ function addFile_board(inputEl, file, eagerUpload, id) {
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addFile(inputEl, file, eagerUpload) {
|
|
|
|
|
|
|
|
|
|
var attachments_frame = '#attachments_fields';
|
|
|
|
@ -66,28 +95,56 @@ function addFile(inputEl, file, eagerUpload) {
|
|
|
|
|
deleteallfiles = $(inputEl).data('deleteAllFiles');
|
|
|
|
|
var attachmentId = addFile.nextAttachmentId++;
|
|
|
|
|
|
|
|
|
|
var fileSpan = $('<span>', { 'id': 'attachments_' + attachmentId, 'class':'attachment' });
|
|
|
|
|
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': 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'))){
|
|
|
|
|
$('<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': 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'))) {
|
|
|
|
|
removeFile();
|
|
|
|
|
if(!eagerUpload){
|
|
|
|
|
(function(e){
|
|
|
|
|
if (!eagerUpload) {
|
|
|
|
|
(function(e) {
|
|
|
|
|
reload(e);
|
|
|
|
|
})(fileSpan);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).toggle(!eagerUpload),
|
|
|
|
|
$('<div>', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
|
|
|
|
|
$('<div>', {
|
|
|
|
|
'class': 'div_attachments',
|
|
|
|
|
'name': 'div_' + 'attachments_' + attachmentId
|
|
|
|
|
})
|
|
|
|
|
).appendTo('#attachments_fields');
|
|
|
|
|
|
|
|
|
|
if(eagerUpload) {
|
|
|
|
|
if (eagerUpload) {
|
|
|
|
|
ajaxUpload(file, attachmentId, fileSpan, inputEl);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -106,8 +163,8 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onProgress(e) {
|
|
|
|
|
if(e.lengthComputable) {
|
|
|
|
|
this.progressbar( 'value', e.loaded * 100 / e.total );
|
|
|
|
|
if (e.lengthComputable) {
|
|
|
|
|
this.progressbar('value', e.loaded * 100 / e.total);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -116,18 +173,17 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
|
ajaxUpload.uploading++;
|
|
|
|
|
|
|
|
|
|
uploadBlob(file, $(inputEl).data('upload-path'), attachmentId, {
|
|
|
|
|
loadstartEventHandler: onLoadstart.bind(progressSpan),
|
|
|
|
|
progressEventHandler: onProgress.bind(progressSpan)
|
|
|
|
|
})
|
|
|
|
|
loadstartEventHandler: onLoadstart.bind(progressSpan),
|
|
|
|
|
progressEventHandler: onProgress.bind(progressSpan)
|
|
|
|
|
})
|
|
|
|
|
.done(function(result) {
|
|
|
|
|
progressSpan.progressbar( 'value', 100 ).remove();
|
|
|
|
|
progressSpan.progressbar('value', 100).remove();
|
|
|
|
|
fileSpan.find('input.description, a').css('display', 'inline-block');
|
|
|
|
|
fileSpan.find('input.is_public_checkbox, a').css('display', 'inline-block');
|
|
|
|
|
})
|
|
|
|
|
.fail(function(result) {
|
|
|
|
|
progressSpan.text(result.statusText);
|
|
|
|
|
if($("#network_issue"))
|
|
|
|
|
{
|
|
|
|
|
if ($("#network_issue")) {
|
|
|
|
|
$("#network_issue").show();
|
|
|
|
|
}
|
|
|
|
|
}).always(function() {
|
|
|
|
@ -143,33 +199,37 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
|
//gcm files count and add delete_all link
|
|
|
|
|
|
|
|
|
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
|
|
|
|
|
var containerid=$(inputEl).data('containerid');
|
|
|
|
|
if(containerid==undefined){
|
|
|
|
|
var count=$('#attachments_fields>span').length;
|
|
|
|
|
$('#upload_file_count').html("<span id=\"count\">"+count+"</span>"+$(inputEl).data('fileCount'));
|
|
|
|
|
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()"}));
|
|
|
|
|
var containerid = $(inputEl).data('containerid');
|
|
|
|
|
if (containerid == undefined) {
|
|
|
|
|
var count = $('#attachments_fields>span').length;
|
|
|
|
|
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
|
|
|
|
|
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()"
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
var count=$('#attachments_fields'+containerid+'>span').length;
|
|
|
|
|
$('#upload_file_count'+containerid).html("<span id=\"count\">"+count+"</span>"+$(inputEl).data('fileCount'));
|
|
|
|
|
if(count>=1){
|
|
|
|
|
var add_attachs=$('.add_attachment').filter(function(index){
|
|
|
|
|
return $(this).data('containerid')==containerid;
|
|
|
|
|
} else {
|
|
|
|
|
var count = $('#attachments_fields' + containerid + '>span').length;
|
|
|
|
|
$('#upload_file_count' + containerid).html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
|
|
|
|
|
if (count >= 1) {
|
|
|
|
|
var add_attachs = $('.add_attachment').filter(function(index) {
|
|
|
|
|
return $(this).data('containerid') == containerid;
|
|
|
|
|
});
|
|
|
|
|
var delete_all=$('.remove_all').filter(function(index){
|
|
|
|
|
return $(this).data('containerid')==containerid;
|
|
|
|
|
var delete_all = $('.remove_all').filter(function(index) {
|
|
|
|
|
return $(this).data('containerid') == containerid;
|
|
|
|
|
});
|
|
|
|
|
if(delete_all.length<1){
|
|
|
|
|
if (delete_all.length < 1) {
|
|
|
|
|
add_attachs.append($("<a> </a>").attr({
|
|
|
|
|
"href":"javascript:void(0)",
|
|
|
|
|
"href": "javascript:void(0)",
|
|
|
|
|
'class': 'remove_all',
|
|
|
|
|
'data-containerid': containerid,
|
|
|
|
|
"onclick": "removeAll('"+containerid+"')"
|
|
|
|
|
"onclick": "removeAll('" + containerid + "')"
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -186,7 +246,7 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
else
|
|
|
|
|
$(inputEl).parents('form').queue('upload', actualUpload.bind(this, file, attachmentId, fileSpan, inputEl));
|
|
|
|
@ -201,23 +261,23 @@ function removeFile() {
|
|
|
|
|
|
|
|
|
|
//gcm delete all file
|
|
|
|
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 start
|
|
|
|
|
function removeAll(containerid){
|
|
|
|
|
if(confirm(deleteallfiles)){
|
|
|
|
|
if(containerid==undefined){
|
|
|
|
|
$(".remove-upload").removeAttr("data-confirm");
|
|
|
|
|
$(".remove-upload").click();
|
|
|
|
|
}else{
|
|
|
|
|
var arr = $(".remove-upload").filter(function(){
|
|
|
|
|
return $(this).data('containerid')==containerid;
|
|
|
|
|
});
|
|
|
|
|
arr.removeAttr("data-confirm");
|
|
|
|
|
arr.click();
|
|
|
|
|
function removeAll(containerid) {
|
|
|
|
|
if (confirm(deleteallfiles)) {
|
|
|
|
|
if (containerid == undefined) {
|
|
|
|
|
$(".remove-upload").removeAttr("data-confirm");
|
|
|
|
|
$(".remove-upload").click();
|
|
|
|
|
} else {
|
|
|
|
|
var arr = $(".remove-upload").filter(function() {
|
|
|
|
|
return $(this).data('containerid') == containerid;
|
|
|
|
|
});
|
|
|
|
|
arr.removeAttr("data-confirm");
|
|
|
|
|
arr.click();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// return false;
|
|
|
|
|
}
|
|
|
|
|
// return false;
|
|
|
|
|
}
|
|
|
|
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
|
|
|
|
|
//gcm
|
|
|
|
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
|
|
|
|
|
//gcm
|
|
|
|
|
|
|
|
|
|
function uploadBlob(blob, uploadUrl, attachmentId, options) {
|
|
|
|
|
|
|
|
|
@ -225,9 +285,9 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
|
|
|
|
|
loadstartEventHandler: $.noop,
|
|
|
|
|
progressEventHandler: $.noop
|
|
|
|
|
}, options);
|
|
|
|
|
if(uploadUrl.indexOf('?') > 0){
|
|
|
|
|
if (uploadUrl.indexOf('?') > 0) {
|
|
|
|
|
uploadUrl = uploadUrl + '&attachment_id=' + attachmentId;
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
uploadUrl = uploadUrl + '?attachment_id=' + attachmentId;
|
|
|
|
|
}
|
|
|
|
|
if (blob instanceof window.File) {
|
|
|
|
@ -254,7 +314,6 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) {
|
|
|
|
|
|
|
|
|
|
function addInputFiles(inputEl) {
|
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
|
|
|
|
|
|
if (inputEl.files) {
|
|
|
|
|
// upload files using ajax
|
|
|
|
|
uploadAndAttachFiles(inputEl.files, inputEl);
|
|
|
|
@ -263,15 +322,22 @@ function addInputFiles(inputEl) {
|
|
|
|
|
// browser not supporting the file API, upload on form submission
|
|
|
|
|
var attachmentId;
|
|
|
|
|
var aFilename = inputEl.value.split(/\/|\\/);
|
|
|
|
|
attachmentId = addFile(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false);
|
|
|
|
|
var count = $('#attachments_fields>span').length;
|
|
|
|
|
attachmentId = addFile(inputEl, {
|
|
|
|
|
name: aFilename[aFilename.length - 1]
|
|
|
|
|
}, false);
|
|
|
|
|
if (attachmentId) {
|
|
|
|
|
$(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]'}).hide();
|
|
|
|
|
$('#upload_file_count').html("<span id=\"count\">"+count+"</span>"+$(inputEl).data('fileCount'));
|
|
|
|
|
$(inputEl).attr({
|
|
|
|
|
name: 'attachments[' + attachmentId + '][file]'
|
|
|
|
|
}).hide();
|
|
|
|
|
if (count <= 0) count = 1;
|
|
|
|
|
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addInputFiles_board(inputEl, id) {
|
|
|
|
|
// var clearedFileInput = $(inputEl).clone().val('');
|
|
|
|
|
|
|
|
|
@ -283,15 +349,20 @@ function addInputFiles_board(inputEl, id) {
|
|
|
|
|
// browser not supporting the file API, upload on form submission
|
|
|
|
|
var attachmentId;
|
|
|
|
|
var aFilename = inputEl.value.split(/\/|\\/);
|
|
|
|
|
attachmentId = addFile_board(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false, id);
|
|
|
|
|
attachmentId = addFile_board(inputEl, {
|
|
|
|
|
name: aFilename[aFilename.length - 1]
|
|
|
|
|
}, false, id);
|
|
|
|
|
if (attachmentId) {
|
|
|
|
|
$(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]'}).hide();
|
|
|
|
|
$('#upload_file_count').html("<span id=\"count\">"+count+"</span>"+$(inputEl).data('fileCount'));
|
|
|
|
|
$(inputEl).attr({
|
|
|
|
|
name: 'attachments[' + attachmentId + '][file]'
|
|
|
|
|
}).hide();
|
|
|
|
|
$('#upload_file_count').html("<span id=\"count\">" + count + "</span>" + $(inputEl).data('fileCount'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//clearedFileInput.insertAfter('#attachments_fields');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function uploadAndAttachFiles(files, inputEl) {
|
|
|
|
|
|
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
@ -299,14 +370,19 @@ function uploadAndAttachFiles(files, inputEl) {
|
|
|
|
|
|
|
|
|
|
var sizeExceeded = false;
|
|
|
|
|
$.each(files, function() {
|
|
|
|
|
if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;}
|
|
|
|
|
if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {
|
|
|
|
|
sizeExceeded = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (sizeExceeded) {
|
|
|
|
|
window.alert(maxFileSizeExceeded);
|
|
|
|
|
} else {
|
|
|
|
|
$.each(files, function() {addFile(inputEl, this, true);});
|
|
|
|
|
$.each(files, function() {
|
|
|
|
|
addFile(inputEl, this, true);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function uploadAndAttachFiles_board(files, inputEl, id) {
|
|
|
|
|
|
|
|
|
|
var maxFileSize = $(inputEl).data('max-file-size');
|
|
|
|
@ -314,14 +390,19 @@ function uploadAndAttachFiles_board(files, inputEl, id) {
|
|
|
|
|
|
|
|
|
|
var sizeExceeded = false;
|
|
|
|
|
$.each(files, function() {
|
|
|
|
|
if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;}
|
|
|
|
|
if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {
|
|
|
|
|
sizeExceeded = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (sizeExceeded) {
|
|
|
|
|
window.alert(maxFileSizeExceeded);
|
|
|
|
|
} else {
|
|
|
|
|
$.each(files, function() {addFile_board(inputEl, this, true, id);});
|
|
|
|
|
$.each(files, function() {
|
|
|
|
|
addFile_board(inputEl, this, true, id);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleFileDropEvent(e) {
|
|
|
|
|
|
|
|
|
|
$(this).removeClass('fileover');
|
|
|
|
@ -345,7 +426,9 @@ function dragOutHandler(e) {
|
|
|
|
|
function setupFileDrop() {
|
|
|
|
|
if (window.File && window.FileList && window.ProgressEvent && window.FormData) {
|
|
|
|
|
|
|
|
|
|
$.event.fixHooks.drop = { props: [ 'dataTransfer' ] };
|
|
|
|
|
$.event.fixHooks.drop = {
|
|
|
|
|
props: ['dataTransfer']
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$('form div.box').has('input:file').each(function() {
|
|
|
|
|
$(this).on({
|
|
|
|
@ -358,18 +441,18 @@ function setupFileDrop() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).ready(setupFileDrop);
|
|
|
|
|
$(function(){
|
|
|
|
|
$(function() {
|
|
|
|
|
$(".file_selector").each(function() {
|
|
|
|
|
deleteallfiles = $(this).data('deleteAllFiles');
|
|
|
|
|
var containerid = $(this).data('containerid');
|
|
|
|
|
if (containerid == undefined)containerid = '';
|
|
|
|
|
if (containerid == undefined) containerid = '';
|
|
|
|
|
var count = $('#attachments_fields' + containerid + '>span').length;
|
|
|
|
|
if (count >= 1) {
|
|
|
|
|
$('#upload_file_count' + containerid).html("<span id=\"count\">" + count + "</span>" + $(this).data('fileCount'));
|
|
|
|
|
var add_attachs = $('.add_attachment').filter(function (index) {
|
|
|
|
|
var add_attachs = $('.add_attachment').filter(function(index) {
|
|
|
|
|
return $(this).data('containerid') == containerid;
|
|
|
|
|
});
|
|
|
|
|
var delete_all = $('.remove_all').filter(function (index) {
|
|
|
|
|
var delete_all = $('.remove_all').filter(function(index) {
|
|
|
|
|
return $(this).data('containerid') == containerid;
|
|
|
|
|
});
|
|
|
|
|
if (delete_all.length < 1) {
|
|
|
|
@ -383,4 +466,4 @@ $(function(){
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|