medium.blade.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <div class="modal fade" id="medium-modal" tabindex="-1" aria-labelledby="exampleModalLabel" data-backdrop="static" aria-hidden="true">
  2. <div class="modal-dialog modal-dialog-centered">
  3. <div class="modal-content">
  4. <div class="pace-demo text-center position-absolute ml-2" hidden style="z-index: 9999; top: 50%; left: 44%;" id="pace-progress-modal-panel">
  5. <div class="theme_squares">
  6. <div class="pace-progress"></div>
  7. <div class="pace_activity"></div>
  8. </div>
  9. </div>
  10. <div class="modal-content">
  11. <button class="modal-close" data-bs-dismiss="modal"><i class="icofont-close"></i></button>
  12. <div class="modal-body p-0">
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. </div>
  18. @once
  19. @push('js')
  20. <script>
  21. $(document).on('click', '.destroy-btn', function() {
  22. const href = $(this).attr('data-attr')
  23. iziToast.question({
  24. timeout: 20000,
  25. close: false,
  26. overlay: true,
  27. displayMode: 'once',
  28. id: 'question',
  29. title: $('#comfirm-delete').text(),
  30. message: $('#can-not-recover-after-delete').text(),
  31. position: 'center',
  32. buttons: [
  33. [`<button><b>${$('#delete').text()}</b></button>`, async function (instance, toast) {
  34. instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
  35. call_destroy_api(href)
  36. }, true],
  37. [`<button>${$('#cancel').text()}</button>`, function (instance, toast) {
  38. instance.hide({ transitionOut: 'fadeOut' }, toast, 'button');
  39. }],
  40. ],
  41. });
  42. });
  43. function call_destroy_api(href) {
  44. $.ajaxSetup({
  45. headers: {
  46. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  47. }
  48. });
  49. $.ajax({
  50. type: "POST",
  51. url: href,
  52. data: {
  53. "_method": 'DELETE',
  54. },
  55. success: function(response) {
  56. if (response.apiStatus) {
  57. iziToast.error({
  58. title: 'Error',
  59. message: response.body ?? $('#api-request-failed-please-check').text(),
  60. });
  61. } else {
  62. iziToast.success({
  63. title: 'Success',
  64. message: $('#action-completed').text(),
  65. });
  66. location.reload()
  67. }
  68. }
  69. });
  70. }
  71. $('#medium-modal').on('hidden.bs.modal', function () {
  72. $('#medium-modal').find('.modal-body').empty()
  73. });
  74. $(document).on('click', '.medium-btn', function(event) {
  75. event.preventDefault();
  76. if ($(this).attr('data-auth')) {
  77. if (isEmpty(window.Member)) {
  78. location.href = '{{ route('member-login') }}'
  79. return
  80. }
  81. }
  82. let href = $(this).attr('data-attr')
  83. const title = $(this).attr('data-title')
  84. let serialize_form = $(this).attr('data-serialize-form')
  85. if (serialize_form) {
  86. href = addParameterToURL(href, $(serialize_form).serialize())
  87. }
  88. $.ajax({
  89. url: href,
  90. success: function(result) {
  91. $('#medium-modal').find('.modal-title').text(title)
  92. $('#medium-modal').modal('show')
  93. $('#medium-modal').find('.modal-body').html(result).show()
  94. },
  95. error: function(jqXHR, testStatus, error) {
  96. console.log(error);
  97. alert("Page " + href + " cannot open. Error:" + error);
  98. },
  99. timeout: 8000
  100. })
  101. });
  102. function addParameterToURL(url, param){
  103. url += (url.split('?')[1] ? '&':'?') + param;
  104. return url;
  105. }
  106. </script>
  107. @endpush
  108. @endonce