mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 11:37:30 +09:00
[AllAM] De-duplicate blocklist.js, list.js, newaddon.js, and xpinstallConfirm.js
This commit is contained in:
parent
65984db0eb
commit
f22be8ca31
9 changed files with 30 additions and 592 deletions
|
|
@ -26,7 +26,7 @@ function init() {
|
|||
|
||||
var richlist = document.getElementById("addonList");
|
||||
var list = gArgs.list;
|
||||
list.sort(function listSort(a, b) { return String.localeCompare(a.name, b.name); });
|
||||
list.sort(function(a, b) { return String.localeCompare(a.name, b.name); });
|
||||
for (let listItem of list) {
|
||||
let item = document.createElement("richlistitem");
|
||||
item.setAttribute("name", listItem.name);
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ const kDialog = "dialog";
|
|||
* caller can inspect the user action after the dialog closes by inspecting the
|
||||
* value of the |result| parameter on this object which is set to the dlgtype
|
||||
* of the button used to close the dialog.
|
||||
*
|
||||
*
|
||||
* window.arguments[0] is an array of strings to display in the tree. If the
|
||||
* array is empty the tree will not be displayed.
|
||||
* window.arguments[1] a JS Object with the following properties:
|
||||
*
|
||||
*
|
||||
* title: A title string, to be displayed in the title bar of the dialog.
|
||||
* message1: A message string, displayed above the addon list
|
||||
* message2: A message string, displayed below the addon list
|
||||
|
|
@ -39,7 +39,7 @@ const kDialog = "dialog";
|
|||
* ...
|
||||
* },
|
||||
*
|
||||
* result: The dlgtype of button that was used to dismiss the dialog.
|
||||
* result: The dlgtype of button that was used to dismiss the dialog.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
|
@ -113,7 +113,7 @@ function init() {
|
|||
message.appendChild(document.createTextNode(params[messageEntry]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
document.getElementById("infoIcon").className =
|
||||
params["iconClass"] ? "spaced " + params["iconClass"] : "spaced alert-icon";
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ var gAddon = null;
|
|||
|
||||
// If the user enables the add-on through some other UI close this window
|
||||
var EnableListener = {
|
||||
onEnabling: function EnableListener_onEnabling(aAddon) {
|
||||
onEnabling: function(aAddon) {
|
||||
if (aAddon.id == gAddon.id)
|
||||
window.close();
|
||||
}
|
||||
|
|
@ -38,11 +38,11 @@ function initialize() {
|
|||
|
||||
let bundle = Services.strings.createBundle("chrome://mozapps/locale/extensions/newaddon.properties");
|
||||
|
||||
AddonManager.getAddonByID(id, function initialize_getAddonByID(aAddon) {
|
||||
// If the add-on doesn't exist or it is already enabled or it cannot be
|
||||
// enabled then this UI is useless, just close it. This shouldn't normally
|
||||
// happen unless session restore restores the tab
|
||||
if (!aAddon || !aAddon.userDisabled ||
|
||||
AddonManager.getAddonByID(id, function(aAddon) {
|
||||
// If the add-on doesn't exist or it is already enabled or it has already
|
||||
// been seen or it cannot be enabled then this UI is useless, just close it.
|
||||
// This shouldn't normally happen unless session restore restores the tab.
|
||||
if (!aAddon || !aAddon.userDisabled || aAddon.seen ||
|
||||
!(aAddon.permissions & AddonManager.PERM_CAN_ENABLE)) {
|
||||
window.close();
|
||||
return;
|
||||
|
|
@ -79,6 +79,14 @@ function initialize() {
|
|||
document.getElementById("location").hidden = true;
|
||||
}
|
||||
|
||||
// Only mark the add-on as seen if the page actually gets focus
|
||||
if (document.hasFocus()) {
|
||||
aAddon.markAsSeen();
|
||||
}
|
||||
else {
|
||||
document.addEventListener("focus", () => aAddon.markAsSeen(), false);
|
||||
}
|
||||
|
||||
var event = document.createEvent("Events");
|
||||
event.initEvent("AddonDisplayed", true, true);
|
||||
document.dispatchEvent(event);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
var XPInstallConfirm = {};
|
||||
|
||||
XPInstallConfirm.init = function XPInstallConfirm_init()
|
||||
XPInstallConfirm.init = function()
|
||||
{
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init()
|
|||
var delay_in_milliseconds = prefs.getIntPref("security.dialog_enable_delay");
|
||||
_installCountdownLength = Math.round(delay_in_milliseconds / 500);
|
||||
} catch (ex) { }
|
||||
|
||||
|
||||
var itemList = document.getElementById("itemList");
|
||||
|
||||
let installMap = new WeakMap();
|
||||
|
|
@ -47,7 +47,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init()
|
|||
window.close();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var numItemsToInstall = args.installs.length;
|
||||
for (let install of args.installs) {
|
||||
var installItem = document.createElement("installitem");
|
||||
|
|
@ -72,7 +72,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init()
|
|||
installMap.set(install, installItem);
|
||||
install.addListener(installListener);
|
||||
}
|
||||
|
||||
|
||||
var introString = bundle.getString("itemWarnIntroSingle");
|
||||
if (numItemsToInstall > 4)
|
||||
introString = bundle.getFormattedString("itemWarnIntroMultiple", [numItemsToInstall]);
|
||||
|
|
@ -81,7 +81,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init()
|
|||
while (introNode.hasChildNodes())
|
||||
introNode.removeChild(introNode.firstChild);
|
||||
introNode.appendChild(textNode);
|
||||
|
||||
|
||||
var okButton = document.documentElement.getButton("accept");
|
||||
okButton.focus();
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ XPInstallConfirm.init = function XPInstallConfirm_init()
|
|||
okButton.label = bundle.getString("installButtonLabel");
|
||||
}
|
||||
|
||||
XPInstallConfirm.onOK = function XPInstallConfirm_onOk()
|
||||
XPInstallConfirm.onOK = function()
|
||||
{
|
||||
Components.classes["@mozilla.org/base/telemetry;1"].
|
||||
getService(Components.interfaces.nsITelemetry).
|
||||
|
|
@ -188,7 +188,7 @@ XPInstallConfirm.onOK = function XPInstallConfirm_onOk()
|
|||
return true;
|
||||
}
|
||||
|
||||
XPInstallConfirm.onCancel = function XPInstallConfirm_onCancel()
|
||||
XPInstallConfirm.onCancel = function()
|
||||
{
|
||||
// Perform the install or cancel after the window has unloaded
|
||||
XPInstallConfirm._installOK = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue