// Convenient way for opening links in external browser, not in the app. // Useful especially if you have a lot of links to deal with. // // Usage: // // Every link with class ".js-external-link" will be opened in external browser. // google // // The same behaviour for many links can be achieved by adding // this class to any parent tag of an anchor tag. // (function () { 'use strict'; var shell = require('shell'); var supportExternalLinks = function (e) { var href; var isExternal = false; var checkDomElement = function (element) { if (element.nodeName === 'A') { href = element.getAttribute('href'); } if (element.classList.contains('js-external-link')) { isExternal = true; } if (href && isExternal) { shell.openExternal(href); e.preventDefault(); } else if (element.parentElement) { checkDomElement(element.parentElement); } } checkDomElement(e.target); } document.addEventListener('click', supportExternalLinks, false); }());