From ad827576ce5ae2c1b4faadeff7bde62da1a1e467 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 1 Jul 2015 12:18:03 -0400 Subject: [PATCH] have the logger open in a separate window --- platform/chromium/vapi-background.js | 13 ++++++++++++- platform/firefox/vapi-background.js | 20 +++++++++++++++++++- src/js/popup.js | 5 ++++- src/popup.html | 4 ++-- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 85bdec7ee..8609a901b 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -286,7 +286,8 @@ vAPI.tabs.get = function(tabId, callback) { // tabId: 1, // the tab is used if set, instead of creating a new one // index: -1, // undefined: end of the list, -1: following tab, or after index // active: false, // opens the tab in background - true and undefined: foreground -// select: true // if a tab is already opened with that url, then select it instead of opening a new one +// select: true, // if a tab is already opened with that url, then select it instead of opening a new one +// popup: true // open in a new window vAPI.tabs.open = function(details) { var targetURL = details.url; @@ -338,6 +339,16 @@ vAPI.tabs.open = function(details) { }); }; + // Open in a standalone window + if ( details.popup === true ) { + chrome.windows.create({ + url: details.url, + focused: details.active, + type: 'popup' + }); + return; + } + if ( details.index !== -1 ) { subWrapper(); return; diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index fd070fabb..0b1090d4e 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -699,7 +699,19 @@ vAPI.tabs.open = function(details) { details.index = tabBrowser.browsers.indexOf(tabBrowser.selectedBrowser) + 1; } - tab = tabBrowser.loadOneTab(details.url, {inBackground: !details.active}); + // Open in a standalone window + if ( details.popup === true ) { + win = Services.ww.openWindow( + win, + details.url, + null, + 'menubar=no,toolbar=no,location=no', + null + ); + return; + } + + tab = tabBrowser.loadOneTab(details.url, { inBackground: !details.active }); if ( details.index !== undefined ) { tabBrowser.moveTabTo(tab, details.index); @@ -2683,6 +2695,12 @@ vAPI.contextMenu.unregister = function(doc) { } var menuitem = doc.getElementById(this.menuItemId); + + // Not guarantee the menu item was actually registered. + if ( menuitem === null ) { + return; + } + var contextMenu = menuitem.parentNode; menuitem.removeEventListener('command', this.onCommand); contextMenu.removeEventListener('popupshowing', this.displayMenuItem); diff --git a/src/js/popup.js b/src/js/popup.js index 309753667..d4dadbae6 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -526,12 +526,15 @@ var gotoURL = function(ev) { ev.preventDefault(); + var rel = this.getAttribute('rel') || ''; + messager.send({ what: 'gotoURL', details: { url: this.getAttribute('href'), select: true, - index: -1 + index: -1, + popup: rel === 'popup' } }); diff --git a/src/popup.html b/src/popup.html index 3e91b2a8f..ef35b5659 100644 --- a/src/popup.html +++ b/src/popup.html @@ -18,8 +18,8 @@

   - -

+ +

?

 

?