mirror of
https://github.com/plausible/analytics.git
synced 2024-11-28 04:30:42 +03:00
61 lines
1.4 KiB
JavaScript
61 lines
1.4 KiB
JavaScript
import css from "../css/app.css"
|
|
import "./polyfills/closest"
|
|
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
|
|
import "phoenix_html"
|
|
|
|
const triggers = document.querySelectorAll('[data-dropdown-trigger]')
|
|
|
|
for (const trigger of triggers) {
|
|
trigger.addEventListener('click', function(e) {
|
|
e.stopPropagation()
|
|
e.currentTarget.nextElementSibling.classList.remove('hidden')
|
|
})
|
|
}
|
|
|
|
if (triggers.length > 0) {
|
|
document.addEventListener('click', function(e) {
|
|
const dropdown = e.target.closest('[data-dropdown]')
|
|
|
|
if (dropdown && e.target.tagName === 'A') {
|
|
dropdown.classList.add('hidden')
|
|
}
|
|
})
|
|
|
|
document.addEventListener('click', function(e) {
|
|
const clickedInDropdown = e.target.closest('[data-dropdown]')
|
|
|
|
if (!clickedInDropdown) {
|
|
for (const dropdown of document.querySelectorAll('[data-dropdown]')) {
|
|
dropdown.classList.add('hidden')
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
const flash = document.getElementById('flash')
|
|
|
|
if (flash) {
|
|
setTimeout(function() {
|
|
flash.style.display = 'none'
|
|
}, 2500)
|
|
}
|
|
|
|
const registerForm = document.getElementById('register-form')
|
|
|
|
if (registerForm) {
|
|
registerForm.addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
setTimeout(submitForm, 1000);
|
|
var formSubmitted = false;
|
|
|
|
function submitForm() {
|
|
if (!formSubmitted) {
|
|
formSubmitted = true;
|
|
registerForm.submit();
|
|
}
|
|
}
|
|
|
|
plausible('Signup', {callback: submitForm});
|
|
})
|
|
}
|