1 /* ----------------------------------
3 * Licensed under The MIT License
4 * http://opensource.org/licenses/MIT
5 * ---------------------------------- */
8 findModals = function ( target ) {
10 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 getModal = function ( event ) {
19 modalToggle = findModals( event.target );
21 if ( !modalToggle || !modalToggle.hash ) return;
23 modal = document.querySelector( modalToggle.hash )
29 window.addEventListener( 'touchend', function ( event ) {
30 var modal = getModal( event );
34 modal.classList.toggle( 'active' );
37 window.addEventListener( 'click', function ( event ) {
38 if ( getModal( event ) ) event.preventDefault();