Lightning fix potpourri: bug 299236 is hacked around with a collapse trick,
which mostly works, kinda -- better than before! bug 298343 is kinda fixed, with a todo list that shows todos and allows completed/incomplete setting via the checkbox, has calendar colouring, and notices new events. Doesn't notice active-calendar-set changes, handle deletion, or let you select the items for editing/deletion yet. Fix some CSS and other problems by using a proper data: url for our magic stylesheet. r=35-degree-heat
This commit is contained in:
Родитель
4ae016e8b0
Коммит
3f7875d176
|
@ -4,6 +4,7 @@ overlay chrome://messenger/content/messenger.xul chrome://lightning/content/mess
|
|||
overlay chrome://messenger/content/preferences/preferences.xul chrome://lightning/content/messenger-overlay-preferences.xul
|
||||
overlay chrome://messenger/content/messenger.xul chrome://lightning/content/messenger-overlay-toolbar.xul
|
||||
overlay chrome://lightning/content/messenger-overlay-sidebar.xul chrome://lightning/content/agenda-tree-overlay.xul
|
||||
overlay chrome://lightning/content/messenger-overlay-sidebar.xul chrome://lightning/content/todo-list-overlay.xul
|
||||
overlay chrome://lightning/content/lightning-standalone.xul chrome://lightning/content/messenger-overlay-sidebar.xul
|
||||
skin lightning classic/1.0 jar:chrome/classic.jar!/skin/classic/lightning/
|
||||
# shared pieces for chrome://calendar/
|
||||
|
|
|
@ -363,6 +363,9 @@ agendaTreeView.calendarObserver = {
|
|||
agendaTreeView.calendarObserver.onAddItem =
|
||||
function observer_onAddItem(item)
|
||||
{
|
||||
if (!(item instanceof Components.interfaces.calIEvent))
|
||||
return;
|
||||
|
||||
var occs = item.getOccurrencesBetween(this.agendaTreeView.today.start,
|
||||
this.agendaTreeView.soon.end, {});
|
||||
occs.forEach(this.agendaTreeView.addItem, this.agendaTreeView);
|
||||
|
@ -372,6 +375,9 @@ function observer_onAddItem(item)
|
|||
agendaTreeView.calendarObserver.onDeleteItem =
|
||||
function observer_onDeleteItem(item, rebuildFlag)
|
||||
{
|
||||
if (!(item instanceof Components.interfaces.calIEvent))
|
||||
return;
|
||||
|
||||
var occs = item.getOccurrencesBetween(this.agendaTreeView.today.start,
|
||||
this.agendaTreeView.soon.end, {});
|
||||
occs.forEach(this.agendaTreeView.deleteItem, this.agendaTreeView);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
var calendarPrefStyleSheet = null;
|
||||
for (var i = 0; i < document.styleSheets.length; i++) {
|
||||
if (document.styleSheets[i].href == "about:blank?calendar-dynamic-style-sheet") {
|
||||
if (document.styleSheets[i].title == "calendar-dynamic-style-sheet") {
|
||||
calendarPrefStyleSheet = document.styleSheets[i];
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
calendar-todo-item {
|
||||
-moz-binding: url("calendar-todo-list.xml#calendar-todo-item");
|
||||
}
|
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<bindings id="calendar-todo-bindings"
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
xmlns:xbl="http://www.mozilla.org/xbl">
|
||||
<binding id="calendar-todo-item" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
||||
<content>
|
||||
<xul:hbox flex="1">
|
||||
<xul:checkbox anonid="todo-check" xbl:inherits="checked=completed" oncommand="document.getBindingParent(this).updateTodoFromDisplay();"/>
|
||||
<xul:label anonid="todo-label" crop="end" xbl:inherits="item-calendar,value=label"/>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
<implementation>
|
||||
<field name="mTodo">null</field>
|
||||
|
||||
<property name="checkbox">
|
||||
<getter><![CDATA[ return document.getAnonymousElementByAttribute(this, "anonid", "todo-check");]]></getter>
|
||||
</property>
|
||||
|
||||
<property name="manager">
|
||||
<getter><![CDATA[ return this.mManager; ]]></getter>
|
||||
<setter><![CDATA[ this.mManager = val; ]]></setter>
|
||||
</property>
|
||||
|
||||
<property name="label">
|
||||
<getter><![CDATA[ return document.getAnonymousElementByAttribute(this, "anonid", "todo-label");]]></getter>
|
||||
</property>
|
||||
|
||||
<method name="fireEvent">
|
||||
<parameter name="aEventType"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var e = document.createEvent("Events");
|
||||
e.initEvent("todo-" + aEventType, false, true);
|
||||
|
||||
this.dispatchEvent(e);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="setAttribute">
|
||||
<parameter name="aAttr"/>
|
||||
<parameter name="aVal"/>
|
||||
<body><![CDATA[
|
||||
if (aAttr == "completed")
|
||||
this.checkbox.setAttribute("checked", aVal);
|
||||
else if (aAttr == "label")
|
||||
this.label.setAttribute("value", aVal);
|
||||
return XULElement.prototype.setAttribute.call(this, aAttr, aVal);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="updateTodoFromDisplay">
|
||||
<body><![CDATA[
|
||||
var dirty = false;
|
||||
var clone = this.mTodo.clone();
|
||||
if (this.mTodo.isCompleted != this.checkbox.checked) {
|
||||
dump("checked changed (" + uneval(this.mTodo.isCompleted) +
|
||||
" => " + uneval(this.checkbox.checked) + "\n");
|
||||
clone.isCompleted = this.checkbox.checked;
|
||||
dirty = true;
|
||||
} else {
|
||||
dump("checked not changed (" + uneval(this.mTodo.isCompleted) +
|
||||
" == " + uneval(this.checkbox.checked) + "\n");
|
||||
}
|
||||
if (this.mTodo.title != this.label.value) {
|
||||
clone.title = this.label.value;
|
||||
dirty = true;
|
||||
}
|
||||
if (dirty) {
|
||||
this.mTodo.calendar.modifyItem(clone, this.mTodo, null);
|
||||
dump(clone.icalComponent.serializeToICS() + "\n");
|
||||
this.mTodo = clone;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="updateDisplayFromTodo">
|
||||
<body><![CDATA[
|
||||
this.setAttribute("completed", this.mTodo.isCompleted);
|
||||
this.setAttribute("label", this.mTodo.title);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="setTodo">
|
||||
<parameter name="aTodo"/>
|
||||
<body><![CDATA[
|
||||
this.mTodo = aTodo;
|
||||
this.updateDisplayFromTodo();
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
|
@ -97,7 +97,6 @@ function showCalendar(aDate1, aDate2)
|
|||
}
|
||||
|
||||
function switchView(type) {
|
||||
var messengerDisplayDeck = document.getElementById("displayDeck");
|
||||
var calendarViewBox = document.getElementById("calendar-view-box");
|
||||
|
||||
var monthView = document.getElementById("calendar-month-view");
|
||||
|
@ -141,8 +140,9 @@ function selectedCalendarPane(event)
|
|||
document.getElementById("displayDeck").selectedPanel =
|
||||
document.getElementById("calendar-view-box");
|
||||
|
||||
// give the view the calendar
|
||||
showCalendar(today());
|
||||
// give the view the calendar, but make sure that everything
|
||||
// has uncollapsed first before we try to relayout!
|
||||
setTimeout(0, function() { showCalendar(today()); });
|
||||
}
|
||||
|
||||
function LtnObserveDisplayDeckChange(event)
|
||||
|
@ -154,8 +154,9 @@ function LtnObserveDisplayDeckChange(event)
|
|||
GetMessagePane().collapsed = true;
|
||||
document.getElementById("threadpane-splitter").collapsed = true;
|
||||
gSearchBox.collapsed = true;
|
||||
document.getElementById("calendar-view-box").collapsed = false;
|
||||
} else {
|
||||
// nothing to "undo" for now
|
||||
document.getElementById("calendar-view-box").collapsed = true;
|
||||
// Later: mark the view as not needing reflow due to new events coming
|
||||
// in, for better performance and batching.
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<?xml-stylesheet href="chrome://calendar/content/calendar-multiday-view.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://calendar/content/calendar-month-view.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://calendar/content/datetimepickers/minimonth.css" type="text/css"?>
|
||||
<?xml-stylesheet href="about:blank?calendar-dynamic-style-sheet" type="text/css"?>
|
||||
<?xml-stylesheet href="data:text/css," title="calendar-dynamic-style-sheet" type="text/css"?>
|
||||
|
||||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
|
@ -17,7 +17,6 @@
|
|||
<script type="application/x-javascript" src="chrome://lightning/content/lightning-utils.js"/>
|
||||
<script type="application/x-javascript" src="chrome://lightning/content/calendar-management.js"/>
|
||||
<script type="application/x-javascript" src="chrome://lightning/content/messenger-overlay-sidebar.js"/>
|
||||
<script type="application/x-javascript" src="chrome://lightning/content/agenda-tree.js"/>
|
||||
|
||||
<vbox id="folderPaneBox">
|
||||
<commandset id="calendar_commands">
|
||||
|
@ -41,10 +40,12 @@
|
|||
<tabbox flex="1">
|
||||
<tabs>
|
||||
<tab label="Agenda"/>
|
||||
<tab label="Todo"/>
|
||||
<tab label="Calendars"/>
|
||||
</tabs>
|
||||
<tabpanels flex="1">
|
||||
<vbox id="agenda-tab-panel"/>
|
||||
<vbox id="todo-tab-panel"/>
|
||||
<vbox flex="1">
|
||||
<hbox>
|
||||
<button label="New..." oncommand="ltnNewCalendar();"/>
|
||||
|
@ -67,7 +68,7 @@
|
|||
</vbox>
|
||||
|
||||
<deck id="displayDeck">
|
||||
<deck id="calendar-view-box" flex="1">
|
||||
<deck flex="1" collapsed="true" id="calendar-view-box">
|
||||
<calendar-month-view id="calendar-month-view" flex="1"/>
|
||||
<calendar-multiday-view orient="vertical" id="calendar-multiday-view" flex="1"/>
|
||||
</deck>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- DOCTYPE overlay SYSTEM "chrome://lightning/locale/lightning.dtd" -->
|
||||
|
||||
<?xml-stylesheet href="chrome://lightning/content/calendar-todo-list.css" type="text/css"?>
|
||||
|
||||
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript" src="chrome://lightning/content/todo-list.js"/>
|
||||
<vbox id="todo-tab-panel">
|
||||
<richlistbox flex="1" id="todo-outer-box"/>
|
||||
</vbox>
|
||||
</overlay>
|
|
@ -0,0 +1,74 @@
|
|||
/* */
|
||||
|
||||
var todoListManager = {
|
||||
mOuterBox: null
|
||||
};
|
||||
|
||||
todoListManager.initialize =
|
||||
function initialize()
|
||||
{
|
||||
this.mOuterBox = document.getElementById("todo-outer-box");
|
||||
getCompositeCalendar().addObserver(this.calendarObserver);
|
||||
this.populateTodoList();
|
||||
};
|
||||
|
||||
todoListManager.addTodo =
|
||||
function addTodo(newTodo)
|
||||
{
|
||||
dump("adding new todo " + newTodo.title + "\n");
|
||||
var newTodoElt = document.createElement("calendar-todo-item");
|
||||
newTodoElt.setAttribute("item-calendar", newTodo.calendar.uri.spec);
|
||||
|
||||
this.mOuterBox.appendChild(newTodoElt);
|
||||
|
||||
newTodoElt.setTodo(newTodo);
|
||||
};
|
||||
|
||||
todoListManager.calendarOpListener =
|
||||
{
|
||||
};
|
||||
|
||||
todoListManager.calendarOpListener.onOperationComplete =
|
||||
function listener_onOperationComplete()
|
||||
{
|
||||
void("finished todo query!\n");
|
||||
};
|
||||
|
||||
todoListManager.calendarOpListener.onGetResult =
|
||||
function listener_onGetResult(calendar, status, itemtype, detail, count, items)
|
||||
{
|
||||
if (!Components.isSuccessCode(status))
|
||||
return Components.reportError("get failed: " + status);
|
||||
|
||||
void("got " + count + " todos\n");
|
||||
items.forEach(todoListManager.addTodo, todoListManager);
|
||||
};
|
||||
|
||||
todoListManager.calendarObserver =
|
||||
{
|
||||
};
|
||||
|
||||
todoListManager.calendarObserver.onAddItem =
|
||||
function observer_onAddItem(item)
|
||||
{
|
||||
if (!(item instanceof Components.interfaces.calITodo))
|
||||
return;
|
||||
|
||||
todoListManager.addTodo(item);
|
||||
};
|
||||
|
||||
todoListManager.populateTodoList =
|
||||
function populateTodoList()
|
||||
{
|
||||
const cIC = Components.interfaces.calICalendar;
|
||||
var filter = cIC.ITEM_FILTER_TYPE_TODO | cIC.ITEM_FILTER_COMPLETED_ALL;
|
||||
getCompositeCalendar().getItems(filter, 0, null, null, this.calendarOpListener);
|
||||
void("started todo query!\n");
|
||||
};
|
||||
|
||||
function initializeTodoList()
|
||||
{
|
||||
todoListManager.initialize();
|
||||
}
|
||||
|
||||
window.addEventListener("load", initializeTodoList, false);
|
|
@ -11,6 +11,10 @@ lightning.jar:
|
|||
content/lightning/lightning-preferences.xul (content/lightning-preferences.xul)
|
||||
content/lightning/lightning-preferences.js (content/lightning-preferences.js)
|
||||
content/lightning/messenger-overlay-toolbar.xul (content/messenger-overlay-toolbar.xul)
|
||||
content/lightning/todo-list-overlay.xul (content/todo-list-overlay.xul)
|
||||
content/lightning/todo-list.js (content/todo-list.js)
|
||||
content/lightning/calendar-todo-list.css (content/calendar-todo-list.css)
|
||||
content/lightning/calendar-todo-list.xml (content/calendar-todo-list.xml)
|
||||
|
||||
en-US.jar:
|
||||
locale/en-US/lightning/lightning.dtd (locale/lightning.dtd)
|
||||
|
|
Загрузка…
Ссылка в новой задаче