mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 19:47:32 +09:00
Issue #832 Part 1: Remove modules, chrome, and preferences.
This commit is contained in:
parent
2bce502df7
commit
7dac76098e
21 changed files with 0 additions and 2998 deletions
|
|
@ -31,18 +31,6 @@ var gContentPane = {
|
|||
menulist.value = FontBuilder.readFontSelection(menulist);
|
||||
}
|
||||
|
||||
// Show translation preferences if we may:
|
||||
const prefName = "browser.translation.ui.show";
|
||||
if (Services.prefs.getBoolPref(prefName)) {
|
||||
let row = document.getElementById("translationBox");
|
||||
row.removeAttribute("hidden");
|
||||
// Showing attribution only for Bing Translator.
|
||||
Components.utils.import("resource:///modules/translation/Translation.jsm");
|
||||
if (Translation.translationEngine == "bing") {
|
||||
document.getElementById("bingAttribution").removeAttribute("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
if (AlertsServiceDND) {
|
||||
let notificationsDoNotDisturbRow =
|
||||
document.getElementById("notificationsDoNotDisturbRow");
|
||||
|
|
@ -66,10 +54,6 @@ var gContentPane = {
|
|||
gContentPane.configureColors);
|
||||
setEventListener("chooseLanguage", "command",
|
||||
gContentPane.showLanguages);
|
||||
setEventListener("translationAttributionImage", "click",
|
||||
gContentPane.openTranslationProviderAttribution);
|
||||
setEventListener("translateButton", "command",
|
||||
gContentPane.showTranslationExceptions);
|
||||
setEventListener("notificationsDoNotDisturb", "command",
|
||||
gContentPane.toggleDoNotDisturbNotifications);
|
||||
|
||||
|
|
@ -274,21 +258,6 @@ var gContentPane = {
|
|||
gSubDialog.open("chrome://browser/content/preferences/languages.xul");
|
||||
},
|
||||
|
||||
/**
|
||||
* Displays the translation exceptions dialog where specific site and language
|
||||
* translation preferences can be set.
|
||||
*/
|
||||
showTranslationExceptions: function ()
|
||||
{
|
||||
gSubDialog.open("chrome://browser/content/preferences/translation.xul");
|
||||
},
|
||||
|
||||
openTranslationProviderAttribution: function ()
|
||||
{
|
||||
Components.utils.import("resource:///modules/translation/Translation.jsm");
|
||||
Translation.openProviderAttribution();
|
||||
},
|
||||
|
||||
toggleDoNotDisturbNotifications: function (event)
|
||||
{
|
||||
AlertsServiceDND.manualDoNotDisturb = event.target.checked;
|
||||
|
|
|
|||
|
|
@ -22,11 +22,6 @@
|
|||
<preference id="font.language.group"
|
||||
name="font.language.group"
|
||||
type="wstring"/>
|
||||
|
||||
<!-- Languages -->
|
||||
<preference id="browser.translation.detectLanguage"
|
||||
name="browser.translation.detectLanguage"
|
||||
type="bool"/>
|
||||
</preferences>
|
||||
|
||||
<script type="application/javascript"
|
||||
|
|
@ -191,23 +186,4 @@
|
|||
label="&chooseButton.label;"
|
||||
accesskey="&chooseButton.accesskey;"/>
|
||||
</hbox>
|
||||
|
||||
<hbox id="translationBox" hidden="true">
|
||||
<hbox align="center" flex="1">
|
||||
<checkbox id="translate" preference="browser.translation.detectLanguage"
|
||||
label="&translateWebPages.label;." accesskey="&translateWebPages.accesskey;"
|
||||
onsyncfrompreference="return gContentPane.updateButtons('translateButton',
|
||||
'browser.translation.detectLanguage');"/>
|
||||
<hbox id="bingAttribution" hidden="true">
|
||||
<label>&translation.options.attribution.beforeLogo;</label>
|
||||
<separator orient="vertical" class="thin"/>
|
||||
<image id="translationAttributionImage" aria-label="Microsoft Translator"
|
||||
src="chrome://browser/content/microsoft-translator-attribution.png"/>
|
||||
<separator orient="vertical" class="thin"/>
|
||||
<label>&translation.options.attribution.afterLogo;</label>
|
||||
</hbox>
|
||||
</hbox>
|
||||
<button id="translateButton" label="&translateExceptions.label;"
|
||||
accesskey="&translateExceptions.accesskey;"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
|
|
|
|||
|
|
@ -31,5 +31,3 @@ browser.jar:
|
|||
content/browser/preferences/sanitize.js
|
||||
content/browser/preferences/selectBookmark.xul
|
||||
content/browser/preferences/selectBookmark.js
|
||||
content/browser/preferences/translation.xul
|
||||
content/browser/preferences/translation.js
|
||||
|
|
|
|||
|
|
@ -1,255 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gLangBundle", () =>
|
||||
Services.strings.createBundle("chrome://global/locale/languageNames.properties"));
|
||||
|
||||
const kPermissionType = "translate";
|
||||
const kLanguagesPref = "browser.translation.neverForLanguages";
|
||||
|
||||
function Tree(aId, aData)
|
||||
{
|
||||
this._data = aData;
|
||||
this._tree = document.getElementById(aId);
|
||||
this._tree.view = this;
|
||||
}
|
||||
|
||||
Tree.prototype = {
|
||||
get boxObject() {
|
||||
return this._tree.treeBoxObject;
|
||||
},
|
||||
get isEmpty() {
|
||||
return !this._data.length;
|
||||
},
|
||||
get hasSelection() {
|
||||
return this.selection.count > 0;
|
||||
},
|
||||
getSelectedItems: function() {
|
||||
let result = [];
|
||||
|
||||
let rc = this.selection.getRangeCount();
|
||||
for (let i = 0; i < rc; ++i) {
|
||||
let min = {}, max = {};
|
||||
this.selection.getRangeAt(i, min, max);
|
||||
for (let j = min.value; j <= max.value; ++j)
|
||||
result.push(this._data[j]);
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
// nsITreeView implementation
|
||||
get rowCount() {
|
||||
return this._data.length;
|
||||
},
|
||||
getCellText: function (aRow, aColumn) {
|
||||
return this._data[aRow];
|
||||
},
|
||||
isSeparator: function(aIndex) {
|
||||
return false;
|
||||
},
|
||||
isSorted: function() {
|
||||
return false;
|
||||
},
|
||||
isContainer: function(aIndex) {
|
||||
return false;
|
||||
},
|
||||
setTree: function(aTree) {},
|
||||
getImageSrc: function(aRow, aColumn) {},
|
||||
getProgressMode: function(aRow, aColumn) {},
|
||||
getCellValue: function(aRow, aColumn) {},
|
||||
cycleHeader: function(column) {},
|
||||
getRowProperties: function(row) {
|
||||
return "";
|
||||
},
|
||||
getColumnProperties: function(column) {
|
||||
return "";
|
||||
},
|
||||
getCellProperties: function(row, column) {
|
||||
return "";
|
||||
},
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsITreeView])
|
||||
};
|
||||
|
||||
function Lang(aCode)
|
||||
{
|
||||
this.langCode = aCode;
|
||||
this._label = gLangBundle.GetStringFromName(aCode);
|
||||
}
|
||||
|
||||
Lang.prototype = {
|
||||
toString: function() {
|
||||
return this._label;
|
||||
}
|
||||
}
|
||||
|
||||
var gTranslationExceptions = {
|
||||
onLoad: function() {
|
||||
if (this._siteTree) {
|
||||
// Re-using an open dialog, clear the old observers.
|
||||
this.uninit();
|
||||
}
|
||||
|
||||
// Load site permissions into an array.
|
||||
this._sites = [];
|
||||
let enumerator = Services.perms.enumerator;
|
||||
while (enumerator.hasMoreElements()) {
|
||||
let perm = enumerator.getNext().QueryInterface(Ci.nsIPermission);
|
||||
|
||||
if (perm.type == kPermissionType &&
|
||||
perm.capability == Services.perms.DENY_ACTION) {
|
||||
this._sites.push(perm.principal.origin);
|
||||
}
|
||||
}
|
||||
Services.obs.addObserver(this, "perm-changed", false);
|
||||
this._sites.sort();
|
||||
|
||||
this._siteTree = new Tree("sitesTree", this._sites);
|
||||
this.onSiteSelected();
|
||||
|
||||
this._langs = this.getLanguageExceptions();
|
||||
Services.prefs.addObserver(kLanguagesPref, this, false);
|
||||
this._langTree = new Tree("languagesTree", this._langs);
|
||||
this.onLanguageSelected();
|
||||
},
|
||||
|
||||
// Get the list of languages we don't translate as an array.
|
||||
getLanguageExceptions: function() {
|
||||
let langs = Services.prefs.getCharPref(kLanguagesPref);
|
||||
if (!langs)
|
||||
return [];
|
||||
|
||||
let result = langs.split(",").map(code => new Lang(code));
|
||||
result.sort();
|
||||
|
||||
return result;
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic == "perm-changed") {
|
||||
if (aData == "cleared") {
|
||||
if (!this._sites.length)
|
||||
return;
|
||||
let removed = this._sites.splice(0, this._sites.length);
|
||||
this._siteTree.boxObject.rowCountChanged(0, - removed.length);
|
||||
}
|
||||
else {
|
||||
let perm = aSubject.QueryInterface(Ci.nsIPermission);
|
||||
if (perm.type != kPermissionType)
|
||||
return;
|
||||
|
||||
if (aData == "added") {
|
||||
if (perm.capability != Services.perms.DENY_ACTION)
|
||||
return;
|
||||
this._sites.push(perm.principal.origin);
|
||||
this._sites.sort();
|
||||
let boxObject = this._siteTree.boxObject;
|
||||
boxObject.rowCountChanged(0, 1);
|
||||
boxObject.invalidate();
|
||||
}
|
||||
else if (aData == "deleted") {
|
||||
let index = this._sites.indexOf(perm.principal.origin);
|
||||
if (index == -1)
|
||||
return;
|
||||
this._sites.splice(index, 1);
|
||||
this._siteTree.boxObject.rowCountChanged(index, -1);
|
||||
this.onSiteSelected();
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.onSiteSelected();
|
||||
}
|
||||
else if (aTopic == "nsPref:changed") {
|
||||
this._langs = this.getLanguageExceptions();
|
||||
let change = this._langs.length - this._langTree.rowCount;
|
||||
this._langTree._data = this._langs;
|
||||
let boxObject = this._langTree.boxObject;
|
||||
if (change)
|
||||
boxObject.rowCountChanged(0, change);
|
||||
boxObject.invalidate();
|
||||
this.onLanguageSelected();
|
||||
}
|
||||
},
|
||||
|
||||
_handleButtonDisabling: function(aTree, aIdPart) {
|
||||
let empty = aTree.isEmpty;
|
||||
document.getElementById("removeAll" + aIdPart + "s").disabled = empty;
|
||||
document.getElementById("remove" + aIdPart).disabled =
|
||||
empty || !aTree.hasSelection;
|
||||
},
|
||||
|
||||
onLanguageSelected: function() {
|
||||
this._handleButtonDisabling(this._langTree, "Language");
|
||||
},
|
||||
|
||||
onSiteSelected: function() {
|
||||
this._handleButtonDisabling(this._siteTree, "Site");
|
||||
},
|
||||
|
||||
onLanguageDeleted: function() {
|
||||
let langs = Services.prefs.getCharPref(kLanguagesPref);
|
||||
if (!langs)
|
||||
return;
|
||||
|
||||
let removed = this._langTree.getSelectedItems().map(l => l.langCode);
|
||||
|
||||
langs = langs.split(",").filter(l => removed.indexOf(l) == -1);
|
||||
Services.prefs.setCharPref(kLanguagesPref, langs.join(","));
|
||||
},
|
||||
|
||||
onAllLanguagesDeleted: function() {
|
||||
Services.prefs.setCharPref(kLanguagesPref, "");
|
||||
},
|
||||
|
||||
onSiteDeleted: function() {
|
||||
let removedSites = this._siteTree.getSelectedItems();
|
||||
for (let origin of removedSites) {
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin);
|
||||
Services.perms.removeFromPrincipal(principal, kPermissionType);
|
||||
}
|
||||
},
|
||||
|
||||
onAllSitesDeleted: function() {
|
||||
if (this._siteTree.isEmpty)
|
||||
return;
|
||||
|
||||
let removedSites = this._sites.splice(0, this._sites.length);
|
||||
this._siteTree.boxObject.rowCountChanged(0, -removedSites.length);
|
||||
|
||||
for (let origin of removedSites) {
|
||||
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin);
|
||||
Services.perms.removeFromPrincipal(principal, kPermissionType);
|
||||
}
|
||||
|
||||
this.onSiteSelected();
|
||||
},
|
||||
|
||||
onSiteKeyPress: function(aEvent) {
|
||||
if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE)
|
||||
this.onSiteDeleted();
|
||||
},
|
||||
|
||||
onLanguageKeyPress: function(aEvent) {
|
||||
if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE)
|
||||
this.onLanguageDeleted();
|
||||
},
|
||||
|
||||
onWindowKeyPress: function(aEvent) {
|
||||
if (aEvent.keyCode == KeyEvent.DOM_VK_ESCAPE)
|
||||
window.close();
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
Services.obs.removeObserver(this, "perm-changed");
|
||||
Services.prefs.removeObserver(kLanguagesPref, this);
|
||||
}
|
||||
};
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://browser/skin/preferences/preferences.css" type="text/css"?>
|
||||
|
||||
<!DOCTYPE dialog SYSTEM "chrome://browser/locale/preferences/translation.dtd">
|
||||
|
||||
<window id="TranslationDialog" class="windowDialog"
|
||||
windowtype="Browser:TranslationExceptions"
|
||||
title="&window.title;"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
style="width: &window.width;;"
|
||||
onload="gTranslationExceptions.onLoad();"
|
||||
onunload="gTranslationExceptions.uninit();"
|
||||
persist="screenX screenY width height"
|
||||
onkeypress="gTranslationExceptions.onWindowKeyPress(event);">
|
||||
|
||||
<script src="chrome://browser/content/preferences/translation.js"/>
|
||||
|
||||
<stringbundle id="bundlePreferences"
|
||||
src="chrome://browser/locale/preferences/preferences.properties"/>
|
||||
|
||||
<keyset>
|
||||
<key key="&windowClose.key;" modifiers="accel" oncommand="window.close();"/>
|
||||
</keyset>
|
||||
|
||||
<vbox class="largeDialogContainer">
|
||||
<vbox class="contentPane" flex="1">
|
||||
<label id="languagesLabel" control="permissionsTree">&noTranslationForLanguages.label;</label>
|
||||
<separator class="thin"/>
|
||||
<tree id="languagesTree" flex="1" style="height: 12em;"
|
||||
hidecolumnpicker="true"
|
||||
onkeypress="gTranslationExceptions.onLanguageKeyPress(event)"
|
||||
onselect="gTranslationExceptions.onLanguageSelected();">
|
||||
<treecols>
|
||||
<treecol id="languageCol" label="&treehead.languageName.label;" flex="1"/>
|
||||
</treecols>
|
||||
<treechildren/>
|
||||
</tree>
|
||||
</vbox>
|
||||
<hbox align="end">
|
||||
<hbox class="actionButtons" flex="1">
|
||||
<button id="removeLanguage" disabled="true"
|
||||
accesskey="&removeLanguage.accesskey;"
|
||||
icon="remove" label="&removeLanguage.label;"
|
||||
oncommand="gTranslationExceptions.onLanguageDeleted();"/>
|
||||
<button id="removeAllLanguages"
|
||||
icon="clear" label="&removeAllLanguages.label;"
|
||||
accesskey="&removeAllLanguages.accesskey;"
|
||||
oncommand="gTranslationExceptions.onAllLanguagesDeleted();"/>
|
||||
<spacer flex="1"/>
|
||||
</hbox>
|
||||
</hbox>
|
||||
<separator/>
|
||||
<vbox class="contentPane" flex="1">
|
||||
<label id="languagesLabel" control="permissionsTree">&noTranslationForSites.label;</label>
|
||||
<separator class="thin"/>
|
||||
<tree id="sitesTree" flex="1" style="height: 12em;"
|
||||
hidecolumnpicker="true"
|
||||
onkeypress="gTranslationExceptions.onSiteKeyPress(event)"
|
||||
onselect="gTranslationExceptions.onSiteSelected();">
|
||||
<treecols>
|
||||
<treecol id="siteCol" label="&treehead.siteName.label;" flex="1"/>
|
||||
</treecols>
|
||||
<treechildren/>
|
||||
</tree>
|
||||
</vbox>
|
||||
</vbox>
|
||||
<hbox align="end">
|
||||
<hbox class="actionButtons" flex="1">
|
||||
<button id="removeSite" disabled="true"
|
||||
accesskey="&removeSite.accesskey;"
|
||||
icon="remove" label="&removeSite.label;"
|
||||
oncommand="gTranslationExceptions.onSiteDeleted();"/>
|
||||
<button id="removeAllSites"
|
||||
icon="clear" label="&removeAllSites.label;"
|
||||
accesskey="&removeAllSites.accesskey;"
|
||||
oncommand="gTranslationExceptions.onAllSitesDeleted();"/>
|
||||
<spacer flex="1"/>
|
||||
<button oncommand="close();" icon="close"
|
||||
label="&button.close.label;" accesskey="&button.close.accesskey;"/>
|
||||
</hbox>
|
||||
</hbox>
|
||||
</window>
|
||||
Loading…
Add table
Add a link
Reference in a new issue