mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 518468 - no easy way to undo after installation of a lightweight theme. r=dtownsend
This commit is contained in:
parent
711b961c05
commit
8b5b0ca856
@ -7062,7 +7062,7 @@ var LightWeightThemeWebInstaller = {
|
||||
handleEvent: function (event) {
|
||||
switch (event.type) {
|
||||
case "InstallBrowserTheme":
|
||||
this._install(event);
|
||||
this._installRequest(event);
|
||||
break;
|
||||
case "PreviewBrowserTheme":
|
||||
this._preview(event);
|
||||
@ -7080,14 +7080,14 @@ var LightWeightThemeWebInstaller = {
|
||||
return this._manager = temp.LightweightThemeManager;
|
||||
},
|
||||
|
||||
_install: function (event) {
|
||||
_installRequest: function (event) {
|
||||
var node = event.target;
|
||||
var data = this._getThemeFromNode(node);
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
if (this._isAllowed(node)) {
|
||||
this._manager.currentTheme = data;
|
||||
this._install(data);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -7102,15 +7102,66 @@ var LightWeightThemeWebInstaller = {
|
||||
label: allowButtonText,
|
||||
accessKey: allowButtonAccesskey,
|
||||
callback: function () {
|
||||
LightWeightThemeWebInstaller._manager.currentTheme = data;
|
||||
LightWeightThemeWebInstaller._install(data);
|
||||
}
|
||||
}];
|
||||
|
||||
this._removePreviousNotifications();
|
||||
|
||||
var notificationBox = gBrowser.getNotificationBox();
|
||||
notificationBox.appendNotification(message, "lwtheme-install-request", "",
|
||||
notificationBox.PRIORITY_INFO_MEDIUM,
|
||||
buttons);
|
||||
},
|
||||
|
||||
_install: function (newTheme) {
|
||||
var previousTheme = this._manager.currentTheme;
|
||||
this._manager.currentTheme = newTheme;
|
||||
if (this._manager.currentTheme &&
|
||||
this._manager.currentTheme.id == newTheme.id)
|
||||
this._postInstallNotification(newTheme, previousTheme);
|
||||
},
|
||||
|
||||
_postInstallNotification: function (newTheme, previousTheme) {
|
||||
function text(id) {
|
||||
return gNavigatorBundle.getString("lwthemePostInstallNotification." + id);
|
||||
}
|
||||
|
||||
var buttons = [{
|
||||
label: text("undoButton"),
|
||||
accessKey: text("undoButton.accesskey"),
|
||||
callback: function () {
|
||||
LightWeightThemeWebInstaller._manager.forgetUsedTheme(newTheme.id);
|
||||
LightWeightThemeWebInstaller._manager.currentTheme = previousTheme;
|
||||
}
|
||||
}, {
|
||||
label: text("manageButton"),
|
||||
accessKey: text("manageButton.accesskey"),
|
||||
callback: function () {
|
||||
BrowserOpenAddonsMgr("themes");
|
||||
}
|
||||
}];
|
||||
|
||||
this._removePreviousNotifications();
|
||||
|
||||
var notificationBox = gBrowser.getNotificationBox();
|
||||
notificationBox.appendNotification(text("message"),
|
||||
"lwtheme-install-notification", "",
|
||||
notificationBox.PRIORITY_INFO_MEDIUM,
|
||||
buttons);
|
||||
},
|
||||
|
||||
_removePreviousNotifications: function () {
|
||||
var box = gBrowser.getNotificationBox();
|
||||
|
||||
["lwtheme-install-request",
|
||||
"lwtheme-install-notification"].forEach(function (value) {
|
||||
var notification = box.getNotificationWithValue(value);
|
||||
if (notification)
|
||||
box.removeNotification(notification);
|
||||
});
|
||||
},
|
||||
|
||||
_preview: function (event) {
|
||||
if (!this._isAllowed(event.target))
|
||||
return;
|
||||
|
@ -39,6 +39,12 @@ lwthemeInstallRequest.message=This site (%S) attempted to install a theme.
|
||||
lwthemeInstallRequest.allowButton=Allow
|
||||
lwthemeInstallRequest.allowButton.accesskey=a
|
||||
|
||||
lwthemePostInstallNotification.message=A new theme has been installed.
|
||||
lwthemePostInstallNotification.undoButton=Undo
|
||||
lwthemePostInstallNotification.undoButton.accesskey=U
|
||||
lwthemePostInstallNotification.manageButton=Manage Themes…
|
||||
lwthemePostInstallNotification.manageButton.accesskey=M
|
||||
|
||||
popupWarning=%S prevented this site from opening a pop-up window.
|
||||
popupWarningMultiple=%S prevented this site from opening %S pop-up windows.
|
||||
popupWarningButton=Options
|
||||
|
Loading…
Reference in New Issue
Block a user