Bug 1478572 - Turn on ESLint in mail/components/preferences (automatic changes). r=aceman

This commit is contained in:
Geoff Lankow 2018-09-03 17:23:00 +12:00
Родитель 3701363684
Коммит 47d44c6d73
22 изменённых файлов: 569 добавлений и 848 удалений

Просмотреть файл

@ -66,6 +66,7 @@ mail/components/*
!mail/components/devtools
!mail/components/downloads
!mail/components/extensions
!mail/components/preferences
# calendar/ exclusions

Просмотреть файл

@ -8,24 +8,23 @@ var FILEACTION_OPEN_INTERNALLY = 2;
var FILEACTION_OPEN_DEFAULT = 3;
var FILEACTION_OPEN_CUSTOM = 4;
var FILEACTION_OPEN_PLUGIN = 5;
function FileAction ()
{
function FileAction() {
}
FileAction.prototype = {
type : "",
extension : "",
type: "",
extension: "",
hasExtension: true,
editable : true,
smallIcon : "",
bigIcon : "",
typeName : "",
action : "",
mimeInfo : null,
customHandler : "",
handleMode : false,
pluginAvailable : false,
pluginEnabled : false,
handledOnlyByPlugin : false
editable: true,
smallIcon: "",
bigIcon: "",
typeName: "",
action: "",
mimeInfo: null,
customHandler: "",
handleMode: false,
pluginAvailable: false,
pluginEnabled: false,
handledOnlyByPlugin: false,
};

Просмотреть файл

@ -18,8 +18,7 @@ var gAdvancedPane = {
mBundle: null,
requestingLocales: null,
init: function ()
{
init() {
this.mPane = document.getElementById("paneAdvanced");
this.updateCompactOptions();
this.mBundle = document.getElementById("bundlePreferences");
@ -29,8 +28,7 @@ var gAdvancedPane = {
this.initMessengerLocale();
}
if (!(("arguments" in window) && window.arguments[1]))
{
if (!(("arguments" in window) && window.arguments[1])) {
// If no tab was specified, select the last used tab.
let preference = document.getElementById("mail.preferences.advanced.selectedTabIndex");
if (preference.value)
@ -55,24 +53,18 @@ var gAdvancedPane = {
let hideSearchUI = false;
let disableSearchUI = false;
ChromeUtils.import("resource:///modules/SearchIntegration.js");
if (SearchIntegration)
{
if (SearchIntegration) {
if (SearchIntegration.osVersionTooLow)
hideSearchUI = true;
else if (SearchIntegration.osComponentsNotRunning)
disableSearchUI = true;
}
else
{
} else {
hideSearchUI = true;
}
if (hideSearchUI)
{
if (hideSearchUI) {
document.getElementById("searchIntegrationContainer").hidden = true;
}
else if (disableSearchUI)
{
} else if (disableSearchUI) {
let searchCheckbox = document.getElementById("searchIntegration");
searchCheckbox.checked = false;
document.getElementById("searchintegration.enable").disabled = true;
@ -96,7 +88,7 @@ var gAdvancedPane = {
}
if (AppConstants.MOZ_UPDATER) {
let distroId = Services.prefs.getCharPref("distribution.id" , "");
let distroId = Services.prefs.getCharPref("distribution.id", "");
if (distroId) {
let distroVersion = Services.prefs.getCharPref("distribution.version");
@ -152,10 +144,8 @@ var gAdvancedPane = {
this.mInitialized = true;
},
tabSelectionChanged: function ()
{
if (this.mInitialized)
{
tabSelectionChanged() {
if (this.mInitialized) {
document.getElementById("mail.preferences.advanced.selectedTabIndex")
.valueFromPreferences = document.getElementById("advancedPrefs").selectedIndex;
}
@ -168,8 +158,7 @@ var gAdvancedPane = {
* default for each type; otherwise, the user is informed that Thunderbird is
* already the default.
*/
checkDefaultNow: function (aAppType)
{
checkDefaultNow(aAppType) {
if (!this.mShellServiceWorking)
return;
@ -178,16 +167,14 @@ var gAdvancedPane = {
"resizable=no", "calledFromPrefs");
},
showConfigEdit: function()
{
showConfigEdit() {
gSubDialog.open("chrome://global/content/config.xul");
},
/**
* Set the default store contract ID.
*/
updateDefaultStore: function(storeID)
{
updateDefaultStore(storeID) {
Services.prefs.setCharPref("mail.serverDefaultStoreContractID", storeID);
},
@ -201,14 +188,13 @@ var gAdvancedPane = {
*/
// Retrieves the amount of space currently used by disk cache
updateActualCacheSize: function()
{
updateActualCacheSize() {
let actualSizeLabel = document.getElementById("actualDiskCacheSize");
let prefStrBundle = document.getElementById("bundlePreferences");
// Needs to root the observer since cache service keeps only a weak reference.
this.observer = {
onNetworkCacheDiskConsumption: function(consumption) {
onNetworkCacheDiskConsumption(consumption) {
let size = DownloadUtils.convertByteUnits(consumption);
// The XBL binding for the string bundle may have been destroyed if
// the page was closed before this callback was executed.
@ -220,8 +206,8 @@ var gAdvancedPane = {
QueryInterface: ChromeUtils.generateQI([
Ci.nsICacheStorageConsumptionObserver,
Ci.nsISupportsWeakReference
])
Ci.nsISupportsWeakReference,
]),
};
actualSizeLabel.value = prefStrBundle.getString("actualDiskCacheSizeCalculated");
@ -234,15 +220,13 @@ var gAdvancedPane = {
} catch (e) {}
},
updateCacheSizeUI: function (smartSizeEnabled)
{
updateCacheSizeUI(smartSizeEnabled) {
document.getElementById("useCacheBefore").disabled = smartSizeEnabled;
document.getElementById("cacheSize").disabled = smartSizeEnabled;
document.getElementById("useCacheAfter").disabled = smartSizeEnabled;
},
readSmartSizeEnabled: function ()
{
readSmartSizeEnabled() {
// The smart_size.enabled preference element is inverted="true", so its
// value is the opposite of the actual pref value
var disabled = document.getElementById("browser.cache.disk.smart_size.enabled").value;
@ -253,8 +237,7 @@ var gAdvancedPane = {
* Converts the cache size from units of KB to units of MB and returns that
* value.
*/
readCacheSize: function ()
{
readCacheSize() {
var preference = document.getElementById("browser.cache.disk.capacity");
return preference.value / 1024;
},
@ -263,8 +246,7 @@ var gAdvancedPane = {
* Converts the cache size as specified in UI (in MB) to KB and returns that
* value.
*/
writeCacheSize: function ()
{
writeCacheSize() {
var cacheSize = document.getElementById("cacheSize");
var intValue = parseInt(cacheSize.value, 10);
return isNaN(intValue) ? 0 : intValue * 1024;
@ -273,8 +255,7 @@ var gAdvancedPane = {
/**
* Clears the cache.
*/
clearCache: function ()
{
clearCache() {
try {
let cache = Cc["@mozilla.org/netwerk/cache-storage-service;1"]
.getService(Ci.nsICacheStorageService);
@ -283,8 +264,7 @@ var gAdvancedPane = {
this.updateActualCacheSize();
},
updateButtons: function (aButtonID, aPreferenceID)
{
updateButtons(aButtonID, aPreferenceID) {
var button = document.getElementById(aButtonID);
var preference = document.getElementById(aPreferenceID);
// This is actually before the value changes, so the value is not as you expect.
@ -301,15 +281,14 @@ var gAdvancedPane = {
* UI Components: Preferences
* Radiogroup i = app.update.auto
*/
updateReadPrefs: function ()
{
updateReadPrefs() {
var autoPref = document.getElementById("app.update.auto");
var radiogroup = document.getElementById("updateRadioGroup");
if (autoPref.value)
radiogroup.value="auto"; // Automatically install updates
radiogroup.value = "auto"; // Automatically install updates
else
radiogroup.value="checkOnly"; // Check, but let me choose
radiogroup.value = "checkOnly"; // Check, but let me choose
var canCheck = Cc["@mozilla.org/updates/update-service;1"].
getService(Ci.nsIApplicationUpdateService).
@ -331,7 +310,7 @@ updateReadPrefs: function ()
wrk.ACCESS_READ | wrk.WOW64_64);
installed = wrk.readIntValue("Installed");
wrk.close();
} catch(e) { }
} catch (e) { }
if (installed != 1) {
document.getElementById("useService").hidden = true;
}
@ -341,8 +320,7 @@ updateReadPrefs: function ()
/**
* Sets the pref values based on the selected item of the radiogroup.
*/
updateWritePrefs: function ()
{
updateWritePrefs() {
var autoPref = document.getElementById("app.update.auto");
var radiogroup = document.getElementById("updateRadioGroup");
switch (radiogroup.value) {
@ -355,20 +333,17 @@ updateWritePrefs: function ()
}
},
showUpdates: function ()
{
showUpdates() {
gSubDialog.open("chrome://mozapps/content/update/history.xul");
},
updateCompactOptions: function(aCompactEnabled)
{
updateCompactOptions(aCompactEnabled) {
document.getElementById("offlineCompactFolderMin").disabled =
!document.getElementById("offlineCompactFolder").checked ||
document.getElementById("mail.purge_threshhold_mb").locked;
},
updateSubmitCrashReports: function(aChecked)
{
updateSubmitCrashReports(aChecked) {
Cc["@mozilla.org/toolkit/crash-reporter;1"]
.getService(Ci.nsICrashReporter)
.submitReports = aChecked;
@ -376,8 +351,7 @@ updateWritePrefs: function ()
/**
* Display the return receipts configuration dialog.
*/
showReturnReceipts: function()
{
showReturnReceipts() {
gSubDialog.open("chrome://messenger/content/preferences/receipts.xul",
"resizable=no");
},
@ -385,8 +359,7 @@ updateWritePrefs: function ()
/**
* Display the the connection settings dialog.
*/
showConnections: function ()
{
showConnections() {
gSubDialog.open("chrome://messenger/content/preferences/connection.xul",
"resizable=no");
},
@ -394,8 +367,7 @@ updateWritePrefs: function ()
/**
* Display the the offline settings dialog.
*/
showOffline: function()
{
showOffline() {
gSubDialog.open("chrome://messenger/content/preferences/offline.xul",
"resizable=no");
},
@ -403,8 +375,7 @@ updateWritePrefs: function ()
/**
* Display the user's certificates and associated options.
*/
showCertificates: function ()
{
showCertificates() {
gSubDialog.open("chrome://pippki/content/certManager.xul");
},
@ -412,8 +383,7 @@ updateWritePrefs: function ()
* security.OCSP.enabled is an integer value for legacy reasons.
* A value of 1 means OCSP is enabled. Any other value means it is disabled.
*/
readEnableOCSP: function ()
{
readEnableOCSP() {
var preference = document.getElementById("security.OCSP.enabled");
// This is the case if the preference is the default value.
if (preference.value === undefined) {
@ -425,8 +395,7 @@ updateWritePrefs: function ()
/**
* See documentation for readEnableOCSP.
*/
writeEnableOCSP: function ()
{
writeEnableOCSP() {
var checkbox = document.getElementById("enableOCSP");
return checkbox.checked ? 1 : 0;
},
@ -434,8 +403,7 @@ updateWritePrefs: function ()
/**
* Display a dialog from which the user can manage his security devices.
*/
showSecurityDevices: function ()
{
showSecurityDevices() {
gSubDialog.open("chrome://pippki/content/device_manager.xul");
},
@ -443,8 +411,7 @@ updateWritePrefs: function ()
* When the user toggles the layers.acceleration.disabled pref,
* sync its new value to the gfx.direct2d.disabled pref too.
*/
updateHardwareAcceleration: function(aVal)
{
updateHardwareAcceleration(aVal) {
if (AppConstants.platforms == "win")
Services.prefs.setBoolPref("gfx.direct2d.disabled", !aVal);
},
@ -454,7 +421,7 @@ updateWritePrefs: function ()
/**
* Open a text link.
*/
openTextLink: function (evt) {
openTextLink(evt) {
// Opening links behind a modal dialog is poor form. Work around flawed
// text-link handling by opening in browser if we'd instead get a content
// tab behind the modal options dialog.
@ -472,7 +439,7 @@ updateWritePrefs: function ()
/**
* Set up or hide the Learn More links for various data collection options
*/
_setupLearnMoreLink: function (pref, element) {
_setupLearnMoreLink(pref, element) {
// set up the Learn More link with the correct URL
let url = Services.prefs.getCharPref(pref);
let el = document.getElementById(element);
@ -484,8 +451,7 @@ updateWritePrefs: function ()
}
},
initSubmitCrashes: function ()
{
initSubmitCrashes() {
var checkbox = document.getElementById("submitCrashesBox");
try {
var cr = Cc["@mozilla.org/toolkit/crash-reporter;1"].
@ -497,8 +463,7 @@ updateWritePrefs: function ()
this._setupLearnMoreLink("toolkit.crashreporter.infoURL", "crashReporterLearnMore");
},
updateSubmitCrashes: function ()
{
updateSubmitCrashes() {
var checkbox = document.getElementById("submitCrashesBox");
try {
var cr = Cc["@mozilla.org/toolkit/crash-reporter;1"].
@ -513,13 +478,12 @@ updateWritePrefs: function ()
*
* In all cases, set up the Learn More link sanely
*/
initTelemetry: function ()
{
initTelemetry() {
if (AppConstants.MOZ_TELEMETRY_REPORTING)
this._setupLearnMoreLink("toolkit.telemetry.infoURL", "telemetryLearnMore");
},
formatLocaleSetLabels: function() {
formatLocaleSetLabels() {
const localeService =
Cc["@mozilla.org/intl/localeservice;1"]
.getService(Ci.mozILocaleService);

Просмотреть файл

@ -69,8 +69,7 @@ var gAppManagerDialog = {
if (list.getRowCount() == 0) {
// The list is now empty, make the bottom part disappear
document.getElementById("appDetails").hidden = true;
}
else {
} else {
// Select the item at the same index, if we removed the last
// item of the list, select the previous item
if (index == list.getRowCount())
@ -99,5 +98,5 @@ var gAppManagerDialog = {
var appType = (app instanceof Ci.nsILocalHandlerApp) ?
"descriptionLocalApp" : "descriptionWebApp";
document.getElementById("appType").value = bundle.getString(appType);
}
},
};

Просмотреть файл

@ -3,7 +3,7 @@
* 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/. */
//****************************************************************************//
//* ***************************************************************************//
// Constants & Enumeration Values
var PREF_DISABLED_PLUGIN_TYPES = "plugin.disable_full_page_plugin_for_types";
@ -29,7 +29,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
//****************************************************************************//
//* ***************************************************************************//
// Utilities
function getDisplayNameForFile(aFile) {
@ -37,18 +37,15 @@ function getDisplayNameForFile(aFile) {
if (aFile instanceof Ci.nsILocalFileWin) {
try {
return aFile.getVersionInfoField("FileDescription");
}
catch(ex) {
} catch (ex) {
// fall through to the file name
}
}
}
else if (AppConstants.platform == "macosx") {
} else if (AppConstants.platform == "macosx") {
if (aFile instanceof Ci.nsILocalFileMac) {
try {
return aFile.bundleDisplayName;
}
catch(ex) {
} catch (ex) {
// fall through to the file name
}
}
@ -81,16 +78,16 @@ function ArrayEnumerator(aItems) {
ArrayEnumerator.prototype = {
_index: 0,
hasMoreElements: function() {
hasMoreElements() {
return this._index < this._contents.length;
},
getNext: function() {
getNext() {
return this._contents[this._index++];
}
},
};
//****************************************************************************//
//* ***************************************************************************//
// HandlerInfoWrapper
/**
@ -119,7 +116,7 @@ HandlerInfoWrapper.prototype = {
// we haven't (yet?) implemented, so we make it a public property.
wrappedHandlerInfo: null,
//**************************************************************************//
//* *************************************************************************//
// Convenience Utils
_handlerSvc: Cc["@mozilla.org/uriloader/handler-service;1"]
@ -128,7 +125,7 @@ HandlerInfoWrapper.prototype = {
_categoryMgr: Cc["@mozilla.org/categorymanager;1"]
.getService(Ci.nsICategoryManager),
//**************************************************************************//
//* *************************************************************************//
// nsIHandlerInfo
// The MIME type or protocol scheme.
@ -158,14 +155,14 @@ HandlerInfoWrapper.prototype = {
// Make sure the preferred handler is in the set of possible handlers.
if (aNewValue)
this.addPossibleApplicationHandler(aNewValue)
this.addPossibleApplicationHandler(aNewValue);
},
get possibleApplicationHandlers() {
return this.wrappedHandlerInfo.possibleApplicationHandlers;
},
addPossibleApplicationHandler: function(aNewHandler) {
addPossibleApplicationHandler(aNewHandler) {
try {
if (this.possibleApplicationHandlers.indexOf(0, aNewHandler) != -1)
return;
@ -173,7 +170,7 @@ HandlerInfoWrapper.prototype = {
this.possibleApplicationHandlers.appendElement(aNewHandler);
},
removePossibleApplicationHandler: function(aHandler) {
removePossibleApplicationHandler(aHandler) {
var defaultApp = this.preferredApplicationHandler;
if (defaultApp && aHandler.equals(defaultApp)) {
// If the app we remove was the default app, we must make sure
@ -213,8 +210,7 @@ HandlerInfoWrapper.prototype = {
!gApplicationsPane.isValidHandlerApp(this.preferredApplicationHandler)) {
if (this.wrappedHandlerInfo.hasDefaultHandler)
return Ci.nsIHandlerInfo.useSystemDefault;
else
return Ci.nsIHandlerInfo.saveToDisk;
return Ci.nsIHandlerInfo.saveToDisk;
}
return this.wrappedHandlerInfo.preferredAction;
@ -257,7 +253,7 @@ HandlerInfoWrapper.prototype = {
},
//**************************************************************************//
//* *************************************************************************//
// nsIMIMEInfo
// The primary file extension associated with this type, if any.
@ -270,13 +266,13 @@ HandlerInfoWrapper.prototype = {
if (this.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo &&
this.wrappedHandlerInfo.primaryExtension)
return this.wrappedHandlerInfo.primaryExtension;
} catch(ex) {}
} catch (ex) {}
return null;
},
//**************************************************************************//
//* *************************************************************************//
// Plugin Handling
// A plugin that can handle this type, if any.
@ -304,7 +300,7 @@ HandlerInfoWrapper.prototype = {
return this._getDisabledPluginTypes().includes(this.type);
},
_getDisabledPluginTypes: function() {
_getDisabledPluginTypes() {
var types = "";
if (Services.prefs.prefHasUserValue(PREF_DISABLED_PLUGIN_TYPES))
@ -315,7 +311,7 @@ HandlerInfoWrapper.prototype = {
return types ? types.split(",") : [];
},
disablePluginType: function() {
disablePluginType() {
var disabledPluginTypes = this._getDisabledPluginTypes();
if (!disabledPluginTypes.includes(this.type))
@ -330,7 +326,7 @@ HandlerInfoWrapper.prototype = {
false);
},
enablePluginType: function() {
enablePluginType() {
var disabledPluginTypes = this._getDisabledPluginTypes();
var type = this.type;
@ -349,19 +345,19 @@ HandlerInfoWrapper.prototype = {
},
//**************************************************************************//
//* *************************************************************************//
// Storage
store: function() {
store() {
this._handlerSvc.store(this.wrappedHandlerInfo);
},
remove: function() {
remove() {
this._handlerSvc.remove(this.wrappedHandlerInfo);
},
//**************************************************************************//
//* *************************************************************************//
// Icons
get smallIcon() {
@ -372,7 +368,7 @@ HandlerInfoWrapper.prototype = {
return this._getIcon(32);
},
_getIcon: function(aSize) {
_getIcon(aSize) {
if (this.primaryExtension)
return "moz-icon://goat." + this.primaryExtension + "?size=" + aSize;
@ -382,7 +378,7 @@ HandlerInfoWrapper.prototype = {
// FIXME: consider returning some generic icon when we can't get a URL for
// one (for example in the case of protocol schemes). Filed as bug 395141.
return null;
}
},
};
var gApplicationsTabController = {
@ -391,7 +387,7 @@ var gApplicationsTabController = {
// of the attachmentPrefs tabs.
mDefaultIndex: 1,
init: function() {
init() {
if (this.mInitialized)
return;
@ -422,58 +418,58 @@ var gApplicationsTabController = {
this.mInitialized = true;
},
tabSelectionChanged: function() {
tabSelectionChanged() {
if (this.mInitialized)
document.getElementById("mail.preferences.applications.selectedTabIndex")
.valueFromPreferences = document.getElementById("attachmentPrefs")
.selectedIndex;
},
}
};
var gCloudFileController = {
commands: {
cmd_addCloudfileAccount: {
isEnabled: function() {
isEnabled() {
return true;
},
doCommand: function() {
doCommand() {
gCloudFileTab.addCloudFileAccount();
},
},
cmd_removeCloudfileAccount: {
isEnabled: function() {
isEnabled() {
let listbox = document.getElementById("cloudFileView");
return listbox.selectedCount > 0;
},
doCommand: function() {
doCommand() {
gCloudFileTab.removeCloudFileAccount();
},
},
cmd_reauthCloudfileAccount: {
isEnabled: function() {
isEnabled() {
return true;
},
doCommand: function() {
doCommand() {
gCloudFileTab.authSelected();
},
},
},
supportsCommand: function(aCommand) {
supportsCommand(aCommand) {
return (aCommand in this.commands);
},
isCommandEnabled: function(aCommand) {
isCommandEnabled(aCommand) {
if (!this.supportsCommand(aCommand))
return false;
return this.commands[aCommand].isEnabled();
},
doCommand: function(aCommand) {
doCommand(aCommand) {
if (!this.supportsCommand(aCommand))
return;
@ -484,8 +480,8 @@ var gCloudFileController = {
cmd.doCommand();
},
onEvent: function(event) {},
}
onEvent(event) {},
};
function CommandUpdate_CloudFile() {
goUpdateCommand("cmd_removeCloudfileAccount");
@ -509,7 +505,7 @@ var gCloudFileTab = {
.createBundle("chrome://messenger/locale/preferences/applications.properties");
},
init: function() {
init() {
if (this._initialized)
return;
@ -613,18 +609,18 @@ var gCloudFileTab = {
let account = cloudFileAccounts.getAccount(accountKey);
let observer = {
onStopRequest: function(aRequest, aContext, aStatusCode) {
onStopRequest(aRequest, aContext, aStatusCode) {
gCloudFileTab._accountCache[accountKey].result = aStatusCode;
gCloudFileTab.onUserInfoRequestDone(accountKey);
},
onStartRequest: function(aRequest, aContext) {
onStartRequest(aRequest, aContext) {
aItem.setAttribute("state", "connecting");
},
};
let accountInfo = {account: account,
let accountInfo = {account,
listItem: aItem,
result: Cr.NS_ERROR_NOT_AVAILABLE}
result: Cr.NS_ERROR_NOT_AVAILABLE};
this._accountCache[accountKey] = accountInfo;
@ -686,17 +682,15 @@ var gCloudFileTab = {
else if (result == Cr.NS_OK) {
this._settingsDeck.selectedPanel = this._settingsPanelWrap;
this._showAccountManagement(account);
}
else if (result == Ci.nsIMsgCloudFileProvider.authErr) {
} else if (result == Ci.nsIMsgCloudFileProvider.authErr) {
this._settingsDeck.selectedPanel = this._authErrorPanel;
}
else {
} else {
Cu.reportError("Unexpected connection error.");
}
},
_showAccountManagement: function CFT__showAccountManagement(aProvider) {
let iframe = document.createElement('iframe');
let iframe = document.createElement("iframe");
iframe.setAttribute("src", aProvider.managementURL);
iframe.setAttribute("flex", "1");
@ -716,7 +710,7 @@ var gCloudFileTab = {
iframe.contentWindow
.wrappedJSObject
.onLoadProvider(aProvider);
} catch(e) {
} catch (e) {
Cu.reportError(e);
}
}, {capture: false, once: true});
@ -807,10 +801,10 @@ var gCloudFileTab = {
},
QueryInterface: ChromeUtils.generateQI(["nsIObserver",
"nsISupportsWeakReference"])
}
"nsISupportsWeakReference"]),
};
//****************************************************************************//
//* ***************************************************************************//
// Prefpane Controller
var gApplicationsPane = {
@ -834,28 +828,28 @@ var gApplicationsPane = {
_visibleTypeDescriptionCount: new Map(),
//**************************************************************************//
//* *************************************************************************//
// Convenience & Performance Shortcuts
// These get defined by init().
_brandShortName : null,
_prefsBundle : null,
_list : null,
_filter : null,
_brandShortName: null,
_prefsBundle: null,
_list: null,
_filter: null,
_mimeSvc : Cc["@mozilla.org/mime;1"]
_mimeSvc: Cc["@mozilla.org/mime;1"]
.getService(Ci.nsIMIMEService),
_helperAppSvc : Cc["@mozilla.org/uriloader/external-helper-app-service;1"]
_helperAppSvc: Cc["@mozilla.org/uriloader/external-helper-app-service;1"]
.getService(Ci.nsIExternalHelperAppService),
_handlerSvc : Cc["@mozilla.org/uriloader/handler-service;1"]
_handlerSvc: Cc["@mozilla.org/uriloader/handler-service;1"]
.getService(Ci.nsIHandlerService),
//**************************************************************************//
//* *************************************************************************//
// Initialization & Destruction
init: function() {
init() {
// Initialize shortcuts to some commonly accessed elements & values.
this._brandShortName =
document.getElementById("bundleBrand").getString("brandShortName");
@ -874,7 +868,7 @@ var gApplicationsPane = {
// Figure out how we should be sorting the list. We persist sort settings
// across sessions, so we can't assume the default sort column/direction.
// XXX should we be using the XUL sort service instead?
this._sortColumn = document.getElementById("typeColumn")
this._sortColumn = document.getElementById("typeColumn");
if (document.getElementById("actionColumn").hasAttribute("sortDirection")) {
this._sortColumn = document.getElementById("actionColumn");
// The typeColumn element always has a sortDirection attribute,
@ -898,25 +892,25 @@ var gApplicationsPane = {
// Notify observers that the UI is now ready
Services.obs.notifyObservers(window, "app-handler-pane-loaded");
}
};
setTimeout(_delayedPaneLoad, 0, this);
},
destroy: function() {
destroy() {
Services.prefs.removeObserver(PREF_SHOW_PLUGINS_IN_LIST, this);
Services.prefs.removeObserver(PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS, this);
},
//**************************************************************************//
//* *************************************************************************//
// nsISupports
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
//**************************************************************************//
//* *************************************************************************//
// nsIObserver
observe: function (aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
// Rebuild the list when there are changes to preferences that influence
// whether or not to show certain entries in the list.
if (aTopic == "nsPref:changed" && !this._storingAction) {
@ -935,19 +929,19 @@ var gApplicationsPane = {
},
//**************************************************************************//
//* *************************************************************************//
// EventListener
handleEvent: function(aEvent) {
handleEvent(aEvent) {
if (aEvent.type == "unload")
this.destroy();
},
//**************************************************************************//
//* *************************************************************************//
// Composed Model Construction
_loadData: function() {
_loadData() {
this._loadPluginHandlers();
this._loadApplicationHandlers();
},
@ -972,7 +966,7 @@ var gApplicationsPane = {
* So even if we could use enabledPlugin to get the plugin that would be used,
* we'd still need to check the pref ourselves to find out if it's enabled.
*/
_loadPluginHandlers: function() {
_loadPluginHandlers() {
for (let i = 0; i < navigator.plugins.length; ++i) {
let plugin = navigator.plugins[i];
for (let j = 0; j < plugin.length; ++j) {
@ -997,7 +991,7 @@ var gApplicationsPane = {
/**
* Load the set of handlers defined by the application datastore.
*/
_loadApplicationHandlers: function() {
_loadApplicationHandlers() {
var wrappedHandlerInfos = this._handlerSvc.enumerate();
while (wrappedHandlerInfos.hasMoreElements()) {
let wrappedHandlerInfo =
@ -1007,8 +1001,7 @@ var gApplicationsPane = {
let handlerInfoWrapper;
if (type in this._handledTypes) {
handlerInfoWrapper = this._handledTypes[type];
}
else {
} else {
handlerInfoWrapper = new HandlerInfoWrapper(type, wrappedHandlerInfo);
this._handledTypes[type] = handlerInfoWrapper;
}
@ -1017,10 +1010,10 @@ var gApplicationsPane = {
}
},
//**************************************************************************//
//* *************************************************************************//
// View Construction
_rebuildVisibleTypes: function() {
_rebuildVisibleTypes() {
// Reset the list of visible types and the visible type description counts.
this._visibleTypes.length = 0;
this._visibleTypeDescriptionCount.clear();
@ -1058,7 +1051,7 @@ var gApplicationsPane = {
}
},
rebuildView: function() {
rebuildView() {
// Clear the list of entries.
while (this._list.childNodes.length > 1)
this._list.lastChild.remove();
@ -1090,7 +1083,7 @@ var gApplicationsPane = {
this._selectLastSelectedType();
},
_matchesFilter: function(aType) {
_matchesFilter(aType) {
var filterValue = this._filter.value.toLowerCase();
return this._describeType(aType).toLowerCase().includes(filterValue) ||
this._describePreferredAction(aType).toLowerCase().includes(filterValue);
@ -1106,7 +1099,7 @@ var gApplicationsPane = {
* @param aHandlerInfo {nsIHandlerInfo} the type being described
* @return {string} a description of the type
*/
_describeType: function(aHandlerInfo) {
_describeType(aHandlerInfo) {
let details = this._typeDetails(aHandlerInfo);
if (details)
@ -1123,12 +1116,12 @@ var gApplicationsPane = {
* @param aHandlerInfo {nsIHandlerInfo} the type to get the extensions for.
* @return {string} the extensions for the type
*/
_typeDetails: function(aHandlerInfo) {
_typeDetails(aHandlerInfo) {
let exts = [];
if (aHandlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo) {
let extIter = aHandlerInfo.wrappedHandlerInfo.getFileExtensions();
while(extIter.hasMore()) {
let ext = "."+extIter.getNext();
while (extIter.hasMore()) {
let ext = "." + extIter.getNext();
if (!exts.includes(ext))
exts.push(ext);
}
@ -1160,7 +1153,7 @@ var gApplicationsPane = {
* is being described
* @return {string} a description of the action
*/
_describePreferredAction: function(aHandlerInfo) {
_describePreferredAction(aHandlerInfo) {
// alwaysAskBeforeHandling overrides the preferred action, so if that flag
// is set, then describe that behavior instead. For most types, this is
// the "alwaysAsk" string, but for the feed type we show something special.
@ -1209,7 +1202,7 @@ var gApplicationsPane = {
}
},
_selectLastSelectedType: function() {
_selectLastSelectedType() {
// If the list is disabled by the pref.downloads.disable_button.edit_actions
// preference being locked, then don't select the type, as that would cause
// it to appear selected, with a different background and an actions menu
@ -1233,7 +1226,7 @@ var gApplicationsPane = {
* @param aHandlerApp {nsIHandlerApp} the handler app in question
* @return {boolean} whether or not it's valid
*/
isValidHandlerApp: function(aHandlerApp) {
isValidHandlerApp(aHandlerApp) {
if (!aHandlerApp)
return false;
@ -1249,7 +1242,7 @@ var gApplicationsPane = {
return false;
},
_isValidHandlerExecutable: function(aExecutable) {
_isValidHandlerExecutable(aExecutable) {
let isExecutable = aExecutable &&
aExecutable.exists() &&
aExecutable.isExecutable();
@ -1269,7 +1262,7 @@ var gApplicationsPane = {
* Rebuild the actions menu for the selected entry. Gets called by
* the richlistitem constructor when an entry in the list gets selected.
*/
rebuildActionsMenu: function() {
rebuildActionsMenu() {
var typeItem = this._list.selectedItem;
if (!typeItem)
@ -1379,8 +1372,7 @@ var gApplicationsPane = {
createItem = false;
}
if (createItem)
{
if (createItem) {
let menuItem = document.createElement("menuitem");
menuItem.setAttribute("oncommand", "gApplicationsPane.chooseApp(event)");
let label = this._prefsBundle.getString("useOtherApp");
@ -1438,7 +1430,7 @@ var gApplicationsPane = {
},
//**************************************************************************//
//* *************************************************************************//
// Sorting & Filtering
_sortColumn: null,
@ -1446,7 +1438,7 @@ var gApplicationsPane = {
/**
* Sort the list when the user clicks on a column header.
*/
sort: function (event) {
sort(event) {
var column = event.target;
// If the user clicked on a new sort column, remove the direction indicator
@ -1469,7 +1461,7 @@ var gApplicationsPane = {
/**
* Sort the list of visible types by the current sort column/direction.
*/
_sortVisibleTypes: function() {
_sortVisibleTypes() {
if (!this._sortColumn)
return;
@ -1498,15 +1490,15 @@ var gApplicationsPane = {
this._visibleTypes.reverse();
},
focusFilterBox: function() {
focusFilterBox() {
this._filter.focus();
this._filter.select();
},
//**************************************************************************//
//* *************************************************************************//
// Changes
onSelectAction: function(aActionItem) {
onSelectAction(aActionItem) {
this._storingAction = true;
let typeItem = this._list.selectedItem;
@ -1515,20 +1507,18 @@ var gApplicationsPane = {
menu.previousSelectedItem = aActionItem;
try {
this._storeAction(aActionItem);
}
finally {
} finally {
this._storingAction = false;
}
},
_storeAction: function(aActionItem) {
_storeAction(aActionItem) {
var typeItem = this._list.selectedItem;
var handlerInfo = this._handledTypes[typeItem.type];
if (aActionItem.hasAttribute("alwaysAsk")) {
handlerInfo.alwaysAskBeforeHandling = true;
}
else if (aActionItem.hasAttribute("action")) {
} else if (aActionItem.hasAttribute("action")) {
let action = parseInt(aActionItem.getAttribute("action"));
// Set the plugin state if we're enabling or disabling a plugin.
@ -1568,7 +1558,7 @@ var gApplicationsPane = {
}
},
manageApp: function(aEvent) {
manageApp(aEvent) {
// Don't let the normal "on select action" handler get this event,
// as we handle it specially ourselves.
aEvent.stopPropagation();
@ -1595,7 +1585,7 @@ var gApplicationsPane = {
"resizable=no", handlerInfo, closingCallback);
},
chooseApp: function(aEvent) {
chooseApp(aEvent) {
// Don't let the normal "on select action" handler get this event,
// as we handle it specially ourselves.
aEvent.stopPropagation();
@ -1678,13 +1668,13 @@ var gApplicationsPane = {
// Mark which item in the list was last selected so we can reselect it
// when we rebuild the list or when the user returns to the prefpane.
onSelectionChanged: function() {
onSelectionChanged() {
if (this._list.selectedItem)
this._list.setAttribute("lastSelectedType",
this._list.selectedItem.getAttribute("type"));
},
confirmDelete: function(aEvent) {
confirmDelete(aEvent) {
aEvent.stopPropagation();
if (Services.prompt.confirm(null,
this._prefsBundle.getString("confirmDeleteTitle"),
@ -1699,7 +1689,7 @@ var gApplicationsPane = {
}
},
onDelete: function(aEvent) {
onDelete(aEvent) {
// We want to delete if either the request came from the confirmDelete
// method (which is the only thing that populates the aEvent parameter),
// or we've hit the delete/backspace key while the list has focus.
@ -1716,7 +1706,7 @@ var gApplicationsPane = {
}
},
_setIconClassForPreferredAction: function(aHandlerInfo, aElement) {
_setIconClassForPreferredAction(aHandlerInfo, aElement) {
// If this returns true, the attribute that CSS sniffs for was set to something
// so you shouldn't manually set an icon URI.
// This removes the existing actionIcon attribute if any, even if returning false.
@ -1743,7 +1733,7 @@ var gApplicationsPane = {
return false;
},
_getIconURLForPreferredAction: function(aHandlerInfo) {
_getIconURLForPreferredAction(aHandlerInfo) {
switch (aHandlerInfo.preferredAction) {
case Ci.nsIHandlerInfo.useSystemDefault:
return this._getIconURLForSystemDefault(aHandlerInfo);
@ -1758,7 +1748,7 @@ var gApplicationsPane = {
return ICON_URL_APP;
},
_getIconURLForHandlerApp: function(aHandlerApp) {
_getIconURLForHandlerApp(aHandlerApp) {
if (aHandlerApp instanceof Ci.nsILocalHandlerApp)
return this._getIconURLForFile(aHandlerApp.executable);
@ -1766,13 +1756,13 @@ var gApplicationsPane = {
return this._getIconURLForWebApp(aHandlerApp.uriTemplate);
if (aHandlerApp instanceof Ci.nsIWebContentHandlerInfo)
return this._getIconURLForWebApp(aHandlerApp.uri)
return this._getIconURLForWebApp(aHandlerApp.uri);
// We know nothing about other kinds of handler apps.
return "";
},
_getIconURLForFile: function(aFile) {
_getIconURLForFile(aFile) {
let urlSpec = Services.io.getProtocolHandler("file")
.QueryInterface(Ci.nsIFileProtocolHandler)
.getURLSpecFromFile(aFile);
@ -1780,7 +1770,7 @@ var gApplicationsPane = {
return "moz-icon://" + urlSpec + "?size=16";
},
_getIconURLForWebApp: function(aWebAppURITemplate) {
_getIconURLForWebApp(aWebAppURITemplate) {
var uri = Services.io.newURI(aWebAppURITemplate);
// Unfortunately we can't use the favicon service to get the favicon,
@ -1796,7 +1786,7 @@ var gApplicationsPane = {
return /^https?/.test(uri.scheme) ? uri.resolve("/favicon.ico") : "";
},
_getIconURLForSystemDefault: function(aHandlerInfo) {
_getIconURLForSystemDefault(aHandlerInfo) {
// Handler info objects for MIME types on some OSes implement a property bag
// interface from which we can get an icon for the default app, so if we're
// dealing with a MIME type on one of those OSes, then try to get the icon.
@ -1809,8 +1799,7 @@ var gApplicationsPane = {
let url = wrappedHandlerInfo.getProperty("defaultApplicationIconURL");
if (url)
return url + "?size=16";
}
catch(ex) { }
} catch (ex) { }
}
}
@ -1818,5 +1807,5 @@ var gApplicationsPane = {
// the icon, or if we couldn't retrieve the icon for some other reason,
// then use a generic icon.
return ICON_URL_APP;
}
},
};

Просмотреть файл

@ -9,15 +9,13 @@ var gAttachmentReminderOptionsDialog = {
keywordListBox: null,
bundle: null,
init: function()
{
init() {
this.keywordListBox = document.getElementById("keywordList");
this.bundle = document.getElementById("bundlePreferences");
this.buildKeywordList();
},
buildKeywordList: function()
{
buildKeywordList() {
var keywordsInCsv = Services.prefs
.getComplexValue("mail.compose.attachment_reminder_keywords",
Ci.nsIPrefLocalizedString);
@ -25,8 +23,7 @@ var gAttachmentReminderOptionsDialog = {
return;
var keywordsInCsv = keywordsInCsv.data;
var keywordsInArr = keywordsInCsv.split(",");
for (var i = 0; i < keywordsInArr.length; i++)
{
for (var i = 0; i < keywordsInArr.length; i++) {
if (keywordsInArr[i])
this.keywordListBox.appendItem(keywordsInArr[i], keywordsInArr[i]);
}
@ -34,13 +31,12 @@ var gAttachmentReminderOptionsDialog = {
this.keywordListBox.selectedIndex = 0;
},
addKeyword: function()
{
addKeyword() {
var input = {value: ""}; // Default to empty.
var ok = Services.prompt.prompt(window,
this.bundle.getString("attachmentReminderNewDialogTitle"),
this.bundle.getString("attachmentReminderNewText"),
input, null, {value:0});
input, null, {value: 0});
if (ok && input.value) {
let newKey = this.keywordListBox.appendItem(input.value, input.value);
this.keywordListBox.ensureElementIsVisible(newKey);
@ -48,8 +44,7 @@ var gAttachmentReminderOptionsDialog = {
}
},
editKeyword: function()
{
editKeyword() {
if (this.keywordListBox.selectedIndex < 0)
return;
var keywordToEdit = this.keywordListBox.selectedItem;
@ -57,22 +52,20 @@ var gAttachmentReminderOptionsDialog = {
var ok = Services.prompt.prompt(window,
this.bundle.getString("attachmentReminderEditDialogTitle"),
this.bundle.getString("attachmentReminderEditText"),
input, null, {value:0});
input, null, {value: 0});
if (ok && input.value) {
this.keywordListBox.selectedItem.value = input.value;
this.keywordListBox.selectedItem.label = input.value;
}
},
removeKeyword: function()
{
removeKeyword() {
if (this.keywordListBox.selectedIndex < 0)
return;
this.keywordListBox.selectedItem.remove();
},
saveKeywords: function()
{
saveKeywords() {
var keywordList = "";
for (var i = 0; i < this.keywordListBox.getRowCount(); i++) {
keywordList += this.keywordListBox.getItemAtIndex(i).getAttribute("value");
@ -82,5 +75,5 @@ var gAttachmentReminderOptionsDialog = {
Services.prefs.setStringPref("mail.compose.attachment_reminder_keywords",
keywordList);
}
},
};

Просмотреть файл

@ -3,26 +3,22 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var gChatPane = {
init: function ()
{
init() {
previewObserver.load();
this.updateDisabledState();
this.updatePlaySound();
},
updateDisabledState: function ()
{
updateDisabledState() {
let broadcaster = document.getElementById("idleReportingEnabled");
if (document.getElementById("messenger.status.reportIdle").value) {
broadcaster.removeAttribute("disabled");
this.updateMessageDisabledState();
}
else
} else
broadcaster.setAttribute("disabled", "true");
},
updateMessageDisabledState: function ()
{
updateMessageDisabledState() {
let textbox = document.getElementById("defaultIdleAwayMessage");
if (document.getElementById("messenger.status.awayWhenIdle").value)
textbox.removeAttribute("disabled");
@ -30,11 +26,9 @@ var gChatPane = {
textbox.setAttribute("disabled", "true");
},
convertURLToLocalFile: function(aFileURL)
{
convertURLToLocalFile(aFileURL) {
// convert the file url into a nsIFile
if (aFileURL)
{
if (aFileURL) {
return Services.io.getProtocolHandler("file")
.QueryInterface(Ci.nsIFileProtocolHandler)
.getFileFromURLSpec(aFileURL);
@ -42,19 +36,16 @@ var gChatPane = {
return null;
},
readSoundLocation: function()
{
readSoundLocation() {
let chatSoundUrlLocation = document.getElementById("chatSoundUrlLocation");
chatSoundUrlLocation.value = document.getElementById("mail.chat.play_sound.url").value;
if (chatSoundUrlLocation.value)
{
if (chatSoundUrlLocation.value) {
chatSoundUrlLocation.label = this.convertURLToLocalFile(chatSoundUrlLocation.value).leafName;
chatSoundUrlLocation.style.backgroundImage = "url(moz-icon://" + chatSoundUrlLocation.label + "?size=16)";
}
},
previewSound: function ()
{
previewSound() {
let sound = Cc["@mozilla.org/sound;1"].createInstance(Ci.nsISound);
let soundLocation = document.getElementById("chatSoundType").value == 1 ?
@ -72,8 +63,7 @@ var gChatPane = {
}
},
browseForSoundFile: function ()
{
browseForSoundFile() {
const nsIFilePicker = Ci.nsIFilePicker;
let fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
@ -110,8 +100,7 @@ var gChatPane = {
});
},
updatePlaySound: function()
{
updatePlaySound() {
// update the sound type radio buttons based on the state of the play sound checkbox
let soundsDisabled = !document.getElementById("chatNotification").checked;
let soundTypeEl = document.getElementById("chatSoundType");
@ -121,5 +110,5 @@ var gChatPane = {
soundsDisabled || (soundTypeEl.value != 1);
document.getElementById("playChatSound").disabled =
soundsDisabled || (!chatSoundUrlLocation && soundTypeEl.value != 0);
}
},
};

Просмотреть файл

@ -8,10 +8,9 @@ ChromeUtils.import("resource://gre/modules/InlineSpellChecker.jsm");
var gComposePane = {
mInitialized: false,
mSpellChecker: null,
mDictCount : 0,
mDictCount: 0,
init: function ()
{
init() {
this.enableAutocomplete();
this.initLanguageMenu();
@ -36,53 +35,44 @@ var gComposePane = {
this.mInitialized = true;
},
tabSelectionChanged: function ()
{
if (this.mInitialized)
{
tabSelectionChanged() {
if (this.mInitialized) {
var preference = document.getElementById("mail.preferences.compose.selectedTabIndex");
preference.valueFromPreferences = document.getElementById("composePrefs").selectedIndex;
}
},
sendOptionsDialog: function()
{
sendOptionsDialog() {
gSubDialog.open("chrome://messenger/content/preferences/sendoptions.xul");
},
attachmentReminderOptionsDialog: function()
{
attachmentReminderOptionsDialog() {
gSubDialog.open("chrome://messenger/content/preferences/attachmentReminder.xul",
"resizable=no");
},
updateAutosave: function()
{
updateAutosave() {
this.enableElement(document.getElementById("autoSaveInterval"),
document.getElementById("autoSave").checked);
},
updateAttachmentCheck: function()
{
updateAttachmentCheck() {
this.enableElement(document.getElementById("attachment_reminder_button"),
document.getElementById("attachment_reminder_label").checked);
},
updateEmailCollection: function()
{
updateEmailCollection() {
this.enableElement(document.getElementById("localDirectoriesList"),
document.getElementById("emailCollectionOutgoing").checked);
},
enableElement: function(aElement, aEnable)
{
enableElement(aElement, aEnable) {
let pref = aElement.getAttribute("preference");
let prefIsLocked = pref ? document.getElementById(pref).locked : false;
aElement.disabled = !aEnable || prefIsLocked;
},
enableAutocomplete: function()
{
enableAutocomplete() {
var acLDAPPref = document.getElementById("ldap_2.autoComplete.useDirectory")
.value;
@ -90,12 +80,11 @@ var gComposePane = {
this.enableElement(document.getElementById("editButton"), acLDAPPref);
},
editDirectories: function()
{
editDirectories() {
gSubDialog.open("chrome://messenger/content/addressbook/pref-editdirectories.xul");
},
initAbDefaultStartupDir: function() {
initAbDefaultStartupDir() {
if (!this.startupDirListener.inited)
this.startupDirListener.load();
@ -117,7 +106,7 @@ var gComposePane = {
}
},
setDefaultStartupDir: function(aDirURI) {
setDefaultStartupDir(aDirURI) {
if (aDirURI) {
// Some AB directory was selected. Set prefs to make this directory
// the default view when starting up the main AB.
@ -129,10 +118,9 @@ var gComposePane = {
}
},
initLanguageMenu: function ()
{
initLanguageMenu() {
var languageMenuList = document.getElementById("languageMenuList");
this.mSpellChecker = Cc['@mozilla.org/spellchecker/engine;1'].getService(Ci.mozISpellCheckingEngine);
this.mSpellChecker = Cc["@mozilla.org/spellchecker/engine;1"].getService(Ci.mozISpellCheckingEngine);
var o1 = {};
var o2 = {};
@ -167,54 +155,49 @@ var gComposePane = {
languageMenuList.setInitialSelection();
},
populateFonts: function()
{
populateFonts() {
var fontsList = document.getElementById("FontSelect");
try
{
try {
var enumerator = Cc["@mozilla.org/gfx/fontenumerator;1"]
.getService(Ci.nsIFontEnumerator);
var localFontCount = { value: 0 }
var localFontCount = { value: 0 };
var localFonts = enumerator.EnumerateAllFonts(localFontCount);
for (var i = 0; i < localFonts.length; ++i)
{
for (var i = 0; i < localFonts.length; ++i) {
// Remove Linux system generic fonts that collide with CSS generic fonts.
if (localFonts[i] != "" && localFonts[i] != "serif" &&
localFonts[i] != "sans-serif" && localFonts[i] != "monospace")
fontsList.appendItem(localFonts[i], localFonts[i]);
}
}
catch(e) { }
} catch (e) { }
// Choose the item after the list is completely generated.
var preference = document.getElementById(fontsList.getAttribute("preference"));
fontsList.value = preference.value;
},
restoreHTMLDefaults: function()
{
restoreHTMLDefaults() {
// reset throws an exception if the pref value is already the default so
// work around that with some try/catch exception handling
try {
document.getElementById('msgcompose.font_face').reset();
document.getElementById("msgcompose.font_face").reset();
} catch (ex) {}
try {
document.getElementById('msgcompose.font_size').reset();
document.getElementById("msgcompose.font_size").reset();
} catch (ex) {}
try {
document.getElementById('msgcompose.text_color').reset();
document.getElementById("msgcompose.text_color").reset();
} catch (ex) {}
try {
document.getElementById('msgcompose.background_color').reset();
document.getElementById("msgcompose.background_color").reset();
} catch (ex) {}
},
startupDirListener: {
inited: false,
domain: "mail.addr_book.view.startupURI",
observe: function(subject, topic, prefName) {
observe(subject, topic, prefName) {
if (topic != "nsPref:changed")
return;
@ -222,7 +205,7 @@ var gComposePane = {
// reinitialize the default startup dir picker to show the new value.
gComposePane.initAbDefaultStartupDir();
},
load: function() {
load() {
// Observe changes of our prefs.
Services.prefs.addObserver(this.domain, this);
// Unload the pref observer when preferences window is closed.
@ -230,9 +213,9 @@ var gComposePane = {
this.inited = true;
},
unload: function(event) {
unload(event) {
Services.prefs.removeObserver(gComposePane.startupDirListener.domain,
gComposePane.startupDirListener);
}
}
},
},
};

Просмотреть файл

@ -6,8 +6,7 @@
ChromeUtils.import("resource://gre/modules/Services.jsm");
var gConnectionsDialog = {
beforeAccept: function ()
{
beforeAccept() {
var proxyTypePref = document.getElementById("network.proxy.type");
if (proxyTypePref.value == 2) {
this.doAutoconfigURLFixup();
@ -35,19 +34,17 @@ var gConnectionsDialog = {
}
var noProxiesPref = document.getElementById("network.proxy.no_proxies_on");
noProxiesPref.value = noProxiesPref.value.replace(/[;]/g,',');
noProxiesPref.value = noProxiesPref.value.replace(/[;]/g, ",");
return true;
},
checkForSystemProxy: function ()
{
checkForSystemProxy() {
if ("@mozilla.org/system-proxy-settings;1" in Cc)
document.getElementById("systemPref").removeAttribute("hidden");
},
proxyTypeChanged: function ()
{
proxyTypeChanged() {
var proxyTypePref = document.getElementById("network.proxy.type");
// Update http
@ -71,8 +68,7 @@ var gConnectionsDialog = {
this.updateReloadButton();
},
updateReloadButton: function ()
{
updateReloadButton() {
// Disable the "Reload PAC" button if the selected proxy type is not PAC or
// if the current value of the PAC textbox does not match the value stored
// in prefs. Likewise, disable the reload button if PAC is not configured
@ -90,14 +86,12 @@ var gConnectionsDialog = {
(proxyTypeCur != 2 || proxyType != 2 || typedURL != pacURL);
},
readProxyType: function ()
{
readProxyType() {
this.proxyTypeChanged();
return undefined;
},
updateProtocolPrefs: function ()
{
updateProtocolPrefs() {
var proxyTypePref = document.getElementById("network.proxy.type");
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
var proxyPrefs = ["ssl", "socks"];
@ -130,8 +124,7 @@ var gConnectionsDialog = {
return undefined;
},
readProxyProtocolPref: function (aProtocol, aIsPort)
{
readProxyProtocolPref(aProtocol, aIsPort) {
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
if (shareProxiesPref.value) {
var pref = document.getElementById("network.proxy.http" + (aIsPort ? "_port" : ""));
@ -142,31 +135,27 @@ var gConnectionsDialog = {
return backupPref.hasUserValue ? backupPref.value : undefined;
},
reloadPAC: function ()
{
reloadPAC() {
Cc["@mozilla.org/network/protocol-proxy-service;1"].
getService().reloadPAC();
},
doAutoconfigURLFixup: function ()
{
doAutoconfigURLFixup() {
var autoURL = document.getElementById("networkProxyAutoconfigURL");
var autoURLPref = document.getElementById("network.proxy.autoconfig_url");
try {
autoURLPref.value = autoURL.value = Services.uriFixup.createFixupURI(autoURL.value, 0).spec;
} catch(ex) {}
} catch (ex) {}
},
readHTTPProxyServer: function ()
{
readHTTPProxyServer() {
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
if (shareProxiesPref.value)
this.updateProtocolPrefs();
return undefined;
},
readHTTPProxyPort: function ()
{
readHTTPProxyPort() {
var shareProxiesPref = document.getElementById("network.proxy.share_proxy_settings");
if (shareProxiesPref.value)
this.updateProtocolPrefs();
@ -201,5 +190,5 @@ var gConnectionsDialog = {
let uriString = input.value.trim();
// turn an empty string into `undefined` to clear the pref back to the default
return uriString.length ? uriString : undefined;
}
},
};

Просмотреть файл

@ -9,13 +9,12 @@ ChromeUtils.import("resource://gre/modules/PluralForm.jsm");
var nsICookie = Ci.nsICookie;
var gCookiesWindow = {
_hosts : {},
_hostOrder : [],
_tree : null,
_bundle : null,
_hosts: {},
_hostOrder: [],
_tree: null,
_bundle: null,
init: function ()
{
init() {
Services.obs.addObserver(this, "cookie-changed");
Services.obs.addObserver(this, "perm-changed");
@ -31,14 +30,12 @@ var gCookiesWindow = {
}
},
uninit: function ()
{
uninit() {
Services.obs.removeObserver(this, "cookie-changed");
Services.obs.removeObserver(this, "perm-changed");
},
_populateList: function (aInitialLoad)
{
_populateList(aInitialLoad) {
this._loadCookies();
this._tree.treeBoxObject.view = this._view;
if (aInitialLoad)
@ -48,21 +45,16 @@ var gCookiesWindow = {
if (aInitialLoad) {
if (("arguments" in window) && window.arguments[2] &&
window.arguments[2].filterString)
{
window.arguments[2].filterString) {
this.setFilter(window.arguments[2].filterString);
}
}
else {
if (document.getElementById("filter").value != "")
} else if (document.getElementById("filter").value != "")
this.filter();
}
this._saveState();
},
_cookieEquals: function (aCookieA, aCookieB, aStrippedHost)
{
_cookieEquals(aCookieA, aCookieB, aStrippedHost) {
return aCookieA.rawHost == aStrippedHost &&
aCookieA.name == aCookieB.name &&
aCookieA.path == aCookieB.path &&
@ -70,8 +62,7 @@ var gCookiesWindow = {
aCookieB.originAttributes);
},
observe: function (aCookie, aTopic, aData)
{
observe(aCookie, aTopic, aData) {
if (aTopic != "cookie-changed")
return;
@ -81,8 +72,7 @@ var gCookiesWindow = {
this._handleCookieChanged(aCookie, strippedHost);
else if (aData == "added")
this._handleCookieAdded(aCookie, strippedHost);
}
else if (aData == "cleared") {
} else if (aData == "cleared") {
this._hosts = {};
this._hostOrder = [];
@ -90,8 +80,7 @@ var gCookiesWindow = {
this._view._rowCount = 0;
this._tree.treeBoxObject.rowCountChanged(0, -oldRowCount);
this._view.selection.clearSelection();
}
else if (aData == "reload") {
} else if (aData == "reload") {
// first, clear any existing entries
this.observe(aCookie, aTopic, "cleared");
@ -103,8 +92,7 @@ var gCookiesWindow = {
// and is rather complicated as selection tracking is difficult
},
_handleCookieChanged: function (changedCookie, strippedHost)
{
_handleCookieChanged(changedCookie, strippedHost) {
var rowIndex = 0;
var cookieItem = null;
if (!this._view._filtered) {
@ -126,12 +114,10 @@ var gCookiesWindow = {
break;
}
}
}
else if (hostItem.open)
} else if (hostItem.open)
rowIndex += hostItem.cookies.length;
}
}
else {
} else {
// Just walk the filter list to find the item. It doesn't matter that
// we don't update the main Host collection when we do this, because
// when the filter is reset the Host collection is rebuilt anyway.
@ -155,8 +141,7 @@ var gCookiesWindow = {
this._updateCookieData(cookieItem);
},
_handleCookieAdded: function (changedCookie, strippedHost)
{
_handleCookieAdded(changedCookie, strippedHost) {
var rowCountImpact = 0;
var addedHost = { value: 0 };
this._addCookie(strippedHost, changedCookie, addedHost);
@ -166,8 +151,7 @@ var gCookiesWindow = {
// see the additional rows as they're hidden.
if (addedHost.value || this._hosts[strippedHost].open)
++rowCountImpact;
}
else {
} else {
// We're in search mode, and the cookie being added matches
// the search condition, so add it to the list.
var c = this._makeCookieObject(strippedHost, changedCookie);
@ -186,19 +170,17 @@ var gCookiesWindow = {
},
_view: {
_filtered : false,
_filterSet : [],
_filtered: false,
_filterSet: [],
_filterValue: "",
_rowCount : 0,
_cacheValid : 0,
_cacheItems : [],
get rowCount()
{
_rowCount: 0,
_cacheValid: 0,
_cacheItems: [],
get rowCount() {
return this._rowCount;
},
_getItemAtIndex: function (aIndex)
{
_getItemAtIndex(aIndex) {
if (this._filtered)
return this._filterSet[aIndex];
@ -208,8 +190,8 @@ var gCookiesWindow = {
var cacheIndex = Math.min(this._cacheValid, aIndex);
if (cacheIndex > 0) {
var cacheItem = this._cacheItems[cacheIndex];
start = cacheItem['start'];
count = hostIndex = cacheItem['count'];
start = cacheItem.start;
count = hostIndex = cacheItem.count;
}
for (var i = start; i < gCookiesWindow._hostOrder.length; ++i) { // var host in gCookiesWindow._hosts) {
@ -219,7 +201,7 @@ var gCookiesWindow = {
return currHost;
hostIndex = count;
var cacheEntry = { 'start' : i, 'count' : count };
var cacheEntry = { "start": i, "count": count };
var cacheStart = count;
if (currHost.open) {
@ -235,16 +217,14 @@ var gCookiesWindow = {
}
++count;
}
}
else {
} else {
// A host entry was open, but we weren't looking for an index
// within that host entry's children, so skip forward over the
// entry's children. We need to add one to increment for the
// host value too.
count += currHost.cookies.length + 1;
}
}
else
} else
++count;
for (var j = cacheStart; j < count; j++)
@ -254,8 +234,7 @@ var gCookiesWindow = {
return null;
},
_removeItemAtIndex: function (aIndex, aCount)
{
_removeItemAtIndex(aIndex, aCount) {
var removeCount = aCount === undefined ? 1 : aCount;
if (this._filtered) {
// remove the cookies from the unfiltered set so that they
@ -294,13 +273,11 @@ var gCookiesWindow = {
}
},
_invalidateCache: function (aIndex)
{
_invalidateCache(aIndex) {
this._cacheValid = Math.min(this._cacheValid, aIndex);
},
getCellText: function (aIndex, aColumn)
{
getCellText(aIndex, aColumn) {
if (!this._filtered) {
var item = this._getItemAtIndex(aIndex);
if (!item)
@ -309,24 +286,20 @@ var gCookiesWindow = {
return item.rawHost;
else if (aColumn.id == "nameCol")
return ("name" in item) ? item.name : "";
}
else {
if (aColumn.id == "domainCol")
} else if (aColumn.id == "domainCol")
return this._filterSet[aIndex].rawHost;
else if (aColumn.id == "nameCol")
return ("name" in this._filterSet[aIndex]) ? this._filterSet[aIndex].name : "";
}
return "";
},
_selection: null,
get selection () { return this._selection; },
set selection (val) { this._selection = val; return val; },
getRowProperties: function (aRow) { return ""; },
getCellProperties: function (aRow, aColumn) { return ""; },
getColumnProperties: function (aColumn) { return ""; },
isContainer: function (aIndex)
{
get selection() { return this._selection; },
set selection(val) { this._selection = val; return val; },
getRowProperties(aRow) { return ""; },
getCellProperties(aRow, aColumn) { return ""; },
getColumnProperties(aColumn) { return ""; },
isContainer(aIndex) {
if (!this._filtered) {
var item = this._getItemAtIndex(aIndex);
if (!item) return false;
@ -334,8 +307,7 @@ var gCookiesWindow = {
}
return false;
},
isContainerOpen: function (aIndex)
{
isContainerOpen(aIndex) {
if (!this._filtered) {
var item = this._getItemAtIndex(aIndex);
if (!item) return false;
@ -343,8 +315,7 @@ var gCookiesWindow = {
}
return false;
},
isContainerEmpty: function (aIndex)
{
isContainerEmpty(aIndex) {
if (!this._filtered) {
var item = this._getItemAtIndex(aIndex);
if (!item) return false;
@ -352,12 +323,11 @@ var gCookiesWindow = {
}
return false;
},
isSeparator: function (aIndex) { return false; },
isSorted: function (aIndex) { return false; },
canDrop: function (aIndex, aOrientation) { return false; },
drop: function (aIndex, aOrientation) {},
getParentIndex: function (aIndex)
{
isSeparator(aIndex) { return false; },
isSorted(aIndex) { return false; },
canDrop(aIndex, aOrientation) { return false; },
drop(aIndex, aOrientation) {},
getParentIndex(aIndex) {
if (!this._filtered) {
var item = this._getItemAtIndex(aIndex);
// If an item has no parent index (i.e. it is at the top level) this
@ -369,8 +339,7 @@ var gCookiesWindow = {
}
return -1;
},
hasNextSibling: function (aParentIndex, aIndex)
{
hasNextSibling(aParentIndex, aIndex) {
if (!this._filtered) {
// |aParentIndex| appears to be bogus, but we can get the real
// parent index by getting the entry for |aIndex| and reading the
@ -388,17 +357,15 @@ var gCookiesWindow = {
}
return false;
}
else {
var parent = this._getItemAtIndex(item.parentIndex);
if (parent && parent.container)
return aIndex < item.parentIndex + parent.cookies.length;
}
}
}
return aIndex < this.rowCount - 1;
},
hasPreviousSibling: function (aIndex)
{
hasPreviousSibling(aIndex) {
if (!this._filtered) {
var item = this._getItemAtIndex(aIndex);
if (!item) return false;
@ -408,8 +375,7 @@ var gCookiesWindow = {
}
return aIndex > 0;
},
getLevel: function (aIndex)
{
getLevel(aIndex) {
if (!this._filtered) {
var item = this._getItemAtIndex(aIndex);
if (!item) return 0;
@ -417,12 +383,11 @@ var gCookiesWindow = {
}
return 0;
},
getImageSrc: function (aIndex, aColumn) {},
getProgressMode: function (aIndex, aColumn) {},
getCellValue: function (aIndex, aColumn) {},
setTree: function (aTree) {},
toggleOpenState: function (aIndex)
{
getImageSrc(aIndex, aColumn) {},
getProgressMode(aIndex, aColumn) {},
getCellValue(aIndex, aColumn) {},
setTree(aTree) {},
toggleOpenState(aIndex) {
if (!this._filtered) {
var item = this._getItemAtIndex(aIndex);
if (!item) return;
@ -435,38 +400,34 @@ var gCookiesWindow = {
gCookiesWindow._tree.treeBoxObject.invalidateRow(aIndex);
}
},
cycleHeader: function (aColumn) {},
selectionChanged: function () {},
cycleCell: function (aIndex, aColumn) {},
isEditable: function (aIndex, aColumn)
{
cycleHeader(aColumn) {},
selectionChanged() {},
cycleCell(aIndex, aColumn) {},
isEditable(aIndex, aColumn) {
return false;
},
isSelectable: function (aIndex, aColumn)
{
isSelectable(aIndex, aColumn) {
return false;
},
setCellValue: function (aIndex, aColumn, aValue) {},
setCellText: function (aIndex, aColumn, aValue) {},
performAction: function (aAction) {},
performActionOnRow: function (aAction, aIndex) {},
performActionOnCell: function (aAction, aindex, aColumn) {}
setCellValue(aIndex, aColumn, aValue) {},
setCellText(aIndex, aColumn, aValue) {},
performAction(aAction) {},
performActionOnRow(aAction, aIndex) {},
performActionOnCell(aAction, aindex, aColumn) {},
},
_makeStrippedHost: function (aHost)
{
_makeStrippedHost(aHost) {
let formattedHost = aHost.startsWith(".") ? aHost.substring(1, aHost.length) : aHost;
return formattedHost.startsWith("www.") ? formattedHost.substring(4, formattedHost.length) : formattedHost;
},
_addCookie: function (aStrippedHost, aCookie, aHostCount)
{
_addCookie(aStrippedHost, aCookie, aHostCount) {
if (!(aStrippedHost in this._hosts) || !this._hosts[aStrippedHost]) {
this._hosts[aStrippedHost] = { cookies : [],
rawHost : aStrippedHost,
level : 0,
open : false,
container : true };
this._hosts[aStrippedHost] = { cookies: [],
rawHost: aStrippedHost,
level: 0,
open: false,
container: true };
this._hostOrder.push(aStrippedHost);
++aHostCount.value;
}
@ -475,26 +436,24 @@ var gCookiesWindow = {
this._hosts[aStrippedHost].cookies.push(c);
},
_makeCookieObject: function (aStrippedHost, aCookie)
{
_makeCookieObject(aStrippedHost, aCookie) {
let host = aCookie.host;
let formattedHost = host.startsWith(".") ? host.substring(1) : host;
let c = { name : aCookie.name,
value : aCookie.value,
isDomain : aCookie.isDomain,
host : aCookie.host,
rawHost : aStrippedHost,
path : aCookie.path,
isSecure : aCookie.isSecure,
expires : aCookie.expires,
level : 1,
container : false,
let c = { name: aCookie.name,
value: aCookie.value,
isDomain: aCookie.isDomain,
host: aCookie.host,
rawHost: aStrippedHost,
path: aCookie.path,
isSecure: aCookie.isSecure,
expires: aCookie.expires,
level: 1,
container: false,
originAttributes: aCookie.originAttributes };
return c;
},
_loadCookies: function ()
{
_loadCookies() {
var e = Services.cookies.enumerator;
var hostCount = { value: 0 };
this._hosts = {};
@ -504,32 +463,29 @@ var gCookiesWindow = {
if (cookie && cookie instanceof Ci.nsICookie) {
var strippedHost = this._makeStrippedHost(cookie.host);
this._addCookie(strippedHost, cookie, hostCount);
}
else
} else
break;
}
this._view._rowCount = hostCount.value;
},
formatExpiresString: function (aExpires)
{
formatExpiresString(aExpires) {
if (aExpires) {
var date = new Date(1000 * aExpires);
const dateTimeFormatter = new Services.intl.DateTimeFormat(undefined, {
dateStyle: "long", timeStyle: "long"
dateStyle: "long", timeStyle: "long",
});
return dateTimeFormatter.format(date);
}
return this._bundle.getString("expireAtEndOfSession");
},
_getUserContextString: function(aUserContextId) {
_getUserContextString(aUserContextId) {
// Thunderbird ignores the context for now.
return this._bundle.getString("defaultUserContextLabel");
},
_updateCookieData: function (aItem)
{
_updateCookieData(aItem) {
var seln = this._view.selection;
var ids = ["name", "value", "host", "path", "isSecure", "expires", "userContext"];
var properties;
@ -545,8 +501,7 @@ var gCookiesWindow = {
for (var i = 0; i < ids.length; ++i) {
document.getElementById(ids[i]).disabled = false;
}
}
else {
} else {
var noneSelected = this._bundle.getString("noCookieSelected");
properties = { name: noneSelected, value: noneSelected, host: noneSelected,
path: noneSelected, expires: noneSelected,
@ -559,8 +514,7 @@ var gCookiesWindow = {
document.getElementById(property).value = properties[property];
},
onCookieSelected: function ()
{
onCookieSelected() {
var item;
var seln = this._tree.view.selection;
if (!this._view._filtered)
@ -597,8 +551,7 @@ var gCookiesWindow = {
document.getElementById("removeAllCookies").disabled = this._view._filtered;
},
deleteCookie: function ()
{
deleteCookie() {
// Selection Notes
// - Selection always moves to *NEXT* adjacent item unless item
// is last child at a given level in which case it moves to *PREVIOUS*
@ -666,8 +619,7 @@ var gCookiesWindow = {
if (!this._view.hasNextSibling(-1, ci))
--nextSelected;
this._view._removeItemAtIndex(ci);
}
else {
} else {
var parent = this._view._getItemAtIndex(item.parentIndex);
--rowCountImpact;
if (parent.cookies.length == 1) {
@ -679,8 +631,7 @@ var gCookiesWindow = {
--nextSelected;
this._view._removeItemAtIndex(item.parentIndex);
invalidateRow = item.parentIndex;
}
else {
} else {
deleteItems.push(item);
if (!this._view.hasNextSibling(-1, ci))
--nextSelected;
@ -691,8 +642,7 @@ var gCookiesWindow = {
tbo.rowCountChanged(ci, rowCountImpact);
if (invalidateRow != -1)
tbo.invalidateRow(invalidateRow);
}
else {
} else {
var rangeCount = seln.getRangeCount();
for (var i = 0; i < rangeCount; ++i) {
var min = {}; var max = {};
@ -729,26 +679,22 @@ var gCookiesWindow = {
}
},
deleteAllCookies: function ()
{
deleteAllCookies() {
Services.cookies.removeAll();
this._tree.focus();
},
onCookieKeyPress: function (aEvent)
{
onCookieKeyPress(aEvent) {
if (aEvent.keyCode == 46)
this.deleteCookie();
},
_lastSortProperty : "",
_lastSortProperty: "",
_lastSortAscending: false,
sort: function (aProperty)
{
sort(aProperty) {
var ascending = (aProperty == this._lastSortProperty) ? !this._lastSortAscending : true;
function sortByHost(a, b)
{
function sortByHost(a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
}
@ -759,8 +705,7 @@ var gCookiesWindow = {
this._hostOrder.reverse();
}
function sortByProperty(a, b)
{
function sortByProperty(a, b) {
return a[aProperty].toLowerCase().localeCompare(b[aProperty].toLowerCase());
}
for (var host in this._hosts) {
@ -786,8 +731,7 @@ var gCookiesWindow = {
this._lastSortProperty = aProperty;
},
clearFilter: function ()
{
clearFilter() {
// Revert to single-select in the tree
this._tree.setAttribute("seltype", "single");
@ -806,8 +750,7 @@ var gCookiesWindow = {
if (sortby == "") {
this._lastSortAscending = false;
this.sort("rawHost");
}
else {
} else {
this._lastSortAscending = !this._lastSortAscending;
this.sort(sortby);
}
@ -828,18 +771,16 @@ var gCookiesWindow = {
document.getElementById("cookiesIntro").value = this._bundle.getString("cookiesAll");
},
_cookieMatchesFilter: function (aCookie)
{
_cookieMatchesFilter(aCookie) {
return aCookie.rawHost.includes(this._view._filterValue) ||
aCookie.name.includes(this._view._filterValue) ||
aCookie.value.includes(this._view._filterValue);
},
_filterCookies: function (aFilterValue)
{
_filterCookies(aFilterValue) {
this._view._filterValue = aFilterValue;
var cookies = [];
for (var i = 0; i < gCookiesWindow._hostOrder.length; ++i) { //var host in gCookiesWindow._hosts) {
for (var i = 0; i < gCookiesWindow._hostOrder.length; ++i) { // var host in gCookiesWindow._hosts) {
var currHost = gCookiesWindow._hosts[gCookiesWindow._hostOrder[i]]; // gCookiesWindow._hosts[host];
if (!currHost) continue;
for (var j = 0; j < currHost.cookies.length; ++j) {
@ -853,8 +794,7 @@ var gCookiesWindow = {
_lastSelectedRanges: [],
_openIndices: [],
_saveState: function ()
{
_saveState() {
// Save selection
var seln = this._view.selection;
this._lastSelectedRanges = [];
@ -874,8 +814,7 @@ var gCookiesWindow = {
}
},
filter: function ()
{
filter() {
var filter = document.getElementById("filter").value;
if (filter == "") {
gCookiesWindow.clearFilter();
@ -907,15 +846,14 @@ var gCookiesWindow = {
document.getElementById("cookiesIntro").value = gCookiesWindow._bundle.getString("cookiesFiltered");
},
setFilter: function (aFilterString) {
setFilter(aFilterString) {
document.getElementById("filter").value = aFilterString;
this.filter();
},
focusFilterBox: function ()
{
focusFilterBox() {
var filter = document.getElementById("filter");
filter.focus();
filter.select();
}
},
};

Просмотреть файл

@ -7,8 +7,7 @@ var gDisplayPane = {
mInitialized: false,
mTagListBox: null,
init: function ()
{
init() {
if (!(("arguments" in window) && window.arguments[1])) {
// If no tab was specified, select the last used tab.
let preference = document.getElementById("mail.preferences.display.selectedTabIndex");
@ -38,8 +37,7 @@ var gDisplayPane = {
/**
* Populates the default font list in UI.
*/
_rebuildFonts: function ()
{
_rebuildFonts() {
var langGroupPref = document.getElementById("font.language.group");
var isSerif = this._readDefaultFontTypeForLanguage(langGroupPref.value) == "serif";
this._selectDefaultLanguageGroup(langGroupPref.value, isSerif);
@ -119,8 +117,7 @@ var gDisplayPane = {
* Returns the type of the current default font for the language denoted by
* aLanguageGroup.
*/
_readDefaultFontTypeForLanguage: function (aLanguageGroup)
{
_readDefaultFontTypeForLanguage(aLanguageGroup) {
const kDefaultFontType = "font.default.%LANG%";
var defaultFontTypePref = kDefaultFontType.replace(/%LANG%/, aLanguageGroup);
var preference = document.getElementById(defaultFontTypePref);
@ -142,8 +139,7 @@ var gDisplayPane = {
* - the font selected by the user is no longer present (e.g. deleted from
* fonts folder)
*/
readFontSelection: function gDisplayPane_readFontSelection()
{
readFontSelection: function gDisplayPane_readFontSelection() {
let element = document.getElementById("defaultFont");
let preference = document.getElementById(element.getAttribute("preference"));
if (preference.value) {
@ -172,8 +168,7 @@ var gDisplayPane = {
return defaultValue;
},
tabSelectionChanged: function ()
{
tabSelectionChanged() {
if (this.mInitialized)
document.getElementById("mail.preferences.display.selectedTabIndex")
.valueFromPreferences = document.getElementById("displayPrefs").selectedIndex;
@ -183,8 +178,7 @@ var gDisplayPane = {
* Displays the fonts dialog, where web page font names and sizes can be
* configured.
*/
configureFonts: function ()
{
configureFonts() {
gSubDialog.open("chrome://messenger/content/preferences/fonts.xul");
},
@ -192,36 +186,30 @@ var gDisplayPane = {
* Displays the colors dialog, where default web page/link/etc. colors can be
* configured.
*/
configureColors: function ()
{
configureColors() {
gSubDialog.open("chrome://messenger/content/preferences/colors.xul",
"resizable=no");
},
// appends the tag to the tag list box
appendTagItem: function(aTagName, aKey, aColor)
{
appendTagItem(aTagName, aKey, aColor) {
let item = this.mTagListBox.appendItem(aTagName, aKey);
item.style.color = aColor;
return item;
},
buildTagList: function()
{
buildTagList() {
let tagArray = MailServices.tags.getAllTags({});
for (let i = 0; i < tagArray.length; ++i)
{
for (let i = 0; i < tagArray.length; ++i) {
let taginfo = tagArray[i];
this.appendTagItem(taginfo.tag, taginfo.key, taginfo.color);
}
},
removeTag: function()
{
removeTag() {
var index = this.mTagListBox.selectedIndex;
if (index >= 0)
{
if (index >= 0) {
var itemToRemove = this.mTagListBox.getItemAtIndex(index);
MailServices.tags.deleteKey(itemToRemove.getAttribute("value"));
itemToRemove.remove();
@ -233,11 +221,9 @@ var gDisplayPane = {
/**
* Open the edit tag dialog
*/
editTag: function()
{
editTag() {
var index = this.mTagListBox.selectedIndex;
if (index >= 0)
{
if (index >= 0) {
var tagElToEdit = this.mTagListBox.getItemAtIndex(index);
var args = {result: "", keyToEdit: tagElToEdit.getAttribute("value"), okCallback: editTagCallback};
let dialog = gSubDialog.open("chrome://messenger/content/newTagDialog.xul",
@ -245,15 +231,13 @@ var gDisplayPane = {
}
},
addTag: function()
{
addTag() {
var args = {result: "", okCallback: addTagCallback};
let dialog = gSubDialog.open("chrome://messenger/content/newTagDialog.xul",
"resizable=no", args);
},
onSelect: function()
{
onSelect() {
let btnEdit = document.getElementById("editTagButton");
let listBox = document.getElementById("tagList");
@ -271,8 +255,7 @@ var gDisplayPane = {
*
* @param aEnableRadioGroup Boolean value indicating whether the feature is enabled.
*/
updateMarkAsReadOptions: function(aEnableRadioGroup)
{
updateMarkAsReadOptions(aEnableRadioGroup) {
let autoMarkAsPref = document.getElementById("mailnews.mark_message_read.delay");
let autoMarkDisabled = !aEnableRadioGroup || autoMarkAsPref.locked;
document.getElementById("markAsReadAutoPreferences").disabled = autoMarkDisabled;
@ -287,8 +270,7 @@ var gDisplayPane = {
* @param aFocusTextBox Boolean value whether Mark As Read On Delay
* option was selected and the textbox should be focused.
*/
updateMarkAsReadTextbox: function(aFocusTextBox)
{
updateMarkAsReadTextbox(aFocusTextBox) {
let globalCheckbox = document.getElementById("automaticallyMarkAsRead");
let delayRadioOption = document.getElementById("markAsReadAfterDelay");
let delayTextbox = document.getElementById("markAsReadDelay");
@ -297,11 +279,10 @@ var gDisplayPane = {
!delayRadioOption.selected || intervalPref.locked;
if (!delayTextbox.disabled && aFocusTextBox)
delayTextbox.focus();
}
},
};
function addTagCallback(aName, aColor)
{
function addTagCallback(aName, aColor) {
MailServices.tags.addTag(aName, aColor, "");
var item = gDisplayPane.appendTagItem(aName, MailServices.tags.getKeyForTag(aName), aColor);
@ -311,13 +292,11 @@ function addTagCallback(aName, aColor)
tagListBox.focus();
}
function editTagCallback()
{
function editTagCallback() {
// update the values of the selected item
var tagListEl = document.getElementById("tagList");
var index = tagListEl.selectedIndex;
if (index >= 0)
{
if (index >= 0) {
var tagElToEdit = tagListEl.getItemAtIndex(index);
var key = tagElToEdit.getAttribute("value");
// update the color and label elements

Просмотреть файл

@ -4,8 +4,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var gDownloadDirSection = {
chooseFolder: function ()
{
chooseFolder() {
const nsIFilePicker = Ci.nsIFilePicker;
var fp = Cc["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
@ -31,8 +30,7 @@ var gDownloadDirSection = {
});
},
onReadUseDownloadDir: function ()
{
onReadUseDownloadDir() {
this.readDownloadDirPref();
var downloadFolder = document.getElementById("downloadFolder");
var chooseFolder = document.getElementById("chooseFolder");
@ -42,8 +40,7 @@ var gDownloadDirSection = {
return undefined;
},
_fileToIndex: function (aFile)
{
_fileToIndex(aFile) {
if (!aFile || aFile.equals(this._getDownloadsFolder("Desktop")))
return 0;
else if (aFile.equals(this._getDownloadsFolder("Downloads")))
@ -51,8 +48,7 @@ var gDownloadDirSection = {
return 2;
},
_indexToFile: function (aIndex)
{
_indexToFile(aIndex) {
switch (aIndex) {
case 0:
return this._getDownloadsFolder("Desktop");
@ -63,8 +59,7 @@ var gDownloadDirSection = {
return customDirPref.value;
},
_getSpecialFolderKey: function (aFolderType)
{
_getSpecialFolderKey(aFolderType) {
if (aFolderType == "Desktop")
return "Desk";
@ -80,8 +75,7 @@ var gDownloadDirSection = {
return "Home";
},
_getDownloadsFolder: function (aFolder)
{
_getDownloadsFolder(aFolder) {
let dir = Services.dirsvc.get(this._getSpecialFolderKey(aFolder),
Ci.nsIFile);
if (aFolder != "Desktop")
@ -90,8 +84,7 @@ var gDownloadDirSection = {
return dir;
},
readDownloadDirPref: function ()
{
readDownloadDirPref() {
var folderListPref = document.getElementById("browser.download.folderList");
var bundlePreferences = document.getElementById("bundlePreferences");
var downloadFolder = document.getElementById("downloadFolder");
@ -116,9 +109,8 @@ var gDownloadDirSection = {
return undefined;
},
writeFolderList: function ()
{
writeFolderList() {
var currentDirPref = document.getElementById("browser.download.downloadDir");
return this._fileToIndex(currentDirPref.value);
}
},
};

Просмотреть файл

@ -72,33 +72,28 @@ var gFontsDialog = {
.catch(Cu.reportError);
},
readFontLanguageGroup()
{
readFontLanguageGroup() {
var languagePref = Preferences.get("font.language.group");
this._selectLanguageGroup(languagePref.value);
return undefined;
},
readUseDocumentFonts: function ()
{
readUseDocumentFonts() {
var preference = Preferences.get("browser.display.use_document_fonts");
return preference.value == 1;
},
writeUseDocumentFonts: function ()
{
writeUseDocumentFonts() {
var useDocumentFonts = document.getElementById("useDocumentFonts");
return useDocumentFonts.checked ? 1 : 0;
},
readFixedWidthForPlainText: function ()
{
readFixedWidthForPlainText() {
var preference = Preferences.get("mail.fixed_width_messages");
return preference.value == 1;
},
writeFixedWidthForPlainText: function ()
{
writeFixedWidthForPlainText() {
var mailFixedWidthMessages = document.getElementById("mailFixedWidthMessages");
return mailFixedWidthMessages.checked;
},
@ -108,8 +103,7 @@ var gFontsDialog = {
* are nsIPrefLocalizedString. Its default value is different depending
* on the user locale (see bug 48842).
*/
ondialogaccept: function()
{
ondialogaccept() {
var sendCharsetStr = Services.prefs.getComplexValue(
"mailnews.send_default_charset", Ci.nsIPrefLocalizedString).data;
@ -129,5 +123,5 @@ var gFontsDialog = {
Services.prefs.clearUserPref("mailnews.view_default_charset");
return true;
}
},
};

Просмотреть файл

@ -7,8 +7,7 @@ var gGeneralPane = {
mPane: null,
mStartPageUrl: "",
init: function ()
{
init() {
this.mPane = document.getElementById("paneGeneral");
this.updateStartPage();
@ -20,8 +19,7 @@ var gGeneralPane = {
/**
* Restores the default start page as the user's start page
*/
restoreDefaultStartPage: function()
{
restoreDefaultStartPage() {
var startPage = document.getElementById("mailnews.start_page.url");
startPage.value = startPage.defaultValue;
},
@ -30,8 +28,7 @@ var gGeneralPane = {
* Returns a formatted url corresponding to the value of mailnews.start_page.url
* Stores the original value of mailnews.start_page.url
*/
readStartPageUrl: function()
{
readStartPageUrl() {
var pref = document.getElementById("mailnews.start_page.url");
this.mStartPageUrl = pref.value;
return Services.urlFormatter.formatURL(this.mStartPageUrl);
@ -42,52 +39,43 @@ var gGeneralPane = {
* If the url matches the formatted version of our stored value, then
* return the unformatted url.
*/
writeStartPageUrl: function()
{
var startPage = document.getElementById('mailnewsStartPageUrl');
writeStartPageUrl() {
var startPage = document.getElementById("mailnewsStartPageUrl");
return Services.urlFormatter.formatURL(this.mStartPageUrl) == startPage.value ? this.mStartPageUrl : startPage.value;
},
customizeMailAlert: function()
{
customizeMailAlert() {
gSubDialog.open("chrome://messenger/content/preferences/notifications.xul",
"resizable=no");
},
configureDockOptions: function()
{
configureDockOptions() {
gSubDialog.open("chrome://messenger/content/preferences/dockoptions.xul",
"resizable=no");
},
convertURLToLocalFile: function(aFileURL)
{
convertURLToLocalFile(aFileURL) {
// convert the file url into a nsIFile
if (aFileURL)
{
if (aFileURL) {
return Services.io
.getProtocolHandler("file")
.QueryInterface(Ci.nsIFileProtocolHandler)
.getFileFromURLSpec(aFileURL);
}
else
return null;
return null;
},
readSoundLocation: function()
{
readSoundLocation() {
var soundUrlLocation = document.getElementById("soundUrlLocation");
soundUrlLocation.value = document.getElementById("mail.biff.play_sound.url").value;
if (soundUrlLocation.value)
{
if (soundUrlLocation.value) {
soundUrlLocation.label = this.convertURLToLocalFile(soundUrlLocation.value).leafName;
soundUrlLocation.style.backgroundImage = "url(moz-icon://" + soundUrlLocation.label + "?size=16)";
}
return undefined;
},
previewSound: function ()
{
previewSound() {
let sound = Cc["@mozilla.org/sound;1"]
.createInstance(Ci.nsISound);
@ -95,8 +83,8 @@ var gGeneralPane = {
// soundType radio-group isn't used for macOS so it is not in the XUL file
// for the platform.
soundLocation = (AppConstants.platform == "macosx" ||
document.getElementById('soundType').value == 1) ?
document.getElementById('soundUrlLocation').value : "";
document.getElementById("soundType").value == 1) ?
document.getElementById("soundUrlLocation").value : "";
if (!soundLocation.includes("file://")) {
// User has not set any custom sound file to be played
@ -107,14 +95,13 @@ var gGeneralPane = {
}
},
browseForSoundFile: function ()
{
browseForSoundFile() {
const nsIFilePicker = Ci.nsIFilePicker;
var fp = Cc["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
// if we already have a sound file, then use the path for that sound file
// as the initial path in the dialog.
var localFile = this.convertURLToLocalFile(document.getElementById('soundUrlLocation').value);
var localFile = this.convertURLToLocalFile(document.getElementById("soundUrlLocation").value);
if (localFile)
fp.displayDirectory = localFile.parent;
@ -142,29 +129,28 @@ var gGeneralPane = {
});
},
updatePlaySound: function()
{
updatePlaySound() {
// Update the sound type radio buttons based on the state of the
// play sound checkbox.
var soundsDisabled = !document.getElementById('newMailNotification').checked;
var soundUrlLocation = document.getElementById('soundUrlLocation').value;
var soundsDisabled = !document.getElementById("newMailNotification").checked;
var soundUrlLocation = document.getElementById("soundUrlLocation").value;
// The UI is different on OS X as the user can only choose between letting
// the system play a default sound or setting a custom one. Therefore,
// "soundTypeEl" does not exist on OS X.
if (AppConstants.platform != "macosx") {
var soundTypeEl = document.getElementById('soundType');
var soundTypeEl = document.getElementById("soundType");
soundTypeEl.disabled = soundsDisabled;
document.getElementById("soundUrlLocation").disabled =
soundsDisabled || soundTypeEl.value != 1;
document.getElementById('playSound').disabled =
document.getElementById("playSound").disabled =
soundsDisabled || (!soundUrlLocation && soundTypeEl.value != 0);
} else {
// On OS X, if there is no selected custom sound then default one will
// be played. We keep consistency by disabling the "Play sound" checkbox
// if the user hasn't selected a custom sound file yet.
document.getElementById('newMailNotification').disabled = !soundUrlLocation;
document.getElementById('playSound').disabled = !soundUrlLocation;
document.getElementById("newMailNotification").disabled = !soundUrlLocation;
document.getElementById("playSound").disabled = !soundUrlLocation;
// The sound type radiogroup is hidden, but we have to keep the
// play_sound.type pref set appropriately.
document.getElementById("mail.biff.play_sound.type").value =
@ -172,14 +158,12 @@ var gGeneralPane = {
}
},
updateStartPage: function()
{
updateStartPage() {
document.getElementById("mailnewsStartPageUrl").disabled =
!document.getElementById("mailnewsStartPageEnabled").checked;
},
updateCustomizeAlert: function()
{
updateCustomizeAlert() {
// The button does not exist on all platforms.
let customizeAlertButton = document.getElementById("customizeMailAlert");
if (customizeAlertButton) {
@ -188,9 +172,9 @@ var gGeneralPane = {
}
},
updateWebSearch: function() {
updateWebSearch() {
Services.search.init({
onInitComplete: function() {
onInitComplete() {
let engineList = document.getElementById("defaultWebSearch");
for (let engine of Services.search.getVisibleEngines()) {
let item = engineList.appendItem(engine.name);
@ -207,7 +191,7 @@ var gGeneralPane = {
engineList.addEventListener("command", function() {
Services.search.currentEngine = engineList.selectedItem.engine;
});
}
},
});
},
};

Просмотреть файл

@ -17,7 +17,7 @@ Conversation.prototype = {
__proto__: jsProtoHelper.GenericConvIMPrototype,
account: {protocol: {name: "Fake Protocol"},
alias: "", name: "Fake Account",
statusInfo: Services.core.globalUserStatus}
statusInfo: Services.core.globalUserStatus},
};
function Message(aWho, aMessage, aObject) {
@ -25,7 +25,7 @@ function Message(aWho, aMessage, aObject) {
}
Message.prototype = {
__proto__: jsProtoHelper.GenericMessagePrototype,
get displayMessage() { return this.originalMessage; }
get displayMessage() { return this.originalMessage; },
};
// Message style tooltips use this.
@ -33,7 +33,7 @@ function getBrowser() { return document.getElementById("previewbrowser"); }
var previewObserver = {
_loaded: false,
load: function() {
load() {
let makeDate = function(aDateString) {
let array = aDateString.split(":");
let now = new Date();
@ -50,7 +50,7 @@ var previewObserver = {
conv.messages = [
new Message(msg.buddy1, msg.message1, {outgoing: true, _alias: msg.nick1, time: makeDate("10:42:22"), _conversation: conv}),
new Message(msg.buddy1, msg.message2, {outgoing: true, _alias: msg.nick1, time: makeDate("10:42:25"), _conversation: conv}),
new Message(msg.buddy2, msg.message3, {incoming: true, _alias: msg.nick2, time: makeDate("10:43:01"), _conversation: conv})
new Message(msg.buddy2, msg.message3, {incoming: true, _alias: msg.nick2, time: makeDate("10:43:01"), _conversation: conv}),
];
previewObserver.conv = conv;
@ -65,7 +65,7 @@ var previewObserver = {
this._loaded = true;
},
showHeaderChanged: function() {
showHeaderChanged() {
if (!previewObserver._loaded)
return;
@ -73,7 +73,7 @@ var previewObserver = {
previewObserver.reloadPreview();
},
currentThemeChanged: function() {
currentThemeChanged() {
if (!this._loaded)
return;
@ -85,7 +85,7 @@ var previewObserver = {
},
_ignoreVariantChange: false,
currentVariantChanged: function() {
currentVariantChanged() {
if (!this._loaded || this._ignoreVariantChange)
return;
@ -97,11 +97,10 @@ var previewObserver = {
this.reloadPreview();
},
displayTheme: function(aTheme) {
displayTheme(aTheme) {
try {
this.theme = getThemeByName(aTheme);
}
catch(e) {
} catch (e) {
document.getElementById("previewDeck").selectedIndex = 0;
return;
}
@ -160,13 +159,13 @@ var previewObserver = {
document.getElementById("previewDeck").selectedIndex = 1;
},
reloadPreview: function() {
reloadPreview() {
this.browser.init(this.conv);
this.browser._theme = this.theme;
Services.obs.addObserver(this, "conversation-loaded");
},
observe: function(aSubject, aTopic, aData) {
observe(aSubject, aTopic, aData) {
if (aTopic != "conversation-loaded" || aSubject != this.browser)
return;
@ -186,5 +185,5 @@ var previewObserver = {
}, 0);
Services.obs.removeObserver(this, "conversation-loaded");
}
},
};

Просмотреть файл

@ -6,16 +6,14 @@ var kAutomatic = 4;
var kRememberLastState = 0;
var gOfflineDialog = {
dialogSetup: function() {
dialogSetup() {
let offlineAutoDetection = document.getElementById("offline.autoDetect");
let offlineStartupStatePref = document.getElementById("offline.startup_state");
offlineStartupStatePref.disabled = offlineAutoDetection.value;
if (offlineStartupStatePref.disabled) {
offlineStartupStatePref.value = kAutomatic;
} else {
if (offlineStartupStatePref.value == kAutomatic)
} else if (offlineStartupStatePref.value == kAutomatic)
offlineStartupStatePref.value = kRememberLastState;
}
}
},
};

Просмотреть файл

@ -16,8 +16,7 @@ var NOTIFICATION_FLUSH_PERMISSIONS = "flush-pending-permissions";
*/
var MAILURI_BASE = "chrome://messenger/content/email=";
function Permission(principal, type, capability)
{
function Permission(principal, type, capability) {
this.principal = principal;
this.origin = principal.origin;
this.type = type;
@ -25,22 +24,20 @@ function Permission(principal, type, capability)
}
var gPermissionManager = {
_type : "",
_permissions : [],
_permissionsToAdd : new Map(),
_permissionsToDelete : new Map(),
_bundle : null,
_tree : null,
_observerRemoved : false,
_type: "",
_permissions: [],
_permissionsToAdd: new Map(),
_permissionsToDelete: new Map(),
_bundle: null,
_tree: null,
_observerRemoved: false,
_view: {
_rowCount: 0,
get rowCount()
{
get rowCount() {
return this._rowCount;
},
getCellText: function (aRow, aColumn)
{
getCellText(aRow, aColumn) {
if (aColumn.id == "siteCol")
return gPermissionManager._permissions[aRow].origin
.replace(MAILURI_BASE, "");
@ -49,25 +46,24 @@ var gPermissionManager = {
return "";
},
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){
isSeparator(aIndex) { return false; },
isSorted() { return false; },
isContainer(aIndex) { return false; },
setTree(aTree) {},
getImageSrc(aRow, aColumn) {},
getProgressMode(aRow, aColumn) {},
getCellValue(aRow, aColumn) {},
cycleHeader(column) {},
getRowProperties(row) { return ""; },
getColumnProperties(column) { return ""; },
getCellProperties(row, column) {
if (column.element.getAttribute("id") == "siteCol")
return "ltr";
return "";
}
},
},
_getCapabilityString: function (aCapability)
{
_getCapabilityString(aCapability) {
var stringKey = null;
switch (aCapability) {
case nsIPermissionManager.ALLOW_ACTION:
@ -86,8 +82,7 @@ var gPermissionManager = {
return this._bundle.getString(stringKey);
},
addPermission: function (aCapability)
{
addPermission(aCapability) {
var textbox = document.getElementById("url");
var input_url = textbox.value.trim();
let principal;
@ -105,7 +100,7 @@ var gPermissionManager = {
principal = Services.scriptSecurityManager.createCodebasePrincipal(uri, {});
// If we have ended up with an unknown scheme, the following will throw.
principal.origin;
} catch(ex) {
} catch (ex) {
let scheme = (this._type != "image" || !input_url.includes("@")) ?
"http://" : MAILURI_BASE;
uri = Services.io.newURI(scheme + input_url);
@ -113,7 +108,7 @@ var gPermissionManager = {
// If we have ended up with an unknown scheme, the following will throw.
principal.origin;
}
} catch(ex) {
} catch (ex) {
var message = this._bundle.getString("invalidURI");
var title = this._bundle.getString("invalidURITitle");
Services.prompt.alert(window, title, message);
@ -137,12 +132,11 @@ var gPermissionManager = {
}
}
let permissionParams = {principal: principal, type: this._type, capability: aCapability};
let permissionParams = {principal, type: this._type, capability: aCapability};
if (!permissionExists) {
this._permissionsToAdd.set(principal.origin, permissionParams);
this._addPermission(permissionParams);
}
else if (!capabilityExists) {
} else if (!capabilityExists) {
this._permissionsToAdd.set(principal.origin, permissionParams);
this._handleCapabilityChange();
}
@ -157,8 +151,7 @@ var gPermissionManager = {
document.getElementById("removeAllPermissions").disabled = this._permissions.length == 0;
},
_removePermission: function(aPermission)
{
_removePermission(aPermission) {
this._removePermissionFromList(aPermission.principal);
// If this permission was added during this session, let's remove
@ -172,8 +165,7 @@ var gPermissionManager = {
},
_handleCapabilityChange: function ()
{
_handleCapabilityChange() {
// Re-do the sort, if the status changed from Block to Allow
// or vice versa, since if we're sorted on status, we may no
// longer be in order.
@ -183,8 +175,7 @@ var gPermissionManager = {
this._tree.treeBoxObject.invalidate();
},
_addPermission: function(aPermission)
{
_addPermission(aPermission) {
this._addPermissionToList(aPermission);
++this._view._rowCount;
this._tree.treeBoxObject.rowCountChanged(this._view.rowCount - 1, 1);
@ -192,8 +183,7 @@ var gPermissionManager = {
this._resortPermissions();
},
_resortPermissions: function()
{
_resortPermissions() {
gTreeUtils.sort(this._tree, this._view, this._permissions,
this._lastPermissionSortColumn,
this._permissionsComparator,
@ -201,34 +191,29 @@ var gPermissionManager = {
!this._lastPermissionSortAscending); // keep sort direction
},
onHostInput: function (aSiteField)
{
onHostInput(aSiteField) {
document.getElementById("btnSession").disabled = !aSiteField.value;
document.getElementById("btnBlock").disabled = !aSiteField.value;
document.getElementById("btnAllow").disabled = !aSiteField.value;
},
onWindowKeyPress: function (aEvent)
{
onWindowKeyPress(aEvent) {
if (aEvent.keyCode == KeyEvent.DOM_VK_ESCAPE)
window.close();
},
onHostKeyPress: function (aEvent)
{
onHostKeyPress(aEvent) {
if (aEvent.keyCode == KeyEvent.DOM_VK_RETURN)
document.getElementById("btnAllow").click();
},
onLoad: function ()
{
onLoad() {
this._bundle = document.getElementById("bundlePreferences");
var params = window.arguments[0];
this.init(params);
},
init: function (aParams)
{
init(aParams) {
if (this._type) {
// reusing an open dialog, clear the old observer
this.uninit();
@ -281,8 +266,7 @@ var gPermissionManager = {
urlField.focus();
},
uninit: function ()
{
uninit() {
if (!this._observerRemoved) {
Services.obs.removeObserver(this, "perm-changed");
@ -290,8 +274,7 @@ var gPermissionManager = {
}
},
observe: function (aSubject, aTopic, aData)
{
observe(aSubject, aTopic, aData) {
if (aTopic == "perm-changed") {
var permission = aSubject.QueryInterface(Ci.nsIPermission);
@ -301,8 +284,7 @@ var gPermissionManager = {
if (aData == "added") {
this._addPermission(permission);
}
else if (aData == "changed") {
} else if (aData == "changed") {
for (var i = 0; i < this._permissions.length; ++i) {
if (permission.matches(this._permissions[i].principal, true)) {
this._permissions[i].capability = this._getCapabilityString(permission.capability);
@ -310,23 +292,20 @@ var gPermissionManager = {
}
}
this._handleCapabilityChange();
}
else if (aData == "deleted") {
} else if (aData == "deleted") {
this._removePermissionFromList(permission);
}
}
},
onPermissionSelected: function ()
{
onPermissionSelected() {
var hasSelection = this._tree.view.selection.count > 0;
var hasRows = this._tree.view.rowCount > 0;
document.getElementById("removePermission").disabled = !hasRows || !hasSelection;
document.getElementById("removeAllPermissions").disabled = !hasRows;
},
onPermissionDeleted: function ()
{
onPermissionDeleted() {
if (!this._view.rowCount)
return;
var removedPermissions = [];
@ -339,8 +318,7 @@ var gPermissionManager = {
document.getElementById("removeAllPermissions").disabled = !this._permissions.length;
},
onAllPermissionsDeleted: function ()
{
onAllPermissionsDeleted() {
if (!this._view.rowCount)
return;
var removedPermissions = [];
@ -353,8 +331,7 @@ var gPermissionManager = {
document.getElementById("removeAllPermissions").disabled = true;
},
onPermissionKeyPress: function (aEvent)
{
onPermissionKeyPress(aEvent) {
if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE ||
((AppConstants.platform == "macosx") &&
aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE))
@ -363,14 +340,12 @@ var gPermissionManager = {
_lastPermissionSortColumn: "",
_lastPermissionSortAscending: false,
_permissionsComparator : function (a, b)
{
_permissionsComparator(a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
},
onPermissionSort: function (aColumn)
{
onPermissionSort(aColumn) {
this._lastPermissionSortAscending = gTreeUtils.sort(this._tree,
this._view,
this._permissions,
@ -381,8 +356,7 @@ var gPermissionManager = {
this._lastPermissionSortColumn = aColumn;
},
onApplyChanges: function()
{
onApplyChanges() {
// Stop observing permission changes since we are about
// to write out the pending adds/deletes and don't need
// to update the UI
@ -399,8 +373,7 @@ var gPermissionManager = {
window.close();
},
_loadPermissions: function ()
{
_loadPermissions() {
this._tree = document.getElementById("permissionsTree");
this._permissions = [];
@ -422,8 +395,7 @@ var gPermissionManager = {
document.getElementById("removeAllPermissions").disabled = this._permissions.length == 0;
},
_addPermissionToList: function (aPermission)
{
_addPermissionToList(aPermission) {
if (aPermission.type == this._type &&
(!this._manageCapability ||
@ -438,8 +410,7 @@ var gPermissionManager = {
}
},
_removePermissionFromList: function (aPrincipal)
{
_removePermissionFromList(aPrincipal) {
for (let i = 0; i < this._permissions.length; ++i) {
// Thunderbird compares origins, not principals here.
if (this._permissions[i].principal.origin == aPrincipal.origin) {
@ -452,18 +423,15 @@ var gPermissionManager = {
}
},
setOrigin: function (aOrigin)
{
setOrigin(aOrigin) {
document.getElementById("url").value = aOrigin;
}
},
};
function setOrigin(aOrigin)
{
function setOrigin(aOrigin) {
gPermissionManager.setOrigin(aOrigin);
}
function initWithParams(aParams)
{
function initWithParams(aParams) {
gPermissionManager.init(aParams);
}

Просмотреть файл

@ -6,7 +6,7 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
ChromeUtils.import("resource:///modules/MailServices.jsm");
window.addEventListener("load", function () {
window.addEventListener("load", function() {
let prefWindow = document.getElementById("MailPreferences");
if (!Services.prefs.getBoolPref("mail.chat.enabled")) {
let radio =

Просмотреть файл

@ -30,10 +30,10 @@ var preferencesTabType = {
modes: {
preferencesTab: {
type: "preferencesTab",
}
},
},
initialize: function() {
initialize() {
let tabmail = document.getElementById("tabmail");
tabmail.registerTabType(this);
},
@ -47,13 +47,13 @@ var preferencesTabType = {
return document.getElementById("tabmail").tabInfo.indexOf(gPrefTab);
},
closeTab: function(aTab) {
closeTab(aTab) {
gPrefTab = null;
},
openTab: function onTabOpened(aTab, aArgs) {
if (!"contentPage" in aArgs) {
throw("contentPage must be specified");
if (!("contentPage" in aArgs)) {
throw ("contentPage must be specified");
}
// First clone the page and set up the basics.

Просмотреть файл

@ -5,16 +5,14 @@
var gPrivacyPane = {
init: function()
{
init() {
},
/**
* Reload the current message after a preference affecting the view
* has been changed and we are in instantApply mode.
*/
reloadMessageInOpener: function()
{
reloadMessageInOpener() {
if (Services.prefs.getBoolPref("browser.preferences.instantApply") &&
window.opener && typeof(window.opener.ReloadMessage) == "function")
window.opener.ReloadMessage();
@ -25,8 +23,7 @@ var gPrivacyPane = {
* enables/disables the rest of the cookie UI accordingly, returning true
* if cookies are enabled.
*/
readAcceptCookies: function()
{
readAcceptCookies() {
let pref = document.getElementById("network.cookie.cookieBehavior");
let acceptThirdPartyLabel = document.getElementById("acceptThirdPartyLabel");
let acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu");
@ -48,8 +45,7 @@ var gPrivacyPane = {
* @return 0 if cookies are accepted, 2 if they are not;
* the value network.cookie.cookieBehavior should get
*/
writeAcceptCookies: function()
{
writeAcceptCookies() {
let accept = document.getElementById("acceptCookies");
let acceptThirdPartyMenu = document.getElementById("acceptThirdPartyMenu");
// if we're enabling cookies, automatically select 'accept third party always'
@ -62,16 +58,15 @@ var gPrivacyPane = {
/**
* Displays fine-grained, per-site preferences for cookies.
*/
showCookieExceptions: function()
{
showCookieExceptions() {
let bundle = document.getElementById("bundlePreferences");
let params = { blockVisible : true,
sessionVisible : true,
allowVisible : true,
prefilledHost : "",
permissionType : "cookie",
windowTitle : bundle.getString("cookiepermissionstitle"),
introText : bundle.getString("cookiepermissionstext") };
let params = { blockVisible: true,
sessionVisible: true,
allowVisible: true,
prefilledHost: "",
permissionType: "cookie",
windowTitle: bundle.getString("cookiepermissionstitle"),
introText: bundle.getString("cookiepermissionstext") };
gSubDialog.open("chrome://messenger/content/preferences/permissions.xul",
null, params);
},
@ -79,19 +74,16 @@ var gPrivacyPane = {
/**
* Displays all the user's cookies in a dialog.
*/
showCookies: function(aCategory)
{
showCookies(aCategory) {
gSubDialog.open("chrome://messenger/content/preferences/cookies.xul");
},
/**
* Converts between network.cookie.cookieBehavior and the third-party cookie UI
*/
readAcceptThirdPartyCookies: function()
{
readAcceptThirdPartyCookies() {
let pref = document.getElementById("network.cookie.cookieBehavior");
switch (pref.value)
{
switch (pref.value) {
case 0:
return "always";
case 1:
@ -105,11 +97,9 @@ var gPrivacyPane = {
}
},
writeAcceptThirdPartyCookies: function()
{
writeAcceptThirdPartyCookies() {
let accept = document.getElementById("acceptThirdPartyMenu").selectedItem;
switch (accept.value)
{
switch (accept.value) {
case "always":
return 0;
case "visited":
@ -126,16 +116,15 @@ var gPrivacyPane = {
* We use the "image" type for that, but it can also be stylesheets or
* iframes.
*/
showRemoteContentExceptions: function()
{
showRemoteContentExceptions() {
let bundle = document.getElementById("bundlePreferences");
let params = { blockVisible : true,
sessionVisible : false,
allowVisible : true,
prefilledHost : "",
permissionType : "image",
windowTitle : bundle.getString("imagepermissionstitle"),
introText : bundle.getString("imagepermissionstext") };
let params = { blockVisible: true,
sessionVisible: false,
allowVisible: true,
prefilledHost: "",
permissionType: "image",
windowTitle: bundle.getString("imagepermissionstitle"),
introText: bundle.getString("imagepermissionstext") };
gSubDialog.open("chrome://messenger/content/preferences/permissions.xul",
null, params);
},

Просмотреть файл

@ -9,12 +9,11 @@ var gSecurityPane = {
mPane: null,
mInitialized: false,
init: function ()
{
init() {
this.mPane = document.getElementById("paneSecurity");
this.updateManualMarkMode(document.getElementById('manualMark').checked);
this.updateJunkLogButton(document.getElementById('enableJunkLogging').checked);
this.updateManualMarkMode(document.getElementById("manualMark").checked);
this.updateJunkLogButton(document.getElementById("enableJunkLogging").checked);
this._initMasterPasswordUI();
@ -31,30 +30,25 @@ var gSecurityPane = {
this.mInitialized = true;
},
tabSelectionChanged: function ()
{
tabSelectionChanged() {
if (this.mInitialized)
document.getElementById("mail.preferences.security.selectedTabIndex")
.valueFromPreferences = document.getElementById("securityPrefs").selectedIndex;
},
updateManualMarkMode: function(aEnableRadioGroup)
{
document.getElementById('manualMarkMode').disabled = !aEnableRadioGroup;
updateManualMarkMode(aEnableRadioGroup) {
document.getElementById("manualMarkMode").disabled = !aEnableRadioGroup;
},
updateJunkLogButton: function(aEnableButton)
{
document.getElementById('openJunkLogButton').disabled = !aEnableButton;
updateJunkLogButton(aEnableButton) {
document.getElementById("openJunkLogButton").disabled = !aEnableButton;
},
openJunkLog: function()
{
openJunkLog() {
gSubDialog.open("chrome://messenger/content/junkLog.xul");
},
resetTrainingData: function()
{
resetTrainingData() {
// make sure the user really wants to do this
var bundle = document.getElementById("bundlePreferences");
var title = bundle.getString("confirmResetJunkTrainingTitle");
@ -73,9 +67,8 @@ var gSecurityPane = {
* Reload the current message after a preference affecting the view
* has been changed and we are in instantApply mode.
*/
reloadMessageInOpener: function()
{
if(Services.prefs.getBoolPref("browser.preferences.instantApply") &&
reloadMessageInOpener() {
if (Services.prefs.getBoolPref("browser.preferences.instantApply") &&
window.opener && typeof(window.opener.ReloadMessage) == "function")
window.opener.ReloadMessage();
},
@ -86,8 +79,7 @@ var gSecurityPane = {
* The master password is controlled by various bits of NSS functionality,
* so the UI for it can't be controlled by the normal preference bindings.
*/
_initMasterPasswordUI: function ()
{
_initMasterPasswordUI() {
var noMP = !LoginHelper.isMasterPasswordSet();
document.getElementById("changeMasterPassword").disabled = noMP;
@ -100,8 +92,7 @@ var gSecurityPane = {
* "use master password" checkbox, and prompts for master password removal
* if one is set.
*/
updateMasterPasswordButton: function ()
{
updateMasterPasswordButton() {
var checkbox = document.getElementById("useMasterPassword");
var button = document.getElementById("changeMasterPassword");
button.disabled = !checkbox.checked;
@ -124,8 +115,7 @@ var gSecurityPane = {
* the current master password. When the dialog is dismissed, master password
* UI is automatically updated.
*/
_removeMasterPassword: function ()
{
_removeMasterPassword() {
var secmodDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].
getService(Ci.nsIPKCS11ModuleDB);
if (secmodDB.isFIPSEnabled) {
@ -133,8 +123,7 @@ var gSecurityPane = {
Services.prompt.alert(window,
bundle.getString("pw_change_failed_title"),
bundle.getString("pw_change2empty_in_fips_mode"));
}
else {
} else {
gSubDialog.open("chrome://mozapps/content/preferences/removemp.xul",
null, null, this._initMasterPasswordUI.bind(this));
}
@ -144,8 +133,7 @@ var gSecurityPane = {
/**
* Displays a dialog in which the master password may be changed.
*/
changeMasterPassword: function ()
{
changeMasterPassword() {
gSubDialog.open("chrome://mozapps/content/preferences/changemp.xul",
null, null, this._initMasterPasswordUI.bind(this));
},
@ -154,14 +142,12 @@ var gSecurityPane = {
* Shows the sites where the user has saved passwords and the associated
* login information.
*/
showPasswords: function ()
{
showPasswords() {
gSubDialog.open("chrome://passwordmgr/content/passwordManager.xul");
},
updateDownloadedPhishingListState: function()
{
document.getElementById('useDownloadedList').disabled = !document.getElementById('enablePhishingDetector').checked;
updateDownloadedPhishingListState() {
document.getElementById("useDownloadedList").disabled = !document.getElementById("enablePhishingDetector").checked;
},
};

Просмотреть файл

@ -10,30 +10,26 @@ var gSendOptionsDialog = {
mHTMLListBox: null,
mPlainTextListBox: null,
init: function ()
{
this.mPrefsBundle = document.getElementById('bundlePreferences');
this.mHTMLListBox = document.getElementById('html_domains');
this.mPlainTextListBox = document.getElementById('plaintext_domains');
init() {
this.mPrefsBundle = document.getElementById("bundlePreferences");
this.mHTMLListBox = document.getElementById("html_domains");
this.mPlainTextListBox = document.getElementById("plaintext_domains");
var htmlDomainPrefString = document.getElementById('mailnews.html_domains').value;
this.loadDomains(document.getElementById('mailnews.html_domains').value,
var htmlDomainPrefString = document.getElementById("mailnews.html_domains").value;
this.loadDomains(document.getElementById("mailnews.html_domains").value,
this.mHTMLListBox);
this.loadDomains(document.getElementById('mailnews.plaintext_domains').value,
this.loadDomains(document.getElementById("mailnews.plaintext_domains").value,
this.mPlainTextListBox);
},
saveDomainPref: function(aHTML)
{
saveDomainPref(aHTML) {
var listbox = aHTML ? this.mHTMLListBox : this.mPlainTextListBox;
var num_domains = 0;
var pref_string = "";
for (var item = listbox.firstChild; item != null; item = item.nextSibling)
{
for (var item = listbox.firstChild; item != null; item = item.nextSibling) {
var domainid = item.firstChild.getAttribute("value");
if (domainid.length > 1)
{
if (domainid.length > 1) {
num_domains++;
// Separate >1 domains by commas.
@ -47,69 +43,61 @@ var gSendOptionsDialog = {
return pref_string;
},
loadDomains: function (aPrefString, aListBox)
{
var arrayOfPrefs = aPrefString.split(',');
loadDomains(aPrefString, aListBox) {
var arrayOfPrefs = aPrefString.split(",");
if (arrayOfPrefs)
for (var i = 0; i < arrayOfPrefs.length; i++)
{
var str = arrayOfPrefs[i].replace(/ /g,"");
for (var i = 0; i < arrayOfPrefs.length; i++) {
var str = arrayOfPrefs[i].replace(/ /g, "");
if (str)
this.addItemToDomainList(aListBox, str);
}
},
removeDomains: function(aHTML)
{
removeDomains(aHTML) {
let listbox = aHTML ? this.mHTMLListBox : this.mPlainTextListBox;
let selectedCount = listbox.selectedItems.length;
for (let i = selectedCount - 1; i >= 0; i--)
listbox.selectedItems[i].remove();
document.getElementById('SendOptionsDialogPane').userChangedValue(listbox);
document.getElementById("SendOptionsDialogPane").userChangedValue(listbox);
},
addDomain: function (aHTML)
{
addDomain(aHTML) {
var listbox = aHTML ? this.mHTMLListBox : this.mPlainTextListBox;
var domainName;
var result = {value:null};
if (Services.prompt.prompt(window, this.mPrefsBundle.getString(listbox.id + 'AddDomainTitle'),
this.mPrefsBundle.getString(listbox.id + 'AddDomain'), result, null, {value:0}))
domainName = result.value.replace(/ /g,"");
var result = {value: null};
if (Services.prompt.prompt(window, this.mPrefsBundle.getString(listbox.id + "AddDomainTitle"),
this.mPrefsBundle.getString(listbox.id + "AddDomain"), result, null, {value: 0}))
domainName = result.value.replace(/ /g, "");
if (domainName && !this.domainAlreadyPresent(domainName))
{
if (domainName && !this.domainAlreadyPresent(domainName)) {
this.addItemToDomainList(listbox, domainName);
document.getElementById('SendOptionsDialogPane').userChangedValue(listbox);
document.getElementById("SendOptionsDialogPane").userChangedValue(listbox);
}
},
domainAlreadyPresent: function(aDomainName)
{
domainAlreadyPresent(aDomainName) {
let matchingDomains = this.mHTMLListBox.querySelectorAll('[value="' + aDomainName + '"]');
if (!matchingDomains.length)
matchingDomains = this.mPlainTextListBox.querySelectorAll('[value="' + aDomainName + '"]');
if (matchingDomains.length)
{
Services.prompt.alert(window, this.mPrefsBundle.getString('domainNameErrorTitle'),
if (matchingDomains.length) {
Services.prompt.alert(window, this.mPrefsBundle.getString("domainNameErrorTitle"),
this.mPrefsBundle.getFormattedString("domainDuplicationError", [aDomainName]));
}
return matchingDomains.length;
},
addItemToDomainList: function (aListBox, aDomainTitle)
{
addItemToDomainList(aListBox, aDomainTitle) {
let label = document.createElement("label");
label.setAttribute("value", aDomainTitle);
let item = document.createElement("richlistitem");
item.appendChild(label);
aListBox.appendChild(item);
}
},
};