Bug 1346797 - Fix calendar eslint issues - Fix mozilla/use-default-preference-values issues. r=MakeMyDay
MozReview-Commit-ID: D9KirkOnTdB
--- a/calendar/base/content/preferences/categories.js
+++ b/calendar/base/content/preferences/categories.js
@@ -142,22 +142,18 @@ var gCategoriesPane = {
},
/**
* Edits the currently selected category using the edit category dialog.
*/
editCategory: function() {
let list = document.getElementById("categorieslist");
let categoryNameFix = cal.formatStringForCSSRule(gCategoryList[list.selectedIndex]);
- let currentColor = null;
- try {
- currentColor = categoryPrefBranch.getCharPref(categoryNameFix);
- } catch (ex) {
- // If the pref doesn't exist, don't bail out here.
- }
+ let currentColor = categoryPrefBranch.getCharPref(categoryNameFix, "");
+
let params = {
title: editTitle,
category: gCategoryList[list.selectedIndex],
color: currentColor
};
if (list.selectedItem) {
if (this.mLoadInContent) {
gSubDialog.open(this.mCategoryDialog, "resizable=no", params);
@@ -282,23 +278,17 @@ var gCategoriesPane = {
/**
* Backs up the category name in case the dialog is canceled.
*
* @see formatStringForCSSRule
* @param categoryNameFix The formatted category name.
*/
backupData: function(categoryNameFix) {
- let currentColor;
- try {
- currentColor = categoryPrefBranch.getCharPref(categoryNameFix);
- } catch (ex) {
- dump("Exception caught in 'backupData': " + ex + "\n");
- currentColor = "##NEW";
- }
+ let currentColor = categoryPrefBranch.getCharPref(categoryNameFix, "##NEW");
for (let i = 0; i < parent.backupPrefList.length; i++) {
if (categoryNameFix == parent.backupPrefList[i].name) {
return;
}
}
parent.backupPrefList[parent.backupPrefList.length] =
{ name: categoryNameFix, color: currentColor };
--- a/calendar/base/content/preferences/editCategory.js
+++ b/calendar/base/content/preferences/editCategory.js
@@ -10,17 +10,17 @@ Components.utils.import("resource://cale
var customColorSelected = false;
/**
* Load Handler, called when the edit category dialog is loaded
*/
function editCategoryLoad() {
let winArg = window.arguments[0];
let color = winArg.color || cal.hashColor(winArg.category);
- let hasColor = (winArg.color != null);
+ let hasColor = !!winArg.color;
document.getElementById("categoryName").value = winArg.category;
document.getElementById("categoryColor").value = color;
document.getElementById("useColor").checked = hasColor;
customColorSelected = hasColor;
document.title = winArg.title;
toggleColor();
}