(function ($) { "use strict"; $('body').on('click', '.reply-comment', function (e) { e.preventDefault(); var $this = $(this); var comment_card = $this.closest('.comments-card'); var comment_id = comment_card.attr('data-id'); var csrf = comment_card.attr('data-csrf'); var address = comment_card.attr('data-address'); var item_id = $('#commentItemId').val(); var item_name = $('#commentItemName').val(); var replyCommentHtml = '
\n' + '\n' + '' + '' + '\n' + '
\n' + '\n' + '
\n' + '\n' + '\n' + '
'; comment_card.append(replyCommentHtml); }); $('body').on('click', '.reply-close', function (e) { e.preventDefault(); $(this).closest('form').remove(); }); $('body').on('click', '.report-comment', function (e) { e.preventDefault(); var comment_id = $(this).attr('data-comment-id'); var item_id = $('#commentItemId').val(); var item_name = $('#commentItemName').val(); var html = '
\n' + '

' + reportLang + '

\n' + '\n' + '
\n' + ' ' + ' ' + '
\n' + ' \n' + ' \n' + '
\n' + '
\n' + '\n' + '
\n' + ' \n' + ' \n' + '
\n' + '
\n' + '
'; Swal.fire({ html: html, showCancelButton: false, showConfirmButton: false, customClass: { content: 'p-0 text-left' }, width: '30rem' }); }); $('body').on('click', '#saveReport', function (e) { var $this = $(this); var form = $('#reportModal form'); var data = form.serializeObject(); var action = form.attr('action'); $this.addClass('loadingbar primary').prop('disabled', true); form.find('input').removeClass('is-invalid'); form.find('textarea').removeClass('is-invalid'); $.post(action, data, function (result) { if (result && result.code === 200) { Swal.fire({ icon: 'success', html: '

' + reportSuccessLang + '

', showConfirmButton: false }); setTimeout(function () { window.location.reload(); }, 2000); } }).fail(function (err) { $this.removeClass('loadingbar primary').prop('disabled', false); var errors = err.responseJSON; if (errors && errors.errors) { Object.keys(errors.errors).forEach(function (key) { var error = errors.errors[key]; var element = form.find('[name="' + key + '"]'); element.addClass('is-invalid'); element.parent().find('.invalid-feedback').text(error[0]); }); } }); }); })(jQuery);