109 lines
3.3 KiB
JavaScript
109 lines
3.3 KiB
JavaScript
function renderUploaderFiler(index, the_file, selector, uploadRoute, extensions, chooseText, that) {
|
|
$(selector + ' input[name="files[]"]').filer({
|
|
showThumbs: true,
|
|
addMore: true,
|
|
allowDuplicates: false,
|
|
limit: 1,
|
|
maxSize: null,
|
|
changeInput: '<div class="jFiler-input-dragDrop nomargin-bottom contract-file-upload required pointer p-2 w-100">\
|
|
<div class="jFiler-input-inner">\
|
|
<div class="jFiler-input-icon">\
|
|
<i class="icon-jfi-folder"></i>\
|
|
</div>\
|
|
<div class="jFiler-input-text">\
|
|
<h3>'+chooseText+'</h3>\
|
|
</div>\
|
|
</div>\
|
|
</div>',
|
|
extensions: extensions,
|
|
uploadFile: {
|
|
url: laroute.route(uploadRoute),
|
|
data: {
|
|
action: 'upload',
|
|
extensions: extensions,
|
|
sub_folder: that.subFolder
|
|
},
|
|
type: 'POST',
|
|
enctype: 'multipart/form-data',
|
|
synchron: true,
|
|
beforeSend: function() {
|
|
that.activeJConfirmButtons(false);
|
|
$(selector + ' .contract-file-upload').hide();
|
|
},
|
|
success: function(data, itemEl, listEl, boxEl, newInputEl, inputEl, id) {
|
|
// console.log('upload');
|
|
// console.log(data);
|
|
// console.log(id);
|
|
// var index = getIndexOf(that.currentSelected, the_file.id);
|
|
// var parent = itemEl.find(".jFiler-jProgressBar").parent();
|
|
var new_file_name = JSON.parse(data);
|
|
var filerKit = inputEl.prop("jFiler");
|
|
filerKit.files_list[id].name = new_file_name;
|
|
itemEl.find(".jFiler-jProgressBar").fadeOut("slow");
|
|
that.createFile(itemEl, index, new_file_name);
|
|
},
|
|
error: function(el) {
|
|
el.find(".jFiler-jProgressBar").fadeOut("slow");
|
|
el.find('.jFiler-item-others').html('\
|
|
<span><i class="glyph-icon icon-file"></i> <b>'+translate.getText.type+':</b> '+strtoupper(new_file_name.extension)+'</span>\
|
|
<div class="current-status text-error"><i class="icon-jfi-minus-circle"></i></div>\
|
|
');
|
|
},
|
|
statusCode: null,
|
|
onProgress: null,
|
|
onComplete: function() {
|
|
that.activeJConfirmButtons(true);
|
|
}
|
|
},
|
|
files: null,
|
|
clipBoardPaste: true,
|
|
excludeName: null,
|
|
beforeRender: null,
|
|
afterRender: null,
|
|
beforeShow: null,
|
|
beforeSelect: null,
|
|
onSelect: null,
|
|
afterShow: null,
|
|
onRemove: function(itemEl, file, id, listEl, boxEl, newInputEl, inputEl) {
|
|
var index = getIndexOf(that.currentSelected, the_file.id);
|
|
that.currentSelected[index].pdfFile = {};
|
|
$(selector + ' .contract-file-upload').show();
|
|
},
|
|
onEmpty: null,
|
|
options: null,
|
|
dialogs: {
|
|
alert: function(text) {
|
|
$.dialog({ title: translate.getText.warning, content: text });
|
|
},
|
|
confirm: function (text, callback) {
|
|
$.confirm({
|
|
title: translate.getText.warning,
|
|
content: text,
|
|
buttons: {
|
|
confirm: {
|
|
text: translate.getText.confirm,
|
|
btnClass: 'btn-danger',
|
|
action: function() {
|
|
callback()
|
|
}
|
|
},
|
|
cancel: {
|
|
text: translate.getText.cancel
|
|
}
|
|
}
|
|
});
|
|
}
|
|
},
|
|
captions: {
|
|
button: translate.getText.choose_files,
|
|
feedback: "",
|
|
feedback2: translate.getText.selected_files,
|
|
removeConfirmation: translate.getText.are_you_sure_you_want_to_remove_this_file,
|
|
errors: {
|
|
filesLimit: translate.getText.file_number_authorized+": <b>{{fi-limit}}</b>",
|
|
filesType: translate.getText.file_extension_authorized+": <b>.{{fi-extensions}}</b>",
|
|
filesSize: translate.getText.file_max_size_authorized+": <b>{{fi-maxSize}} MB.</b>"
|
|
}
|
|
}
|
|
});
|
|
} |