answer_from_admin_chat.blade.php
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<div class="hide">
<div id="answer_from_admin_chat_modal" class="modal-dialog">
<div class="modal-dialog-title">
<h2>Ответить работодателю</h2>
</div>
<div class="modal-dialog-body">
<textarea class="textarea" name="text" placeholder="" required></textarea>
</div>
<div class="modal-dialog-footer">
<button type="button" class="button answer-from-admin-chat-button">Отправить</button>
<button type="button" class="button button_light" onclick="$.fancybox.close();">Закрыть</button>
</div>
</div>
</div>
<script>
$(function (){
$('.answer-from-admin-chat-button').click(function(){
spinStart($(this));
var wrap = $(this).closest('#answer_from_admin_chat_modal');
var to_user_id = wrap.data('to-user-id');
var reply_message_id = wrap.data('message-id');
var textarea = wrap.find('[name="text"]');
var text = textarea.val()
textarea.removeClass('border-red');
if (!text.trim()){
textarea.addClass('border-red');
return;
}
$.ajax({
type: "POST",
url: "{{ route('send_message') }}",
data: {
to_user_id: to_user_id,
reply_message_id: reply_message_id,
text: text
},
dataType: 'json',
headers: {
'X-CSRF-TOKEN': $('[name="_token"]').val()
},
success: function(res){
if (res && res.success && res.url_redirect){
window.location.replace(res.url_redirect);
} else{
location.reload();
}
}
});
});
});
</script>