message.blade.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. @extends('admin.partial.template-full')
  2. @section('section')
  3. <div class="title d-flex justify-content-between align-items-center">
  4. <span><a href="/i/admin/users/show/{{$user->id}}" class="btn btn-outline-secondary btn-sm font-weight-bold">Back</a></span>
  5. <span class="text-center">
  6. <h3 class="font-weight-bold mb-0">&commat;{{$profile->username}}</h3>
  7. <p class="mb-0 small text-muted text-uppercase font-weight-bold">
  8. <span>{{$profile->statuses()->count()}} Posts</span>
  9. <span class="px-1">|</span>
  10. <span>{{$profile->followers()->count()}} Followers</span>
  11. <span class="px-1">|</span>
  12. <span>{{$profile->following()->count()}} Following</span>
  13. </p>
  14. </span>
  15. <span>
  16. <div class="dropdown">
  17. <button class="btn btn-outline-secondary btn-sm font-weight-bold dropdown-toggle" type="button" id="userActions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-bars"></i></button>
  18. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="userActions">
  19. <a class="dropdown-item" href="/i/admin/users/show/{{$user->id}}">
  20. <span class="font-weight-bold">Overview</span>
  21. </a>
  22. <a class="dropdown-item" href="{{$profile->url()}}">
  23. <span class="font-weight-bold">View Profile</span>
  24. </a>
  25. <div class="dropdown-divider"></div>
  26. <a class="dropdown-item" href="/i/admin/users/edit/{{$user->id}}">
  27. <span class="font-weight-bold">Edit</span>
  28. </a>
  29. <a class="dropdown-item" href="/i/admin/users/modtools/{{$user->id}}">
  30. <span class="font-weight-bold">Mod Tools</span>
  31. </a>
  32. <a class="dropdown-item" href="/i/admin/users/modlogs/{{$user->id}}">
  33. <span class="font-weight-bold">Mod Logs</span>
  34. </a>
  35. <div class="dropdown-divider"></div>
  36. <a class="dropdown-item" href="/i/admin/users/delete/{{$user->id}}">
  37. <span class="text-danger font-weight-bold">Delete Account</span>
  38. </a>
  39. </div>
  40. </div>
  41. </span>
  42. </div>
  43. <hr>
  44. <div class="row mb-3">
  45. <div class="col-12 col-md-8 offset-md-2">
  46. <p class="title h4 font-weight-bold mt-2 py-2">Send Message</p>
  47. <hr>
  48. <div class="row">
  49. <div class="col-12">
  50. @if ($errors->any())
  51. <div class="alert alert-danger">
  52. <ul>
  53. @foreach ($errors->all() as $error)
  54. <li>{{ $error }}</li>
  55. @endforeach
  56. </ul>
  57. </div>
  58. @endif
  59. <form method="post" id="messageForm">
  60. @csrf
  61. <div class="form-group">
  62. <textarea class="form-control" rows="8" placeholder="Message body ..." id="message" name="message"></textarea>
  63. <p class="help-text mb-0 small text-muted">
  64. <span>Plain text only, html will not be rendered.</span>
  65. <span class="float-right msg-counter"><span class="msg-count">0</span>/500</span>
  66. </p>
  67. </div>
  68. <p class="float-right">
  69. <button type="button" class="btn btn-primary py-1 font-weight-bold" onclick="submitWarning()"><i class="fas fa-message"></i> SEND</button>
  70. </p>
  71. </form>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. @endsection
  77. @push('scripts')
  78. <script type="text/javascript">
  79. $('#message').on('keyup change paste submit', function(e) {
  80. let len = e.target.value.length;
  81. $('.msg-count').text(len);
  82. });
  83. function submitWarning() {
  84. let msg = document.querySelector('#message');
  85. if(msg.value.length < 5) {
  86. swal('Oops!', 'Your message must be longer than 5 characters.', 'error');
  87. return;
  88. }
  89. if(msg.value.length > 500) {
  90. swal('Oops!', 'Your message must be shorter than 500 characters.', 'error');
  91. return;
  92. }
  93. swal({
  94. title: "Are you sure?",
  95. text: "Are you sure you want to send this message to {{$user->username}}?",
  96. icon: "warning",
  97. buttons: true,
  98. dangerMode: true,
  99. })
  100. .then((sendMessage) => {
  101. if (sendMessage) {
  102. $('#messageForm').submit();
  103. } else {
  104. return;
  105. }
  106. });
  107. }
  108. </script>
  109. @endpush