From a3fb35be007a44e5ba35e5ee9d75af3634bf5dac Mon Sep 17 00:00:00 2001 From: Daniel MacDougall Date: Sat, 18 Aug 2012 22:58:15 -0700 Subject: Move inline popup javascript to popup.js --- popup.html | 141 +++++++++++++++++++++++++++---------------------------------- popup.js | 20 +++++++++ 2 files changed, 82 insertions(+), 79 deletions(-) create mode 100644 popup.js diff --git a/popup.html b/popup.html index 7fb9b646..c5944992 100644 --- a/popup.html +++ b/popup.html @@ -1,79 +1,62 @@ - - -
-
- - - -
- -
- -
-
- - - - + + + + + + +
+
+ + + +
+ +
+ +
+
+ + diff --git a/popup.js b/popup.js new file mode 100644 index 00000000..859f30f3 --- /dev/null +++ b/popup.js @@ -0,0 +1,20 @@ +function onLoad() { + document.getElementById("optionsLink").setAttribute("href", chrome.extension.getURL("options.html")); + chrome.tabs.getSelected(null, function(tab) { + // The common use case is to disable Vimium at the domain level. + // This regexp will match "http://www.example.com/" from "http://www.example.com/path/to/page.html". + var domain = tab.url.match(/[^\/]*\/\/[^\/]*\//) || tab.url; + document.getElementById("popupInput").value = domain + "*"; + }); +} + +function onExcludeUrl(e) { + var url = document.getElementById("popupInput").value; + chrome.extension.getBackgroundPage().addExcludedUrl(url); + document.getElementById("excludeConfirm").setAttribute("style", "display: inline-block"); +} + +document.addEventListener("DOMContentLoaded", function() { + document.getElementById("popupButton").addEventListener("click", onExcludeUrl, false); + onLoad(); +}); -- cgit v1.2.3 From 038ae30e4275aa5b59d84833f2cdca38a40bfc71 Mon Sep 17 00:00:00 2001 From: Daniel MacDougall Date: Sat, 18 Aug 2012 23:29:52 -0700 Subject: Re-enable browser action with new icons --- background_scripts/main.js | 11 ++++------- icons/browser_action_disabled.png | Bin 0 -> 32025 bytes icons/browser_action_enabled.png | Bin 0 -> 37455 bytes manifest.json | 6 +++++- 4 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 icons/browser_action_disabled.png create mode 100644 icons/browser_action_enabled.png diff --git a/background_scripts/main.js b/background_scripts/main.js index 41fb3441..605eeb0c 100644 --- a/background_scripts/main.js +++ b/background_scripts/main.js @@ -359,16 +359,13 @@ function updateOpenTabs(tab) { * 3. Active tab is enabled but should be disabled -> disable icon and disable vimium */ function updateActiveState(tabId) { - // TODO(philc): Re-enable once we've restyled the browser action icon. - return; - var enabledIcon = "icons/icon48.png"; - var disabledIcon = "icons/icon48disabled.png"; + var enabledIcon = "icons/browser_action_enabled.png"; + var disabledIcon = "icons/browser_action_disabled.png"; chrome.tabs.get(tabId, function(tab) { // Default to disabled state in case we can't connect to Vimium, primarily for the "New Tab" page. - // TODO(philc): Re-enable once we've restyled the browser action icon. - // chrome.browserAction.setIcon({ path: disabledIcon }); + chrome.browserAction.setIcon({ path: disabledIcon }); chrome.tabs.sendRequest(tabId, { name: "getActiveState" }, function(response) { - var isCurrentlyEnabled = response.enabled; + var isCurrentlyEnabled = response !== undefined && response.enabled; var shouldBeEnabled = isEnabledForUrl({url: tab.url}).isEnabledForUrl; if (isCurrentlyEnabled) { diff --git a/icons/browser_action_disabled.png b/icons/browser_action_disabled.png new file mode 100644 index 00000000..458ffe72 Binary files /dev/null and b/icons/browser_action_disabled.png differ diff --git a/icons/browser_action_enabled.png b/icons/browser_action_enabled.png new file mode 100644 index 00000000..fe4c36bb Binary files /dev/null and b/icons/browser_action_enabled.png differ diff --git a/manifest.json b/manifest.json index 5c451700..f872660d 100644 --- a/manifest.json +++ b/manifest.json @@ -39,5 +39,9 @@ "run_at": "document_start", "all_frames": true } - ] + ], + "browser_action": { + "default_icon": "icons/browser_action_disabled.png", + "default_popup": "popup.html" + } } -- cgit v1.2.3