57 lines
2.3 KiB
JavaScript
57 lines
2.3 KiB
JavaScript
|
|
|
||
|
|
$(document).ready(function() {
|
||
|
|
|
||
|
|
$("#message_chat_form_files-edit").change(function(event){
|
||
|
|
var fileInput = document.getElementById("message_chat_form_files-edit");
|
||
|
|
var fileInputStatic = new Object();
|
||
|
|
/*const selectedFiles = fileInput.files;
|
||
|
|
console.log(selectedFiles);
|
||
|
|
console.log(fileInput.files);
|
||
|
|
console.log(typeof(fileInput.files));
|
||
|
|
console.log(typeof(fileInput.files[0]));*/
|
||
|
|
$("#files-info").empty();
|
||
|
|
$("#files-info").append('<dl id="files-info-list">');
|
||
|
|
for (var i = 0; i < fileInput.files.length; i++) {
|
||
|
|
fileInputStatic[i] = fileInput.files[i];
|
||
|
|
$("#files-info-list").append('<li style="margin: 4px 0">' + fileInput.files[i]['name'] + ' <a href="#" class="remove-file" data-ifile="' + i + '">⨉</a></li>');
|
||
|
|
}
|
||
|
|
|
||
|
|
$(".remove-file").click(function(event){
|
||
|
|
event.preventDefault();
|
||
|
|
var ifile = $(this).attr('data-ifile');
|
||
|
|
$("#files-info-list a[data-ifile=" + ifile + "]").parent().remove();
|
||
|
|
var fileInputBuffer = new DataTransfer();
|
||
|
|
|
||
|
|
delete fileInputStatic[ifile];
|
||
|
|
for(var k in fileInputStatic){
|
||
|
|
fileInputBuffer.items.add(fileInputStatic[k]);
|
||
|
|
}
|
||
|
|
fileInput.files = fileInputBuffer.files;
|
||
|
|
console.log(fileInputBuffer);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
$("#message_chat_form").submit(function(event){
|
||
|
|
$("#message_chat_form_submit-edit").html("Сообщение отправляется...");
|
||
|
|
$("#message_chat_form_submit-edit").attr('disabled', true);
|
||
|
|
});
|
||
|
|
|
||
|
|
if($("#message_chat_form_category-edit").val() == 'Другое'){
|
||
|
|
$("#message_chat_form_other_category-block").show();
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
$("#message_chat_form_other_category-block").hide();
|
||
|
|
}
|
||
|
|
|
||
|
|
$("#message_chat_form_category-edit").change(function(){
|
||
|
|
if($("#message_chat_form_category-edit").val() == 'Другое'){
|
||
|
|
$("#message_chat_form_other_category-block").show();
|
||
|
|
$("#message_chat_form_other_category-edit").attr('required', 'required');
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
$("#message_chat_form_other_category-block").hide();
|
||
|
|
$("#message_chat_form_other_category-edit").removeAttr('required');
|
||
|
|
}
|
||
|
|
});
|
||
|
|
|
||
|
|
});
|