| 1 |
/* Hover Card — frontend.js */ |
| 2 |
/* Primary reveal is CSS-driven. This adds touch-device support. */ |
| 3 |
( function () { |
| 4 |
function init() { |
| 5 |
document.querySelectorAll( '.bkhc-card' ).forEach( function ( card ) { |
| 6 |
card.addEventListener( 'touchstart', function () { |
| 7 |
card.classList.toggle( 'bkhc-touch-active' ); |
| 8 |
}, { passive: true } ); |
| 9 |
} ); |
| 10 |
|
| 11 |
// Close touch-active when tapping outside |
| 12 |
document.addEventListener( 'touchstart', function ( e ) { |
| 13 |
document.querySelectorAll( '.bkhc-card.bkhc-touch-active' ).forEach( function ( card ) { |
| 14 |
if ( ! card.contains( e.target ) ) { |
| 15 |
card.classList.remove( 'bkhc-touch-active' ); |
| 16 |
} |
| 17 |
} ); |
| 18 |
}, { passive: true } ); |
| 19 |
} |
| 20 |
|
| 21 |
if ( document.readyState === 'loading' ) { |
| 22 |
document.addEventListener( 'DOMContentLoaded', init ); |
| 23 |
} else { |
| 24 |
init(); |
| 25 |
} |
| 26 |
} )(); |
| 27 |
|