Merge pull request #52 from tophf/reuse-ntp

Re-use an active new tab page for manager/editor
This commit is contained in:
Jason Barnabe 2015-03-03 20:58:19 -06:00
commit 1920a5e890

View File

@ -146,14 +146,21 @@ function openLinkInTabOrWindow(event) {
if (prefs.getPref('openEditInWindow', false)) { if (prefs.getPref('openEditInWindow', false)) {
chrome.windows.create({url: event.target.href}); chrome.windows.create({url: event.target.href});
} else { } else {
chrome.tabs.create({url: event.target.href}); openLink(event);
} }
} }
function openLink(event) { function openLink(event) {
event.preventDefault(); event.preventDefault();
chrome.tabs.query({currentWindow: true, active: true}, function (tabs) {
if (tabs && tabs.length && tabs[0].url.match(/^chrome:\/\/newtab\/?$/)) {
chrome.tabs.update({url: event.target.href});
close(); // close the popup
} else {
chrome.tabs.create({url: event.target.href}); chrome.tabs.create({url: event.target.href});
} }
});
}
function handleUpdate(style) { function handleUpdate(style) {
var installed = document.getElementById("installed"); var installed = document.getElementById("installed");