base.blade.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. @yield('main')
  2. <script>
  3. $(function(){
  4. $('.modal-date').flatpickr({
  5. dateFormat: 'd M Y'
  6. });
  7. $('.modal-time').flatpickr({
  8. noCalendar: true,
  9. enableTime: true,
  10. dateFormat: "h:i K",
  11. });
  12. $('.modal-form').on('submit', function(event){
  13. event.preventDefault();
  14. var self=$(this);
  15. $('.btn-submit').prop('disabled', true);
  16. $(self).waitMe({
  17. effect: 'facebook',
  18. text: 'Please! Wait ...'
  19. });
  20. $(this).ajaxSubmit({
  21. success:function(res){
  22. $(self).waitMe('hide');
  23. if(res.msg){
  24. new Noty({
  25. theme:'sunset',
  26. text: res.msg,
  27. type: 'success',
  28. timeout:1000,
  29. callbacks:{
  30. afterClose:function(){
  31. var replace_content=self.find('input[name=replace_content]').val();
  32. if(replace_content){
  33. url=self.find("input[name='replace_content']").data('replace');
  34. $(replace_content).waitMe({
  35. effect: 'facebook',
  36. text: 'Please! Wait ...'
  37. });
  38. $(replace_content).load(url, null, function(){
  39. $(replace_content).waitMe('hide');
  40. });
  41. $('#modal_page').modal('hide');
  42. }else window.location.reload();
  43. }
  44. }
  45. }).show();
  46. }
  47. },
  48. error:function(res){
  49. $(self).waitMe('hide');
  50. let msg="Request submission failed. Please! try again later.";
  51. if(res.responseJSON && res.responseJSON.msg){
  52. msg=res.responseJSON.msg;
  53. }
  54. new Noty({
  55. theme:'sunset',
  56. text: msg,
  57. type: 'error',
  58. timeout:3000,
  59. callbacks:{
  60. afterClose:function(){
  61. $('.btn-submit').prop('disabled', false);
  62. }
  63. }
  64. }).show();
  65. }
  66. });
  67. });
  68. });
  69. </script>