зеркало из https://github.com/mozilla/pjs.git
Bug 340229 Removing a color completely from a category doesn't update the rule, r1=lilmatt, r2=mvl
This commit is contained in:
Родитель
ed94ca56d6
Коммит
85ecee76bf
|
@ -243,7 +243,7 @@ function updateStyleSheetForObject(aObject, aSheet) {
|
|||
// This is a calendar, so we're going to set the background color
|
||||
name = aObject.uri.spec;
|
||||
selectorPrefix = "item-calendar=";
|
||||
ruleUpdaterFunc = function calendarRuleFunc(aRule) {
|
||||
ruleUpdaterFunc = function calendarRuleFunc(aRule, aIndex) {
|
||||
var color = getCalendarManager().getCalendarPref(aObject, 'color');
|
||||
if (!color) {
|
||||
color = "#A8C2E1";
|
||||
|
@ -256,10 +256,12 @@ function updateStyleSheetForObject(aObject, aSheet) {
|
|||
// use the ~= selector, since there could be multiple categories
|
||||
name = aObject.replace(' ','_');
|
||||
selectorPrefix = "item-category~=";
|
||||
ruleUpdaterFunc = function categoryRuleFunc(aRule) {
|
||||
ruleUpdaterFunc = function categoryRuleFunc(aRule, aIndex) {
|
||||
var color = getPrefSafe("calendar.category.color."+aObject, null);
|
||||
if (color) {
|
||||
aRule.style.border = color + " solid 2px";
|
||||
} else {
|
||||
aSheet.deleteRule(aIndex);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -267,11 +269,12 @@ function updateStyleSheetForObject(aObject, aSheet) {
|
|||
var selector = '.calendar-item[' + selectorPrefix + '"' + name + '"]';
|
||||
|
||||
// Now go find our rule
|
||||
var rule;
|
||||
var rule, ruleIndex;
|
||||
for (var i = 0; i < aSheet.cssRules.length; i++) {
|
||||
var maybeRule = aSheet.cssRules[i];
|
||||
if (maybeRule.selectorText && (maybeRule.selectorText == selector)) {
|
||||
rule = maybeRule;
|
||||
ruleIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +284,7 @@ function updateStyleSheetForObject(aObject, aSheet) {
|
|||
rule = aSheet.cssRules[aSheet.cssRules.length-1];
|
||||
}
|
||||
|
||||
ruleUpdaterFunc(rule);
|
||||
ruleUpdaterFunc(rule, ruleIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -159,15 +159,24 @@ function getPrefSafe(aPrefName, aDefault) {
|
|||
const nsIPrefBranch = Components.interfaces.nsIPrefBranch;
|
||||
const prefB = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(nsIPrefBranch);
|
||||
switch (prefB.getPrefType(aPrefName)) {
|
||||
case nsIPrefBranch.PREF_BOOL:
|
||||
return prefB.getBoolPref(aPrefName);
|
||||
case nsIPrefBranch.PREF_INT:
|
||||
return prefB.getIntPref(aPrefName);
|
||||
case nsIPrefBranch.PREF_STRING:
|
||||
return prefB.getCharPref(aPrefName);
|
||||
default: // includes nsIPrefBranch.PREF_INVALID
|
||||
return aDefault;
|
||||
var value;
|
||||
try {
|
||||
switch (prefB.getPrefType(aPrefName)) {
|
||||
case nsIPrefBranch.PREF_BOOL:
|
||||
value = prefB.getBoolPref(aPrefName);
|
||||
break;
|
||||
case nsIPrefBranch.PREF_INT:
|
||||
value = prefB.getIntPref(aPrefName);
|
||||
break;
|
||||
case nsIPrefBranch.PREF_STRING:
|
||||
value = prefB.getCharPref(aPrefName);
|
||||
break;
|
||||
default: // includes nsIPrefBranch.PREF_INVALID
|
||||
return aDefault;
|
||||
}
|
||||
return value;
|
||||
} catch(ex) {
|
||||
return aDefault;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче