2019-09-02 14:29:19 +03:00
|
|
|
import css from "../css/app.css"
|
|
|
|
import "./polyfills/closest"
|
2020-07-02 11:21:59 +03:00
|
|
|
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) {
|
2019-11-19 07:30:42 +03:00
|
|
|
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
|
|
|
})
|
|
|
|
}
|