|
1 | | -// resources/js/app.js |
2 | | - |
3 | 1 | import "./bootstrap"; |
4 | 2 | import "./echo"; |
5 | | - |
6 | | -import "instascan"; |
7 | | - |
8 | | -import Alpine from "alpinejs"; |
9 | | -window.Alpine = Alpine; |
10 | | -Alpine.start(); |
11 | | - |
12 | | -import "swiper/swiper-bundle.css"; |
13 | | -import Swiper from "swiper/bundle"; |
14 | | - |
15 | | -// Lógica para o botão de copiar URL |
16 | | -document.addEventListener("DOMContentLoaded", () => { |
17 | | - const buttonCopy = document.querySelector("#copy"); |
18 | | - if (buttonCopy) { |
19 | | - buttonCopy.addEventListener("click", (e) => { |
20 | | - const input = document.querySelector("#share-input"); |
21 | | - input.select(); |
22 | | - document.execCommand("copy"); |
23 | | - |
24 | | - buttonCopy.innerText = "Copiado!"; |
25 | | - setTimeout(() => { |
26 | | - buttonCopy.innerText = "Copiar"; |
27 | | - }, 2000); |
28 | | - }); |
29 | | - } |
30 | | -}); |
31 | | - |
32 | | -// Funções e lógica do modal de convite |
33 | | -function closeModal() { |
34 | | - const inviteModal = document.getElementById("invite_modal"); |
35 | | - if (inviteModal) { |
36 | | - inviteModal.style.display = "none"; |
37 | | - } |
38 | | -} |
39 | | - |
40 | | -function openInviteModal() { |
41 | | - const inviteModal = document.getElementById("invite_modal"); |
42 | | - if (inviteModal) { |
43 | | - inviteModal.style.display = "flex"; |
44 | | - } |
45 | | -} |
46 | | - |
47 | | -document.addEventListener("DOMContentLoaded", () => { |
48 | | - const inviteForm = document.getElementById("invite_form"); |
49 | | - if (inviteForm) { |
50 | | - inviteForm.addEventListener("submit", function (e) { |
51 | | - e.preventDefault(); |
52 | | - |
53 | | - const formData = new FormData(this); |
54 | | - const actionUrl = |
55 | | - inviteForm.getAttribute("data-action") || "/campaign/invite"; |
56 | | - |
57 | | - fetch(actionUrl, { |
58 | | - method: "POST", |
59 | | - headers: { |
60 | | - // Só adiciona o header se o meta existir |
61 | | - ...(document.querySelector('meta[name="csrf-token"]') |
62 | | - ? { |
63 | | - "X-CSRF-TOKEN": document.querySelector( |
64 | | - 'meta[name="csrf-token"]' |
65 | | - ).content, |
66 | | - } |
67 | | - : {}), |
68 | | - }, |
69 | | - body: formData, |
70 | | - }) |
71 | | - .then((response) => response.json()) |
72 | | - .then((data) => { |
73 | | - alert(data.message); |
74 | | - closeModal(); |
75 | | - }) |
76 | | - .catch((error) => { |
77 | | - console.error("Erro:", error); |
78 | | - alert( |
79 | | - "Ocorreu um erro ao enviar o convite. Tente novamente." |
80 | | - ); |
81 | | - }); |
82 | | - }); |
83 | | - } |
84 | | -}); |
85 | | - |
86 | | -window.closeModal = closeModal; |
87 | | -window.openInviteModal = openInviteModal; |
88 | | - |
89 | | -// Inicialização do Swiper (com breakpoints para cards menores e alinhados) |
90 | | -document.addEventListener("DOMContentLoaded", function () { |
91 | | - if (document.querySelector(".mySwiper")) { |
92 | | - const swiper = new Swiper(".mySwiper", { |
93 | | - spaceBetween: 20, |
94 | | - loop: false, |
95 | | - centeredSlides: false, // Garante que os slides não fiquem centralizados |
96 | | - |
97 | | - // Adiciona um offset antes do primeiro slide para alinhar com o padding da página (p-5 = 20px) |
98 | | - slidesOffsetBefore: 20, |
99 | | - |
100 | | - pagination: { |
101 | | - el: ".swiper-pagination", |
102 | | - clickable: true, |
103 | | - }, |
104 | | - |
105 | | - navigation: { |
106 | | - nextEl: ".swiper-button-next", |
107 | | - prevEl: ".swiper-button-prev", |
108 | | - }, |
109 | | - |
110 | | - breakpoints: { |
111 | | - // Mobile (0px e acima) |
112 | | - 0: { |
113 | | - slidesPerView: 1.2, // Mostra 1 card completo e um pedaço do próximo |
114 | | - spaceBetween: 15, |
115 | | - slidesOffsetBefore: 20, |
116 | | - }, |
117 | | - // Pequenas telas (ex: tablets pequenos, 640px e acima) |
118 | | - 640: { |
119 | | - slidesPerView: 2.5, // Mostra 2.5 cards |
120 | | - spaceBetween: 20, |
121 | | - slidesOffsetBefore: 20, |
122 | | - }, |
123 | | - // Tablets e desktops menores (768px e acima) |
124 | | - 768: { |
125 | | - slidesPerView: 3.5, // Mostra 3.5 cards |
126 | | - spaceBetween: 25, |
127 | | - slidesOffsetBefore: 20, |
128 | | - }, |
129 | | - // Desktops médios (992px e acima) |
130 | | - 992: { |
131 | | - slidesPerView: 4.5, // Mostra 4.5 cards |
132 | | - spaceBetween: 30, |
133 | | - slidesOffsetBefore: 20, |
134 | | - }, |
135 | | - // Desktops maiores (1200px e acima) |
136 | | - 1200: { |
137 | | - slidesPerView: 5.5, // Mostra 5.5 cards |
138 | | - spaceBetween: 30, |
139 | | - slidesOffsetBefore: 20, |
140 | | - }, |
141 | | - }, |
142 | | - }); |
143 | | - } |
144 | | -}); |
| 3 | +import "./validators"; |
| 4 | +import "./alpine"; |
0 commit comments