Bug 366560 Merge calendarUtils.js and calUtils.js r=lilmatt, mvl

git-svn-id: svn://10.0.0.236/trunk@220036 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jminta%gmail.com
2007-02-13 02:50:58 +00:00
parent 634b39ab7f
commit d864938399
38 changed files with 589 additions and 180 deletions

View File

@@ -62,7 +62,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/calendar-alarm-dialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<!-- The dialog -->
<vbox id="alarmlist" flex="1" style="overflow: auto;">

View File

@@ -38,7 +38,7 @@
- ***** END LICENSE BLOCK *****
-->
<!-- Note that this file depends on helper functions in calendarUtils.js-->
<!-- Note that this file depends on helper functions in calUtils.js-->
<bindings id="calendar-specific-view-bindings"
xmlns="http://www.mozilla.org/xbl"
@@ -64,9 +64,8 @@
viewElement.daysOffArray = [];
// add a preference observer to monitor changes
var pb2 = Components.classes
["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var pb2 = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
pb2.addObserver("calendar.", this.mPrefObserver, false);
viewElement.mMinVerticalPixelsPerMinute = 0.7;
@@ -75,9 +74,8 @@
]]></constructor>
<destructor><![CDATA[
var pb2 = Components.classes
["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var pb2 = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
pb2.removeObserver("calendar.", this.mPrefObserver);
return;
]]></destructor>

View File

@@ -37,7 +37,7 @@
- ***** END LICENSE BLOCK *****
-->
<!-- Note that this file depends on helper functions in calendarUtils.js-->
<!-- Note that this file depends on helper functions in calUtils.js-->
<bindings id="calendar-specific-view-bindings"
xmlns="http://www.mozilla.org/xbl"
@@ -64,17 +64,15 @@
this.updateDaysOffPrefs();
// add a preference observer to monitor changes
var pb2 = Components.classes
["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var pb2 = Cc["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch2);
pb2.addObserver("calendar.", this.mPrefObserver, false);
return;
]]></constructor>
<destructor><![CDATA[
var pb2 = Components.classes
["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var pb2 = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
pb2.removeObserver("calendar.", this.mPrefObserver);
return;
]]></destructor>

View File

@@ -37,7 +37,7 @@
- ***** END LICENSE BLOCK *****
-->
<!-- Note that this file depends on helper functions in calendarUtils.js-->
<!-- Note that this file depends on helper functions in calUtils.js-->
<bindings id="calendar-specific-view-bindings"
xmlns="http://www.mozilla.org/xbl"
@@ -67,17 +67,15 @@
this.updateDaysOffPrefs();
// add a preference observer to monitor changes
var pb2 = Components.classes
["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var pb2 = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
pb2.addObserver("calendar.", this.mPrefObserver, false);
return;
]]></constructor>
<destructor><![CDATA[
var pb2 = Components.classes
["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var pb2 = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
pb2.removeObserver("calendar.", this.mPrefObserver);
return;
]]></destructor>

View File

@@ -38,7 +38,7 @@
- ***** END LICENSE BLOCK *****
-->
<!-- Note that we depend on some helper functions in calendarUtils.js here-->
<!-- Note that we depend on some helper functions in calUtils.js here-->
<bindings id="calendar-specific-view-bindings"
xmlns="http://www.mozilla.org/xbl"
@@ -61,9 +61,8 @@
this.mWeekStartOffset = getPrefSafe("calendar.week.start", 0);
// add a preference observer to monitor changes
var pb2 = Components.classes
["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var pb2 = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
pb2.addObserver("calendar.", this.mPrefObserver, false);
this.updateDaysOffPrefs();
@@ -71,9 +70,8 @@
]]></constructor>
<destructor><![CDATA[
var pb2 = Components.classes
["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch2);
var pb2 = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
pb2.removeObserver("calendar.", this.mPrefObserver);
return;
]]></destructor>

View File

@@ -64,7 +64,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/calendar-event-dialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<!-- Used for the button to show/hide details -->

View File

@@ -218,6 +218,63 @@ function getOccurrenceOrParent(occurrence) {
}
}
/**
* Read default alarm settings from user preferences and apply them to
* the event/todo passed in.
*
* @param aItem The event or todo the settings should be applied to.
*/
function setDefaultAlarmValues(aItem)
{
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
var alarmsBranch = prefService.getBranch("calendar.alarms.");
if (isEvent(aItem)) {
try {
if (alarmsBranch.getIntPref("onforevents") == 1) {
var alarmOffset = Components.classes["@mozilla.org/calendar/duration;1"]
.createInstance(Components.interfaces.calIDuration);
try {
var units = alarmsBranch.getCharPref("eventalarmunit");
alarmOffset[units] = alarmsBranch.getIntPref("eventalarmlen");
alarmOffset.isNegative = true;
} catch(ex) {
alarmOffset.minutes = 15;
}
aItem.alarmOffset = alarmOffset;
aItem.alarmRelated = Components.interfaces.calIItemBase.ALARM_RELATED_START;
}
} catch (ex) {
Components.utils.reportError(
"Failed to apply default alarm settings to event: " + ex);
}
} else if (isToDo(aItem)) {
try {
if (alarmsBranch.getIntPref("onfortodos") == 1) {
// You can't have an alarm if the entryDate doesn't exist.
if (!aItem.entryDate) {
aItem.entryDate = getSelectedDay().clone();
}
var alarmOffset = Components.classes["@mozilla.org/calendar/duration;1"]
.createInstance(Components.interfaces.calIDuration);
try {
var units = alarmsBranch.getCharPref("todoalarmunit");
alarmOffset[units] = alarmsBranch.getIntPref("todoalarmlen");
alarmOffset.isNegative = true;
} catch(ex) {
alarmOffset.minutes = 15;
}
aItem.alarmOffset = alarmOffset;
aItem.alarmRelated = Components.interfaces.calIItemBase.ALARM_RELATED_START;
}
} catch (ex) {
Components.utils.reportError(
"Failed to apply default alarm settings to task: " + ex);
}
}
}
// Undo/Redo code
var gTransactionMgr = Components.classes["@mozilla.org/transactionmanager;1"]
.createInstance(Components.interfaces.nsITransactionManager);

