From 781da8b0cbf735fa0f6183d8db58cf59d00e7cb1 Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sat, 30 Jan 2010 00:48:49 -0800 Subject: Save the current version to localStorage, and when an update arrives, show a user notification. This closes #64. Note that updates won't trigger until we've saved the user's version to their localStorage, which means this change will go into effect for our users the version *after* the next release (so 1.16). --- background_page.html | 74 ++++++++++++++++++++++++++++++++++++++++++++++------ vimiumFrontend.js | 22 ++++++++++++---- 2 files changed, 83 insertions(+), 13 deletions(-) diff --git a/background_page.html b/background_page.html index 9b10172e..e98c7453 100644 --- a/background_page.html +++ b/background_page.html @@ -1,6 +1,10 @@ - + \ No newline at end of file diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 6a864cc4..4d380d2d 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -82,6 +82,14 @@ function initializePreDomReady() { else platform = "Windows"; + chrome.extension.onRequest.addListener(function(request, sender, sendResponse) { + if (request.name == "hideUpgradeNotification") + HUD.hideUpgradeNotification(); + else if (request.name == "showUpgradeNotification" && isEnabledForUrl) + HUD.showUpgradeNotification(request.version); + sendResponse({}); // Free up the resources used by this open connection. + }); + chrome.extension.onConnect.addListener(function(port, name) { if (port.name == "executePageCommand") { port.onMessage.addListener(function(args) { @@ -536,15 +544,19 @@ HUD = { showUpgradeNotification: function(version) { HUD.upgradeNotificationElement().innerHTML = "Vimium has been updated to " + "" + - version + ".x"; - var closeLink = HUD.upgradeNotificationElement().getElementsByClassName("close-button")[0]; - closeLink.addEventListener("click", HUD.onCloseNotificationClick, false); + version + ".x"; + var links = HUD.upgradeNotificationElement().getElementsByTagName("a"); + links[0].addEventListener("click", HUD.onUpdateLinkClicked, false); + links[1].addEventListener("click", function(event) { + event.preventDefault(); + HUD.onUpdateLinkClicked(); + }); Tween.fade(HUD.upgradeNotificationElement(), 1.0, 150); }, - onCloseNotificationClick: function(event) { - event.preventDefault(); + onUpdateLinkClicked: function(event) { HUD.hideUpgradeNotification(); + chrome.extension.sendRequest({ handler: "upgradeNotificationClosed" }); }, hideUpgradeNotification: function(clickEvent) { -- cgit v1.2.3