Open popup as tab if browser does not support popup.

This commit is contained in:
FelisCatus 2017-08-03 23:10:02 -04:00
parent d8684c6d24
commit 6f0f3e4636
5 changed files with 13 additions and 2 deletions

View File

@ -272,12 +272,17 @@ class ChromeOptions extends OmegaTarget.Options
url: chrome.extension.getURL('options.html#/ui')
)
if quickSwitch
if quickSwitch or not chrome.browserAction.setPopup?
chrome.browserAction.setPopup?({popup: ''})
if not @_quickSwitchInit
@_quickSwitchInit = true
chrome.browserAction.onClicked.addListener (tab) =>
@clearBadge()
if not @_options['-enableQuickSwitch']
# If we reach here, then the browser does not support popup.
# Let's open the popup page in a tab.
chrome.tabs.create(url: 'popup/index.html')
return
profiles = @_options['-quickSwitchProfiles']
index = profiles.indexOf(@_currentProfileName)
index = (index + 1) % profiles.length
@ -290,7 +295,7 @@ class ChromeOptions extends OmegaTarget.Options
return if url.substr(0, 4) == 'moz-'
chrome.tabs.reload(tab.id)
else
chrome.browserAction.setPopup?({popup: 'popup/index.html'})
chrome.browserAction.setPopup({popup: 'popup/index.html'})
Promise.resolve()
setInspect: (settings) ->

View File

@ -21,6 +21,7 @@ html(lang='en' ng-app='omegaPopup' ng-controller='PopupCtrl' ng-csp)
head
meta(charset='utf-8')
title {{'popup_title' | tr}}
meta(name='viewport' content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no')
link(rel='stylesheet' href='lib/bootstrap/css/bootstrap.min.css')
link(rel='stylesheet' href='css/popup.css')
body(ng-class='{"with-condition-form": showConditionForm}')

View File

@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>SwitchyOmega Popup</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="css/index.css">
</head>
<body>

View File

@ -14,6 +14,9 @@
function closePopup() {
window.close();
// If the popup is opened as a tab, the above won't work. Let's reload then.
document.body.style.opacity = 0;
setTimeout(function() { history.go(0); }, 300);
}
function showOptions(e) {

View File

@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<title>SwitchyOmega Popup</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" href="css/dialog.css">
</head>
<body>