tricks
Version:
ES6 modules
22 lines (18 loc) • 481 B
JavaScript
import delegate from '../events/delegate';
import cordova from '../support/cordova';
export default (root = document) => {
if (!cordova) {
return false;
}
else {
// Enable event delegation to fix anchor elements
delegate('a', 'click', e => {
const target = e.delegateTarget;
// Check this is a valid external URL...
if (target.href && target.href.match(/^https?:\/\//)) {
e.preventDefault();
window.open(target.href, '_system');
}
}, root);
}
};