|
|
|
@ -37,7 +37,7 @@ function addFile_board(inputEl, file, eagerUpload, id) {
|
|
|
|
|
$('<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(){
|
|
|
|
|
$('<a> </a>').attr({ 'href': "#", 'class': 'remove-upload', 'data-containerid':id }).click(function(){
|
|
|
|
|
if(confirm($(inputEl).data('areYouSure'))){
|
|
|
|
|
removeFile();
|
|
|
|
|
if(!eagerUpload){
|
|
|
|
@ -142,6 +142,9 @@ 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){
|
|
|
|
@ -151,6 +154,27 @@ function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
|
|
|
|
|
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;
|
|
|
|
|
});
|
|
|
|
|
var delete_all=$('.remove_all').filter(function(index){
|
|
|
|
|
return $(this).data('containerid')==containerid;
|
|
|
|
|
});
|
|
|
|
|
if(delete_all.length<1){
|
|
|
|
|
add_attachs.append($("<a> </a>").attr({
|
|
|
|
|
"href":"javascript:void(0)",
|
|
|
|
|
'class': 'remove_all',
|
|
|
|
|
'data-containerid': containerid,
|
|
|
|
|
"onclick": "removeAll('"+containerid+"')"
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//gcm
|
|
|
|
|
|
|
|
|
@ -176,13 +200,23 @@ function removeFile() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//gcm delete all file
|
|
|
|
|
function removeAll(){
|
|
|
|
|
//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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// return false;
|
|
|
|
|
}
|
|
|
|
|
//modify by yutao 2015-5-14 当1个页面存在多个上传控件时此块代码存在bug 故改之 end
|
|
|
|
|
//gcm
|
|
|
|
|
|
|
|
|
|
function uploadBlob(blob, uploadUrl, attachmentId, options) {
|
|
|
|
@ -324,3 +358,29 @@ function setupFileDrop() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).ready(setupFileDrop);
|
|
|
|
|
$(function(){
|
|
|
|
|
$(".file_selector").each(function() {
|
|
|
|
|
deleteallfiles = $(this).data('deleteAllFiles');
|
|
|
|
|
var containerid = $(this).data('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) {
|
|
|
|
|
return $(this).data('containerid') == containerid;
|
|
|
|
|
});
|
|
|
|
|
var delete_all = $('.remove_all').filter(function (index) {
|
|
|
|
|
return $(this).data('containerid') == containerid;
|
|
|
|
|
});
|
|
|
|
|
if (delete_all.length < 1) {
|
|
|
|
|
add_attachs.append($("<a> </a>").attr({
|
|
|
|
|
"href": "javascript:void(0)",
|
|
|
|
|
'class': 'remove_all',
|
|
|
|
|
'data-containerid': containerid,
|
|
|
|
|
"onclick": "removeAll('" + containerid + "')"
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|