Change panel references to popup
Panels have been deprecated for a long time, and when creating them a
popup is created instead, so this change introduces the following:
- Instead of trying to create a panel, create a popup directly
- Change all i18n strings so "popups" are mentioned instead of "panels"
- Change the |uniquetab| option so it is now set to "popup" instead of
"panel", while being backwards-compatible with the "panel" value.
- Change the default |uniquetab| option to "popup", because users seem
to like this option the most (impression from the CWS reviews).
Fixes: #13
Change-Id: I67aea8168013dd4b77d4ea4229179bcd5145cb6d
diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json
index 6366c58..1f950f3 100644
--- a/src/_locales/en/messages.json
+++ b/src/_locales/en/messages.json
@@ -54,8 +54,8 @@
"description": "Option which defines where should the translations be shown (in this case, each translation will be opened in the same tab used for the previous translation, or will open a new tab if there aren't any translation tabs open)."
},
"options_tabsoption_3": {
- "message": "Open Google Translate in a panel (you need to activate <a href='chrome://flags/#enable-panels' id='panelsflag'>--enable-panels</a> flag). <sup style='color:red; font-weight: bold;'> EXPERIMENTAL</sup>",
- "description": "Option which defines where should the translations be shown (in this case, each translation will be opened in a new panel)."
+ "message": "Open Google Translate in a popup.",
+ "description": "Option which defines where should the translations be shown (in this case, each translation will be opened in a new popup)."
},
"options_savebutton": {
"message": "Save",
diff --git a/src/background.js b/src/background.js
index 8fed6f6..7058875 100644
--- a/src/background.js
+++ b/src/background.js
@@ -39,10 +39,10 @@
});
});
});
- } else if (items.uniquetab == 'panel') {
+ } else if (items.uniquetab == 'panel' || items.uniquetab == 'popup') {
chrome.windows.create(
{
- type: 'panel',
+ type: 'popup',
url,
width: 1000,
height: 382,
@@ -163,7 +163,7 @@
chrome.storage.sync.get(null, function(items) {
if (details.reason == 'install') {
if (isEmpty(items)) {
- var settings = {'translateinto': {}, 'uniquetab': ''},
+ var settings = {'translateinto': {}, 'uniquetab': 'popup'},
default_language_1 =
chrome.i18n.getMessage('@@ui_locale').replace('_', '-'),
default_language_2 =
diff --git a/src/js/options.js b/src/js/options.js
index b502450..9fc10df 100644
--- a/src/js/options.js
+++ b/src/js/options.js
@@ -45,7 +45,7 @@
if (isEmpty(items)) {
items = {
translateinto: {},
- uniquetab: '',
+ uniquetab: 'popup',
};
chrome.storage.sync.set(items);
}
@@ -53,14 +53,10 @@
// Check the checkbox of the window opening
if (items.uniquetab === 'yep') $('#uniquetab').checked = true;
if (items.uniquetab === '') $('#varioustabs').checked = true;
- if (items.uniquetab === 'panel') $('#panel').checked = true;
+ if (items.uniquetab === 'panel' || items.uniquetab === 'popup')
+ $('#popup').checked = true;
// Add event listeners for certain buttons and links
- $('#panelsflag').addEventListener('click', _ => {
- event.preventDefault();
- chrome.tabs.create({url: 'chrome://flags/#enable-panels'});
- });
-
$('#save').addEventListener('click', _ => {
saveOptions(true);
});
diff --git a/src/options.html b/src/options.html
index ef2efc5..0d40a36 100644
--- a/src/options.html
+++ b/src/options.html
@@ -29,7 +29,7 @@
<div id="otheroptions">
<p><input type="radio" name="uniquetab" id="varioustabs" value=""> <label id="varioustabs_label" for="varioustabs" data-i18n="tabsoption_1"></label></p>
<p><input type="radio" name="uniquetab" id="uniquetab" value="yep"> <label id="uniquetab_label" for="uniquetab" data-i18n="tabsoption_2"></label></p>
- <p><input type="radio" name="uniquetab" id="panel" value="panel"> <label id="panel_label" for="panel" data-i18n="tabsoption_3"></label></p>
+ <p><input type="radio" name="uniquetab" id="popup" value="popup"> <label id="popup_label" for="popup" data-i18n="tabsoption_3"></label></p>
</div>
<button id="save" data-i18n="savebutton"></button>