From c00431cdc8246e412d7e052475254390c329ea96 Mon Sep 17 00:00:00 2001 From: mikeller Date: Sun, 14 Jul 2019 09:39:08 +1200 Subject: [PATCH] Fix opening of external links in browser. --- src/js/main.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/js/main.js b/src/js/main.js index 6063379b..9216ccba 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -5,8 +5,6 @@ var nwGui = getNwGui(); var googleAnalytics = analytics; var analytics = undefined; -openNewWindowsInExternalBrowser(); - $(document).ready(function () { $.getJSON('version.json', function(data) { CONFIGURATOR.gitChangesetId = data.gitChangesetId; @@ -88,6 +86,12 @@ function setupAnalytics(result) { this.close(true); }); + win.on('new-win-policy', function(frame, url, policy) { + // do not open the window + policy.ignore(); + // and open it in external browser + nwGui.Shell.openExternal(url); + }); } else { // Looks like we're in Chrome - but the event does not actually get fired chrome.runtime.onSuspend.addListener(sendCloseEvent); @@ -808,19 +812,6 @@ function getManifestVersion(manifest) { return version; } -function openNewWindowsInExternalBrowser() { - if (nwGui) { - //Get the current window - var win = nwGui.Window.get(); - - //Listen to the new window event - win.on('new-win-policy', function (frame, url, policy) { - gui.Shell.openExternal(url); - policy.ignore(); - }); - } -} - function showErrorDialog(message) { var dialog = $('.dialogError')[0];