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');
11 for (; target && target !== document; target = target.parentNode) {
12 for (i = modals.length; i--;) { if (modals[i] === target) return target; }
16 var getModal = function (event) {
17 var modalToggle = findModals(event.target);
18 if (modalToggle && modalToggle.hash) return document.querySelector(modalToggle.hash);
21 window.addEventListener('touchend', function (event) {
22 var modal = getModal(event);
23 if (modal) modal.classList.toggle('active');
26 window.addEventListener('click', function (event) {
27 if (getModal(event)) event.preventDefault();