View File

@@ -40,7 +40,7 @@
- ***** END LICENSE BLOCK *****
-->
<!-- Note that this file depends on helper functions in calendarUtils.js-->
<!-- Note that this file depends on helper functions in calUtils.js-->
<bindings id="calendar-month-view-bindings"
xmlns="http://www.mozilla.org/xbl"
@@ -71,11 +71,11 @@
var str = null;
// if val is an event and not an all day event, show start time in title
if (val instanceof Components.interfaces.calIEvent && !val.startDate.isDate) {
var df = Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
.getService(Components.interfaces.calIDateTimeFormatter);
if (isEvent(val) && !val.startDate.isDate) {
var df = Cc["@mozilla.org/calendar/datetime-formatter;1"].
getService(Ci.calIDateTimeFormatter);
str = df.formatTime(val.startDate.getInTimezone(this.calendarView.mTimezone));
} else if (val instanceof Components.interfaces.calITodo) {
} else if (isToDo(val)) {
// yeah, this should really be a little picture instead of a "*"
str = "* ";
} else {
@@ -97,21 +97,21 @@
<handlers>
<handler event="draggesture"><![CDATA[
var dragService = Components.classes["@mozilla.org/widget/dragservice;1"]
.getService(Components.interfaces.nsIDragService);
var transfer = Components.classes["@mozilla.org/widget/transferable;1"]
.createInstance(Components.interfaces.nsITransferable);
var dragService = Cc["@mozilla.org/widget/dragservice;1"].
getService(Ci.nsIDragService);
var transfer = Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
var item = this.occurrence;
transfer.addDataFlavor("text/calendar");
var flavourProvider = {
QueryInterface: function(aIID) {
if (aIID.equals(Components.interfaces.nsIFlavorDataProvider) ||
aIID.equals(Components.interfaces.nsISupports)) {
if (aIID.equals(Ci.nsIFlavorDataProvider) ||
aIID.equals(Ci.nsISupports)) {
return this;
}
throw Components.results.NS_NOINTERFACE;
throw Cr.NS_NOINTERFACE;
},
item: item,
@@ -120,31 +120,31 @@
(aInFlavor == "application/vnd.x-moz-cal-task")) {
aOutData.value = this.item;
aOutDataLen.value = 1;
return Components.results.NS_OK;
return Cr.NS_OK;
} else {
alert("error:"+aInFlavor);
}
}
};
if (item instanceof Components.interfaces.calIEvent) {
if (isEvent(item)) {
transfer.addDataFlavor("application/vnd.x-moz-cal-event");
transfer.setTransferData("application/vnd.x-moz-cal-event", flavourProvider, 0);
} else if (item instanceof Components.interfaces.calITodo) {
} else if (isToDo(item)) {
transfer.addDataFlavor("application/vnd.x-moz-cal-task");
transfer.setTransferData("application/vnd.x-moz-cal-task", flavourProvider, 0);
}
// Also set some normal data-types, in case we drag into another app
var supportsString = Components.classes["@mozilla.org/supports-string;1"]
.createInstance(Components.interfaces.nsISupportsString);
var supportsString = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
supportsString.data = item.icalComponent.serializeToICS();
transfer.setTransferData("text/calendar", supportsString, supportsString.data.length*2);
transfer.setTransferData("text/unicode", supportsString, supportsString.data.length*2);
var action = dragService.DRAGDROP_ACTION_MOVE;
var supArray = Components.classes["@mozilla.org/supports-array;1"]
.createInstance(Components.interfaces.nsISupportsArray);
var supArray = Cc["@mozilla.org/supports-array;1"].
createInstance(Ci.nsISupportsArray);
supArray.AppendElement(transfer);
// OK, now that the data is all set up, start playing with the shadows
@@ -167,8 +167,8 @@
// for that case.
var monthbox = this.parentBox;
monthbox.monthView.dropListener = function checkStillDragging() {
var dragService = Components.classes["@mozilla.org/widget/dragservice;1"]
.getService(Components.interfaces.nsIDragService);
var dragService = Cc["@mozilla.org/widget/dragservice;1"].
getService(Ci.nsIDragService);
var session;
try {
session = dragService.getCurrentSession();
@@ -270,7 +270,7 @@
<parameter name="aDate"/>
<body><![CDATA[
if (!aDate)
throw Components.results.NS_ERROR_NULL_POINTER;
throw Cr.NS_ERROR_NULL_POINTER;
// Remove all the old events
this.mItemData = new Array();
@@ -370,11 +370,11 @@
this.mItemData.sort(
function (a, b) {
var aIsEvent = (a.item instanceof Components.interfaces.calIEvent);
var aIsTodo = (a.item instanceof Components.interfaces.calITodo);
var aIsEvent = isEvent(a.item);
var aIsTodo = isToDo(a.item);
var bIsEvent = (b.item instanceof Components.interfaces.calIEvent);
var bIsTodo = (b.item instanceof Components.interfaces.calITodo);
var bIsEvent = isEvent(b.item);
var bIsTodo = isToDo(b.item);
if ((!aIsEvent && !aIsTodo) || (!bIsEvent && !bIsTodo)) {
// XXX ????
@@ -508,8 +508,8 @@
if (this.mDate)
this.monthView.selectedDay = this.mDate;
]]></handler>
<handler event="dblclick"><![CDATA[
event.stopPropagation();
<handler event="dblclick"><![CDATA[
event.stopPropagation();
this.monthView.controller.createNewEvent();
]]></handler>
<handler event="dragenter"><![CDATA[
@@ -517,8 +517,8 @@
getService(Ci.nsIDragService);
var session = dragService.getCurrentSession();
session.canDrop = true;
this.removeDropShadows();
this.addDropShadows();
this.removeDropShadows();
this.addDropShadows();
]]></handler>
<handler event="dragover"><![CDATA[
@@ -527,19 +527,19 @@
var session = dragService.getCurrentSession();
session.canDrop = true;
]]></handler>
<handler event="dragexit"><![CDATA[
if (event.originalTarget != this) {
<handler event="dragexit"><![CDATA[
if (event.originalTarget != this) {
return;
}
this.removeDropShadows();
var dragService = Cc["@mozilla.org/widget/dragservice;1"].
getService(Ci.nsIDragService);
var session = dragService.getCurrentSession();
session.canDrop = false;
var session = dragService.getCurrentSession();
session.canDrop = false;
]]></handler>
<handler event="dragdrop"><![CDATA[
var dragService = Components.classes["@mozilla.org/widget/dragservice;1"]
<handler event="dragdrop"><![CDATA[
var dragService = Cc["@mozilla.org/widget/dragservice;1"].
getService(Ci.nsIDragService);
var session = dragService.getCurrentSession();
@@ -570,7 +570,7 @@
}
if (!session.sourceNode || !session.sourceNode.occurrence) {
return;
return;
}
event.stopPropagation();
@@ -580,7 +580,7 @@
beginMove.isDate = true;
var duration = boxDate.subtractDate(beginMove);
newStart = item.startDate.clone();
newStart.addDuration(duration);
newStart.addDuration(duration);
newStart.normalize();
newEnd = item.endDate.clone();
newEnd.addDuration(duration);
@@ -1018,7 +1018,7 @@
this.refresh();
]]></body>
</method>
<method name="setDateList">
<parameter name="aCount"/>
<parameter name="aDates"/>
@@ -1283,10 +1283,10 @@
<method name="findBoxesForItem">
<parameter name="aItem"/>
<body><![CDATA[
var targetDate = null;
var targetDate = null;
var finishDate = null;
var boxes = new Array();
// All our boxes are in default tz, so we need these times in them too.
if (isEvent(aItem)) {
targetDate = aItem.startDate.getInTimezone(this.mTimezone);
@@ -1378,8 +1378,7 @@
if (oldLength != this.mSelectedItems.length) {
this.fireEvent("itemselect", this.mSelectedItems);
}
]]></body>
</method>
]]></body>
</method>
<method name="today">
@@ -1394,9 +1393,9 @@
<!-- our private observers and listeners -->
<field name="mOperationListener"><![CDATA[
({
calView: this,
<field name="mOperationListener"><![CDATA[
({
calView: this,
QueryInterface: function (aIID) {
if (!aIID.equals(Ci.calIOperationListener) &&
@@ -1426,10 +1425,10 @@
]]></field>
<field name="mObserver"><![CDATA[
// the calIObserver, and calICompositeObserver
({
calView: this,
// the calIObserver, and calICompositeObserver
({
calView: this,
QueryInterface: function (aIID) {
if (!aIID.equals(Ci.calIObserver) &&
!aIID.equals(Ci.calICompositeObserver) &&
@@ -1452,9 +1451,9 @@
onLoad: function() {
this.calView.refresh();
},
onAddItem: function (aItem) {
if (this.mBatchCount) {
onAddItem: function (aItem) {
if (this.mBatchCount) {
return;
}
if (isToDo(aItem) && !this.calView.mTasksInView) {
@@ -1467,10 +1466,10 @@
for each (var occ in occs)
this.calView.doAddItem(occ);
},
onModifyItem: function (aNewItem, aOldItem) {
if (this.mBatchCount) {
return;
onModifyItem: function (aNewItem, aOldItem) {
if (this.mBatchCount) {
return;
}
if (isToDo(aNewItem) && isToDo(aOldItem) &&
!this.calView.mTasksInView) {
@@ -1479,8 +1478,7 @@
var occs;
occs = aOldItem.getOccurrencesBetween(this.calView.startDate,
this.calView.queryEndDate,
{});
this.calView.queryEndDate,
{});
for each (var occ in occs)
this.calView.doDeleteItem(occ);
@@ -1494,9 +1492,9 @@
for each (var occ in occs)
this.calView.doAddItem(occ);
},
onDeleteItem: function (aItem) {
if (this.mBatchCount) {
onDeleteItem: function (aItem) {
if (this.mBatchCount) {
return;
}
if (isToDo(aItem) && !this.calView.mTasksInView) {
@@ -1529,7 +1527,7 @@
}
})
]]></field>
</implementation>
<handlers>

View File

@@ -41,7 +41,7 @@
- ***** END LICENSE BLOCK *****
-->
<!-- Note that this file depends on helper functions in calendarUtils.js-->
<!-- Note that this file depends on helper functions in calUtils.js-->
<bindings id="calendar-multiday-view-bindings"
xmlns="http://www.mozilla.org/xbl"
@@ -131,9 +131,8 @@
while (topbox.lastChild)
topbox.removeChild(topbox.lastChild);
var formatter =
Components.classes["@mozilla.org/intl/scriptabledateformat;1"]
.getService(Components.interfaces.nsIScriptableDateFormat);
var formatter = Cc["@mozilla.org/intl/scriptabledateformat;1"].
getService(Ci.nsIScriptableDateFormat);
var timeString;
var theMin = this.mStartMin;
var theHour = Math.floor(theMin / 60);
@@ -154,8 +153,8 @@
box = makeTimeBox("", dur * this.mPixPerMin);
} else {
timeString = formatter.FormatTime("",
Components.interfaces.nsIScriptableDateFormat
.timeFormatNoSeconds, theHour, 0, 0);
Ci.nsIScriptableDateFormat.timeFormatNoSeconds,
theHour, 0, 0);
box = makeTimeBox(timeString, dur * this.mPixPerMin);
}
@@ -1258,15 +1257,14 @@
var endhr = Math.floor(realendmin / 60);
var endmin = realendmin % 60;
var formatter =
Components.classes["@mozilla.org/intl/scriptabledateformat;1"]
.getService(Components.interfaces.nsIScriptableDateFormat);
var formatter = Cc["@mozilla.org/intl/scriptabledateformat;1"].
getService(Ci.nsIScriptableDateFormat);
var startstr = formatter.FormatTime("",
Components.interfaces.nsIScriptableDateFormat.timeFormatNoSeconds,
starthr, startmin, 0);
Ci.nsIScriptableDateFormat.timeFormatNoSeconds,
starthr, startmin, 0);
var endstr = formatter.FormatTime("",
Components.interfaces.nsIScriptableDateFormat.timeFormatNoSeconds,
endhr, endmin, 0);
Ci.nsIScriptableDateFormat.timeFormatNoSeconds,
endhr, endmin, 0);
this.fgboxes.startlabel.setAttribute("value", startstr);
this.fgboxes.endlabel.setAttribute("value", endstr);
@@ -1721,9 +1719,9 @@
// the calIObserver, and calICompositeObserver
({
QueryInterface: function QueryInterface(aIID) {
if (!aIID.equals(Components.interfaces.calIObserver) &&
!aIID.equals(Components.interfaces.calICompositeObserver) &&
!aIID.equals(Components.interfaces.nsISupports)) {
if (!aIID.equals(Ci.calIObserver) &&
!aIID.equals(Ci.calICompositeObserver) &&
!aIID.equals(Ci.nsISupports)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
@@ -1749,13 +1747,13 @@
return;
}
if (aItem instanceof Components.interfaces.calITodo &&
(!aItem.entryDate || !aItem.dueDate))
if (isToDo(aItem) && (!aItem.entryDate || !aItem.dueDate)) {
return;
}
if (aItem instanceof Components.interfaces.calITodo &&
!this.calView.mTasksInView)
if (isToDo(aItem) && !this.calView.mTasksInView) {
return;
}
var occs = aItem.getOccurrencesBetween(this.calView.startDate,
this.calView.queryEndDate,
@@ -1772,14 +1770,13 @@
return;
}
if (aNewItem instanceof Components.interfaces.calITodo &&
aOldItem instanceof Components.interfaces.calITodo &&
if (isToDo(aNewItem) && isToDo(aOldItem) &&
!this.calView.mTasksInView)
return;
var occs;
if (!(aOldItem instanceof Components.interfaces.calITodo) ||
if (!isToDo(aOldItem) ||
(aOldItem.entryDate && aOldItem.dueDate)) {
occs = aOldItem.getOccurrencesBetween(this.calView.startDate,
this.calView.queryEndDate,
@@ -1788,9 +1785,10 @@
this.calView.doDeleteEvent(occ);
}
}
if (aNewItem instanceof Components.interfaces.calITodo &&
(!aNewItem.entryDate || !aNewItem.dueDate || !this.mTasksInView))
if (isToDo(Ci.calITodo) &&
(!aNewItem.entryDate || !aNewItem.dueDate || !this.mTasksInView)) {
return;
}
occs = aOldItem.getOccurrencesBetween(this.calView.startDate,
this.calView.queryEndDate,
{});
@@ -1810,13 +1808,13 @@
return;
}
if (aItem instanceof Components.interfaces.calITodo &&
!this.calView.mTasksInView)
if (isToDo(Ci.calITodo) && !this.calView.mTasksInView) {
return;
}
if (aItem instanceof Components.interfaces.calITodo &&
(!aItem.entryDate || !aItem.dueDate))
if (isToDo(Ci.calITodo) && (!aItem.entryDate || !aItem.dueDate)) {
return;
}
var occs = aItem.getOccurrencesBetween(this.calView.startDate,
this.calView.queryEndDate,
@@ -1868,8 +1866,7 @@
return;
function hasGoodDates(item) {
if (item instanceof Components.interfaces.calITodo &&
(!item.entryDate || !item.dueDate)) {
if (isToDo(item) && (!item.entryDate || !item.dueDate)) {
return false;
}
return true;
@@ -2471,8 +2468,8 @@
var labelbox;
var df = Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
.getService(Components.interfaces.calIDateTimeFormatter);
var df = Cc["@mozilla.org/calendar/datetime-formatter;1"].
getService(Ci.calIDateTimeFormatter);
if (counter < labelboxkids.length) {
labelbox = labelboxkids[counter];
labelbox.firstChild.setAttribute("value", df.formatDateWithoutYear(d));
@@ -2684,8 +2681,7 @@
<method name="today">
<body><![CDATA[
var date = Components.classes["@mozilla.org/calendar/datetime;1"]
.createInstance(Components.interfaces.calIDateTime);
var date = createDateTime();
date.jsDate = new Date();
date = date.getInTimezone(this.mTimezone);
date.isDate = true;
@@ -2723,7 +2719,7 @@
<body><![CDATA[
var minute = 0;
var childbox = document.getAnonymousElementByAttribute(this, "anonid", "childbox");
var scrollBoxObject = childbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
var scrollBoxObject = childbox.boxObject.QueryInterface(Ci.nsIScrollBoxObject);
if (scrollBoxObject != null) {
var x = {};
var y = {};
@@ -2742,7 +2738,7 @@
<parameter name="aMinute"/>
<body><![CDATA[
var childbox = document.getAnonymousElementByAttribute(this, "anonid", "childbox");
var scrollBoxObject = childbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
var scrollBoxObject = childbox.boxObject.QueryInterface(Ci.nsIScrollBoxObject);
if (scrollBoxObject != null) {
var x = {};
var y = {};
@@ -2760,7 +2756,7 @@
<handlers>
<handler event="keypress"><![CDATA[
const kKE = Components.interfaces.nsIDOMKeyEvent;
const kKE = Ci.nsIDOMKeyEvent;
if (event.keyCode == kKE.DOM_VK_BACK_SPACE ||
event.keyCode == kKE.DOM_VK_DELETE)
{

View File

@@ -62,7 +62,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/calendar-publish-dialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript">
var closeButtonLabel = "&calendar.publish.close.button;";

View File

@@ -61,7 +61,7 @@
<script type="application/x-javascript" src="chrome://calendar/content/calendar-recurrence-dialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<vbox>

View File

@@ -37,7 +37,7 @@
- ***** END LICENSE BLOCK *****
-->
<!-- Note that this file depends on helper functions in calendarUtils.js-->
<!-- Note that this file depends on helper functions in calUtils.js-->
<bindings id="calendar-core-view-bindings"
xmlns="http://www.mozilla.org/xbl"

View File

@@ -180,6 +180,17 @@ function currentView() {
return getViewDeck().selectedPanel;
}
/**
* Returns the selected day in the views in a app (Sunbird vs. Lightning)
* neutral way
*/
function getSelectedDay() {
var sbView = document.getElementById("view-deck");
var ltnView = document.getElementById("calendar-view-box");
var viewDeck = sbView || ltnView;
return viewDeck.selectedPanel.selectedDay;
}
/** Creates a timer that will fire after midnight. Pass in a function as
* aRefreshCallback that should be called at that time.
*/

View File

@@ -36,8 +36,6 @@
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
const SUNBIRD_UID = "{718e30fb-e89b-41dd-9da7-e25a45638b28}";
const FIREFOX_UID = "{ec8030f7-c20a-464f-9b0e-13a3a9e97384}";
@@ -282,7 +280,7 @@ var gDataMigrator = {
// is installed, we have to nuke it. The old extension defines some of
// the same paths as we do, and the resulting file conflicts result in
// first-class badness. getCompositeCalendar is a conflicting function
// that exists in Lighnting's version of calendarUtils.js. If it isn't
// that exists in Lighnting's version of calUtils.js. If it isn't
// defined, we have a conflict.
if (this.isLightning() && !("getCompositeCalendar" in window)) {

View File

@@ -54,7 +54,7 @@
<script type="application/x-javascript"
src="chrome://calendar/content/preferences/general.js"/>
<script type="application/x-javascript"
src="chrome://calendar/content/calendarUtils.js"/>
src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript"
src="chrome://calendar/content/calendar-dialog-utils.js"/>

View File

@@ -55,7 +55,7 @@
<script type="application/x-javascript"
src="chrome://calendar/content/preferences/timezones.js"/>
<script type="application/x-javascript"
src="chrome://calendar/content/calendarUtils.js"/>
src="chrome://calendar/content/calUtils.js"/>
<preferences>
<preference id="calendar.timezone.local"

View File

@@ -26,6 +26,7 @@ calendar.jar:
content/calendar/calendar-view-bindings.css (content/calendar-view-bindings.css)
content/calendar/calendar-view-core.xml (content/calendar-view-core.xml)
content/calendar/calendar-views.js (content/calendar-views.js)
content/calendar/calUtils.js (src/calUtils.js)
content/calendar/calErrorPrompt.xul (content/calErrorPrompt.xul)
content/calendar/chooseCalendarDialog.xul (content/chooseCalendarDialog.xul)
content/calendar/import-export.js (content/import-export.js)

View File

@@ -48,27 +48,6 @@ function newTimerWithCallback(callback, delay, repeating)
return timer;
}
function jsDateToDateTime(date)
{
var newDate = Components.classes["@mozilla.org/calendar/datetime;1"].createInstance(Components.interfaces.calIDateTime);
newDate.jsDate = date;
return newDate;
}
function jsDateToFloatingDateTime(date)
{
var newDate = Components.classes["@mozilla.org/calendar/datetime;1"].createInstance(Components.interfaces.calIDateTime);
newDate.timezone = "floating";
newDate.year = date.getFullYear();
newDate.month = date.getMonth();
newDate.day = date.getDate();
newDate.hour = date.getHours();
newDate.minute = date.getMinutes();
newDate.second = date.getSeconds();
newDate.normalize();
return newDate;
}
function calAlarmService() {
this.wrappedJSObject = this;

View File

@@ -81,12 +81,17 @@ function initBaseComponent()
/* Update these in calBaseCID.h */
const componentData =
[
/* calItemBase must be first: later scripts depend on it */
/* calItemBase and calUtils must be first: later scripts depend on them */
{cid: null,
contractid: null,
script: "calItemBase.js",
constructor: null},
{cid: null,
contractid: null,
script: "calUtils.js",
constructor: null},
{cid: Components.ID("{f42585e7-e736-4600-985d-9624c1c51992}"),
contractid: "@mozilla.org/calendar/manager;1",
script: "calCalendarManager.js",

View File

@@ -35,9 +35,6 @@
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
/**
* Constructor of calItipItem object
*/

View File

@@ -59,12 +59,326 @@ function createDateTime() {
createInstance(Ci.calIDateTime);
}
/* Returns a clean new calIRecurrenceInfo */
function createRecurrenceInfo() {
return Cc["@mozilla.org/calendar/recurrence-info;1"].
createInstance(Ci.calIRecurrenceInfo);
}
/* Returns a clean new calIAttendee */
function createAttendee() {
return Cc["@mozilla.org/calendar/attendee;1"].
createInstance(Ci.calIAttendee);
}
/* Shortcut to the calendar-manager service */
function getCalendarManager() {
return Components.classes["@mozilla.org/calendar/manager;1"].
getService(Ci.calICalendarManager);
}
/**
* Function to get the (cached) best guess at a user's default timezone. We'll
* use the value of the calendar.timezone.local preference, if it exists. If
* not, we'll do our best guess.
*
* @returns a string of the Mozilla TZID for the user's default timezone.
*/
var gDefaultTimezone;
function calendarDefaultTimezone() {
if (!gDefaultTimezone) {
gDefaultTimezone = getPrefSafe("calendar.timezone.local", null);
if (!gDefaultTimezone) {
gDefaultTimezone = guessSystemTimezone();
}
}
return gDefaultTimezone;
}
/**
* We're going to do everything in our power, short of rumaging through the
* user's actual file-system, to figure out the time-zone they're in. The
* deciding factors are the offsets given by (northern-hemisphere) summer and
* winter JSdates. However, when available, we also use the name of the
* timezone in the JSdate, or a string-bundle term from the locale.
*
* @returns a ICS timezone string.
*/
function guessSystemTimezone() {
var probableTZ = null;
var TZname1 = null;
var TZname2 = null;
var Date1 = (new Date(2005,6,20)).toString();
var Date2 = (new Date(2005,12,20)).toString();
var nameData1 = Date1.match(/[^(]* ([^ ]*) \(([^)]+)\)/);
var nameData2 = Date2.match(/[^(]* ([^ ]*) \(([^)]+)\)/);
if (nameData1 && nameData1[2]) {
TZname1 = nameData1[2];
}
if (nameData2 && nameData2[2]) {
TZname2 = nameData2[2];
}
var index = Date1.indexOf('+');
if (index < 0) {
index = Date2.indexOf('-');
}
// the offset is always 5 characters long
var TZoffset1 = Date1.substr(index, 5);
index = Date2.indexOf('+');
if (index < 0)
index = Date2.indexOf('-');
// the offset is always 5 characters long
var TZoffset2 = Date2.substr(index, 5);
dump("Guessing system timezone:\n");
dump("TZoffset1: " + TZoffset1 + "\nTZoffset2: " + TZoffset2 + "\n");
if (TZname1 && TZname2) {
dump("TZname1: " + TZname1 + "\nTZname2: " + TZname2 + "\n");
}
var icsSvc = Cc["@mozilla.org/calendar/ics-service;1"].
getService(Ci.calIICSService);
// returns 0=definitely not, 1=maybe, 2=likely
function checkTZ(someTZ)
{
var comp = icsSvc.getTimezone(someTZ);
var subComp = comp.getFirstSubcomponent("VTIMEZONE");
var standard = subComp.getFirstSubcomponent("STANDARD");
var standardTZOffset = standard.getFirstProperty("TZOFFSETTO").valueAsIcalString;
var standardName = standard.getFirstProperty("TZNAME").valueAsIcalString;
var daylight = subComp.getFirstSubcomponent("DAYLIGHT");
var daylightTZOffset = null;
var daylightName = null;
if (daylight) {
daylightTZOffset = daylight.getFirstProperty("TZOFFSETTO").valueAsIcalString;
daylightName = daylight.getFirstProperty("TZNAME").valueAsIcalString;
}
if (TZoffset2 == standardTZOffset && TZoffset2 == TZoffset1 &&
!daylight) {
if (!standardName || standardName == TZname1) {
return 2;
}
return 1;
}
if (TZoffset2 == standardTZOffset && TZoffset1 == daylightTZOffset) {
if ((!standardName || standardName == TZname1) &&
(!daylightName || daylightName == TZname2)) {
return 2;
}
return 1;
}
// Now flip them and check again, to cover the southern hemisphere case
if (TZoffset1 == standardTZOffset && TZoffset2 == TZoffset1 &&
!daylight) {
if (!standardName || standardName == TZname2) {
return 2;
}
return 1;
}
if (TZoffset1 == standardTZOffset && TZoffset2 == daylightTZOffset) {
if ((!standardName || standardName == TZname2) &&
(!daylightName || daylightName == TZname1)) {
return 2;
}
return 1;
}
return 0;
}
try {
var stringBundleTZ = gCalendarBundle.getString("likelyTimezone");
if (stringBundleTZ.indexOf("/mozilla.org/") == -1) {
// This happens if the l10n team didn't know how to get a time from
// tzdata.c. To convert an Olson time to a ics-timezone-string we
// need to append this prefix.
stringBundleTZ = "/mozilla.org/20050126_1/" + stringBundleTZ;
}
switch (checkTZ(stringBundleTZ)) {
case 0:
break;
case 1:
if (!probableTZ)
probableTZ = stringBundleTZ;
break;
case 2:
return stringBundleTZ;
}
}
catch (ex) { // Oh well, this didn't work, next option...
}
var tzIDs = icsSvc.timezoneIds;
while (tzIDs.hasMore()) {
var theTZ = tzIDs.getNext();
switch (checkTZ(theTZ)) {
case 0: break;
case 1:
if (!probableTZ) {
probableTZ = theTZ;
}
break;
case 2:
return theTZ;
}
}
// If we get to this point, should we alert the user?
if (probableTZ) {
return probableTZ;
}
// Everything failed, so this is our only option.
return "floating";
}
/**
* Shared dialog functions
*/
/**
* Opens the Create Calendar wizard
*
* @param aCallback a function to be performed after calendar creation
*/
function openCalendarWizard(aCallback) {
openDialog("chrome://calendar/content/calendarCreation.xul", "caEditServer",
"chrome,titlebar,modal", aCallback);
}
/**
* Opens the calendar properties window for aCalendar
*
* @param aCalendar the calendar whose properties should be displayed
* @param aCallback function that should be run when the dialog is accepted
*/
function openCalendarProperties(aCalendar, aCallback) {
openDialog("chrome://calendar/content/calendarProperties.xul",
"caEditServer", "chrome,titlebar,modal",
{calendar: aCalendar, onOk: aCallback});
}
/**
* Opens the print dialog
*/
function calPrint() {
openDialog("chrome://calendar/content/printDialog.xul", "Print",
"centerscreen,chrome,resizable");
}
/**
* Other functions
*/
/**
* Takes a string and returns an nsIURI
*
* @param aUriString the string of the address to for the spec of the nsIURI
*
* @returns an nsIURI whose spec is aUriString
*/
function makeURL(aUriString) {
var ioSvc = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService);
return ioSvc.newURI(aUriString, null, null);
}
/**
* Returns a calIDateTime that corresponds to the current time in the user's
* default timezone.
*/
function now() {
var d = createDateTime();
d.jsDate = new Date();
return d.getInTimezone(calendarDefaultTimezone());
}
/**
* Returns a calIDateTime corresponding to a javascript Date
*
* @param aDate a javascript date
* @returns a calIDateTime whose jsDate is aDate
*
* @warning Use of this function is strongly discouraged. calIDateTime should
* be used directly whenever possible.
*/
function jsDateToDateTime(aDate) {
var newDate = createDateTime();
newDate.jsDate = aDate;
return newDate;
}
/**
* Returns a calIDateTime with a floating timezone and each field the same as
* the equivalent field of the javascript date aDate
*
* @param aDate a javascript date
* @returns a calIDateTime with all of the fields the same as aDate
*
* @warning Like jsDateToDateTime, use of the function is strongly discouraged.
*/
function jsDateToFloatingDateTime(aDate) {
var newDate = createDateTime();
newDate.timezone = "floating";
newDate.year = aDate.getFullYear();
newDate.month = aDate.getMonth();
newDate.day = aDate.getDate();
newDate.hour = aDate.getHours();
newDate.minute = aDate.getMinutes();
newDate.second = aDate.getSeconds();
newDate.normalize();
return newDate;
}
/**
* Selects an item with id aItemId in the radio group with id aRadioGroupId
*
* @param aRadioGroupId the id of the radio group which contains the item
* @param aItemId the item to be selected
*/
function calRadioGroupSelectItem(aRadioGroupId, aItemId) {
var radioGroup = document.getElementById(aRadioGroupId);
var items = radioGroup.getElementsByTagName("radio");
var index;
for (var i in items) {
if (items[i].getAttribute("id") == aItemId) {
index = i;
break;
}
}
ASSERT(index && index != 0, "Can't find radioGroup item to select.", true);
radioGroup.selectedIndex = index;
}
/**
* Determines whether or not the aObject is a calIEvent
*
* @param aObject the object to test
* @returns true if the object is a calIEvent, false otherwise
*/
function isEvent(aObject) {
return aObject instanceof Ci.calIEvent;
}
/**
* Determines whether or not the aObject is a calITodo
*
* @param aObject the object to test
* @returns true if the object is a calITodo, false otherwise
*/
function isToDo(aObject) {
return aObject instanceof Ci.calITodo;
}
/**
* Normal get*Pref calls will throw if the pref is undefined. This function
* will get a bool, int, or string pref. If the pref is undefined, it will
@@ -114,6 +428,39 @@ function setPref(aPrefName, aPrefType, aPrefValue) {
}
}
/**
* Helper function to set a localized (complex) pref from a given string
*
* @param aPrefName the (full) name of preference to set
* @param aString the string to which the preference value should be set
*/
function setLocalizedPref(aPrefName, aString) {
const prefB = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
var str = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
str.data = aString;
prefB.setComplexValue(aPrefName, Ci.nsISupportsString, str);
}
/**
* Like getPrefSafe, except for complex prefs (those used for localized data).
*
* @param aPrefName the (full) name of preference to get
* @param aDefault (optional) the value to return if the pref is undefined
*/
function getLocalizedPref(aPrefName, aDefault) {
const pb2 = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch2);
var result;
try {
result = pb2.getComplexValue(aPrefName, Ci.nsISupportsString).data;
} catch(ex) {
return aDefault;
}
return result;
}
/**
* Gets the value of a string in a .properties file
*
@@ -385,8 +732,6 @@ calAuthPrompt.prototype = {
* color against a background of bgColor.
*
* @param bgColor the background color as a "#RRGGBB" string
*
* (copied from calendarUtils.js to be available to print formatters)
*/
function getContrastingTextColor(bgColor)
{

View File

@@ -41,7 +41,7 @@
- exists so we can check for whether that extension is installed and nuke it
- in that case. Note that this check *cannot* be done in any file that may
- die as a result of the conflict (including messanger-overlay-sidebar.js).
- Nor can it depend on files which may conflict, like calendarUtils.js.
- Nor can it depend on files which may conflict.
-->
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>

View File

@@ -64,7 +64,7 @@
<overlay id="ltnSidebarOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarCreation.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/mouseoverPreviews.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-item-editing.js"/>

View File

@@ -37,7 +37,6 @@ calendar.jar:
content/calendar/calendarCreation.xul (/calendar/resources/content/calendarCreation.xul)
content/calendar/calendarCreation.js (/calendar/resources/content/calendarCreation.js)
content/calendar/mouseoverPreviews.js (/calendar/resources/content/mouseoverPreviews.js)
content/calendar/calendarUtils.js (/calendar/resources/content/calendarUtils.js)
content/calendar/datetimepickers/datetimepickers.css (/calendar/resources/content/datetimepickers/datetimepickers.css)
content/calendar/datetimepickers/datetimepickers.xml (/calendar/resources/content/datetimepickers/datetimepickers.xml)
content/calendar/datetimepickers/minimonth.css (/calendar/resources/content/datetimepickers/minimonth.css)

View File

@@ -60,7 +60,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/calendar-invitations-dialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/caleUtils.js"/>
<script type="application/x-javascript" >
var invitationsText = "&calendar.invitations.dialog.invitations.text;";

View File

@@ -63,7 +63,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/sun-calendar-event-dialog-attendees.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<attendees-page id="attendees-page" range="16" flex="1"/>

View File

@@ -62,7 +62,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/sun-calendar-event-dialog-recurrence.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<recurrence-page id="recurrence-page" flex="1" orient="vertical"/>

View File

@@ -62,7 +62,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/sun-calendar-event-dialog-reminder.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<!-- Listbox with custom reminders -->

View File

@@ -61,7 +61,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/sun-calendar-event-dialog-timezone.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<hbox align="center">

View File

@@ -68,7 +68,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/sun-calendar-event-dialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-dialog-utils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/applicationUtil.js"/>
<script type="application/x-javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/x-javascript" src="chrome://global/content/printUtils.js"/>

View File

@@ -54,7 +54,7 @@
onwizardfinish=""
persist="screenX screenY">
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarCreation.js"/>
<wizardpage pageid="initialPage"

View File

@@ -297,13 +297,16 @@ function initCalendarManager()
// Set up a pref listener so the proper UI bits can be refreshed when prefs
// are changed.
var pb2 = prefService.getBranch("").QueryInterface(
Components.interfaces.nsIPrefBranch2);
var prefService = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
var pb2 = prefService.getBranch("").QueryInterface(Ci.nsIPrefBranch2);
pb2.addObserver("calendar.", calPrefObserver, false);
}
function finishCalendarManager() {
// Remove the category color pref observer
var prefService = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
var pbi = prefService.getBranch("");
pbi = pbi.QueryInterface(Components.interfaces.nsIPrefBranch2);
pbi.removeObserver("calendar.category.color.", categoryPrefObserver);
@@ -341,6 +344,8 @@ function initColors() {
for (var j in calendars)
updateStyleSheetForObject(calendars[j], gCachedStyleSheet);
var prefService = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
var categoryPrefBranch = prefService.getBranch("calendar.category.color.");
var prefArray = categoryPrefBranch.getChildList("", {});
for (var i = 0; i < prefArray.length; i++)

View File

@@ -57,7 +57,7 @@
xmlns:nc="http://home.netscape.com/NC-rdf#">
<script type="application/x-javascript" src="chrome://calendar/content/calendarProperties.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<!-- STRING BUNDLE for calendar properties -->
<stringbundleset id="stringbundleset">

View File

@@ -417,3 +417,30 @@ function createTooltipHeaderDescription(text)
label.appendChild(document.createTextNode(text));
return label;
}
/** If now is during an occurrence, return the ocurrence.
Else if now is before an ocurrence, return the next ocurrence.
Otherwise return the previous ocurrence. **/
function getCurrentNextOrPreviousRecurrence(calendarEvent)
{
if (!calendarEvent.recurrenceInfo) {
return calendarEvent;
}
var dur = calendarEvent.duration.clone();
dur.isNegative = true;
// To find current event when now is during event, look for occurrence
// starting duration ago.
var probeTime = now();
probeTime.addDuration(dur);
var occ = calendarEvent.recurrenceInfo.getNextOccurrence(probeTime);
if (!occ) {
var occs = calendarEvent.recurrenceInfo.getOccurrences(calendarEvent.startDate, probeTime, 0, {});
occ = occs[occs.length -1];
}
return occ;
}

View File

@@ -75,7 +75,7 @@
xmlns:nc="http://home.netscape.com/NC-rdf#">
<script type="application/x-javascript" src="chrome://calendar/content/printDialog.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://global/content/printUtils.js"/>
<hbox id="firstHbox" flex="1">

View File

@@ -64,7 +64,7 @@
<!-- Javascript includes -->
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/publishDialog.js"/>
<script type="application/x-javascript" >

View File

@@ -5,7 +5,6 @@ calendar.jar:
* content/calendar/applicationUtil.js (content/applicationUtil.js)
content/calendar/attachFile.js (content/attachFile.js)
* content/calendar/calendar.js (content/calendar.js)
content/calendar/calendarUtils.js (content/calendarUtils.js)
content/calendar/calendarManagement.js (content/calendarManagement.js)
content/calendar/calendarWindow.js (content/calendarWindow.js)
content/calendar/calendarCreation.xul (content/calendarCreation.xul)

View File

@@ -67,7 +67,7 @@
<script type="application/x-javascript" src="chrome://calendar/content/calendar.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendar-item-editing.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calUtils.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/calendarWindow.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/mouseoverPreviews.js"/>
<script type="application/x-javascript" src="chrome://calendar/content/unifinder.js"/>