1 /* ----------------------------------
3 * Licensed under The MIT License
4 * http://opensource.org/licenses/MIT
5 * ---------------------------------- */
8 var findModals = function (target) {
10 var modals = document.querySelectorAll('a');
12 for (; target && target !== document; target = target.parentNode) {
13 for (i = modals.length; i--;) { if (modals[i] === target) return target; }
17 var getModal = function (event) {
18 var modalToggle = findModals(event.target);
19 if (!modalToggle || !modalToggle.hash) return;
21 return document.querySelector(modalToggle.hash);
24 window.addEventListener('touchend', function (event) {
25 var modal = getModal(event);
26 if (modal) modal.classList.toggle('active');
29 window.addEventListener('click', function (event) {
30 if (getModal(event)) event.preventDefault();