Created
May 11, 2016 15:13
-
-
Save foaly-nr1/c92e9e9ba00c3971bf5a5f4876628692 to your computer and use it in GitHub Desktop.
Prevents Bootstrap modal from being opened if cmd/ctrl key is pressed when triggering link is clicked
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prevents Bootstrap modal from being opened if cmd key is pressed when triggering link is clicked. | |
*/ | |
(function BS3ModalCmd() { | |
'use strict'; | |
// We listen during the capture phase to always be before bootstrap's event listeners. However, | |
// we can't detect whether the click is relevant for us, as a child element of the triggering | |
// element might have been clicked. We therefore just stop propagation for all clicks #hacky | |
document.addEventListener('click', (e) => { | |
if (e.metaKey) { | |
e.stopPropagation(); | |
} | |
}, true); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment