analytics/assets/js/app.js

61 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-09-02 14:29:19 +03:00
import css from "../css/app.css"
import "./polyfills/closest"
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch'
2019-09-02 14:29:19 +03:00
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')
}
})
2019-09-02 14:29:19 +03:00
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)
}
2019-10-31 08:39:51 +03:00
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();
}
}
2020-02-05 17:08:34 +03:00
plausible('Signup', {callback: submitForm});
2019-10-31 08:39:51 +03:00
})
}