From 6f0f3e4636d01cf5c8bb4dcaac802232108417c7 Mon Sep 17 00:00:00 2001 From: FelisCatus Date: Thu, 3 Aug 2017 23:10:02 -0400 Subject: [PATCH] Open popup as tab if browser does not support popup. --- .../src/module/options.coffee | 9 +++++++-- omega-web/src/popup.jade | 1 + omega-web/src/popup/index.html | 1 + omega-web/src/popup/js/index.js | 3 +++ omega-web/src/popup/proxy_not_controllable.html | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/omega-target-chromium-extension/src/module/options.coffee b/omega-target-chromium-extension/src/module/options.coffee index a3d0228..d08cd71 100644 --- a/omega-target-chromium-extension/src/module/options.coffee +++ b/omega-target-chromium-extension/src/module/options.coffee @@ -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) -> diff --git a/omega-web/src/popup.jade b/omega-web/src/popup.jade index 5d9807f..aab0aff 100644 --- a/omega-web/src/popup.jade +++ b/omega-web/src/popup.jade @@ -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}') diff --git a/omega-web/src/popup/index.html b/omega-web/src/popup/index.html index b0826d3..dd194a0 100644 --- a/omega-web/src/popup/index.html +++ b/omega-web/src/popup/index.html @@ -3,6 +3,7 @@ SwitchyOmega Popup + diff --git a/omega-web/src/popup/js/index.js b/omega-web/src/popup/js/index.js index 4ec1154..d5c7824 100644 --- a/omega-web/src/popup/js/index.js +++ b/omega-web/src/popup/js/index.js @@ -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) { diff --git a/omega-web/src/popup/proxy_not_controllable.html b/omega-web/src/popup/proxy_not_controllable.html index e9728d7..df5f64f 100644 --- a/omega-web/src/popup/proxy_not_controllable.html +++ b/omega-web/src/popup/proxy_not_controllable.html @@ -3,6 +3,7 @@ SwitchyOmega Popup +