Bustage/Regression fixes for bug 475715 - Create a binding for the calendar list. r=ssitter
This commit is contained in:
Родитель
5cac123c17
Коммит
3864b9703e
|
@ -81,21 +81,23 @@ function promptDeleteCalendar(aCalendar) {
|
|||
* Called to initialize the calendar manager for a window.
|
||||
*/
|
||||
function loadCalendarManager() {
|
||||
// Set up the composite calendar in the calendar list widget.
|
||||
let tree = document.getElementById("calendar-list-tree-widget");
|
||||
tree.compositeCalendar = getCompositeCalendar();
|
||||
|
||||
// Create the home calendar if no calendar exists.
|
||||
let calendars = getCalendarManager().getCalendars({});
|
||||
if (!calendars.length) {
|
||||
initHomeCalendar();
|
||||
}
|
||||
|
||||
// Set up the composite calendar in the calendar list widget.
|
||||
let tree = document.getElementById("calendar-list-tree-widget");
|
||||
tree.compositeCalendar = getCompositeCalendar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the initial "Home" calendar if no calendar exists.
|
||||
*/
|
||||
function initHomeCalendar() {
|
||||
let calMgr = cal.getCalendarManager();
|
||||
let composite = getCompositeCalendar();
|
||||
let url = makeURL("moz-profile-calendar://");
|
||||
let homeCalendar = calMgr.createCalendar("storage", url);
|
||||
|
||||
|
|
|
@ -544,27 +544,24 @@ var categoryManagement = {
|
|||
// Add color information to the stylesheets.
|
||||
categories.forEach(categoryManagement.updateStyleSheetForCategory,
|
||||
categoryManagement);
|
||||
|
||||
categoryPrefBranch.addObserver("", this, false);
|
||||
categoryPrefBranch.addObserver("", categoryManagement, false);
|
||||
},
|
||||
|
||||
cleanupCategories: function cM_cleanupCategories() {
|
||||
let prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
let categoryPrefBranch = prefService.getBranch("calendar.category.color.");
|
||||
categoryPrefBranch.removeObserver("", this, false);
|
||||
let categoryPrefBranch = prefService.getBranch("calendar.category.color.")
|
||||
.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||
categoryPrefBranch.removeObserver("", categoryManagement, false);
|
||||
},
|
||||
|
||||
observe: function cM_observe(aSubject, aTopic, aPrefName) {
|
||||
if (aPrefName.substring(0, 24) == "calendar.category.color.") {
|
||||
this.updateStyleSheetForCateogry(aPrefName.substring(24));
|
||||
}
|
||||
this.updateStyleSheetForCategory(aPrefName);
|
||||
// TODO Currently, the only way to find out if categories are removed is
|
||||
// to initially grab the calendar.categories.names preference and then
|
||||
// observe changes to it. it would be better if we had hooks for this,
|
||||
// so we could delete the rule from our style cache and also remove its
|
||||
// color preference.
|
||||
|
||||
},
|
||||
|
||||
categoryStyleCache: {},
|
||||
|
@ -573,7 +570,7 @@ var categoryManagement = {
|
|||
if (!(aCatName in this.categoryStyleCache)) {
|
||||
// We haven't created a rule for this category yet, do so now.
|
||||
let sheet = getViewStyleSheet();
|
||||
let ruleString = '.category-color-box[categories~="' + aCalendar.id + '"] {} ';
|
||||
let ruleString = '.category-color-box[categories~="' + aCatName + '"] {} ';
|
||||
let ruleIndex = sheet.insertRule(ruleString, sheet.cssRules.length);
|
||||
|
||||
this.categoryStyleCache[aCatName] = sheet.cssRules[ruleIndex];
|
||||
|
|
|
@ -58,6 +58,8 @@
|
|||
this.calMgrObserver.listTree = null;
|
||||
]]></destructor>
|
||||
|
||||
<field name="mAddingFromComposite">false</field>
|
||||
|
||||
<property name="compositeCalendar">
|
||||
<getter><![CDATA[
|
||||
if (!this.mCompositeCalendar) {
|
||||
|
@ -72,8 +74,10 @@
|
|||
|
||||
// Now that we have a composite calendar, we can get all calendars
|
||||
// from the calendar manager.
|
||||
let calendars = cal.getCalendarManager().getCalendars({});
|
||||
this.mAddingFromComposite = true;
|
||||
let calendars = sortCalendarArray(getCalendarManager().getCalendars({}));
|
||||
calendars.forEach(this.addCalendar, this);
|
||||
this.mAddingFromComposite = false;
|
||||
|
||||
return val;
|
||||
]]></setter>
|
||||
|
@ -263,7 +267,6 @@
|
|||
if (this.mCompositeCalendar) {
|
||||
this.mCompositeCalendar.removeObserver(this.compositeObserver);
|
||||
}
|
||||
|
||||
]]></destructor>
|
||||
|
||||
<field name="calObserver"><![CDATA[
|
||||
|
@ -418,10 +421,19 @@
|
|||
<method name="sortOrderChanged">
|
||||
<parameter name=""/>
|
||||
<body><![CDATA[
|
||||
if (this.mAddingFromComposite) {
|
||||
return;
|
||||
}
|
||||
let event = document.createEvent('Events');
|
||||
event.initEvent("SortOrderChanged", true, false);
|
||||
event.sortOrder = this.sortOrder
|
||||
this.dispatchEvent(event);
|
||||
|
||||
let handler = this.getAttribute("onSortOrderChanged");
|
||||
if (handler) {
|
||||
// Call the given code in a function
|
||||
(new Function("event", handler))(event);
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
<method name="displayScrollbarSpacer">
|
||||
|
|
|
@ -174,7 +174,7 @@
|
|||
|
||||
<tabpanel id="tablist-calendarlist">
|
||||
<!-- This will be overlayed by calendar-calendars-list.xul -->
|
||||
<tree id="calendar-list-tree-widget" flex="1"/>
|
||||
<calendar-list-tree id="calendar-list-tree-widget" flex="1"/>
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
|
Загрузка…
Ссылка в новой задаче