Wedding Invitation
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

guestbook.blade.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <div class="flex flex-col gap-5 w-4/5">
  2. <div class="flex flex-col justify-center text-center gap-3 fade-element">
  3. <p class="font-medium text-gray-600 pb-3">Ruangan Ucapan</p>
  4. <div id="guestbook-container">
  5. @include('partials.guestbook', ['entry' => $guestbooks->first()])
  6. </div>
  7. <div class="join flex justify-center" id="pagination-buttons">
  8. @for ($i = 1; $i <= $totalPages; $i++)
  9. <button class="join-item btn btn-xs {{ $i == 1 ? 'btn-active' : '' }} hidden" data-page="{{ $i }}">{{ $i }}</button>
  10. @endfor
  11. </div>
  12. </div>
  13. <div class="text-center flex justify-center pb-2 gap-2 fade-element">
  14. <a onclick="guestbook.showModal()" class="rounded-full border-solid border-2 border-navbarcolor py-1 px-3 font-medium text-gray-600">
  15. <i class="fa-solid fa-pen-fancy"></i>
  16. <span>Beri Ucapan</span>
  17. </a>
  18. <a onclick="allguestbook.showModal()" class="rounded-full border-solid border-2 border-navbarcolor py-1 px-3 font-medium text-gray-600">
  19. <i class="fa-solid fa-eye"></i>
  20. <span>Lihat Ucapan</span>
  21. </a>
  22. </div>
  23. <div class="text-center pb-2 fade-element">
  24. <a onclick="rsvp.showModal()" class="rounded-full border-solid border-2 border-navbarcolor py-1 px-3 font-medium text-gray-600">
  25. <i class="fa-solid fa-clipboard"></i>
  26. <span>Sahkan Kehadiran</span>
  27. </a>
  28. </div>
  29. <hr class="border-t-1 border-gray-300 mt-5 mb-3 w-4/5 self-center fade-element">
  30. @include('modals.guestbook-modal')
  31. @include('modals.show-all-guestbook')
  32. </div>
  33. @push('script')
  34. <script>
  35. $(document).ready(function() {
  36. var autoSwitchInterval = 4500; // 3 seconds
  37. var currentPage = 1;
  38. var totalPages = {{ $totalPages }}; // Total number of pages
  39. function fetchGuestbook(page) {
  40. $.ajax({
  41. url: '{{ route('guestbook.ajax') }}',
  42. type: 'GET',
  43. data: { page: page },
  44. success: function(response) {
  45. $('#guestbook-container').html(response.guestbook);
  46. // Update pagination buttons
  47. $('#pagination-buttons .join-item').removeClass('btn-active');
  48. $('#pagination-buttons .join-item[data-page="' + page + '"]').addClass('btn-active');
  49. // Update currentPage
  50. currentPage = page;
  51. },
  52. error: function(xhr) {
  53. console.log(xhr.responseText);
  54. }
  55. });
  56. }
  57. // Auto-switching every 3 seconds
  58. setInterval(function() {
  59. var nextPage = currentPage + 1;
  60. if (nextPage > totalPages) {
  61. nextPage = 1;
  62. }
  63. fetchGuestbook(nextPage);
  64. }, autoSwitchInterval);
  65. // Handle pagination button click
  66. $('#pagination-buttons').on('click', '.join-item', function() {
  67. var page = $(this).data('page');
  68. fetchGuestbook(page);
  69. });
  70. });
  71. </script>
  72. @endpush