(function ($) { "use strict" function makeModalHtml(itemId, itemType) { return `

${deleteRequestLang}

${deleteRequestDescriptionLang}
` } $('body').on('click', '.js-content-delete-action', function (e) { e.preventDefault(); e.stopPropagation(); const $this = $(this); const href = $this.attr('href'); const itemId = $this.attr('data-item'); const itemType = $this.attr('data-item-type'); Swal.fire({ html: makeModalHtml(itemId, itemType), showCancelButton: false, showConfirmButton: false, customClass: { content: 'p-0 text-left', }, width: '36rem', }) }); $('body').on('click', '.js-send-delete-request', function (e) { e.preventDefault(); const $this = $(this); let form = $this.closest('.js-delete-content-form'); let data = serializeObjectByTag(form); let action = form.attr('data-action'); $this.addClass('loadingbar primary').prop('disabled', true); form.find('textarea').removeClass('is-invalid'); $.post(action, data, function (result) { if (result && result.code === 200) { //window.location.reload(); Swal.fire({ icon: 'success', title: result.title, html: '

' + result.msg + '

', showConfirmButton: false, width: '25rem', }); setTimeout(() => { window.location.reload(); }, 1500) } }).fail(err => { $this.removeClass('loadingbar primary').prop('disabled', false); var errors = err.responseJSON; if (errors && errors.errors) { Object.keys(errors.errors).forEach((key) => { const error = errors.errors[key]; let element = form.find('.js-ajax-' + key); element.addClass('is-invalid'); element.parent().find('.invalid-feedback').text(error[0]); }); } }) }); })(jQuery)