--- a/calendar/.eslintrc
+++ b/calendar/.eslintrc
@@ -383,13 +383,16 @@
"consistent-this": [2, "self"],
// Disallow unnecessary .call() and .apply()
"no-useless-call": 2,
// Require dot notation when accessing properties
"dot-notation": 2,
+ // Disallow named function expressions
+ "func-names": [2, "never"],
+
// The following rules will not be enabled currently, but are kept here for
// easier updates in the future.
"no-else-return": 0,
}
}
--- a/calendar/base/backend/calBackendLoader.js
+++ b/calendar/base/backend/calBackendLoader.js
@@ -28,17 +28,17 @@ calBackendLoader.prototype = {
}),
loaded: false,
observe: function() {
// Nothing to do here, just need the entry so this is instanciated
},
- loadBackend: function loadBackend() {
+ loadBackend: function() {
if (this.loaded) {
return;
}
let backend = Services.prefs.getBoolPref("calendar.icaljs") ? "icaljs" : "libical";
let uri = Services.io.getProtocolHandler("resource")
.QueryInterface(Components.interfaces.nsIResProtocolHandler)
--- a/calendar/base/backend/icaljs/calICSService-worker.js
+++ b/calendar/base/backend/icaljs/calICSService-worker.js
@@ -6,17 +6,17 @@
* ChromeWorker for parseICSAsync method in calICSService.js
*/
var NS_OK = 0;
var NS_ERROR_FAILURE = 2147500037;
importScripts("resource://calendar/modules/ical.js");
-onmessage = function onmessage(event) {
+onmessage = function(event) {
try {
let comp = ICAL.parse(event.data);
postMessage({ rc: NS_OK, data: comp });
} catch (e) {
postMessage({ rc: NS_ERROR_FAILURE, data: "Exception occurred: " + e });
}
close();
};
--- a/calendar/base/backend/icaljs/calICSService.js
+++ b/calendar/base/backend/icaljs/calICSService.js
@@ -349,17 +349,17 @@ calIcalComponent.prototype = {
addSubcomponent: function(comp) {
comp.getReferencedTimezones({}).forEach(this.addTimezoneReference, this);
let jscomp = unwrapSingle(ICAL.Component, comp);
this.innerObject.addSubcomponent(jscomp);
},
propertyIterator: null,
- getFirstProperty: function getFirstProperty(kind) {
+ getFirstProperty: function(kind) {
if (kind == "ANY") {
kind = null;
} else if (kind) {
kind = kind.toLowerCase();
}
let innerObject = this.innerObject;
this.propertyIterator = (function* () {
let props = innerObject.getAllProperties(kind);
@@ -382,17 +382,17 @@ calIcalComponent.prototype = {
yield new calIcalProperty(prop);
}
}
})();
return this.getNextProperty(kind);
},
- getNextProperty: function getNextProperty(kind) {
+ getNextProperty: function(kind) {
if (this.propertyIterator) {
let next = this.propertyIterator.next();
if (next.done) {
this.propertyIterator = null;
}
return next.value;
} else {
@@ -462,24 +462,24 @@ calICSService.prototype = {
classID: calICSServiceClassID,
classInfo: XPCOMUtils.generateCI({
contractID: "@mozilla.org/calendar/ics-service;1",
classDescription: "ICS component and property service",
classID: calICSServiceClassID,
interfaces: [Components.interfaces.calIICSService]
}),
- parseICS: function parseICS(serialized, tzProvider) {
+ parseICS: function(serialized, tzProvider) {
// TODO ical.js doesn't support tz providers, but this is usually null
// or our timezone service anyway.
let comp = ICAL.parse(serialized);
return new calIcalComponent(new ICAL.Component(comp));
},
- parseICSAsync: function parseICSAsync(serialized, tzProvider, listener) {
+ parseICSAsync: function(serialized, tzProvider, listener) {
// There are way too many error checking messages here, but I had so
// much pain with this method that I don't want it to break again.
try {
let worker = new ChromeWorker("resource://calendar/calendar-js/calICSService-worker.js");
worker.onmessage = function(event) {
let rc = Components.results.NS_ERROR_FAILURE;
let icalComp = null;
try {
@@ -501,20 +501,20 @@ calICSService.prototype = {
worker.postMessage(serialized);
} catch (e) {
// If an error occurs above, the calling code will hang. Catch the exception just in case
cal.ERROR("[calICSService] Error starting parsing worker: " + e);
listener.onParsingComplete(Components.results.NS_ERROR_FAILURE, null);
}
},
- createIcalComponent: function createIcalComponent(kind) {
+ createIcalComponent: function(kind) {
return new calIcalComponent(new ICAL.Component(kind.toLowerCase()));
},
- createIcalProperty: function createIcalProperty(kind) {
+ createIcalProperty: function(kind) {
return new calIcalProperty(new ICAL.Property(kind.toLowerCase()));
},
createIcalPropertyFromString: function(str) {
return new calIcalProperty(ICAL.Property.fromString(str.trim(), ICAL.design.icalendar));
}
};
--- a/calendar/base/content/agenda-listbox.js
+++ b/calendar/base/content/agenda-listbox.js
@@ -18,58 +18,56 @@ var agendaListbox = {
kDefaultTimezone: null,
showsToday: false,
soonDays: 5
};
/**
* Initialize the agenda listbox, used on window load.
*/
-agendaListbox.init =
-function initAgendaListbox() {
+agendaListbox.init = function() {
this.agendaListboxControl = document.getElementById("agenda-listbox");
this.agendaListboxControl.removeAttribute("suppressonselect");
let showTodayHeader = (document.getElementById("today-header-hidden").getAttribute("checked") == "true");
let showTomorrowHeader = (document.getElementById("tomorrow-header-hidden").getAttribute("checked") == "true");
let showSoonHeader = (document.getElementById("nextweek-header-hidden").getAttribute("checked") == "true");
this.today = new Synthetic(showTodayHeader, 1, false);
this.addPeriodListItem(this.today, "today-header");
this.tomorrow = new Synthetic(showTomorrowHeader, 1, false);
this.soonDays = getSoondaysPreference();
this.soon = new Synthetic(showSoonHeader, this.soonDays, true);
this.periods = [this.today, this.tomorrow, this.soon];
this.mPendingRefreshJobs = new Map();
let prefObserver = {
- observe: function aL_observe(aSubject, aTopic, aPrefName) {
+ observe: function(aSubject, aTopic, aPrefName) {
switch (aPrefName) {
case "calendar.agendaListbox.soondays":
agendaListbox.soonDays = getSoondaysPreference();
agendaListbox.updateSoonSection();
break;
}
}
};
Services.prefs.addObserver("calendar.agendaListbox", prefObserver, false);
// Make sure the agenda listbox is unloaded
let self = this;
window.addEventListener("unload",
- function unload_agendaListbox() {
+ function() {
Services.prefs.removeObserver("calendar.agendaListbox", prefObserver);
self.uninit();
},
false);
};
/**
* Clean up the agenda listbox, used on window unload.
*/
-agendaListbox.uninit =
-function uninit() {
+agendaListbox.uninit = function() {
if (this.calendar) {
this.calendar.removeObserver(this.calendarObserver);
}
for (let period of this.periods) {
if (period.listItem) {
period.listItem.getCheckbox()
.removeEventListener("CheckboxStateChange",
@@ -83,47 +81,44 @@ function uninit() {
* Adds a period item to the listbox. This is a section of the today pane like
* "Today", "Tomorrow", and is usually a <agenda-checkbox-richlist-item> tag. A
* copy of the template node is made and added to the agenda listbox.
*
* @param aPeriod The period item to add.
* @param aItemId The id of an <agenda-checkbox-richlist-item> to add to,
* without the "-hidden" suffix.
*/
-agendaListbox.addPeriodListItem =
-function addPeriodListItem(aPeriod, aItemId) {
+agendaListbox.addPeriodListItem = function(aPeriod, aItemId) {
aPeriod.listItem = document.getElementById(aItemId + "-hidden").cloneNode(true);
agendaListbox.agendaListboxControl.appendChild(aPeriod.listItem);
aPeriod.listItem.id = aItemId;
aPeriod.listItem.getCheckbox().setChecked(aPeriod.open);
aPeriod.listItem.getCheckbox().addEventListener("CheckboxStateChange", this.onCheckboxChange, true);
};
/**
* Remove a period item from the agenda listbox.
* @see agendaListbox::addPeriodListItem
*/
-agendaListbox.removePeriodListItem =
-function removePeriodListItem(aPeriod) {
+agendaListbox.removePeriodListItem = function(aPeriod) {
if (aPeriod.listItem) {
aPeriod.listItem.getCheckbox().removeEventListener("CheckboxStateChange", this.onCheckboxChange, true);
if (aPeriod.listItem) {
aPeriod.listItem.remove();
aPeriod.listItem = null;
}
}
};
/**
* Handler function called when changing the checkbox state on period items.
*
* @param event The DOM event that triggered the checkbox state change.
*/
-agendaListbox.onCheckboxChange =
-function onCheckboxChange(event) {
+agendaListbox.onCheckboxChange = function(event) {
let periodCheckbox = event.target;
let lopen = (periodCheckbox.getAttribute("checked") == "true");
let listItem = getParentNodeOrThis(periodCheckbox, "agenda-checkbox-richlist-item");
let period = listItem.getItem();
period.open = lopen;
// as the agenda-checkboxes are only transient we have to set the "checked"
// attribute at their hidden origins to make that attribute persistent.
document.getElementById(listItem.id + "-hidden").setAttribute("checked",
@@ -148,48 +143,44 @@ function onCheckboxChange(event) {
calendarController.onSelectionChanged({ detail: [] });
};
/**
* Handler function called when an agenda listbox item is selected
*
* @param aListItem The agenda-base-richlist-item that was selected.
*/
-agendaListbox.onSelect =
-function onSelect(aListItem) {
+agendaListbox.onSelect = function(aListItem) {
let listbox = document.getElementById("agenda-listbox");
let item = aListItem || listbox.selectedItem;
if (aListItem) {
listbox.selectedItem = item;
}
calendarController.onSelectionChanged({ detail: agendaListbox.getSelectedItems() });
};
/**
* Handler function called when the agenda listbox becomes focused
*/
-agendaListbox.onFocus =
-function onFocus() {
+agendaListbox.onFocus = function() {
calendarController.onSelectionChanged({ detail: agendaListbox.getSelectedItems() });
};
/**
* Handler function called when the agenda listbox loses focus.
*/
-agendaListbox.onBlur =
-function onBlur() {
+agendaListbox.onBlur = function() {
calendarController.onSelectionChanged({ detail: [] });
};
/**
* Handler function called when a key was pressed on the agenda listbox
*/
-agendaListbox.onKeyPress =
-function onKeyPress(aEvent) {
+agendaListbox.onKeyPress = function(aEvent) {
let listItem = aEvent.target;
if (listItem.localName == "richlistbox") {
listItem = listItem.selectedItem;
}
switch (aEvent.keyCode) {
case aEvent.DOM_VK_RETURN:
document.getElementById("agenda_edit_event_command").doCommand();
break;
@@ -209,63 +200,59 @@ function onKeyPress(aEvent) {
}
break;
}
};
/**
* Calls the event dialog to edit the currently selected item
*/
-agendaListbox.editSelectedItem =
-function editSelectedItem() {
+agendaListbox.editSelectedItem = function() {
let listItem = document.getElementById("agenda-listbox").selectedItem;
if (listItem) {
modifyEventWithDialog(listItem.occurrence, null, true);
}
};
/**
* Finds the appropriate period for the given item, i.e finds "Tomorrow" if the
* item occurrs tomorrow.
*
* @param aItem The item to find the period for.
*/
-agendaListbox.findPeriodsForItem =
-function findPeriodsForItem(aItem) {
+agendaListbox.findPeriodsForItem = function(aItem) {
let retPeriods = [];
for (let i = 0; i < this.periods.length; i++) {
if (this.periods[i].open) {
if (checkIfInRange(aItem, this.periods[i].start, this.periods[i].end)) {
retPeriods.push(this.periods[i]);
}
}
}
return retPeriods;
};
/**
* Gets the start of the earliest period shown in the agenda listbox
*/
-agendaListbox.getStart =
-function getStart() {
+agendaListbox.getStart = function() {
let retStart = null;
for (let i = 0; i < this.periods.length; i++) {
if (this.periods[i].open) {
retStart = this.periods[i].start;
break;
}
}
return retStart;
};
/**
* Gets the end of the latest period shown in the agenda listbox
*/
-agendaListbox.getEnd =
-function getEnd() {
+agendaListbox.getEnd = function() {
let retEnd = null;
for (let i = this.periods.length - 1; i >= 0; i--) {
if (this.periods[i].open) {
retEnd = this.periods[i].end;
break;
}
}
return retEnd;
@@ -275,18 +262,17 @@ function getEnd() {
* Adds an item to an agenda period before another existing item.
*
* @param aNewItem The calIItemBase to add.
* @param aAgendaItem The existing item to insert before.
* @param aPeriod The period to add the item to.
* @param visible If true, the item should be visible.
* @return The newly created XUL element.
*/
-agendaListbox.addItemBefore =
-function addItemBefore(aNewItem, aAgendaItem, aPeriod, visible) {
+agendaListbox.addItemBefore = function(aNewItem, aAgendaItem, aPeriod, visible) {
let newelement = null;
if (aNewItem.startDate.isDate) {
newelement = createXULElement("agenda-allday-richlist-item");
} else {
newelement = createXULElement("agenda-richlist-item");
}
// set the item at the richlistItem. When the duration of the period
// is bigger than 1 (day) the starttime of the item has to include
@@ -303,18 +289,17 @@ function addItemBefore(aNewItem, aAgenda
/**
* Adds an item to the agenda listbox. This function finds the correct period
* for the item and inserts it correctly so the period stays sorted.
*
* @param aItem The calIItemBase to add.
* @return The newly created XUL element.
*/
-agendaListbox.addItem =
-function addItem(aItem) {
+agendaListbox.addItem = function(aItem) {
if (!isEvent(aItem)) {
return null;
}
let periods = this.findPeriodsForItem(aItem);
if (periods.length == 0) {
return null;
}
let newlistItem = null;
@@ -358,18 +343,17 @@ function addItem(aItem) {
/**
* Checks if the given item happens before the comparison item.
*
* @param aItem The item to compare.
* @param aCompItem The item to compare with.
* @param aPeriod The period where the items are inserted.
* @return True, if the aItem happens before aCompItem.
*/
-agendaListbox.isBefore =
-function isBefore(aItem, aCompItem, aPeriod) {
+agendaListbox.isBefore = function(aItem, aCompItem, aPeriod) {
let itemDate = this.comparisonDate(aItem, aPeriod);
let compItemDate = this.comparisonDate(aCompItem, aPeriod);
let itemDateEndDate = itemDate.clone();
itemDateEndDate.day++;
if (compItemDate.day == itemDate.day) {
// In the same day the order is:
// - all-day events (single day);
@@ -411,18 +395,17 @@ function isBefore(aItem, aCompItem, aPer
/**
* Returns the start or end date of an item according to which of them
* must be displayed in a given period of the agenda
*
* @param aItem The item to compare.
* @param aPeriod The period where the item is inserted.
* @return The start or end date of the item showed in the agenda.
*/
-agendaListbox.comparisonDate =
-function comparisonDate(aItem, aPeriod) {
+agendaListbox.comparisonDate = function(aItem, aPeriod) {
let periodStartDate = aPeriod.start.clone();
periodStartDate.isDate = true;
let periodEndDate = aPeriod.end.clone();
periodEndDate.day--;
let startDate = aItem.startDate.clone();
startDate.isDate = true;
let endDate = aItem.endDate.clone();
@@ -450,18 +433,17 @@ function comparisonDate(aItem, aPeriod)
/**
* Gets the listitems for a given item, possibly in a given period.
*
* @param aItem The item to get the list items for.
* @param aPeriod (optional) the period to search in.
* @return An array of list items for the given item.
*/
-agendaListbox.getListItems =
-function getListItems(aItem, aPeriod) {
+agendaListbox.getListItems = function(aItem, aPeriod) {
let retlistItems = [];
let periods = [aPeriod];
if (!aPeriod) {
periods = this.findPeriodsForItem(aItem);
}
if (periods.length > 0) {
for (let i = 0; i < periods.length; i++) {
let period = periods[i];
@@ -485,18 +467,17 @@ function getListItems(aItem, aPeriod) {
/**
* Removes the given item from the agenda listbox
*
* @param aItem The item to remove.
* @param aMoveSelection If true, the selection will be moved to the next
* sibling that is not an period item.
* @return Returns true if the removed item was selected.
*/
-agendaListbox.deleteItem =
-function deleteItem(aItem, aMoveSelection) {
+agendaListbox.deleteItem = function(aItem, aMoveSelection) {
let isSelected = false;
let listItems = this.getListItems(aItem);
if (listItems.length > 0) {
for (let i = listItems.length - 1; i >= 0; i--) {
let listItem = listItems[i];
let isSelected2 = listItem.selected;
if (isSelected2 && !isSelected) {
isSelected = true;
@@ -510,18 +491,17 @@ function deleteItem(aItem, aMoveSelectio
return isSelected;
};
/**
* Remove all items belonging to the specified calendar.
*
* @param aCalendar The item to compare.
*/
-agendaListbox.deleteItemsFromCalendar =
-function deleteItemsFromCalendar(aCalendar) {
+agendaListbox.deleteItemsFromCalendar = function(aCalendar) {
let childNodes = Array.from(this.agendaListboxControl.childNodes);
for (let childNode of childNodes) {
if (childNode && childNode.occurrence &&
childNode.occurrence.calendar.id == aCalendar.id) {
childNode.remove();
}
}
};
@@ -529,80 +509,75 @@ function deleteItemsFromCalendar(aCalend
/**
* Compares two items to see if they have the same id and their start date
* matches
*
* @param aItem The item to compare.
* @param aCompItem The item to compare with.
* @return True, if the items match with the above noted criteria.
*/
-agendaListbox.isSameEvent =
-function isSameEvent(aItem, aCompItem) {
+agendaListbox.isSameEvent = function(aItem, aCompItem) {
return aItem.id == aCompItem.id &&
aItem[calGetStartDateProp(aItem)].compare(aCompItem[calGetStartDateProp(aCompItem)]) == 0;
};
/**
* Checks if the currently selected node in the listbox is an Event item (not a
* period item).
*
* @return True, if the node is not a period item.
*/
-agendaListbox.isEventSelected =
-function isEventSelected() {
+agendaListbox.isEventSelected = function() {
let listItem = this.agendaListboxControl.selectedItem;
if (listItem) {
return this.isEventListItem(listItem);
}
return false;
};
/**
* Delete the selected item from its calendar (if it is an event item)
*
* @param aDoNotConfirm If true, the user will not be prompted.
*/
-agendaListbox.deleteSelectedItem =
-function deleteSelectedItem(aDoNotConfirm) {
+agendaListbox.deleteSelectedItem = function(aDoNotConfirm) {
let listItem = this.agendaListboxControl.selectedItem;
if (this.isEventListItem(listItem)) {
let selectedItems = [listItem.occurrence];
calendarViewController.deleteOccurrences(selectedItems.length,
selectedItems,
false,
aDoNotConfirm);
}
};
/**
* If a Period item is targeted by the passed DOM event, opens the event dialog
* with the period's start date prefilled.
*
* @param aEvent The DOM event that targets the period.
*/
-agendaListbox.createNewEvent =
-function createNewEvent(aEvent) {
+agendaListbox.createNewEvent = function(aEvent) {
if (!this.isEventListItem(aEvent.target)) {
// Create new event for the date currently displayed in the agenda. Setting
// isDate = true automatically makes the start time be the next full hour.
let eventStart = agendaListbox.today.start.clone();
eventStart.isDate = true;
if (calendarController.isCommandEnabled("calendar_new_event_command")) {
createEventWithDialog(getSelectedCalendar(), eventStart);
}
}
};
/**
* Sets up the context menu for the agenda listbox
*
* @param popup The <menupopup> element to set up.
*/
-agendaListbox.setupContextMenu =
-function setupContextMenu(popup) {
+agendaListbox.setupContextMenu = function(popup) {
let listItem = this.agendaListboxControl.selectedItem;
let enabled = this.isEventListItem(listItem);
let menuitems = popup.childNodes;
for (let i = 0; i < menuitems.length; i++) {
setBooleanAttribute(menuitems[i], "disabled", !enabled);
}
let menu = document.getElementById("calendar-today-pane-menu-attendance-menu");
@@ -614,18 +589,17 @@ function setupContextMenu(popup) {
* Refreshes the agenda listbox. If aStart or aEnd is not passed, the agenda
* listbox's limiting dates will be used.
*
* @param aStart (optional) The start date for the item query.
* @param aEnd (optional) The end date for the item query.
* @param aCalendar (optional) If specified, the single calendar from
* which the refresh will occur.
*/
-agendaListbox.refreshCalendarQuery =
-function refreshCalendarQuery(aStart, aEnd, aCalendar) {
+agendaListbox.refreshCalendarQuery = function(aStart, aEnd, aCalendar) {
let refreshJob = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
agendaListbox: this,
calendar: null,
calId: null,
operation: null,
cancelled: false,
@@ -704,18 +678,17 @@ function refreshCalendarQuery(aStart, aE
};
refreshJob.execute();
};
/**
* Sets up the calendar for the agenda listbox.
*/
-agendaListbox.setupCalendar =
-function setupCalendar() {
+agendaListbox.setupCalendar = function() {
this.init();
if (this.calendar == null) {
this.calendar = getCompositeCalendar();
}
if (this.calendar) {
// XXX This always gets called, does that happen on purpose?
this.calendar.removeObserver(this.calendarObserver);
}
@@ -729,18 +702,17 @@ function setupCalendar() {
* Refreshes the period dates, especially when a period is showing "today".
* Usually called at midnight to update the agenda pane. Also retrieves the
* items from the calendar.
*
* @see #refreshCalendarQuery
* @param newDate The first date to show if the agenda pane doesn't show
* today.
*/
-agendaListbox.refreshPeriodDates =
-function refreshPeriodDates(newDate) {
+agendaListbox.refreshPeriodDates = function(newDate) {
this.kDefaultTimezone = calendarDefaultTimezone();
// Today: now until midnight of tonight
let oldshowstoday = this.showstoday;
this.showstoday = this.showsToday(newDate);
if ((this.showstoday) && (!oldshowstoday)) {
this.addPeriodListItem(this.tomorrow, "tomorrow-header");
this.addPeriodListItem(this.soon, "nextweek-header");
} else if (!this.showstoday) {
@@ -763,30 +735,28 @@ function refreshPeriodDates(newDate) {
this.refreshCalendarQuery();
};
/**
* Adds a listener to this agenda listbox.
*
* @param aListener The listener to add.
*/
-agendaListbox.addListener =
-function addListener(aListener) {
+agendaListbox.addListener = function(aListener) {
this.mListener = aListener;
};
/**
* Checks if the agenda listbox is showing "today". Without arguments, this
* function assumes the today attribute of the agenda listbox.
*
* @param aStartDate (optional) The day to check if its "today".
* @return Returns true if today is shown.
*/
-agendaListbox.showsToday =
-function showsToday(aStartDate) {
+agendaListbox.showsToday = function(aStartDate) {
let lstart = aStartDate;
if (!lstart) {
lstart = this.today.start;
}
let lshowsToday = sameDay(now(), lstart);
if (lshowsToday) {
this.periods = [this.today, this.tomorrow, this.soon];
} else {
@@ -794,65 +764,61 @@ function showsToday(aStartDate) {
}
return lshowsToday;
};
/**
* Moves the selection. Moves down unless the next item is a period item, in
* which case the selection moves up.
*/
-agendaListbox.moveSelection =
-function moveSelection() {
+agendaListbox.moveSelection = function() {
if (!this.isEventListItem(this.agendaListboxControl.selectedItem.nextSibling)) {
this.agendaListboxControl.goUp();
} else {
this.agendaListboxControl.goDown();
}
};
/**
* Gets an array of selected items. If a period node is selected, it is not
* included.
*
* @return An array with all selected items.
*/
-agendaListbox.getSelectedItems =
-function getSelectedItems() {
+agendaListbox.getSelectedItems = function() {
let items = [];
if (this.isEventListItem(this.agendaListboxControl.selectedItem)) {
// If at some point we support selecting multiple items, this array can
// be expanded.
items = [this.agendaListboxControl.selectedItem.occurrence];
}
return items;
};
/**
* Checks if the passed node in the listbox is an Event item (not a
* period item).
*
* @param aListItem The node to check for.
* @return True, if the node is not a period item.
*/
-agendaListbox.isEventListItem =
-function isEventListItem(aListItem) {
+agendaListbox.isEventListItem = function(aListItem) {
let isListItem = (aListItem != null);
if (isListItem) {
let localName = aListItem.localName;
isListItem = (localName == "agenda-richlist-item" ||
localName == "agenda-allday-richlist-item");
}
return isListItem;
};
/**
* Removes all Event items, keeping the period items intact.
*/
-agendaListbox.removeListItems =
-function removeListItems() {
+agendaListbox.removeListItems = function() {
let listItem = this.agendaListboxControl.lastChild;
if (listItem) {
let leaveloop = false;
do {
let newlistItem = null;
if (listItem) {
newlistItem = listItem.previousSibling;
} else {
@@ -870,18 +836,17 @@ function removeListItems() {
}
};
/**
* Gets the list item node by its associated event's hashId.
*
* @return The XUL node if successful, otherwise null.
*/
-agendaListbox.getListItemByHashId =
-function getListItemByHashId(ahashId) {
+agendaListbox.getListItemByHashId = function(ahashId) {
let listItem = this.agendaListboxControl.firstChild;
let leaveloop = false;
do {
if (this.isEventListItem(listItem)) {
if (listItem.occurrence.hashId == ahashId) {
return listItem;
}
}
@@ -903,83 +868,77 @@ agendaListbox.calendarOpListener = {
* Calendar and composite observer, used to keep agenda listbox up to date.
* @see calIObserver
* @see calICompositeObserver
*/
agendaListbox.calendarObserver = {
agendaListbox: agendaListbox
};
-agendaListbox.calendarObserver.QueryInterface =
-function agenda_QI(aIID) {
+agendaListbox.calendarObserver.QueryInterface = function(aIID) {
if (!aIID.equals(Components.interfaces.calIObserver) &&
!aIID.equals(Components.interfaces.calICompositeObserver) &&
!aIID.equals(Components.interfaces.nsISupports)) {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
return this;
};
// calIObserver:
-agendaListbox.calendarObserver.onStartBatch = function agenda_onBatchStart() {
+agendaListbox.calendarObserver.onStartBatch = function() {
};
-agendaListbox.calendarObserver.onEndBatch =
-function() {
+agendaListbox.calendarObserver.onEndBatch = function() {
};
agendaListbox.calendarObserver.onLoad = function() {
this.agendaListbox.refreshCalendarQuery();
};
-agendaListbox.calendarObserver.onAddItem = function observer_onAddItem(item) {
+agendaListbox.calendarObserver.onAddItem = function(item) {
if (!isEvent(item)) {
return;
}
// get all sub items if it is a recurring item
let occs = this.getOccurrencesBetween(item);
occs.forEach(this.agendaListbox.addItem, this.agendaListbox);
setCurrentEvent();
};
-agendaListbox.calendarObserver.getOccurrencesBetween =
-function getOccurrencesBetween(aItem) {
+agendaListbox.calendarObserver.getOccurrencesBetween = function(aItem) {
let occs = [];
let start = this.agendaListbox.getStart();
let end = this.agendaListbox.getEnd();
if (start && end) {
occs = aItem.getOccurrencesBetween(start, end, {});
}
return occs;
};
-agendaListbox.calendarObserver.onDeleteItem =
-function observer_onDeleteItem(item, rebuildFlag) {
+agendaListbox.calendarObserver.onDeleteItem = function(item, rebuildFlag) {
this.onLocalDeleteItem(item, true);
};
-agendaListbox.calendarObserver.onLocalDeleteItem =
-function observer_onLocalDeleteItem(item, moveSelection) {
+agendaListbox.calendarObserver.onLocalDeleteItem = function(item, moveSelection) {
if (!isEvent(item)) {
return false;
}
let selectedItemHashId = -1;
// get all sub items if it is a recurring item
let occs = this.getOccurrencesBetween(item);
for (let i = 0; i < occs.length; i++) {
let isSelected = this.agendaListbox.deleteItem(occs[i], moveSelection);
if (isSelected) {
selectedItemHashId = occs[i].hashId;
}
}
return selectedItemHashId;
};
-agendaListbox.calendarObserver.onModifyItem =
-function observer_onModifyItem(newItem, oldItem) {
+agendaListbox.calendarObserver.onModifyItem = function(newItem, oldItem) {
let selectedItemHashId = this.onLocalDeleteItem(oldItem, false);
if (!isEvent(newItem)) {
return;
}
this.onAddItem(newItem);
if (selectedItemHashId != -1) {
let listItem = agendaListbox.getListItemByHashId(selectedItemHashId);
if (listItem) {
@@ -1013,38 +972,35 @@ agendaListbox.calendarObserver.onPropert
}
};
agendaListbox.calendarObserver.onPropertyDeleting = function(aCalendar, aName) {
this.onPropertyChanged(aCalendar, aName, null, null);
};
-agendaListbox.calendarObserver.onCalendarRemoved =
-function agenda_calRemoved(aCalendar) {
+agendaListbox.calendarObserver.onCalendarRemoved = function(aCalendar) {
if (!aCalendar.getProperty("disabled")) {
this.agendaListbox.deleteItemsFromCalendar(aCalendar);
}
};
-agendaListbox.calendarObserver.onCalendarAdded =
-function agenda_calAdded(aCalendar) {
+agendaListbox.calendarObserver.onCalendarAdded = function(aCalendar) {
if (!aCalendar.getProperty("disabled")) {
this.agendaListbox.refreshCalendarQuery(null, null, aCalendar);
}
};
agendaListbox.calendarObserver.onDefaultCalendarChanged = function(aCalendar) {
};
/**
* Updates the "Upcoming" section of today pane when preference soondays changes
**/
-agendaListbox.updateSoonSection =
-function updateSoonSection() {
+agendaListbox.updateSoonSection = function() {
this.soon.duration = this.soonDays;
this.soon.open = true;
let soonHeader = document.getElementById("nextweek-header");
if (soonHeader) {
soonHeader.setItem(this.soon, true);
agendaListbox.refreshPeriodDates(now());
}
};
--- a/calendar/base/content/calendar-base-view.xml
+++ b/calendar/base/content/calendar-base-view.xml
@@ -46,17 +46,17 @@
({ WorkdaysOnly: 1,
TasksInView: 2,
ShowCompleted: 4,
})
]]></field>
<field name="mPrefObserver"><![CDATA[
({ calView: this,
- observe: function calViewPrefChange(subj, topic, pref) {
+ observe: function(subj, topic, pref) {
this.calView.handlePreference(subj, topic, pref);
return;
}
})
]]></field>
<field name="mObserver"><![CDATA[
// the calIObserver, calICompositeObserver, and calIAlarmServiceObserver
@@ -64,26 +64,26 @@
QueryInterface: XPCOMUtils.generateQI([
Components.interfaces.calIObserver,
Components.interfaces.calIAlarmServiceObserver,
Components.interfaces.calICompositeObserver
]),
calView: this,
- onStartBatch: function onStartBatch() {
+ onStartBatch: function() {
},
- onEndBatch: function onEndBatch() {
+ onEndBatch: function() {
},
- onLoad: function onLoad() {
+ onLoad: function() {
this.calView.refresh();
},
- onAddItem: function onAddItem(aItem) {
+ onAddItem: function(aItem) {
if (cal.isToDo(aItem)) {
if (!aItem.entryDate && !aItem.dueDate) {
return;
}
if (!this.calView.mTasksInView) {
return;
}
if (aItem.isCompleted && !this.calView.mShowCompleted) {
@@ -95,17 +95,17 @@
this.calView.queryEndDate,
{});
for (let occ of occs) {
this.calView.doAddItem(occ);
}
return;
},
- onModifyItem: function onModifyItem(aNewItem, aOldItem) {
+ onModifyItem: function(aNewItem, aOldItem) {
if (cal.isToDo(aNewItem) && cal.isToDo(aOldItem) &&
!this.calView.mTasksInView) {
return;
}
let occs;
if (!cal.isToDo(aOldItem) || aOldItem.entryDate || aOldItem.dueDate) {
occs = aOldItem.getOccurrencesBetween(this.calView.startDate,
@@ -127,17 +127,17 @@
occs = aNewItem.getOccurrencesBetween(this.calView.startDate,
this.calView.queryEndDate,
{});
for (let occ of occs) {
this.calView.doAddItem(occ);
}
},
- onDeleteItem: function onDeleteItem(aItem) {
+ onDeleteItem: function(aItem) {
if (cal.isToDo(aItem)) {
if (!this.calView.mTasksInView) {
return;
}
if (!aItem.entryDate && !aItem.dueDate) {
return;
}
if (aItem.isCompleted && !this.calView.mShowCompleted) {
@@ -148,17 +148,17 @@
let occs = aItem.getOccurrencesBetween(this.calView.startDate,
this.calView.queryEndDate,
{});
for (let occ of occs) {
this.calView.doDeleteItem(occ);
}
},
- onError: function onError(aCalendar, aErrNo, aMessage) { },
+ onError: function(aCalendar, aErrNo, aMessage) { },
onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
switch (aName) {
case "suppressAlarms":
if (!Preferences.get("calendar.alarms.indicator.show", true) ||
aCalendar.getProperty("capabilities.alarms.popup.supported") === false) {
break;
}
@@ -174,55 +174,54 @@
onPropertyDeleting: function(aCalendar, aName) {
// Values are not important here yet.
this.onPropertyChanged(aCalendar, aName, null, null);
},
//
// calIAlarmServiceObserver stuff
//
- onAlarm: function onAlarm(aAlarmItem) {
+ onAlarm: function(aAlarmItem) {
this.calView.flashAlarm(aAlarmItem, false);
},
- onRemoveAlarmsByItem: function onRemoveAlarmsByItem(aItem) {
+ onRemoveAlarmsByItem: function(aItem) {
// Stop the flashing for the item.
this.calView.flashAlarm(aItem, true);
},
- onRemoveAlarmsByCalendar: function onRemoveAlarmsByCalendar(aCalendar) {
+ onRemoveAlarmsByCalendar: function(aCalendar) {
// Stop the flashing for all items of this calendar
for (let key in this.calView.mFlashingEvents) {
let item = this.calView.mFlashingEvents[key];
if (item.calendar.id == aCalendar.id) {
this.calView.flashAlarm(item, true);
}
}
},
- onAlarmsLoaded: function _onAlarmsLoaded(aCalendar) {},
+ onAlarmsLoaded: function(aCalendar) {},
//
// calICompositeObserver stuff
// XXXvv we can be smarter about how we handle this stuff
//
- onCalendarAdded: function onCalendarAdded(aCalendar) {
+ onCalendarAdded: function(aCalendar) {
if (!aCalendar.getProperty("disabled")) {
this.calView.addItemsFromCalendar(aCalendar);
}
},
- onCalendarRemoved: function onCalendarRemoved(aCalendar) {
+ onCalendarRemoved: function(aCalendar) {
if (!aCalendar.getProperty("disabled")) {
this.calView.deleteItemsFromCalendar(aCalendar);
}
},
- onDefaultCalendarChanged:
- function onDefaultCalendarChanged(aNewDefaultCalendar) {
+ onDefaultCalendarChanged: function(aNewDefaultCalendar) {
// don't care, for now
}
})
]]></field>
<constructor><![CDATA[
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
@@ -242,20 +241,19 @@
.getAttribute("checked") == "true");
this.showCompleted = (document.getElementById(kShowCompleted)
.getAttribute("checked") == "true");
this.mTimezone = calendarDefaultTimezone();
let alarmService = Components.classes["@mozilla.org/calendar/alarm-service;1"]
.getService(Components.interfaces.calIAlarmService);
alarmService.addObserver(this.mObserver);
- let self = this;
this.setAttribute("type", this.type);
- this.mResizeHandler = function resizeHandler() {
- self.onResize(self);
+ this.mResizeHandler = () => {
+ this.onResize(this);
};
this.viewBroadcaster.addEventListener(this.getAttribute("type") + "viewresized", this.mResizeHandler, true);
// add a preference observer to monitor changes
Services.prefs.addObserver("calendar.", this.mPrefObserver, false);
this.weekStartOffset = Preferences.get("calendar.week.start", 0);
this.updateDaysOffPrefs();
this.mPendingRefreshJobs = new Map();
this.mLog = Log4Moz.getConfiguredLogger("calBaseView");
--- a/calendar/base/content/calendar-common-sets.js
+++ b/calendar/base/content/calendar-common-sets.js
@@ -88,33 +88,33 @@ var calendarController = {
"calendar_in_foreground": true,
"calendar_in_background": true,
"calendar_mode_calendar": true,
"calendar_mode_task": true,
"cmd_selectAll": true
},
- updateCommands: function cC_updateCommands() {
+ updateCommands: function() {
for (let command in this.commands) {
goUpdateCommand(command);
}
},
- supportsCommand: function cC_supportsCommand(aCommand) {
+ supportsCommand: function(aCommand) {
if (aCommand in this.commands) {
return true;
}
if (this.defaultContoller) {
return this.defaultContoller.supportsCommand(aCommand);
}
return false;
},
- isCommandEnabled: function cC_isCommandEnabled(aCommand) {
+ isCommandEnabled: function(aCommand) {
switch (aCommand) {
case "calendar_new_event_command":
case "calendar_new_event_context_command":
return CalendarNewEventsCommandEnabled;
case "calendar_modify_focused_item_command":
return this.item_selected;
case "calendar_modify_event_command":
return this.item_selected;
@@ -252,17 +252,17 @@ var calendarController = {
if (aCommand in this.commands) {
// All other commands we support should be enabled by default
return true;
}
}
return false;
},
- doCommand: function cC_doCommand(aCommand) {
+ doCommand: function(aCommand) {
switch (aCommand) {
// Common Commands
case "calendar_new_event_command":
createEventWithDialog(getSelectedCalendar(),
getDefaultStartDate(currentView().selectedDay));
break;
case "calendar_new_event_context_command": {
let newStart = currentView().selectedDateTime;
@@ -425,36 +425,36 @@ var calendarController = {
this.defaultController.doCommand(aCommand);
return;
}
}
return;
},
- onEvent: function cC_onEvent(aEvent) {
+ onEvent: function(aEvent) {
},
- isCalendarInForeground: function cC_isCalendarInForeground() {
+ isCalendarInForeground: function() {
return gCurrentMode && gCurrentMode != "mail";
},
- isInMode: function cC_isInMode(mode) {
+ isInMode: function(mode) {
switch (mode) {
case "mail":
return !isCalendarInForeground();
case "calendar":
return gCurrentMode && gCurrentMode == "calendar";
case "task":
return gCurrentMode && gCurrentMode == "task";
}
return false;
},
- onSelectionChanged: function cC_onSelectionChanged(aEvent) {
+ onSelectionChanged: function(aEvent) {
let selectedItems = aEvent.detail;
calendarUpdateDeleteCommand(selectedItems);
calendarController.item_selected = selectedItems && (selectedItems.length > 0);
let selLength = (selectedItems === undefined ? 0 : selectedItems.length);
let selected_events_readonly = 0;
let selected_events_requires_network = 0;
@@ -669,17 +669,17 @@ var calendarController2 = {
"cmd_showQuickFilterBar": true
},
// These functions can use the same from the calendar controller for now.
updateCommands: calendarController.updateCommands,
supportsCommand: calendarController.supportsCommand,
onEvent: calendarController.onEvent,
- isCommandEnabled: function isCommandEnabled(aCommand) {
+ isCommandEnabled: function(aCommand) {
switch (aCommand) {
// Thunderbird Commands
case "cmd_cut":
return calendarController.selected_items_writable;
case "cmd_copy":
return calendarController.item_selected;
case "cmd_paste":
return canPaste();
@@ -702,17 +702,17 @@ var calendarController2 = {
return false;
case "cmd_showQuickFilterBar":
return calendarController.isInMode("task");
default:
return true;
}
},
- doCommand: function doCommand(aCommand) {
+ doCommand: function(aCommand) {
switch (aCommand) {
case "cmd_cut":
cutToClipboard();
break;
case "cmd_copy":
copyToClipboard();
break;
case "cmd_paste":
--- a/calendar/base/content/calendar-extract.js
+++ b/calendar/base/content/calendar-extract.js
@@ -2,17 +2,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://calendar/modules/calExtract.jsm");
Components.utils.import("resource://calendar/modules/calUtils.jsm");
Components.utils.import("resource://gre/modules/Preferences.jsm");
var calendarExtract = {
- onShowLocaleMenu: function onShowLocaleMenu(target) {
+ onShowLocaleMenu: function(target) {
let localeList = document.getElementById(target.id);
let langs = [];
let chrome = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIXULChromeRegistry);
chrome.QueryInterface(Components.interfaces.nsIToolkitChromeRegistry);
let locales = chrome.getLocalesForPackage("calendar");
let langRegex = /^(([^-]+)-*(.*))$/;
@@ -54,23 +54,23 @@ var calendarExtract = {
});
removeChildren(localeList);
for (let lang of langs) {
addMenuItem(localeList, lang[0], lang[1], null);
}
},
- extractWithLocale: function extractWithLocale(event, isEvent) {
+ extractWithLocale: function(event, isEvent) {
event.stopPropagation();
let locale = event.target.value;
this.extractFromEmail(isEvent, true, locale);
},
- extractFromEmail: function extractFromEmail(isEvent, fixedLang, fixedLocale) {
+ extractFromEmail: function(isEvent, fixedLang, fixedLocale) {
// TODO would be nice to handle multiple selected messages,
// though old conversion functionality didn't
let message = gFolderDisplay.selectedMessage;
let messenger = Components.classes["@mozilla.org/messenger;1"]
.createInstance(Components.interfaces.nsIMessenger);
let listener = Components.classes["@mozilla.org/network/sync-stream-listener;1"]
.createInstance(Components.interfaces.nsISyncStreamListener);
let uri = message.folder.getUriForMsg(message);
@@ -204,34 +204,34 @@ var calendarExtract = {
createEventWithDialog(null, null, null, null, item);
}
}
let timeSpent = (new Date()).getTime() - time;
cal.LOG("[calExtract] Total time spent for conversion (including loading of dictionaries): " + timeSpent + "ms");
},
- addListeners: function addListeners() {
+ addListeners: function() {
if (window.top.document.location == "chrome://messenger/content/messenger.xul") {
// covers initial load and folder change
let folderTree = document.getElementById("folderTree");
folderTree.addEventListener("select", this.setState, false);
// covers selection change in a folder
let msgTree = window.top.GetThreadTree();
msgTree.addEventListener("select", this.setState, false);
window.addEventListener("unload", () => {
folderTree.removeEventListener("select", this.setState, false);
msgTree.removeEventListener("select", this.setState, false);
}, false);
}
},
- setState: function setState() {
+ setState: function() {
let eventButton = document.getElementById("extractEventButton");
let taskButton = document.getElementById("extractTaskButton");
let hdrEventButton = document.getElementById("hdrExtractEventButton");
let hdrTaskButton = document.getElementById("hdrExtractTaskButton");
let contextMenu = document.getElementById("mailContext-calendar-convert-menu");
let contextMenuEvent = document.getElementById("mailContext-calendar-convert-event-menuitem");
let contextMenuTask = document.getElementById("mailContext-calendar-convert-task-menuitem");
let eventDisabled = (gFolderDisplay.selectedCount == 0);
--- a/calendar/base/content/calendar-invitations-manager.js
+++ b/calendar/base/content/calendar-invitations-manager.js
@@ -16,26 +16,26 @@ var gInvitationsRequestManager = {
mRequestStatusList: {},
/**
* Add a request to the request manager.
*
* @param calendar The calendar to add for.
* @param op The operation to add
*/
- addRequestStatus: function IRM_addRequestStatus(calendar, op) {
+ addRequestStatus: function(calendar, op) {
if (op) {
this.mRequestStatusList[calendar.id] = op;
}
},
/**
* Cancel all pending requests
*/
- cancelPendingRequests: function IRM_cancelPendingRequests() {
+ cancelPendingRequests: function() {
for (let id in this.mRequestStatusList) {
let request = this.mRequestStatusList[id];
if (request && request.isPending) {
request.cancel(null);
}
}
this.mRequestStatusList = {};
}
@@ -82,48 +82,45 @@ InvitationsManager.prototype = {
mTimer: null,
/**
* Schedule an update for the invitations manager asynchronously.
*
* @param firstDelay The timeout before the operation should start.
* @param operationListener The calIGenericOperationListener to notify.
*/
- scheduleInvitationsUpdate: function IM_scheduleInvitationsUpdate(firstDelay,
- operationListener) {
+ scheduleInvitationsUpdate: function(firstDelay, operationListener) {
this.cancelInvitationsUpdate();
- let self = this;
- this.mTimer = setTimeout(function startInvitationsTimer() {
+ this.mTimer = setTimeout(() => {
if (Preferences.get("calendar.invitations.autorefresh.enabled", true)) {
- self.mTimer = setInterval(function repeatingInvitationsTimer() {
- self.getInvitations(operationListener);
+ this.mTimer = setInterval(() => {
+ this.getInvitations(operationListener);
}, Preferences.get("calendar.invitations.autorefresh.timeout", 3) * 60000);
}
- self.getInvitations(operationListener);
+ this.getInvitations(operationListener);
}, firstDelay);
},
/**
* Cancel pending any pending invitations update.
*/
- cancelInvitationsUpdate: function IM_cancelInvitationsUpdate() {
+ cancelInvitationsUpdate: function() {
clearTimeout(this.mTimer);
},
/**
* Retrieve invitations from all calendars. Notify all passed
* operation listeners.
*
* @param operationListener1 The first operation listener to notify.
* @param operationListener2 (optinal) The second operation listener to
* notify.
*/
- getInvitations: function IM_getInvitations(operationListener1,
- operationListener2) {
+ getInvitations: function(operationListener1, operationListener2) {
let listeners = [];
if (operationListener1) {
listeners.push(operationListener1);
}
if (operationListener2) {
listeners.push(operationListener2);
}
@@ -234,18 +231,17 @@ InvitationsManager.prototype = {
* sounds fishy to me. Maybe there is a more encapsulated solution.
*
* @param onLoadOpListener The operation listener to notify when
* getting invitations. Should be passed
* to this.getInvitations().
* @param finishedCallBack A callback function to call when the
* dialog has completed.
*/
- openInvitationsDialog: function IM_openInvitationsDialog(onLoadOpListener,
- finishedCallBack) {
+ openInvitationsDialog: function(onLoadOpListener, finishedCallBack) {
let args = {};
args.onLoadOperationListener = onLoadOpListener;
args.queue = [];
args.finishedCallBack = finishedCallBack;
args.requestManager = gInvitationsRequestManager;
args.invitationsManager = this;
// the dialog will reset this to auto when it is done loading
window.setCursor("wait");
@@ -261,18 +257,17 @@ InvitationsManager.prototype = {
* Process the passed job queue. A job is an object that consists of an
* action, a newItem and and oldItem. This processor only takes "modify"
* operations into account.
*
* @param queue The array of objects to process.
* @param jobQueueFinishedCallBack A callback function called when
* job has finished.
*/
- processJobQueue: function IM_processJobQueue(queue,
- jobQueueFinishedCallBack) {
+ processJobQueue: function(queue, jobQueueFinishedCallBack) {
// TODO: undo/redo
function operationListener(mgr, queueCallback, oldItem_) {
this.mInvitationsManager = mgr;
this.mJobQueueFinishedCallBack = queueCallback;
this.mOldItem = oldItem_;
}
operationListener.prototype = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
@@ -327,31 +322,28 @@ InvitationsManager.prototype = {
/**
* Checks if the internal item list contains the given item
* XXXdbo Please document these correctly.
*
* @param item The item to look for.
* @return A boolean value indicating if the item was found.
*/
- hasItem: function IM_hasItem(item) {
+ hasItem: function(item) {
let hid = item.hashId;
- return this.mItemList.some(
- function someFunc(item_) {
- return hid == item_.hashId;
- });
+ return this.mItemList.some(item_ => hid == item_.hashId);
},
/**
* Adds an item to the internal item list.
* XXXdbo Please document these correctly.
*
* @param item The item to add.
*/
- addItem: function IM_addItem(item) {
+ addItem: function(item) {
let recInfo = item.recurrenceInfo;
if (recInfo && !cal.isOpenInvitation(item)) {
// scan exceptions:
let ids = recInfo.getExceptionIds({});
for (let id of ids) {
let ex = recInfo.getExceptionFor(id);
if (ex && this.validateItem(ex) && !this.hasItem(ex)) {
this.mItemList.push(ex);
@@ -363,52 +355,49 @@ InvitationsManager.prototype = {
},
/**
* Removes an item from the internal item list
* XXXdbo Please document these correctly.
*
* @param item The item to remove.
*/
- deleteItem: function IM_deleteItem(item) {
+ deleteItem: function(item) {
let id = item.id;
- this.mItemList.filter(
- function filterFunc(item_) {
- return id != item_.id;
- });
+ this.mItemList.filter(item_ => id != item_.id);
},
/**
* Remove all items from the internal item list
* XXXdbo Please document these correctly.
*/
- deleteAllItems: function IM_deleteAllItems() {
+ deleteAllItems: function() {
this.mItemList = [];
},
/**
* Helper function to create a start date to search from. This date is the
* current time with hour/minute/second set to zero.
*
* @return Potential start date.
*/
- getStartDate: function IM_getStartDate() {
+ getStartDate: function() {
let date = now();
date.second = 0;
date.minute = 0;
date.hour = 0;
return date;
},
/**
* Updates the start date for the invitations manager to the date returned
* from this.getStartDate(), unless the previously existing start date is
* the same or after what getStartDate() returned.
*/
- updateStartDate: function IM_updateStartDate() {
+ updateStartDate: function() {
if (!this.mStartDate) {
this.mStartDate = this.getStartDate();
} else {
let startDate = this.getStartDate();
if (startDate.compare(this.mStartDate) > 0) {
this.mStartDate = startDate;
}
}
@@ -417,17 +406,17 @@ InvitationsManager.prototype = {
/**
* Checks if the item is valid for the invitation manager. Checks if the
* item is in the range of the invitation manager and if the item is a valid
* invitation.
*
* @param item The item to check
* @return A boolean indicating if the item is a valid invitation.
*/
- validateItem: function IM_validateItem(item) {
+ validateItem: function(item) {
if (item.calendar instanceof Components.interfaces.calISchedulingSupport &&
!item.calendar.isInvitation(item)) {
return false; // exclude if organizer has invited himself
}
let start = item[calGetStartDateProp(item)] || item[calGetEndDateProp(item)];
return (cal.isOpenInvitation(item) &&
start.compare(this.mStartDate) >= 0);
}
--- a/calendar/base/content/calendar-item-editing.js
+++ b/calendar/base/content/calendar-item-editing.js
@@ -373,21 +373,21 @@ function openEventDialog(calendarItem, c
// Set up some defaults
mode = mode || "new";
calendar = calendar || getSelectedCalendar();
let calendars = getCalendarManager().getCalendars({});
calendars = calendars.filter(isCalendarWritable);
let isItemSupported;
if (isToDo(calendarItem)) {
- isItemSupported = function isTodoSupported(aCalendar) {
+ isItemSupported = function(aCalendar) {
return (aCalendar.getProperty("capabilities.tasks.supported") !== false);
};
} else if (isEvent(calendarItem)) {
- isItemSupported = function isEventSupported(aCalendar) {
+ isItemSupported = function(aCalendar) {
return (aCalendar.getProperty("capabilities.events.supported") !== false);
};
}
// Filter out calendars that don't support the given calendar item
calendars = calendars.filter(isItemSupported);
// Filter out calendar/items that we cannot write to/modify
--- a/calendar/base/content/calendar-management.js
+++ b/calendar/base/content/calendar-management.js
@@ -356,29 +356,29 @@ var compositeObserver = {
onPropertyChanged: function() {},
onPropertyDeleting: function() {},
onLoad: function() {
calendarUpdateNewItemsCommand();
document.commandDispatcher.updateCommands("calendar_commands");
},
- onCalendarAdded: function cO_onCalendarAdded(aCalendar) {
+ onCalendarAdded: function(aCalendar) {
// Update the calendar commands for number of remote calendars and for
// more than one calendar
document.commandDispatcher.updateCommands("calendar_commands");
},
- onCalendarRemoved: function cO_onCalendarRemoved(aCalendar) {
+ onCalendarRemoved: function(aCalendar) {
// Update commands to disallow deleting the last calendar and only
// allowing reload remote calendars when there are remote calendars.
document.commandDispatcher.updateCommands("calendar_commands");
},
- onDefaultCalendarChanged: function cO_onDefaultCalendarChanged(aNewCalendar) {
+ onDefaultCalendarChanged: function(aNewCalendar) {
// A new default calendar may mean that the new calendar has different
// ACLs. Make sure the commands are updated.
calendarUpdateNewItemsCommand();
document.commandDispatcher.updateCommands("calendar_commands");
}
};
/**
@@ -395,44 +395,44 @@ function openCalendarSubscriptionsDialog
}
/**
* Calendar Offline Manager
*/
var calendarOfflineManager = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver]),
- init: function cOM_init() {
+ init: function() {
if (this.initialized) {
throw Components.results.NS_ERROR_ALREADY_INITIALIZED;
}
Services.obs.addObserver(this, "network:offline-status-changed", false);
this.updateOfflineUI(!this.isOnline());
this.initialized = true;
},
- uninit: function cOM_uninit() {
+ uninit: function() {
if (!this.initialized) {
throw Components.results.NS_ERROR_NOT_INITIALIZED;
}
Services.obs.removeObserver(this, "network:offline-status-changed", false);
this.initialized = false;
},
- isOnline: function cOM_isOnline() {
+ isOnline: function() {
return !Services.io.offline;
},
- updateOfflineUI: function cOM_updateOfflineUI(aIsOffline) {
+ updateOfflineUI: function(aIsOffline) {
// Refresh the current view
currentView().goToDay(currentView().selectedDay);
// Set up disabled locks for offline
document.commandDispatcher.updateCommands("calendar_commands");
},
- observe: function cOM_observe(aSubject, aTopic, aState) {
+ observe: function(aSubject, aTopic, aState) {
if (aTopic == "network:offline-status-changed") {
this.updateOfflineUI(aState == "offline");
}
}
};
--- a/calendar/base/content/calendar-menus.xml
+++ b/calendar/base/content/calendar-menus.xml
@@ -12,18 +12,17 @@
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="task-menupopup" extends="xul:menupopup">
<implementation>
<field name="mType">null</field>;
<field name="mPopupHandler">null</field>
<field name="mParentMenuPopup">null</field>
<constructor><![CDATA[
- let self = this;
- this.mPopupHandler = function popupHandler() { self.changeMenuByPropertyName(); };
+ this.mPopupHandler = () => { this.schangeMenuByPropertyName(); };
this.mParentMenuPopup = getParentNodeOrThis(this, "menupopup");
this.mParentMenuPopup.addEventListener("popupshowing", this.mPopupHandler, true);
]]></constructor>
<destructor><![CDATA[
this.mParentMenuPopup.removeEventListener("popupshowing", this.mPopupHandler, true);
]]></destructor>
<!-- This method checks a command which naming follows
--- a/calendar/base/content/calendar-statusbar.js
+++ b/calendar/base/content/calendar-statusbar.js
@@ -20,36 +20,36 @@ Components.utils.import("resource://gre/
mThrobber: null,
mProgressMode: Components.interfaces.calIStatusObserver.NO_PROGRESS,
mCurIndex: 0,
mInitialized: false,
mCalendars: {},
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIStatusObserver]),
- initialize: function cStObs_initialize(aWindow) {
+ initialize: function(aWindow) {
if (!this.mInitialized) {
this.mWindow = aWindow;
this.mStatusText = this.mWindow.document.getElementById("statusText");
this.mStatusBar = this.mWindow.document.getElementById("statusbar-icon");
this.mStatusProgressPanel = this.mWindow.document.getElementById("statusbar-progresspanel");
this.mThrobber = this.mWindow.document.getElementById("navigator-throbber");
this.mInitialized = true;
}
},
- showStatusString: function cStObs_showStatusString(status) {
+ showStatusString: function(status) {
this.mStatusText.setAttribute("label", status);
},
get spinning() {
return this.mProgressMode;
},
- startMeteors: function cStObs_startMeteors(aProgressMode, aCalendarCount) {
+ startMeteors: function(aProgressMode, aCalendarCount) {
if (aProgressMode != Components.interfaces.calIStatusObserver.NO_PROGRESS) {
if (!this.mInitialized) {
Components.utils.reportError("StatusObserver has not been initialized!");
return;
}
this.mCalendars = {};
this.mCurIndex = 0;
if (aCalendarCount) {
@@ -66,34 +66,34 @@ Components.utils.import("resource://gre/
this.showStatusString(commonStatus);
}
if (this.mThrobber) {
this.mThrobber.setAttribute("busy", true);
}
}
},
- stopMeteors: function cStObs_stopMeteors() {
+ stopMeteors: function() {
if (!this.mInitialized) {
return;
}
if (this.spinning != Components.interfaces.calIStatusObserver.NO_PROGRESS) {
this.mProgressMode = Components.interfaces.calIStatusObserver.NO_PROGRESS;
this.mStatusProgressPanel.collapsed = true;
this.mStatusBar.setAttribute("mode", "normal");
this.mStatusBar.value = 0;
this.mCalendarCount = 0;
this.showStatusString("");
if (this.mThrobber) {
this.mThrobber.setAttribute("busy", false);
}
}
},
- calendarCompleted: function cStObs_calendarCompleted(aCalendar) {
+ calendarCompleted: function(aCalendar) {
if (!this.mInitialized) {
return;
}
if (this.spinning != Components.interfaces.calIStatusObserver.NO_PROGRESS) {
if (this.spinning == Components.interfaces.calIStatusObserver.DETERMINED_PROGRESS) {
if (!this.mCalendars[aCalendar.id] || this.mCalendars[aCalendar.id] === undefined) {
this.mCalendars[aCalendar.id] = true;
this.mStatusBar.value = parseInt(this.mStatusBar.value, 10) + this.mCalendarStep;
--- a/calendar/base/content/calendar-task-editing.js
+++ b/calendar/base/content/calendar-task-editing.js
@@ -42,28 +42,28 @@ var taskEdit = {
/**
* Helper function to set readonly and aria-disabled states and the value
* for a given target.
*
* @param aTarget The ID or XUL node to set the value
* @param aDisable A boolean if the target should be disabled.
* @param aValue The value that should be set on the target.
*/
- setupTaskField: function tE_setupTaskField(aTarget, aDisable, aValue) {
+ setupTaskField: function(aTarget, aDisable, aValue) {
aTarget.value = aValue;
setElementValue(aTarget, aDisable && "true", "readonly");
setElementValue(aTarget, aDisable && "true", "aria-disabled");
},
/**
* Handler function to call when the quick-add textbox gains focus.
*
* @param aEvent The DOM focus event
*/
- onFocus: function tE_onFocus(aEvent) {
+ onFocus: function(aEvent) {
let edit = aEvent.target;
if (edit.localName == "input") {
// For some reason, we only receive an onfocus event for the textbox
// when debugging with venkman.
edit = edit.parentNode.parentNode;
}
let calendar = getSelectedCalendar();
@@ -83,17 +83,17 @@ var taskEdit = {
}
},
/**
* Handler function to call when the quick-add textbox loses focus.
*
* @param aEvent The DOM blur event
*/
- onBlur: function tE_onBlur(aEvent) {
+ onBlur: function(aEvent) {
let edit = aEvent.target;
if (edit.localName == "input") {
// For some reason, we only receive the blur event for the input
// element. There are no targets that point to the textbox. Go up
// the parent chain until we reach the textbox.
edit = edit.parentNode.parentNode;
}
@@ -122,17 +122,17 @@ var taskEdit = {
edit.showsInstructions = true;
},
/**
* Handler function to call on keypress for the quick-add textbox.
*
* @param aEvent The DOM keypress event
*/
- onKeyPress: function tE_onKeyPress(aEvent) {
+ onKeyPress: function(aEvent) {
if (aEvent.keyCode == Components.interfaces.nsIDOMKeyEvent.DOM_VK_RETURN) {
let edit = aEvent.target;
if (edit.value && edit.value.length > 0) {
let item = cal.createTodo();
setDefaultItemValues(item);
item.title = edit.value;
edit.value = "";
@@ -140,32 +140,32 @@ var taskEdit = {
}
}
},
/**
* Window load function to set up all quick-add textboxes. The texbox must
* have the class "task-edit-field".
*/
- onLoad: function tE_onLoad(aEvent) {
+ onLoad: function(aEvent) {
window.removeEventListener("load", taskEdit.onLoad, false);
// TODO use getElementsByClassName
let taskEditFields = document.getElementsByAttribute("class", "task-edit-field");
for (let i = 0; i < taskEditFields.length; i++) {
taskEdit.onBlur({ target: taskEditFields[i] });
}
getCompositeCalendar().addObserver(taskEdit.compositeObserver);
taskEdit.observedCalendar = getSelectedCalendar();
},
/**
* Window load function to clean up all quick-add fields.
*/
- onUnload: function tE_onUnload() {
+ onUnload: function() {
getCompositeCalendar().removeObserver(taskEdit.compositeObserver);
taskEdit.observedCalendar = null;
},
/**
* Observer to watch for readonly, disabled and capability changes of the
* observed calendar.
*
@@ -178,37 +178,33 @@ var taskEdit = {
onStartBatch: function() {},
onEndBatch: function() {},
onLoad: function(aCalendar) {},
onAddItem: function(aItem) {},
onModifyItem: function(aNewItem, aOldItem) {},
onDeleteItem: function(aDeletedItem) {},
onError: function(aCalendar, aErrNo, aMessage) {},
- onPropertyChanged: function tE_calObs_onPropertyChanged(aCalendar,
- aName,
- aValue,
- aOldValue) {
+ onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
if (aCalendar.id != getSelectedCalendar().id) {
// Optimization: if the given calendar isn't the default calendar,
// then we don't need to change any readonly/disabled states.
return;
}
switch (aName) {
case "readOnly":
case "disabled":
let taskEditFields = document.getElementsByAttribute("class", "task-edit-field");
for (let i = 0; i < taskEditFields.length; i++) {
taskEdit.onBlur({ target: taskEditFields[i] });
}
}
},
- onPropertyDeleting: function tE_calObs_onPropertyDeleting(aCalendar,
- aName) {
+ onPropertyDeleting: function(aCalendar, aName) {
// Since the old value is not used directly in onPropertyChanged,
// but should not be the same as the value, set it to a different
// value.
this.onPropertyChanged(aCalendar, aName, null, null);
}
},
/**
@@ -231,19 +227,19 @@ var taskEdit = {
onAddItem: function(aItem) {},
onModifyItem: function(aNewItem, aOldItem) {},
onDeleteItem: function(aDeletedItem) {},
onError: function(aCalendar, aErrNo, aMessage) {},
onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {},
onPropertyDeleting: function(aCalendar, aName) {},
// calICompositeObserver:
- onCalendarAdded: function onCalendarAdded(aCalendar) {},
- onCalendarRemoved: function onCalendarRemoved(aCalendar) {},
- onDefaultCalendarChanged: function tE_compObs_onDefaultCalendarChanged(aNewDefault) {
+ onCalendarAdded: function(aCalendar) {},
+ onCalendarRemoved: function(aCalendar) {},
+ onDefaultCalendarChanged: function(aNewDefault) {
let taskEditFields = document.getElementsByAttribute("class", "task-edit-field");
for (let i = 0; i < taskEditFields.length; i++) {
taskEdit.onBlur({ target: taskEditFields[i] });
}
taskEdit.observedCalendar = aNewDefault;
}
}
};
--- a/calendar/base/content/calendar-task-tree.xml
+++ b/calendar/base/content/calendar-task-tree.xml
@@ -373,28 +373,28 @@
return (this.mSelectedColumn = aCol);
},
/**
* High-level task tree manipulation
*/
// Adds an array of items to the list if they match the currently applied filter.
- addItems: function tTV_addItems(aItems, aDontSort) {
+ addItems: function(aItems, aDontSort) {
this.modifyItems(aItems, [], aDontSort, true);
},
// Removes an array of items from the list.
- removeItems: function tTV_removeItems(aItems) {
+ removeItems: function(aItems) {
this.modifyItems([], aItems, true, false);
},
// Removes an array of old items from the list, and adds an array of new items if
// they match the currently applied filter.
- modifyItems: function tTV_modifyItems(aNewItems, aOldItems, aDontSort, aSelectNew) {
+ modifyItems: function(aNewItems, aOldItems, aDontSort, aSelectNew) {
let selItem = this.binding.currentTask;
let selIndex = this.tree.currentIndex;
let firstHash = null;
let remIndexes = [];
aNewItems = aNewItems || [];
aOldItems = aOldItems || [];
this.treebox.beginUpdateBatch();
@@ -461,27 +461,27 @@
if (selIndex > -1) {
this.tree.view.selection.select(selIndex);
this.treebox.ensureRowIsVisible(selIndex);
}
this.treebox.endUpdateBatch();
},
- clear: function tTV_clear() {
+ clear: function() {
let count = this.binding.mTaskArray.length;
if (count > 0) {
this.binding.mTaskArray = [];
this.binding.mHash2Index = {};
this.treebox.rowCountChanged(0, -count);
this.tree.view.selection.clearSelection();
}
},
- updateItem: function tTV_updateItem(aItem) {
+ updateItem: function(aItem) {
let index = this.binding.mHash2Index[aItem.hashId];
if (index) {
this.treebox.invalidateRow(index);
}
},
/**
* nsITreeView methods and properties
@@ -490,29 +490,29 @@
get rowCount() {
return this.binding.mTaskArray.length;
},
// TODO this code is currently identical to the unifinder. We should
// create an itemTreeView that these tree views can inherit, that
// contains this code, and possibly other code related to sorting and
// storing items. See bug 432582 for more details.
- getCellProperties: function mTV_getCellProperties(aRow, aCol) {
+ getCellProperties: function(aRow, aCol) {
let rowProps = this.getRowProperties(aRow);
let colProps = this.getColumnProperties(aCol);
return rowProps + (rowProps && colProps ? " " : "") + colProps;
},
// Called to get properties to paint a column background.
// For shading the sort column, etc.
- getColumnProperties: function mTV_getColumnProperties(aCol) {
+ getColumnProperties: function(aCol) {
return aCol.element.getAttribute("anonid") || "";
},
- getRowProperties: function mTV_getRowProperties(aRow) {
+ getRowProperties: function(aRow) {
let properties = [];
let item = this.binding.mTaskArray[aRow];
if (item.priority > 0 && item.priority < 5) {
properties.push("highpriority");
} else if (item.priority > 5 && item.priority < 10) {
properties.push("lowpriority");
}
properties.push(getProgressAtom(item));
@@ -535,17 +535,17 @@
properties = properties.concat(item.getCategories({})
.map(formatStringForCSSRule));
return properties.join(" ");
},
// Called on the view when a cell in a non-selectable cycling
// column (e.g., unread/flag/etc.) is clicked.
- cycleCell: function mTV_cycleCell(aRow, aCol) {
+ cycleCell: function(aRow, aCol) {
let task = this.binding.mTaskArray[aRow];
// prevent toggling completed status for parent items of
// repeating tasks or when the calendar is read-only.
if (!task || task.recurrenceInfo || task.calendar.readOnly) {
return;
}
if (aCol != null) {
@@ -554,17 +554,17 @@
let newTask = task.clone().QueryInterface(Components.interfaces.calITodo);
newTask.isCompleted = !task.completedDate;
doTransaction("modify", newTask, newTask.calendar, task, null);
}
}
},
// Called on the view when a header is clicked.
- cycleHeader: function mTV_cycleHeader(aCol) {
+ cycleHeader: function(aCol) {
if (!this.selectedColumn) {
this.sortDirection = "ascending";
} else if (!this.sortDirection || this.sortDirection == "descending") {
this.sortDirection = "ascending";
} else {
this.sortDirection = "descending";
}
this.selectedColumn = aCol.element;
@@ -576,17 +576,17 @@
let index = this.binding.mHash2Index[item.hashId];
this.tree.view.selection.toggleSelect(index);
}
}
},
// The text for a given cell. If a column consists only of an
// image, then the empty string is returned.
- getCellText: function mTV_getCellText(aRow, aCol) {
+ getCellText: function(aRow, aCol) {
let task = this.binding.mTaskArray[aRow];
if (!task) {
return false;
}
switch (aCol.element.getAttribute("itemproperty")) {
case "title":
// return title, or "Untitled" if empty/null
@@ -612,105 +612,105 @@
case "completed":
case "priority":
default:
return "";
}
},
// This method is only called for columns of type other than text.
- getCellValue: function mTV_getCellValue(aRow, aCol) {
+ getCellValue: function(aRow, aCol) {
let task = this.binding.mTaskArray[aRow];
if (!task) {
return null;
}
switch (aCol.element.getAttribute("itemproperty")) {
case "percentComplete":
return task.percentComplete;
}
return null;
},
// SetCellValue is called when the value of the cell has been set by the user.
// This method is only called for columns of type other than text.
- setCellValue: function mTV_setCellValue(aRow, aCol, aValue) {
+ setCellValue: function(aRow, aCol, aValue) {
return null;
},
// The image path for a given cell. For defining an icon for a cell.
// If the empty string is returned, the :moz-tree-image pseudoelement will be used.
- getImageSrc: function mTV_getImageSrc(aRow, aCol) {
+ getImageSrc: function(aRow, aCol) {
// Return the empty string in order
// to use moz-tree-image pseudoelement :
// it is mandatory to return "" and not false :-(
return "";
},
// IsEditable is called to ask the view if the cell contents are editable.
// A value of true will result in the tree popping up a text field when the user
// tries to inline edit the cell.
- isEditable: function mTV_isEditable(aRow, aCol) {
+ isEditable: function(aRow, aCol) {
return true;
},
// Called during initialization to link the view to the front end box object.
- setTree: function mTV_setTree(aTreeBox) {
+ setTree: function(aTreeBox) {
this.treebox = aTreeBox;
},
// Methods that can be used to test whether or not a twisty should
// be drawn, and if so, whether an open or closed twisty should be used.
- isContainer: function mTV_isContainer(aRow) {
+ isContainer: function(aRow) {
return false;
},
- isContainerOpen: function mTV_isContainerOpen(aRow) {
+ isContainerOpen: function(aRow) {
return false;
},
- isContainerEmpty: function mTV_isContainerEmpty(aRow) {
+ isContainerEmpty: function(aRow) {
return false;
},
// IsSeparator is used to determine if the row at index is a separator.
// A value of true will result in the tree drawing a horizontal separator.
// The tree uses the ::moz-tree-separator pseudoclass to draw the separator.
- isSeparator: function mTV_isSeparator(aRow) {
+ isSeparator: function(aRow) {
return false;
},
// Specifies if there is currently a sort on any column.
// Used mostly by drag'n'drop to affect drop feedback.
- isSorted: function mTV_isSorted(aRow) {
+ isSorted: function(aRow) {
return false;
},
- canDrop: function mTV_canDrop() { return false; },
+ canDrop: function() { return false; },
- drop: function mTV_drop(aRow, aOrientation) {},
+ drop: function(aRow, aOrientation) {},
- getParentIndex: function mTV_getParentIndex(aRow) {
+ getParentIndex: function(aRow) {
return -1;
},
// The level is an integer value that represents the level of indentation.
// It is multiplied by the width specified in the :moz-tree-indentation
// pseudoelement to compute the exact indendation.
- getLevel: function mTV_getLevel(aRow) {
+ getLevel: function(aRow) {
return 0;
},
// The image path for a given cell. For defining an icon for a cell.
// If the empty string is returned, the :moz-tree-image pseudoelement
// will be used.
- getImgSrc: function mTV_getImgSrc(aRow, aCol) {
+ getImgSrc: function(aRow, aCol) {
return null;
},
// The progress mode for a given cell. This method is only called for
// columns of type |progressmeter|.
- getProgressMode: function mTV_getProgressMode(aRow, aCol) {
+ getProgressMode: function(aRow, aCol) {
switch (aCol.element.getAttribute("itemproperty")) {
case "percentComplete":
let task = this.binding.mTaskArray[aRow];
if (aCol.element.boxObject.width > 75 &&
task.percentComplete > 0) {
// XXX Would be nice if we could use relative widths,
// i.e "15ex", but there is no scriptable interface.
return Components.interfaces.nsITreeView.PROGRESS_NORMAL;
@@ -719,19 +719,19 @@
}
return Components.interfaces.nsITreeView.PROGRESS_NONE;
},
/**
* Task Tree Events
*/
- onSelect: function tTV_onSelect(event) {},
+ onSelect: function(event) {},
- onDoubleClick: function tTV_onDoubleClick(event) {
+ onDoubleClick: function(event) {
if (event.button == 0) {
let initialDate = getDefaultStartDate(this.binding.getInitialDate());
let col = {};
let item = this._getItemFromEvent(event, col);
if (item) {
let colAnonId = col.value.element.getAttribute("itemproperty");
if (colAnonId == "completed") {
// item holds checkbox state toggled by first click,
@@ -741,17 +741,17 @@
modifyEventWithDialog(item, null, true, initialDate);
}
} else {
createTodoWithDialog(null, null, null, null, initialDate);
}
}
},
- onKeyPress: function tTV_onKeyPress(event) {
+ onKeyPress: function(event) {
const kKE = Components.interfaces.nsIDOMKeyEvent;
switch (event.keyCode || event.which) {
case kKE.DOM_VK_DELETE:
document.popupNode = this.binding;
document.getElementById("calendar_delete_todo_command").doCommand();
event.preventDefault();
event.stopPropagation();
break;
@@ -769,42 +769,42 @@
if (index > -1) {
modifyEventWithDialog(this.binding.mTaskArray[index]);
}
break;
}
},
// Set the context menu on mousedown to change it before it is opened
- onMouseDown: function tTV_onMouseDown(event) {
+ onMouseDown: function(event) {
let tree = document.getAnonymousElementByAttribute(this.binding,
"anonid",
"calendar-task-tree");
if (!this._getItemFromEvent(event)) {
tree.view.selection.invalidateSelection();
}
},
/**
* Private methods and attributes
*/
- _getItemFromEvent: function tTV_getItemFromEvent(event, aCol, aRow) {
+ _getItemFromEvent: function(event, aCol, aRow) {
aRow = aRow || {};
let childElt = {};
this.treebox.getCellAt(event.clientX, event.clientY, aRow, aCol || {}, childElt);
if (!childElt.value) {
return false;
}
return aRow && aRow.value > -1 && this.binding.mTaskArray[aRow.value];
},
// Helper function to display datetimes
- _formatDateTime: function tTV_formatDateTime(aDateTime) {
+ _formatDateTime: function(aDateTime) {
let dateFormatter = Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
.getService(Components.interfaces.calIDateTimeFormatter);
// datetime is from todo object, it is not a javascript date
if (aDateTime && aDateTime.isValid) {
let dateTime = aDateTime.getInTimezone(calendarDefaultTimezone());
return dateFormatter.formatDateTime(dateTime);
}
@@ -824,81 +824,81 @@
QueryInterface: XPCOMUtils.generateQI([
Components.interfaces.calICompositeObserver,
Components.interfaces.calIObserver
]),
/**
* calIObserver methods and properties
*/
- onStartBatch: function tTO_onStartBatch() {
+ onStartBatch: function() {
},
- onEndBatch: function tTO_onEndBatch() {
+ onEndBatch: function() {
},
- onLoad: function tTO_onLoad() {
+ onLoad: function() {
this.binding.refresh();
},
- onAddItem: function tTO_onAddItem(aItem) {
+ onAddItem: function(aItem) {
if (cal.isToDo(aItem)) {
this.binding.mTreeView.addItems(this.binding.mFilter.getOccurrences(aItem));
}
},
- onModifyItem: function tTO_onModifyItem(aNewItem, aOldItem) {
- if ((cal.isToDo(aNewItem) || cal.isToDo(aOldItem))) {
+ onModifyItem: function(aNewItem, aOldItem) {
+ if (cal.isToDo(aNewItem) || cal.isToDo(aOldItem)) {
this.binding.mTreeView.modifyItems(this.binding.mFilter.getOccurrences(aNewItem),
this.binding.mFilter.getOccurrences(aOldItem));
// we also need to notify potential listeners.
let event = document.createEvent("Events");
event.initEvent("select", true, false);
this.binding.dispatchEvent(event);
}
},
- onDeleteItem: function tTO_onDeleteItem(aDeletedItem) {
+ onDeleteItem: function(aDeletedItem) {
if (cal.isToDo(aDeletedItem)) {
this.binding.mTreeView.removeItems(this.binding.mFilter.getOccurrences(aDeletedItem));
}
},
- onError: function tTO_onError(aCalendar, aErrNo, aMessage) {},
- onPropertyChanged: function tTO_onPropertyChanged(aCalendar, aName, aValue, aOldValue) {
+ onError: function(aCalendar, aErrNo, aMessage) {},
+ onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
switch (aName) {
case "disabled":
if (aValue) {
this.binding.onCalendarRemoved(aCalendar);
} else {
this.binding.onCalendarAdded(aCalendar);
}
break;
}
},
- onPropertyDeleting: function tTO_onPropertyDeleting(aCalendar, aName) {
+ onPropertyDeleting: function(aCalendar, aName) {
this.onPropertyChanged(aCalendar, aName, null, null);
},
/**
* calICompositeObserver methods and properties
*/
- onCalendarAdded: function tTO_onCalendarAdded(aCalendar) {
+ onCalendarAdded: function(aCalendar) {
if (!aCalendar.getProperty("disabled")) {
this.binding.onCalendarAdded(aCalendar);
}
},
- onCalendarRemoved: function tTO_onCalendarRemoved(aCalendar) {
+ onCalendarRemoved: function(aCalendar) {
this.binding.onCalendarRemoved(aCalendar);
},
- onDefaultCalendarChanged: function tTO_onDefaultCalendarChanged(aNewDefaultCalendar) {}
+ onDefaultCalendarChanged: function(aNewDefaultCalendar) {}
})
]]></field>
<method name="observe">
<parameter name="aSubject"/>
<parameter name="aTopic"/>
<parameter name="aPrefName"/>
<body><![CDATA[
--- a/calendar/base/content/calendar-task-view.js
+++ b/calendar/base/content/calendar-task-view.js
@@ -11,17 +11,17 @@ Components.utils.import("resource://gre/
var taskDetailsView = {
/**
* Task Details Events
*
* XXXberend Please document this function, possibly also consolidate since
* its the only function in taskDetailsView.
*/
- onSelect: function tDV_onSelect(event) {
+ onSelect: function(event) {
function displayElement(id, flag) {
setBooleanAttribute(id, "hidden", !flag);
return flag;
}
let dateFormatter =
Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
.getService(Components.interfaces.calIDateTimeFormatter);
@@ -142,23 +142,23 @@ var taskDetailsView = {
"if (event.button != 2) launchBrowser(this.value);");
urlLabel.setAttribute("context", "taskview-link-context-menu");
attachmentRows.appendChild(urlLabel);
}
}
}
},
- loadCategories: function loadCategories(event) {
+ loadCategories: function(event) {
let panel = event.target;
let item = document.getElementById("calendar-task-tree").currentTask;
panel.loadItem(item);
},
- saveCategories: function saveCategories(event) {
+ saveCategories: function(event) {
let panel = event.target;
let item = document.getElementById("calendar-task-tree").currentTask;
let categoriesMap = {};
for (let cat of item.getCategories({})) {
categoriesMap[cat] = true;
}
--- a/calendar/base/content/calendar-unifinder.js
+++ b/calendar/base/content/calendar-unifinder.js
@@ -58,92 +58,92 @@ function getCurrentUnifinderFilter() {
var unifinderObserver = {
QueryInterface: XPCOMUtils.generateQI([
Components.interfaces.calICompositeObserver,
Components.interfaces.nsIObserver,
Components.interfaces.calIObserver
]),
// calIObserver:
- onStartBatch: function uO_onStartBatch() {
+ onStartBatch: function() {
},
- onEndBatch: function uO_onEndBatch() {
+ onEndBatch: function() {
refreshEventTree();
},
- onLoad: function uO_onLoad() {
+ onLoad: function() {
if (isUnifinderHidden() && !gUnifinderNeedsRefresh) {
// If the unifinder is hidden, all further item operations might
// produce invalid entries in the unifinder. From now on, ignore
// those operations and refresh as soon as the unifinder is shown
// again.
gUnifinderNeedsRefresh = true;
unifinderTreeView.clearItems();
}
},
- onAddItem: function uO_onAddItem(aItem) {
+ onAddItem: function(aItem) {
if (isEvent(aItem) &&
!gUnifinderNeedsRefresh &&
unifinderTreeView.mFilter.isItemInFilters(aItem)
) {
this.addItemToTree(aItem);
}
},
- onModifyItem: function uO_onModifyItem(aNewItem, aOldItem) {
+ onModifyItem: function(aNewItem, aOldItem) {
this.onDeleteItem(aOldItem);
this.onAddItem(aNewItem);
},
- onDeleteItem: function uO_onDeleteItem(aDeletedItem) {
+ onDeleteItem: function(aDeletedItem) {
if (isEvent(aDeletedItem) && !gUnifinderNeedsRefresh) {
this.removeItemFromTree(aDeletedItem);
}
},
- onError: function uO_onError(aCalendar, aErrNo, aMessage) {},
+ onError: function(aCalendar, aErrNo, aMessage) {},
- onPropertyChanged: function uO_onPropertyChanged(aCalendar, aName, aValue, aOldValue) {
+ onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
switch (aName) {
case "disabled":
refreshEventTree();
break;
}
},
- onPropertyDeleting: function uO_onPropertyDeleting(aCalendar, aName) {
+ onPropertyDeleting: function(aCalendar, aName) {
this.onPropertyChanged(aCalendar, aName, null, null);
},
// calICompositeObserver:
- onCalendarAdded: function uO_onCalendarAdded(aAddedCalendar) {
+ onCalendarAdded: function(aAddedCalendar) {
if (!aAddedCalendar.getProperty("disabled")) {
addItemsFromCalendar(aAddedCalendar,
addItemsFromSingleCalendarInternal);
}
},
- onCalendarRemoved: function uO_onCalendarRemoved(aDeletedCalendar) {
+ onCalendarRemoved: function(aDeletedCalendar) {
if (!aDeletedCalendar.getProperty("disabled")) {
deleteItemsFromCalendar(aDeletedCalendar);
}
},
- onDefaultCalendarChanged: function uO_onDefaultCalendarChanged(aNewDefaultCalendar) {},
+ onDefaultCalendarChanged: function(aNewDefaultCalendar) {},
/**
* Add an unifinder item to the tree. It is safe to call these for any
* event. The functions will determine whether or not anything actually
* needs to be done to the tree.
*
* @return aItem The item to add to the tree.
*/
- addItemToTree: function uO_addItemToTree(aItem) {
+ addItemToTree: function(aItem) {
let items;
let filter = unifinderTreeView.mFilter;
if (filter.startDate && filter.endDate) {
items = aItem.getOccurrencesBetween(filter.startDate, filter.endDate, {});
} else {
items = [aItem];
}
@@ -152,29 +152,29 @@ var unifinderObserver = {
/**
* Remove an item from the unifinder tree. It is safe to call these for any
* event. The functions will determine whether or not anything actually
* needs to be done to the tree.
*
* @return aItem The item to remove from the tree.
*/
- removeItemFromTree: function uO_removeItemFromTree(aItem) {
+ removeItemFromTree: function(aItem) {
let items;
let filter = unifinderTreeView.mFilter;
if (filter.startDate && filter.endDate && (aItem.parentItem == aItem)) {
items = aItem.getOccurrencesBetween(filter.startDate, filter.endDate, {});
} else {
items = [aItem];
}
// XXX: do we really still need this, we are always checking it in the refreshInternal
unifinderTreeView.removeItems(items.filter(filter.isItemInFilters, filter));
},
- observe: function uO_observe(aSubject, aTopic, aPrefName) {
+ observe: function(aSubject, aTopic, aPrefName) {
switch (aPrefName) {
case "calendar.date.format":
case "calendar.timezone.local":
refreshEventTree();
break;
}
}
};
@@ -439,34 +439,34 @@ var unifinderTreeView = {
eventIndexMap: {},
/**
* Add an item to the unifinder tree.
*
* @param aItemArray An array of items to add.
* @param aDontSort If true, the items will only be appended.
*/
- addItems: function uTV_addItems(aItemArray, aDontSort) {
+ addItems: function(aItemArray, aDontSort) {
this.eventArray = this.eventArray.concat(aItemArray);
let newCount = (this.eventArray.length - aItemArray.length - 1);
this.tree.rowCountChanged(newCount, aItemArray.length);
if (aDontSort) {
this.calculateIndexMap();
} else {
this.sortItems();
}
},
/**
* Remove items from the unifinder tree.
*
* @param aItemArray An array of items to remove.
*/
- removeItems: function uTV_removeItems(aItemArray) {
+ removeItems: function(aItemArray) {
let indexesToRemove = [];
// Removing items is a bit tricky. Our getItemRow function takes the
// index from a cached map, so removing an item from the array will
// remove the wrong indexes. We don't want to just invalidate the map,
// since this will cause O(n^2) behavior. Instead, we keep a sorted
// array of the indexes to remove:
for (let item of aItemArray) {
let row = this.getItemRow(item);
@@ -495,28 +495,28 @@ var unifinderTreeView = {
// (given that Array.unshift doesn't loop but just prepends or maps
// memory smartly) O(3n) behavior. Lets hope its worth it.
this.calculateIndexMap(true);
},
/**
* Clear all items from the unifinder.
*/
- clearItems: function uTV_clearItems() {
+ clearItems: function() {
let oldCount = this.eventArray.length;
this.eventArray = [];
this.tree.rowCountChanged(0, -oldCount);
this.calculateIndexMap();
},
/**
* Sets the items that should be in the unifinder. This removes all items
* that were previously in the unifinder.
*/
- setItems: function uTV_setItems(aItemArray, aDontSort) {
+ setItems: function(aItemArray, aDontSort) {
let oldCount = this.eventArray.length;
this.eventArray = aItemArray.slice(0);
this.tree.rowCountChanged(oldCount - 1, this.eventArray.length - oldCount);
if (aDontSort) {
this.calculateIndexMap();
} else {
this.sortItems();
@@ -527,31 +527,31 @@ var unifinderTreeView = {
* Recalculate the index map that improves performance when accessing
* unifinder items. This is usually done automatically when adding/removing
* items.
*
* @param aDontInvalidate (optional) Don't invalidate the tree, i.e if
* you correctly issued rowCountChanged
* notices.
*/
- calculateIndexMap: function uTV_calculateIndexMap(aDontInvalidate) {
+ calculateIndexMap: function(aDontInvalidate) {
this.eventIndexMap = {};
for (let i = 0; i < this.eventArray.length; i++) {
this.eventIndexMap[this.eventArray[i].hashId] = i;
}
if (!aDontInvalidate) {
this.tree.invalidate();
}
},
/**
* Sort the items in the unifinder by the currently selected column.
*/
- sortItems: function uTV_sortItems() {
+ sortItems: function() {
if (this.selectedColumn) {
let modifier = (this.sortDirection == "descending" ? -1 : 1);
let sortKey = unifinderTreeView.selectedColumn.getAttribute("itemproperty");
let sortType = cal.getSortTypeForSortKey(sortKey);
// sort (key,item) entries
cal.sortEntry.mSortKey = sortKey;
cal.sortEntry.mSortStartedDate = now();
let entries = this.eventArray.map(cal.sortEntry, cal.sortEntry);
@@ -562,54 +562,54 @@ var unifinderTreeView = {
},
/**
* Get the index of the row associated with the passed item.
*
* @param item The item to search for.
* @return The row index of the passed item.
*/
- getItemRow: function uTV_getItemRow(item) {
+ getItemRow: function(item) {
if (this.eventIndexMap[item.hashId] === undefined) {
return -1;
}
return this.eventIndexMap[item.hashId];
},
/**
* Get the item at the given row index.
*
* @param item The row index to get the item for.
* @return The item at the given row.
*/
- getItemAt: function uTV_getItemAt(aRow) {
+ getItemAt: function(aRow) {
return this.eventArray[aRow];
},
/**
* Get the calendar item from the given DOM event
*
* @param event The DOM mouse event to get the item for.
* @return The item under the mouse position.
*/
- getItemFromEvent: function uTV_getItemFromEvent(event) {
+ getItemFromEvent: function(event) {
let row = this.tree.getRowAt(event.clientX, event.clientY);
if (row > -1) {
return this.getItemAt(row);
}
return null;
},
/**
* Change the selection in the unifinder.
*
* @param aItemArray An array of items to select.
*/
- setSelectedItems: function uTV_setSelectedItems(aItemArray) {
+ setSelectedItems: function(aItemArray) {
if (this.doingSelection || !this.tree || !this.tree.view) {
return;
}
this.doingSelection = true;
// If no items were passed, get the selected items from the view.
aItemArray = aItemArray || currentView().getSelectedItems({});
@@ -646,17 +646,17 @@ var unifinderTreeView = {
// This needs to be in a setTimeout
setTimeout(function() { unifinderTreeView.resetAllowSelection(); }, 1);
},
/**
* Due to a selection issue described in bug 168211 this method is needed to
* re-add the selection listeners selection listeners.
*/
- resetAllowSelection: function uTV_resetAllowSelection() {
+ resetAllowSelection: function() {
if (!this.tree) {
return;
}
/**
* Do not change anything in the following lines, they are needed as
* described in the selection observer above
*/
this.doingSelection = false;
@@ -673,22 +673,22 @@ var unifinderTreeView = {
return this.eventArray.length;
},
// TODO this code is currently identical to the task tree. We should create
// an itemTreeView that these tree views can inherit, that contains this
// code, and possibly other code related to sorting and storing items. See
// bug 432582 for more details.
- getCellProperties: function uTV_getCellProperties(aRow, aCol) {
+ getCellProperties: function(aRow, aCol) {
let rowProps = this.getRowProperties(aRow);
let colProps = this.getColumnProperties(aCol);
return rowProps + (rowProps && colProps ? " " : "") + colProps;
},
- getRowProperties: function uTV_getRowProperties(aRow) {
+ getRowProperties: function(aRow) {
let properties = [];
let item = this.eventArray[aRow];
if (item.priority > 0 && item.priority < 5) {
properties.push("highpriority");
} else if (item.priority > 5 && item.priority < 10) {
properties.push("lowpriority");
}
@@ -706,63 +706,63 @@ var unifinderTreeView = {
}
// Task categories
properties = properties.concat(item.getCategories({})
.map(formatStringForCSSRule));
return properties.join(" ");
},
- getColumnProperties: function uTV_getColumnProperties(aCol) { return ""; },
+ getColumnProperties: function(aCol) { return ""; },
- isContainer: function uTV_isContainer() {
+ isContainer: function() {
return false;
},
- isContainerOpen: function uTV_isContainerOpen(aRow) {
+ isContainerOpen: function(aRow) {
return false;
},
- isContainerEmpty: function uTV_isContainerEmpty(aRow) {
+ isContainerEmpty: function(aRow) {
return false;
},
- isSeparator: function uTV_isSeparator(aRow) {
+ isSeparator: function(aRow) {
return false;
},
- isSorted: function uTV_isSorted(aRow) {
+ isSorted: function(aRow) {
return false;
},
- canDrop: function uTV_canDrop(aRow, aOrientation) {
+ canDrop: function(aRow, aOrientation) {
return false;
},
- drop: function uTV_drop(aRow, aOrientation) {},
+ drop: function(aRow, aOrientation) {},
- getParentIndex: function uTV_getParentIndex(aRow) {
+ getParentIndex: function(aRow) {
return -1;
},
- hasNextSibling: function uTV_hasNextSibling(aRow, aAfterIndex) {},
+ hasNextSibling: function(aRow, aAfterIndex) {},
- getLevel: function uTV_getLevel(aRow) {
+ getLevel: function(aRow) {
return 0;
},
- getImageSrc: function uTV_getImageSrc(aRow, aOrientation) {},
+ getImageSrc: function(aRow, aOrientation) {},
- getProgressMode: function uTV_getProgressMode(aRow, aCol) {},
+ getProgressMode: function(aRow, aCol) {},
- getCellValue: function uTV_getCellValue(aRow, aCol) {
+ getCellValue: function(aRow, aCol) {
return null;
},
- getCellText: function uTV_getCellText(row, column) {
+ getCellText: function(row, column) {
let calendarEvent = this.eventArray[row];
switch (column.element.getAttribute("itemproperty")) {
case "title":
return (calendarEvent.title ? calendarEvent.title.replace(/\n/g, " ") : "");
case "startDate":
return formatUnifinderEventDateTime(calendarEvent.startDate);
@@ -788,46 +788,46 @@ var unifinderTreeView = {
case "calendar":
return calendarEvent.calendar.name;
default:
return false;
}
},
- setTree: function uTV_setTree(tree) {
+ setTree: function(tree) {
this.tree = tree;
},
- toggleOpenState: function uTV_toggleOpenState(aRow) {},
+ toggleOpenState: function(aRow) {},
- cycleHeader: function uTV_cycleHeader(col) {
+ cycleHeader: function(col) {
if (!this.selectedColumn) {
this.sortDirection = "ascending";
} else if (!this.sortDirection || this.sortDirection == "descending") {
this.sortDirection = "ascending";
} else {
this.sortDirection = "descending";
}
this.selectedColumn = col.element;
this.sortItems();
},
- isEditable: function uTV_isEditable(aRow, aCol) {
+ isEditable: function(aRow, aCol) {
return false;
},
- setCellValue: function uTV_setCellValue(aRow, aCol, aValue) {},
- setCellText: function uTV_setCellText(aRow, aCol, aValue) {},
+ setCellValue: function(aRow, aCol, aValue) {},
+ setCellText: function(aRow, aCol, aValue) {},
- performAction: function uTV_performAction(aAction) {},
+ performAction: function(aAction) {},
- performActionOnRow: function uTV_performActionOnRow(aAction, aRow) {},
+ performActionOnRow: function(aAction, aRow) {},
- performActionOnCell: function uTV_performActionOnCell(aAction, aRow, aCol) {},
+ performActionOnCell: function(aAction, aRow, aCol) {},
outParameter: {} // used to obtain dates during sort
};
/**
* Refresh the unifinder tree by getting items from the composite calendar and
* applying the current filter.
*/
@@ -877,33 +877,24 @@ function addItemsFromCalendar(aCalendar,
// If the unifinder is hidden, don't refresh the events to reduce needed
// getItems calls.
return;
}
let refreshListener = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
mEventArray: [],
- onOperationComplete: function rET_onOperationComplete(aOpCalendar,
- aStatus,
- aOperationType,
- aId,
- aDateTime) {
+ onOperationComplete: function(aOpCalendar, aStatus, aOperationType, aId, aDateTime) {
let refreshTreeInternalFunc = function() {
aAddItemsInternalFunc(refreshListener.mEventArray);
};
setTimeout(refreshTreeInternalFunc, 0);
},
- onGetResult: function rET_onGetResult(aOpCalendar,
- aStatus,
- aItemType,
- aDetail,
- aCount,
- aItems) {
+ onGetResult: function(aOpCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
refreshListener.mEventArray = refreshListener.mEventArray.concat(aItems);
}
};
let filter = 0;
filter |= aCalendar.ITEM_FILTER_TYPE_EVENT;
--- a/calendar/base/content/calendar-view-core.xml
+++ b/calendar/base/content/calendar-view-core.xml
@@ -66,34 +66,33 @@
</content>
<implementation>
<constructor><![CDATA[
Components.utils.import("resource://calendar/modules/calAlarmUtils.jsm");
Components.utils.import("resource://calendar/modules/calUtils.jsm");
Components.utils.import("resource://gre/modules/Preferences.jsm");
- let self = this;
- this.eventNameTextbox.onblur = function onBlur() {
- self.stopEditing(true);
+ this.eventNameTextbox.onblur = () => {
+ this.stopEditing(true);
};
- this.eventNameTextbox.onkeypress = function onKeyPress(event) {
+ this.eventNameTextbox.onkeypress = (event) => {
// save on enter
if (event.keyCode == 13) {
- self.stopEditing(true);
+ this.stopEditing(true);
// abort on escape
} else if (event.keyCode == 27) {
- self.stopEditing(false);
+ this.stopEditing(false);
}
};
- function stopPropagationIfEditing(event) {
- if (self.mEditing) {
+ let stopPropagationIfEditing = (event) => {
+ if (this.mEditing) {
event.stopPropagation();
}
- }
+ };
// while editing, single click positions cursor, so don't propagate.
this.eventNameTextbox.onclick = stopPropagationIfEditing;
// while editing, double click selects words, so don't propagate.
this.eventNameTextbox.ondblclick = stopPropagationIfEditing;
// while editing, don't propagate mousedown/up (selects calEvent).
this.eventNameTextbox.onmousedown = stopPropagationIfEditing;
this.eventNameTextbox.onmouseup = stopPropagationIfEditing;
]]></constructor>
@@ -322,21 +321,20 @@
// If the left button was used and the item is already selected
// and there are no multiple items selected start
// the 'single click edit' timeout. Otherwise select the item too.
// Also, check if the calendar is readOnly or we are offline.
if (this.selected && !(event.ctrlKey || event.metaKey) &&
isCalendarWritable(this.mOccurrence.calendar)) {
- let self = this;
if (this.editingTimer) {
clearTimeout(this.editingTimer);
}
- this.editingTimer = setTimeout(function editingTimeout() { self.startEditing(); }, 350);
+ this.editingTimer = setTimeout(() => this.startEditing(), 350);
} else {
this.select(event);
event.stopPropagation();
}
]]></handler>
<handler event="dblclick" button="0"><![CDATA[
event.stopPropagation();
--- a/calendar/base/content/calendar-views.js
+++ b/calendar/base/content/calendar-views.js
@@ -400,17 +400,17 @@ function updateStyleSheetForViews(aCalen
* Note we need to keep the categoryPrefBranch variable outside of
* initCategories since branch observers only live as long as the branch object
* is alive, and out of categoryManagement to avoid cyclic references.
*/
var categoryPrefBranch;
var categoryManagement = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver]),
- initCategories: function cM_initCategories() {
+ initCategories: function() {
categoryPrefBranch = Services.prefs.getBranch("calendar.category.color.");
let categories = categoryPrefBranch.getChildList("");
// Fix illegally formatted category prefs.
for (let i in categories) {
let category = categories[i];
if (category.search(/[^_0-9a-z-]/) != -1) {
let categoryFix = formatStringForCSSRule(category);
@@ -426,33 +426,33 @@ var categoryManagement = {
}
// Add color information to the stylesheets.
categories.forEach(categoryManagement.updateStyleSheetForCategory,
categoryManagement);
categoryPrefBranch.addObserver("", categoryManagement, false);
},
- cleanupCategories: function cM_cleanupCategories() {
+ cleanupCategories: function() {
categoryPrefBranch = Services.prefs.getBranch("calendar.category.color.");
categoryPrefBranch.removeObserver("", categoryManagement);
},
- observe: function cM_observe(aSubject, aTopic, aPrefName) {
+ observe: function(aSubject, aTopic, aPrefName) {
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: {},
- updateStyleSheetForCategory: function cM_updateStyleSheetForCategory(aCatName) {
+ updateStyleSheetForCategory: function(aCatName) {
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~="' + aCatName + '"] {} ';
let ruleIndex = sheet.insertRule(ruleString, sheet.cssRules.length);
this.categoryStyleCache[aCatName] = sheet.cssRules[ruleIndex];
}
@@ -637,23 +637,20 @@ function editSelectedEvents() {
/**
* Select all events from all calendars. Use with care.
*/
function selectAllEvents() {
let items = [];
let listener = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
- onOperationComplete: function selectAll_ooc(aCalendar, aStatus,
- aOperationType, aId,
- aDetail) {
+ onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
currentView().setSelectedItems(items.length, items, false);
},
- onGetResult: function selectAll_ogr(aCalendar, aStatus, aItemType,
- aDetail, aCount, aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
for (let item of aItems) {
items.push(item);
}
}
};
let composite = getCompositeCalendar();
let filter = composite.ITEM_FILTER_CLASS_OCCURRENCES;
@@ -673,17 +670,17 @@ function selectAllEvents() {
let end = currentView().endDay.clone();
end.day += 1;
composite.getItems(filter, 0, currentView().startDay, end, listener);
}
var cal = cal || {};
cal.navigationBar = {
- setDateRange: function setDateRange(aStartDate, aEndDate) {
+ setDateRange: function(aStartDate, aEndDate) {
let docTitle = "";
if (aStartDate) {
let intervalLabel = document.getElementById("intervalDescription");
let firstWeekNo = getWeekInfoService().getWeekTitle(aStartDate);
let secondWeekNo = firstWeekNo;
let weekLabel = document.getElementById("calendarWeek");
if (aStartDate.nativeTime == aEndDate.nativeTime) {
intervalLabel.value = getDateFormatter().formatDate(aStartDate);
--- a/calendar/base/content/calendar-views.xml
+++ b/calendar/base/content/calendar-views.xml
@@ -51,20 +51,19 @@
</implementation>
</binding>
<binding id="calendar-week-view"
extends="chrome://calendar/content/calendar-multiday-view.xml#calendar-multiday-view">
<implementation implements="calICalendarView">
<constructor><![CDATA[
// add a listener for the mode change
- let self = this;
- this.mModeHandler = function modeHandler(event) {
+ this.mModeHandler = (event) => {
if (event.attrName == "mode") {
- self.onModeChanged(event);
+ this.onModeChanged(event);
}
};
document.getElementById("modeBroadcaster").addEventListener("DOMAttrModified", this.mModeHandler, true);
]]></constructor>
<destructor><![CDATA[
document.getElementById("modeBroadcaster").removeEventListener("DOMAttrModified", this.mModeHandler, true);
]]></destructor>
--- a/calendar/base/content/dialogs/calendar-alarm-dialog.js
+++ b/calendar/base/content/dialogs/calendar-alarm-dialog.js
@@ -94,17 +94,17 @@ var gRelativeDateUpdateTimer;
function setupWindow() {
// We want to update when we are at 0 seconds past the minute. To do so, use
// setTimeout to wait until we are there, then setInterval to execute every
// minute. Since setInterval is not totally exact, we may run into problems
// here. I hope not!
let current = new Date();
let timeout = (60 - current.getSeconds()) * 1000;
- gRelativeDateUpdateTimer = setTimeout(function wait_until_next_minute() {
+ gRelativeDateUpdateTimer = setTimeout(() => {
updateRelativeDates();
gRelativeDateUpdateTimer = setInterval(updateRelativeDates, 60 * 1000);
}, timeout);
// Give focus to the alarm richlist after onload completes. See bug 103197
setTimeout(onFocusWindow, 0);
}
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.js
@@ -104,17 +104,17 @@ function onLoad() {
scrollbar.boxObject.height + "px; }", 0);
break;
}
}
// attach an observer to get notified of changes
// that are relevant to this dialog.
let prefObserver = {
- observe: function aD_observe(aSubject, aTopic, aPrefName) {
+ observe: function(aSubject, aTopic, aPrefName) {
switch (aPrefName) {
case "calendar.view.daystarthour":
case "calendar.view.dayendhour":
initTimeRange();
propagateDateTime();
break;
}
}
@@ -989,17 +989,17 @@ function onTimeChange(event) {
* binding. It has been taken out of the binding to prevent leaks.
*/
function calFreeBusyListener(aFbElement, aBinding) {
this.mFbElement = aFbElement;
this.mBinding = aBinding;
}
calFreeBusyListener.prototype = {
- onResult: function cFBL_onResult(aRequest, aEntries) {
+ onResult: function(aRequest, aEntries) {
if (aRequest && !aRequest.isPending) {
// Find request in list of pending requests and remove from queue:
this.mBinding.mPendingRequests = this.mBinding.mPendingRequests.filter(aOp => aRequest.id != aOp.id);
}
if (aEntries) {
this.mFbElement.onFreeBusy(aEntries);
}
}
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees.xml
@@ -66,21 +66,17 @@
<constructor><![CDATA[
Components.utils.import("resource://calendar/modules/calUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource:///modules/mailServices.js");
this.mMaxAttendees = 0;
- let self = this;
- let load = function loadHandler() {
- self.onLoad();
- };
- window.addEventListener("load", load, true);
+ window.addEventListener("load", this.onLoad.bind(this), true);
]]></constructor>
<method name="onLoad">
<body><![CDATA[
this.onInitialize();
// this trigger the continous update chain, which
// effectively calls this.onModify() on predefined
@@ -703,22 +699,20 @@
<property name="documentSize">
<getter><![CDATA[
return this.mRowHeight * this.mMaxAttendees;
]]></getter>
</property>
<method name="fitDummyRows">
<body><![CDATA[
- let self = this;
- let func = function attendees_list_fitDummyRows() {
- self.calcContentHeight();
- self.createOrRemoveDummyRows();
- };
- setTimeout(func, 0);
+ setTimeout(() => {
+ this.calcContentHeight();
+ this.createOrRemoveDummyRows();
+ }, 0);
]]></body>
</method>
<method name="calcContentHeight">
<body><![CDATA[
let listbox =
document.getAnonymousElementByAttribute(
this, "anonid", "listbox");
--- a/calendar/base/content/dialogs/calendar-event-dialog-freebusy.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-freebusy.xml
@@ -436,21 +436,17 @@
// of the timebar starts. The range is the number of days
// we should be able to show. The start- and enddate
// is the time the event is scheduled for.
let kDefaultTimezone = calendarDefaultTimezone();
this.startDate = startTime.getInTimezone(kDefaultTimezone);
this.endDate = endTime.getInTimezone(kDefaultTimezone);
this.mRange = Number(this.getAttribute("range"));
- let self = this;
- let load = function loadHandler() {
- self.onLoad();
- };
- window.addEventListener("load", load, true);
+ window.addEventListener("load", this.onLoad.bind(this), true);
]]></constructor>
<method name="refresh">
<body><![CDATA[
let date = this.mStartDate.clone();
let template =
document.getAnonymousElementByAttribute(
this, "anonid", "template");
@@ -1081,25 +1077,18 @@
this.initTimeRange();
this.mRange = Number(this.getAttribute("range"));
this.mMaxFreeBusy = 0;
this.mPendingRequests = [];
- let self = this;
- let load = function freebusy_grid_loadHandler() {
- self.onLoad();
- };
- window.addEventListener("load", load, true);
- let unload = function freebusy_grid_unloadHandler() {
- self.onUnload();
- };
- window.addEventListener("unload", unload, true);
+ window.addEventListener("load", this.onLoad.bind(this), true);
+ window.addEventListener("unload", this.onUnload.bind(this), true);
]]></constructor>
<property name="startDate">
<getter><![CDATA[
return this.mStartDate;
]]></getter>
<setter><![CDATA[
this.mStartDate = val.clone();
@@ -1497,22 +1486,20 @@
}
}
return null;
]]></body>
</method>
<method name="fitDummyRows">
<body><![CDATA[
- let self = this;
- let func = function func() {
- self.calcContentHeight();
- self.createOrRemoveDummyRows();
- };
- setTimeout(func, 0);
+ setTimeout(() => {
+ this.calcContentHeight();
+ this.createOrRemoveDummyRows();
+ }, 0);
]]></body>
</method>
<method name="calcContentHeight">
<body><![CDATA[
let listbox =
document.getAnonymousElementByAttribute(
this, "anonid", "listbox");
--- a/calendar/base/content/dialogs/calendar-event-dialog-recurrence-preview.xml
+++ b/calendar/base/content/dialogs/calendar-event-dialog-recurrence-preview.xml
@@ -32,20 +32,17 @@
<implementation>
<field name="mRecurrenceInfo">null</field>
<field name="mResizeHandler">null</field>
<field name="mDateTime">null</field>
<constructor><![CDATA[
- let self = this;
- this.mResizeHandler = function recurrence_preview_resizeHandler() {
- self.onResize();
- };
+ this.mResizeHandler = this.onResize.bind(this);
window.addEventListener("resize", this.mResizeHandler, true);
]]></constructor>
<destructor><![CDATA[
window.removeEventListener("resize", this.mResizeHandler, true);
]]></destructor>
<property name="dateTime">
--- a/calendar/base/content/dialogs/calendar-invitations-dialog.js
+++ b/calendar/base/content/dialogs/calendar-invitations-dialog.js
@@ -10,38 +10,29 @@ Components.utils.import("resource://gre/
/**
* Sets up the invitations dialog from the window arguments, retrieves the
* invitations from the invitations manager.
*/
function onLoad() {
let operationListener = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
- onOperationComplete: function oL_onOperationComplete(aCalendar,
- aStatus,
- aOperationType,
- aId,
- aDetail) {
+ onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
let updatingBox = document.getElementById("updating-box");
updatingBox.setAttribute("hidden", "true");
let richListBox = document.getElementById("invitations-listbox");
if (richListBox.getRowCount() > 0) {
richListBox.selectedIndex = 0;
} else {
let noInvitationsBox =
document.getElementById("noinvitations-box");
noInvitationsBox.removeAttribute("hidden");
}
},
- onGetResult: function oL_onGetResult(aCalendar,
- aStatus,
- aItemType,
- aDetail,
- aCount,
- aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
if (!Components.isSuccessCode(aStatus)) {
return;
}
document.title = invitationsText + " (" + aCount + ")";
let updatingBox = document.getElementById("updating-box");
updatingBox.setAttribute("hidden", "true");
let richListBox = document.getElementById("invitations-listbox");
for (let item of aItems) {
--- a/calendar/base/content/dialogs/calendar-print-dialog.js
+++ b/calendar/base/content/dialogs/calendar-print-dialog.js
@@ -134,22 +134,20 @@ function getPrintSettings(receiverFunc)
dump("Error : no case in printDialog.js::printCalendar()");
}
// Some filters above might have filled the events list themselves. If not,
// then fetch the items here.
if (requiresFetch) {
let listener = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
- onOperationComplete:
- function onOperationComplete(aCalendar, aStatus, aOperationType, aId, aDateTime) {
+ onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDateTime) {
receiverFunc(settings);
},
- onGetResult:
- function onGetResult(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
settings.eventList = settings.eventList.concat(aItems);
if (!settings.printTasksWithNoDueDate) {
eventWithDueDate = [];
for (let item of settings.eventList) {
if (item.dueDate || item.endDate) {
eventWithDueDate.push(item);
}
}
@@ -194,17 +192,17 @@ function getFilter(settings) {
}
/**
* Looks at the selections the user has made (start date, layout, etc.), and
* updates the HTML in the iframe accordingly. This is also called when a
* dialog UI element has changed, since we'll want to refresh the preview.
*/
function refreshHtml(finishFunc) {
- getPrintSettings(function getSettingsResponse(settings) {
+ getPrintSettings((settings) => {
document.title = calGetString("calendar", "PrintPreviewWindowTitle", [settings.title]);
let printformatter = Components.classes[settings.layoutCId]
.createInstance(Components.interfaces.calIPrintFormatter);
let html = "";
try {
let pipe = Components.classes["@mozilla.org/pipe;1"]
.createInstance(Components.interfaces.nsIPipe);
@@ -245,61 +243,60 @@ function refreshHtml(finishFunc) {
);
}
/**
* This is a nsIWebProgressListener that closes the dialog on completion, makes
* sure printing works without issues
*/
var closeOnComplete = {
- onStateChange: function onStateChange(aProgress, aRequest, aStateFlags, aStatus) {
+ onStateChange: function(aProgress, aRequest, aStateFlags, aStatus) {
if (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) {
// The request is complete, close the window.
document.documentElement.cancelDialog();
}
},
onProgressChange: function() {},
onLocationChange: function() {},
onStatusChange: function() {},
onSecurityChange: function() {}
};
/**
* Prints the document and then closes the window
*/
function printAndClose() {
- refreshHtml(
- function finish() {
- let webBrowserPrint = PrintUtils.getWebBrowserPrint();
- let printSettings = PrintUtils.getPrintSettings();
+ refreshHtml(() => {
+ let webBrowserPrint = PrintUtils.getWebBrowserPrint();
+ let printSettings = PrintUtils.getPrintSettings();
- // Evicts "about:blank" header
- printSettings.docURL = " ";
+ // Evicts "about:blank" header
+ printSettings.docURL = " ";
- // Start the printing, this is just what PrintUtils does, but we
- // apply our own settings.
- try {
- webBrowserPrint.print(printSettings, closeOnComplete);
- if (gPrintSettingsAreGlobal && gSavePrintSettings) {
- let PSSVC = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
- .getService(Components.interfaces.nsIPrintSettingsService);
- PSSVC.savePrintSettingsToPrefs(printSettings, true,
- printSettings.kInitSaveAll);
- PSSVC.savePrintSettingsToPrefs(printSettings, false,
- printSettings.kInitSavePrinterName);
- }
- } catch (e) {
- // Pressing cancel is expressed as an NS_ERROR_ABORT return value,
- // causing an exception to be thrown which we catch here.
- if (e.result != Components.results.NS_ERROR_ABORT) {
- throw e;
- }
+ // Start the printing, this is just what PrintUtils does, but we
+ // apply our own settings.
+ try {
+ webBrowserPrint.print(printSettings, closeOnComplete);
+ if (gPrintSettingsAreGlobal && gSavePrintSettings) {
+ let PSSVC = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
+ .getService(Components.interfaces.nsIPrintSettingsService);
+ PSSVC.savePrintSettingsToPrefs(printSettings, true,
+ printSettings.kInitSaveAll);
+ PSSVC.savePrintSettingsToPrefs(printSettings, false,
+ printSettings.kInitSavePrinterName);
}
- });
+ } catch (e) {
+ // Pressing cancel is expressed as an NS_ERROR_ABORT return value,
+ // causing an exception to be thrown which we catch here.
+ if (e.result != Components.results.NS_ERROR_ABORT) {
+ throw e;
+ }
+ }
+ });
return false; // leave open
}
/**
* Called when once a date has been selected in the datepicker.
*/
function onDatePick() {
calRadioGroupSelectItem("view-field", "custom-range");
--- a/calendar/base/content/dialogs/calendar-subscriptions-dialog.js
+++ b/calendar/base/content/dialogs/calendar-subscriptions-dialog.js
@@ -101,17 +101,17 @@ function onSearch() {
richListBox.clear();
let registeredCals = {};
for (let calendar of getCalendarManager().getCalendars({})) {
registeredCals[calendar.id] = true;
}
let opListener = {
- onResult: function search_onResult(op, result) {
+ onResult: function(op, result) {
if (result) {
for (let calendar of result) {
richListBox.addCalendar(calendar, registeredCals[calendar.id]);
}
}
if (!op.isPending) {
let statusDeck = document.getElementById("status-deck");
if (richListBox.getRowCount() > 0) {
--- a/calendar/base/content/dialogs/calendar-summary-dialog.js
+++ b/calendar/base/content/dialogs/calendar-summary-dialog.js
@@ -23,23 +23,20 @@ function onLoad() {
// the calling entity provides us with an object that is responsible
// for recording details about the initiated modification. the 'finalize'-property
// is our hook in order to receive a notification in case the operation needs
// to be terminated prematurely. this function will be called if the calling
// entity needs to immediately terminate the pending modification. in this
// case we serialize the item and close the window.
if (args.job) {
- // keep this context...
- let self = this;
-
// store the 'finalize'-functor in the provided job-object.
- args.job.finalize = function finalize() {
+ args.job.finalize = () => {
// store any pending modifications...
- self.onAccept();
+ this.onAccept();
let calendarItem = window.calendarItem;
// ...and close the window.
window.close();
return calendarItem;
};
--- a/calendar/base/content/import-export.js
+++ b/calendar/base/content/import-export.js
@@ -107,17 +107,17 @@ function loadEventsFromFile(aCalendar) {
return;
} else if (calendars.length == 1) {
// There's only one calendar, so it's silly to ask what calendar
// the user wants to import into.
putItemsIntoCal(calendars[0], items, filePath);
} else {
// Ask what calendar to import into
let args = {};
- args.onOk = function putItems(aCal) { putItemsIntoCal(aCal, items, filePath); };
+ args.onOk = (aCal) => { putItemsIntoCal(aCal, items, filePath); };
args.calendars = calendars;
args.promptText = calGetString("calendar", "importPrompt");
openDialog("chrome://calendar/content/chooseCalendarDialog.xul",
"_blank", "chrome,titlebar,modal,resizable", args);
}
}
}
--- a/calendar/base/content/preferences/alarms.js
+++ b/calendar/base/content/preferences/alarms.js
@@ -10,74 +10,74 @@ Components.utils.import("resource://gre/
/**
* Global Object to hold methods for the alarms pref pane
*/
var gAlarmsPane = {
/**
* Initialize the alarms pref pane. Sets up dialog controls to match the
* values set in prefs.
*/
- init: function gAP_init() {
+ init: function() {
// Enable/disable the alarm sound URL box and buttons
this.alarmsPlaySoundPrefChanged();
// Set the correct singular/plural for the time units
updateMenuLabelsPlural("eventdefalarmlen", "eventdefalarmunit");
updateMenuLabelsPlural("tododefalarmlen", "tododefalarmunit");
updateUnitLabelPlural("defaultsnoozelength", "defaultsnoozelengthunit", "minutes");
},
/**
* Converts the given file url to a nsILocalFile
*
* @param aFileURL A string with a file:// url.
* @return The corresponding nsILocalFile.
*/
- convertURLToLocalFile: function gAP_convertURLToLocalFile(aFileURL) {
+ convertURLToLocalFile: function(aFileURL) {
// Convert the file url into a nsILocalFile
if (aFileURL) {
let fph = Services.io
.getProtocolHandler("file")
.QueryInterface(Components.interfaces.nsIFileProtocolHandler);
return fph.getFileFromURLSpec(aFileURL);
} else {
return null;
}
},
/**
* Handler function to be called when the calendar.alarms.soundURL pref has
* changed. Updates the label in the dialog.
*/
- readSoundLocation: function gAP_readSoundLocation() {
+ readSoundLocation: function() {
let soundUrl = document.getElementById("alarmSoundFileField");
soundUrl.value = document.getElementById("calendar.alarms.soundURL").value;
if (soundUrl.value.startsWith("file://")) {
soundUrl.label = this.convertURLToLocalFile(soundUrl.value).leafName;
} else {
soundUrl.label = soundUrl.value;
}
soundUrl.image = "moz-icon://" + soundUrl.label + "?size=16";
return undefined;
},
/**
* Causes the default sound to be selected in the dialog controls
*/
- useDefaultSound: function gAP_useDefaultSound() {
+ useDefaultSound: function() {
let defaultSoundUrl = "chrome://calendar/content/sound.wav";
document.getElementById("calendar.alarms.soundURL").value = defaultSoundUrl;
document.getElementById("alarmSoundCheckbox").checked = true;
this.readSoundLocation();
},
/**
* Opens a filepicker to open a local sound for the alarm.
*/
- browseAlarm: function gAP_browseAlarm() {
+ browseAlarm: function() {
const nsIFilePicker = Components.interfaces.nsIFilePicker;
let fp = Components.classes["@mozilla.org/filepicker;1"]
.createInstance(nsIFilePicker);
let bundlePreferences = document.getElementById("bundleCalendarPreferences");
let title = bundlePreferences.getString("Open");
let wildmat = "*.wav";
let label = bundlePreferences.getFormattedString("filterWav", [wildmat], 1);
@@ -93,17 +93,17 @@ var gAlarmsPane = {
document.getElementById("alarmSoundCheckbox").checked = true;
this.readSoundLocation();
}
},
/**
* Plays the alarm sound currently selected.
*/
- previewAlarm: function gAP_previewAlarm() {
+ previewAlarm: function() {
let soundUrl = document.getElementById("alarmSoundFileField").value;
let soundIfc = Components.classes["@mozilla.org/sound;1"]
.createInstance(Components.interfaces.nsISound);
let url;
try {
soundIfc.init();
if (soundUrl && soundUrl.length && soundUrl.length > 0) {
url = Services.io.newURI(soundUrl, null, null);
@@ -116,17 +116,17 @@ var gAlarmsPane = {
}
},
/**
* Handler function to call when the calendar.alarms.playsound preference
* has been changed. Updates the disabled state of fields that depend on
* playing a sound.
*/
- alarmsPlaySoundPrefChanged: function gAP_alarmsPlaySoundPrefChanged() {
+ alarmsPlaySoundPrefChanged: function() {
let alarmsPlaySoundPref =
document.getElementById("calendar.alarms.playsound");
let items = [document.getElementById("alarmSoundFileField"),
document.getElementById("calendar.prefs.alarm.sound.useDefault"),
document.getElementById("calendar.prefs.alarm.sound.browse"),
document.getElementById("calendar.prefs.alarm.sound.play")];
--- a/calendar/base/content/preferences/categories.js
+++ b/calendar/base/content/preferences/categories.js
@@ -15,17 +15,17 @@ var categoryPrefBranch = Services.prefs.
* Global Object to hold methods for the categories pref pane
*/
var gCategoriesPane = {
/**
* Initialize the categories pref pane. Sets up dialog controls to show the
* categories saved in preferences.
*/
- init: function gCP_init() {
+ init: function() {
// On non-instant-apply platforms, once this pane has been loaded,
// attach our "revert all changes" function to the parent prefwindow's
// "ondialogcancel" event.
let parentPrefWindow = document.documentElement;
if (!parentPrefWindow.instantApply) {
let existingOnDialogCancel = parentPrefWindow.getAttribute("ondialogcancel");
parentPrefWindow.setAttribute("ondialogcancel",
"gCategoriesPane.panelOnCancel(); " +
@@ -58,23 +58,23 @@ var gCategoriesPane = {
this.updateCategoryList();
},
/**
* Updates the listbox containing the categories from the categories saved
* in preferences.
*/
- updatePrefs: function gCP_updatePrefs() {
+ updatePrefs: function() {
cal.sortArrayByLocaleCollator(gCategoryList);
document.getElementById("calendar.categories.names").value =
categoriesArrayToString(gCategoryList);
},
- updateCategoryList: function gCP_updateCategoryList() {
+ updateCategoryList: function() {
this.updatePrefs();
let listbox = document.getElementById("categorieslist");
listbox.clearSelection();
this.updateButtons();
while (listbox.lastChild.id != "categoryColumns") {
@@ -101,34 +101,34 @@ var gCategoriesPane = {
listbox.appendChild(newListItem);
}
},
/**
* Adds a category, opening the edit category dialog to prompt the user to
* set up the category.
*/
- addCategory: function gCP_addCategory() {
+ addCategory: function() {
let listbox = document.getElementById("categorieslist");
listbox.clearSelection();
this.updateButtons();
window.openDialog("chrome://calendar/content/preferences/editCategory.xul",
"addCategory",
// Workaround for Bug 1151440 - the HTML color picker won't work
// in linux when opened from modal dialog
AppConstants.platform == "linux"
? "centerscreen,chrome,resizable=no"
: "modal,centerscreen,chrome,resizable=no",
"", null, addTitle);
},
/**
* Edits the currently selected category using the edit category dialog.
*/
- editCategory: function gCP_editCategory() {
+ editCategory: function() {
let list = document.getElementById("categorieslist");
let categoryNameFix = 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.
}
@@ -143,17 +143,17 @@ var gCategoriesPane = {
: "modal,centerscreen,chrome,resizable=no",
gCategoryList[list.selectedIndex], currentColor, editTitle);
}
},
/**
* Removes the selected category.
*/
- deleteCategory: function gCP_deleteCategory() {
+ deleteCategory: function() {
let list = document.getElementById("categorieslist");
if (list.selectedCount < 1) {
return;
}
let categoryNameFix = formatStringForCSSRule(gCategoryList[list.selectedIndex]);
this.backupData(categoryNameFix);
try {
@@ -183,17 +183,17 @@ var gCategoriesPane = {
},
/**
* Saves the given category to the preferences.
*
* @param categoryName The name of the category.
* @param categoryColor The color of the category
*/
- saveCategory: function gCP_saveCateogry(categoryName, categoryColor) {
+ saveCategory: function(categoryName, categoryColor) {
let list = document.getElementById("categorieslist");
// Check to make sure another category doesn't have the same name
let toBeDeleted = -1;
for (let i = 0; i < gCategoryList.length; i++) {
if (i == list.selectedIndex) {
continue;
}
@@ -247,29 +247,29 @@ var gCategoriesPane = {
let updatedCategory = gCategoryList.indexOf(categoryName);
list.ensureIndexIsVisible(updatedCategory);
list.selectedIndex = updatedCategory;
},
/**
* Enable the edit and delete category buttons.
*/
- updateButtons: function gCP_updateButtons() {
+ updateButtons: function() {
let categoriesList = document.getElementById("categorieslist");
document.getElementById("deleteCButton").disabled = (categoriesList.selectedCount <= 0);
document.getElementById("editCButton").disabled = (categoriesList.selectedCount != 1);
},
/**
* Backs up the category name in case the dialog is canceled.
*
* @see formatStringForCSSRule
* @param categoryNameFix The formatted category name.
*/
- backupData: function gCP_backupData(categoryNameFix) {
+ backupData: function(categoryNameFix) {
let currentColor;
try {
currentColor = categoryPrefBranch.getCharPref(categoryNameFix);
} catch (ex) {
dump("Exception caught in 'backupData': " + ex + "\n");
currentColor = "##NEW";
}
@@ -282,27 +282,27 @@ var gCategoriesPane = {
{ name: categoryNameFix, color: currentColor };
},
/**
* Event Handler function to be called on doubleclick of the categories
* list. If the edit function is enabled and the user doubleclicked on a
* list item, then edit the selected category.
*/
- listOnDblClick: function gCP_listOnDblClick(event) {
+ listOnDblClick: function(event) {
if (event.target.localName == "listitem" &&
!document.getElementById("editCButton").disabled) {
this.editCategory();
}
},
/**
* Reverts category preferences in case the cancel button is pressed.
*/
- panelOnCancel: function gCP_panelOnCancel() {
+ panelOnCancel: function() {
for (let i = 0; i < parent.backupPrefList.length; i++) {
if (parent.backupPrefList[i].color == "##NEW") {
try {
categoryPrefBranch.clearUserPref(parent.backupPrefList[i].name);
} catch (ex) {
dump("Exception caught in 'panelOnCancel': " + ex + "\n");
}
} else {
--- a/calendar/base/content/preferences/general.js
+++ b/calendar/base/content/preferences/general.js
@@ -9,17 +9,17 @@ Components.utils.import("resource://cale
/**
* Global Object to hold methods for the general pref pane
*/
var gCalendarGeneralPane = {
/**
* Initialize the general pref pane. Sets up dialog controls to match the
* values set in prefs.
*/
- init: function gCGP_init() {
+ init: function() {
let df = Components.classes["@mozilla.org/calendar/datetime-formatter;1"]
.getService(Components.interfaces.calIDateTimeFormatter);
let dateFormattedLong = df.formatDateLong(now());
let dateFormattedShort = df.formatDateShort(now());
// menu items include examples of current date formats.
document.getElementById("dateformat-long-menuitem")
@@ -59,17 +59,17 @@ var gCalendarGeneralPane = {
prefValue = calendarDefaultTimezone().tzid;
}
tzMenuList.value = prefValue;
// Set the soondays menulist preference
this.initializeTodaypaneMenu();
},
- updateDefaultTodoDates: function gCGP_updateDefaultTodoDates() {
+ updateDefaultTodoDates: function() {
let defaultDue = document.getElementById("default_task_due").value;
let defaultStart = document.getElementById("default_task_start").value;
let offsetValues = ["offsetcurrent", "offsetnexthour"];
document.getElementById("default_task_due_offset")
.style.visibility = offsetValues.includes(defaultDue) ? "" : "hidden";
document.getElementById("default_task_start_offset")
.style.visibility = offsetValues.includes(defaultStart) ? "" : "hidden";
@@ -79,17 +79,17 @@ var gCalendarGeneralPane = {
},
updateItemtypeDeck: function() {
let panelId = document.getElementById("defaults-itemtype-menulist").value;
let panel = document.getElementById(panelId);
document.getElementById("defaults-itemtype-deck").selectedPanel = panel;
},
- initializeTodaypaneMenu: function gCGP_initializeTodaypaneMenu() {
+ initializeTodaypaneMenu: function() {
// Assign the labels for the menuitem
let soondaysMenu = document.getElementById("soondays-menulist");
let items = soondaysMenu.getElementsByTagName("menuitem");
for (let menuItem of items) {
let menuitemValue = Number(menuItem.value);
if (menuitemValue > 7) {
menuItem.label = unitPluralForm(menuitemValue / 7, "weeks");
} else {
@@ -110,13 +110,13 @@ var gCalendarGeneralPane = {
} else {
soonpref = soonpref > 28 ? 28 : 1;
Preferences.set(prefName, soonpref, "INT");
}
document.getElementById("soondays-menulist").value = soonpref;
},
- updateTodaypaneMenu: function gCGP_updateTodaypaneMenu() {
+ updateTodaypaneMenu: function() {
let soonpref = Number(document.getElementById("soondays-menulist").value);
Preferences.set("calendar.agendaListbox.soondays", soonpref);
}
};
--- a/calendar/base/content/preferences/views.js
+++ b/calendar/base/content/preferences/views.js
@@ -7,28 +7,28 @@
/**
* Global Object to hold methods for the views pref pane
*/
var gViewsPane = {
/**
* Initialize the views pref pane. Sets up dialog controls to match the
* values set in prefs.
*/
- init: function gVP_init() {
+ init: function() {
this.updateViewEndMenu(document.getElementById("daystarthour").value);
this.updateViewStartMenu(document.getElementById("dayendhour").value);
this.updateViewWorkDayCheckboxes(document.getElementById("weekstarts").value);
this.initializeViewStartEndMenus();
},
/**
* Initialize the strings for the "day starts at" and "day ends at"
* menulists. This is needed to respect locales that use AM/PM.
*/
- initializeViewStartEndMenus: function gVP_initializeViewStartEndMenus() {
+ initializeViewStartEndMenus: function() {
let labelIdStart;
let labelIdEnd;
let timeFormatter = Components.classes["@mozilla.org/intl/scriptabledateformat;1"]
.getService(Components.interfaces.nsIScriptableDateFormat);
// 1 to 23 instead of 0 to 24 to keep midnight & noon as the localized strings
for (let theHour = 1; theHour <= 23; theHour++) {
let time = timeFormatter.FormatTime("", Components.interfaces.nsIScriptableDateFormat
.timeFormatNoSeconds, theHour, 0, 0);
@@ -48,17 +48,17 @@ var gViewsPane = {
/**
* Updates the view end menu to only display hours after the selected view
* start.
*
* @param aStartValue The value selected for view start.
*/
- updateViewEndMenu: function gVP_updateViewEndMenu(aStartValue) {
+ updateViewEndMenu: function(aStartValue) {
let endMenuKids = document.getElementById("dayendhourpopup")
.childNodes;
for (let i = 0; i < endMenuKids.length; i++) {
if (Number(endMenuKids[i].value) <= Number(aStartValue)) {
endMenuKids[i].setAttribute("hidden", true);
} else {
endMenuKids[i].removeAttribute("hidden");
}
@@ -66,17 +66,17 @@ var gViewsPane = {
},
/**
* Updates the view start menu to only display hours before the selected view
* end.
*
* @param aEndValue The value selected for view end.
*/
- updateViewStartMenu: function gVP_updateViewStartMenu(aEndValue) {
+ updateViewStartMenu: function(aEndValue) {
let startMenuKids = document.getElementById("daystarthourpopup")
.childNodes;
for (let i = 0; i < startMenuKids.length; i++) {
if (Number(startMenuKids[i].value) >= Number(aEndValue)) {
startMenuKids[i].setAttribute("hidden", true);
} else {
startMenuKids[i].removeAttribute("hidden");
}
@@ -84,16 +84,16 @@ var gViewsPane = {
},
/**
* Update the workday checkboxes based on the start of the week.
*
* @Param weekStart The (0-based) index of the weekday the week
* should start at.
*/
- updateViewWorkDayCheckboxes: function gVP_updateViewWorkDayCheckboxes(weekStart) {
+ updateViewWorkDayCheckboxes: function(weekStart) {
weekStart = Number(weekStart);
for (let i = weekStart; i < weekStart + 7; i++) {
let checkbox = document.getElementById("dayoff" + (i % 7));
checkbox.parentNode.appendChild(checkbox);
}
}
};
--- a/calendar/base/content/today-pane.js
+++ b/calendar/base/content/today-pane.js
@@ -19,17 +19,17 @@ var TodayPane = {
startY: 0,
distance: 0,
session: false
},
/**
* Load Handler, sets up the today pane controls.
*/
- onLoad: function onLoad() {
+ onLoad: function() {
TodayPane.paneViews = [cal.calGetString("calendar", "eventsandtasks"),
cal.calGetString("calendar", "tasksonly"),
cal.calGetString("calendar", "eventsonly")];
agendaListbox.setupCalendar();
TodayPane.initializeMiniday();
TodayPane.setShortWeekdays();
document.getElementById("modeBroadcaster").addEventListener("DOMAttrModified", TodayPane.onModeModified, false);
@@ -38,26 +38,26 @@ var TodayPane = {
document.getElementById("today-splitter").addEventListener("command", onCalendarViewResize, false);
TodayPane.updateSplitterState();
TodayPane.previousMode = document.getElementById("modeBroadcaster").getAttribute("mode");
},
/**
* Unload handler, cleans up the today pane on window unload.
*/
- onUnload: function onUnload() {
+ onUnload: function() {
document.getElementById("modeBroadcaster").removeEventListener("DOMAttrModified", TodayPane.onModeModified, false);
document.getElementById("today-splitter").removeEventListener("command", onCalendarViewResize, false);
},
/**
* Sets up the label for the switcher that allows switching between today pane
* views. (event+task, task only, event only)
*/
- setTodayHeader: function setTodayHeader() {
+ setTodayHeader: function() {
let currentMode = document.getElementById("modeBroadcaster").getAttribute("mode");
let agendaIsVisible = document.getElementById("agenda-panel").isVisible(currentMode);
let todoIsVisible = document.getElementById("todo-tab-panel").isVisible(currentMode);
let index = 2;
if (agendaIsVisible && todoIsVisible) {
index = 0;
} else if (!agendaIsVisible && todoIsVisible) {
index = 1;
@@ -86,17 +86,17 @@ var TodayPane = {
}
onCalendarViewResize();
},
/**
* Sets up the miniday display in the today pane.
*/
- initializeMiniday: function initializeMiniday() {
+ initializeMiniday: function() {
// initialize the label denoting the current month, year and calendarweek
// with numbers that are supposed to consume the largest width
// in order to guarantee that the text will not be cropped when modified
// during runtime
const kYEARINIT = "5555";
const kCALWEEKINIT = "55";
let monthdisplaydeck = document.getElementById("monthNameContainer");
let childNodes = monthdisplaydeck.childNodes;
@@ -113,17 +113,17 @@ var TodayPane = {
agendaListbox.addListener(this);
this.setDay(now);
},
/**
* Go to month/week/day views when double-clicking a label inside miniday
*/
- onDoubleClick: function md_onDoubleClick(aEvent) {
+ onDoubleClick: function(aEvent) {
if (aEvent.button == 0) {
if (aEvent.target.id == "datevalue-label") {
switchCalendarView("day", true);
} else if (aEvent.target.parentNode.id == "weekdayNameContainer") {
switchCalendarView("day", true);
} else if (aEvent.target.id == "currentWeek-label") {
switchCalendarView("week", true);
} else if (aEvent.target.parentNode.id == "monthNameContainer") {
@@ -137,17 +137,17 @@ var TodayPane = {
currentView().goToDay(agendaListbox.today.start);
}
},
/**
* Set conditions about start dragging on day-label or start switching
* with time on navigation buttons.
*/
- onMousedown: function md_onMousedown(aEvent, aDir) {
+ onMousedown: function(aEvent, aDir) {
if (aEvent.button != 0) {
return;
}
let element = aEvent.target;
if (element.id == "previous-day-button" ||
element.id == "next-day-button") {
// Start switching days by pressing, without release, the navigation buttons
element.addEventListener("mouseout", TodayPane.stopSwitching, false);
@@ -163,17 +163,17 @@ var TodayPane = {
},
/**
* Figure out the mouse distance from the center of the day's label
* to the current position.
*
* NOTE: This function is usually called without the correct this pointer.
*/
- onMousemove: function md_onMousemove(aEvent) {
+ onMousemove: function(aEvent) {
const MIN_DRAG_DISTANCE_SQ = 49;
let x = aEvent.clientX - TodayPane.minidayDrag.startX;
let y = aEvent.clientY - TodayPane.minidayDrag.startY;
if (TodayPane.minidayDrag.session) {
if (x * x + y * y >= MIN_DRAG_DISTANCE_SQ) {
let distance = Math.floor(Math.sqrt(x * x + y * y) - Math.sqrt(MIN_DRAG_DISTANCE_SQ));
// Dragging on the left/right side, the day date decrease/increase
TodayPane.minidayDrag.distance = (x > 0) ? distance : -distance;
@@ -195,17 +195,17 @@ var TodayPane = {
TodayPane.updateAdvanceTimer();
}
},
/**
* Figure out the days switching speed according to the position (when
* dragging) or time elapsed (when pressing buttons).
*/
- updateAdvanceTimer: function md_updateAdvanceTimer(aEvent, aDir) {
+ updateAdvanceTimer: function(aEvent, aDir) {
const INITIAL_TIME = 400;
const REL_DISTANCE = 8;
const MINIMUM_TIME = 100;
const ACCELERATE_COUNT_LIMIT = 7;
const SECOND_STEP_TIME = 200;
if (TodayPane.minidayDrag.session) {
// Dragging the day label: days switch with cursor distance and time.
let dir = (TodayPane.minidayDrag.distance > 0) - (TodayPane.minidayDrag.distance < 0);
@@ -230,17 +230,17 @@ var TodayPane = {
},
/**
* Stop automatic days switching when releasing the mouse button or the
* position is outside the window.
*
* NOTE: This function is usually called without the correct this pointer.
*/
- stopSwitching: function stopSwitching(aEvent) {
+ stopSwitching: function(aEvent) {
let element = aEvent.target;
if (TodayPane.minidayDrag.session &&
aEvent.type == "mouseout" &&
element.id != "messengerWindow") {
return;
}
if (TodayPane.minidayTimer) {
clearTimeout(TodayPane.minidayTimer);
@@ -270,32 +270,32 @@ var TodayPane = {
* Helper function to set the month description on the today pane header.
*
* @param aMonthLabel The XUL node to set the month label on.
* @param aIndex The month number, 0-based.
* @param aYear The year this month should be displayed with
* @param aCalWeek The calendar week that should be shown.
* @return The value set on aMonthLabel.
*/
- setMonthDescription: function setMonthDescription(aMonthLabel, aIndex, aYear, aCalWeek) {
+ setMonthDescription: function(aMonthLabel, aIndex, aYear, aCalWeek) {
if (this.cwlabel == null) {
this.cwlabel = cal.calGetString("calendar", "shortcalendarweek");
}
document.getElementById("currentWeek-label").value = this.cwlabel + " " + aCalWeek;
aMonthLabel.value = cal.getDateFormatter().shortMonthName(aIndex) + " " + aYear;
return aMonthLabel.value;
},
/**
* Cycle the view shown in the today pane (event+task, event, task).
*
* @param aCycleForward If true, the views are cycled in the forward
* direction, otherwise in the opposite direction
*/
- cyclePaneView: function cyclePaneView(aCycleForward) {
+ cyclePaneView: function(aCycleForward) {
if (this.paneViews == null) {
return;
}
let index = parseInt(document.getElementById("today-pane-header").getAttribute("index"), 10);
index = index + aCycleForward;
let nViewLen = this.paneViews.length;
if (index >= nViewLen) {
index = 0;
@@ -310,17 +310,17 @@ var TodayPane = {
todoPanel.setVisible(isTodoPanelVisible);
agendaPanel.setVisible(isAgendaPanelVisible);
this.setTodayHeader();
},
/**
* Shows short weekday names in the weekdayNameContainer
*/
- setShortWeekdays: function setShortWeekdays() {
+ setShortWeekdays: function() {
let weekdisplaydeck = document.getElementById("weekdayNameContainer");
let childNodes = weekdisplaydeck.childNodes;
// Workaround for bug 1070491. Show the correct weekday after
// startup even if deck's selectedIndex is reset to 0.
let weekday = cal.now().weekday + 1;
childNodes[0].setAttribute("value", cal.calGetString("dateFormat", "day." + weekday + ".Mmm"));
@@ -329,30 +329,30 @@ var TodayPane = {
}
},
/**
* Sets the shown date from a JSDate.
*
* @param aNewDate The date to show.
*/
- setDaywithjsDate: function setDaywithjsDate(aNewDate) {
+ setDaywithjsDate: function(aNewDate) {
let newdatetime = cal.jsDateToDateTime(aNewDate, cal.floating());
newdatetime = newdatetime.getInTimezone(cal.calendarDefaultTimezone());
this.setDay(newdatetime, true);
},
/**
* Sets the first day shown in the today pane.
*
* @param aNewDate The calIDateTime to set.
* @param aDontUpdateMinimonth If true, the minimonth will not be
* updated to show the same date.
*/
- setDay: function setDay(aNewDate, aDontUpdateMinimonth) {
+ setDay: function(aNewDate, aDontUpdateMinimonth) {
this.start = aNewDate.clone();
let daylabel = document.getElementById("datevalue-label");
daylabel.value = this.start.day;
let weekdaylabel = document.getElementById("weekdayNameContainer");
weekdaylabel.selectedIndex = this.start.weekday + 1;
@@ -371,58 +371,58 @@ var TodayPane = {
},
/**
* Advance by a given number of days in the today pane.
*
* @param aDir The number of days to advance. Negative numbers advance
* backwards in time.
*/
- advance: function advance(aDir) {
+ advance: function(aDir) {
if (aDir != 0) {
this.start.day += aDir;
this.setDay(this.start);
}
},
/**
* Checks if the today pane is showing today's date.
*/
- showsToday: function showsToday() {
+ showsToday: function() {
return cal.sameDay(cal.now(), this.start);
},
/**
* Update the period headers in the agenda listbox using the today pane's
* start date.
*/
- updatePeriod: function updatePeriod() {
+ updatePeriod: function() {
agendaListbox.refreshPeriodDates(this.start.clone());
updateCalendarToDoUnifinder();
},
/**
* Display a certain section in the minday/minimonth part of the todaypane.
*
* @param aSection The section to display
*/
- displayMiniSection: function displayMiniSection(aSection) {
+ displayMiniSection: function(aSection) {
document.getElementById("today-minimonth-box").setVisible(aSection == "minimonth");
document.getElementById("mini-day-box").setVisible(aSection == "miniday");
document.getElementById("today-none-box").setVisible(aSection == "none");
setBooleanAttribute(document.getElementById("today-Minimonth"), "freebusy", aSection == "minimonth");
},
/**
* Handler function for the DOMAttrModified event used to observe the
* todaypane-splitter.
*
* @param aEvent The DOM event occurring on attribute modification.
*/
- onModeModified: function onModeModified(aEvent) {
+ onModeModified: function(aEvent) {
if (aEvent.attrName == "mode") {
let todaypane = document.getElementById("today-pane-panel");
// Store the previous mode panel's width.
todaypane.setModeAttribute("modewidths", todaypane.width, TodayPane.previousMode);
TodayPane.setTodayHeader();
TodayPane.updateSplitterState();
todaypane.width = todaypane.getModeAttribute("modewidths", "width");
@@ -430,40 +430,40 @@ var TodayPane = {
}
},
/**
* Toggle the today-pane and update its visual appearance.
*
* @param aEvent The DOM event occurring on activated command.
*/
- toggleVisibility: function toggleVisbility(aEvent) {
+ toggleVisibility: function(aEvent) {
document.getElementById("today-pane-panel").togglePane(aEvent);
TodayPane.setTodayHeader();
TodayPane.updateSplitterState();
},
/**
* Update the today-splitter state and today-pane width with saved
* mode-dependent values.
*/
- updateSplitterState: function updateSplitterState() {
+ updateSplitterState: function() {
let splitter = document.getElementById("today-splitter");
let todaypaneVisible = document.getElementById("today-pane-panel").isVisible();
setElementValue(splitter, !todaypaneVisible && "true", "hidden");
if (todaypaneVisible) {
splitter.setAttribute("state", "open");
}
},
/**
* Generates the todaypane toggle command when the today-splitter
* is being collapsed or uncollapsed.
*/
- onCommandTodaySplitter: function onCommandTodaySplitter() {
+ onCommandTodaySplitter: function() {
let todaypane = document.getElementById("today-pane-panel");
let splitterState = document.getElementById("today-splitter").getAttribute("state");
if (splitterState == "collapsed" && todaypane.isVisible() ||
splitterState != "collapsed" && !todaypane.isVisible()) {
document.getElementById("calendar_toggle_todaypane_command").doCommand();
}
}
};
--- a/calendar/base/content/widgets/calendar-list-tree.xml
+++ b/calendar/base/content/widgets/calendar-list-tree.xml
@@ -65,91 +65,87 @@
</property>
<field name="calMgrObserver"><![CDATA[
({
listTree: this,
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calICalendarManagerObserver]),
// calICalendarManagerObserver
- onCalendarRegistered: function cMO_onCalendarRegistered(aCalendar) {
+ onCalendarRegistered: function(aCalendar) {
this.listTree.addCalendar(aCalendar);
let composite = this.listTree.compositeCalendar;
let inComposite = aCalendar.getProperty(composite.prefPrefix +
"-in-composite");
if ((inComposite === null) || inComposite) {
composite.addCalendar(aCalendar);
}
},
- onCalendarUnregistering: function cMO_onCalendarUnregistering(aCalendar) {
+ onCalendarUnregistering: function(aCalendar) {
this.listTree.removeCalendar(aCalendar);
},
- onCalendarDeleting: function cMO_onCalendarDeleting(aCalendar) {
+ onCalendarDeleting: function(aCalendar) {
// Now that the calendar is unregistered, update the commands to
// make sure that New Event/Task commands are correctly
// enabled/disabled.
document.commandDispatcher.updateCommands("calendar_commands");
}
})
]]></field>
<field name="compositeObserver"><![CDATA[
({
listTree: this,
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calICompositeObserver,
Components.interfaces.calIObserver]),
// calICompositeObserver
- onCalendarAdded: function onCalendarAdded(aCalendar) {
+ onCalendarAdded: function(aCalendar) {
// Make sure the checkbox state is updated
this.listTree.updateCalendar(aCalendar);
},
- onCalendarRemoved: function onCalendarRemoved(aCalendar) {
+ onCalendarRemoved: function(aCalendar) {
// Make sure the checkbox state is updated
this.listTree.updateCalendar(aCalendar);
},
- onDefaultCalendarChanged: function cMO_onDefaultCalendarChanged(aCalendar) {
+ onDefaultCalendarChanged: function(aCalendar) {
},
// calIObserver
- onStartBatch: function cO_onStartBatch() { },
- onEndBatch: function cO_onEndBatch() { },
- onLoad: function cO_onLoad() { },
+ onStartBatch: function() { },
+ onEndBatch: function() { },
+ onLoad: function() { },
- onAddItem: function cO_onAddItem(aItem) {
+ onAddItem: function(aItem) {
if (aItem.calendar.type != "caldav") {
this.listTree.ensureCalendarVisible(aItem.calendar);
}
},
- onModifyItem: function cO_onModifyItem(aNewItem, aOldItem) {
+ onModifyItem: function(aNewItem, aOldItem) {
if (aNewItem.calendar.type != "caldav") {
this.listTree.ensureCalendarVisible(aNewItem.calendar);
}
},
- onDeleteItem: function cO_onDeleteItem(aDeletedItem) { },
- onError: function cO_onError(aCalendar, aErrNo, aMessage) { },
+ onDeleteItem: function(aDeletedItem) { },
+ onError: function(aCalendar, aErrNo, aMessage) { },
- onPropertyChanged: function cO_onPropertyChanged(aCalendar,
- aName,
- aValue,
- aOldValue) {
+ onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
switch (aName) {
case "disabled":
case "readOnly":
calendarUpdateNewItemsCommand();
document.commandDispatcher.updateCommands("calendar_commands");
break;
}
},
- onPropertyDeleting: function cO_onPropertyDeleting(aCalendar,
- aName) {
+ onPropertyDeleting: function(aCalendar, aName) {
}
})
]]></field>
</implementation>
<handlers>
<handler event="dblclick"><![CDATA[
let col = {};
let calendar = this.getCalendarFromEvent(event, col);
@@ -253,29 +249,26 @@
]]></destructor>
<field name="calObserver"><![CDATA[
({
listTree: this,
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIObserver]),
// calIObserver. Note that each registered calendar uses this observer
- onStartBatch: function cMO_onStartBatch() { },
- onEndBatch: function cMO_onEndBatch() { },
- onLoad: function cMO_onLoad() { },
+ onStartBatch: function() { },
+ onEndBatch: function() { },
+ onLoad: function() { },
- onAddItem: function cMO_onAddItem(aItem) { },
- onModifyItem: function cMO_onModifyItem(aNewItem, aOldItem) { },
- onDeleteItem: function cMO_onDeleteItem(aDeletedItem) { },
- onError: function cMO_onError(aCalendar, aErrNo, aMessage) { },
+ onAddItem: function(aItem) { },
+ onModifyItem: function(aNewItem, aOldItem) { },
+ onDeleteItem: function(aDeletedItem) { },
+ onError: function(aCalendar, aErrNo, aMessage) { },
- onPropertyChanged: function cMO_onPropertyChanged(aCalendar,
- aName,
- aValue,
- aOldValue) {
+ onPropertyChanged: function(aCalendar, aName, aValue, aOldValue) {
switch (aName) {
case "color":
// TODO See other TODO in this file about updateStyleSheetForViews
if ("updateStyleSheetForViews" in window) {
updateStyleSheetForViews(aCalendar);
}
this.listTree.updateCalendarColor(aCalendar);
// Fall through, update item in any case
@@ -283,43 +276,42 @@
case "currentStatus":
case "readOnly":
case "disabled":
this.listTree.updateCalendar(aCalendar);
// Fall through, update commands in any cases.
}
},
- onPropertyDeleting: function cMO_onPropertyDeleting(aCalendar,
- aName) {
+ onPropertyDeleting: function(aCalendar, aName) {
// Since the old value is not used directly in onPropertyChanged,
// but should not be the same as the value, set it to a different
// value.
this.onPropertyChanged(aCalendar, aName, null, null);
}
})
]]></field>
<field name="compositeObserver"><![CDATA[
({
listTree: this,
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calICompositeObserver]),
// calICompositeObserver
- onCalendarAdded: function onCalendarAdded(aCalendar) {
+ onCalendarAdded: function(aCalendar) {
// Make sure the checkbox state is updated
this.listTree.updateCalendar(aCalendar);
},
- onCalendarRemoved: function onCalendarRemoved(aCalendar) {
+ onCalendarRemoved: function(aCalendar) {
// Make sure the checkbox state is updated
this.listTree.updateCalendar(aCalendar);
},
- onDefaultCalendarChanged: function cMO_onDefaultCalendarChanged(aCalendar) {
+ onDefaultCalendarChanged: function(aCalendar) {
}
})
]]></field>
<property name="treechildren"
readonly="true"
onget="return document.getAnonymousElementByAttribute(this, 'anonid', 'treechildren')"/>
<property name="tree"
--- a/calendar/base/modules/calAlarmUtils.jsm
+++ b/calendar/base/modules/calAlarmUtils.jsm
@@ -9,17 +9,17 @@ this.EXPORTED_SYMBOLS = ["cal"]; // even
cal.alarms = {
/**
* Read default alarm settings from user preferences and apply them to the
* event/todo passed in. The item's calendar should be set to ensure the
* correct alarm type is set.
*
* @param aItem The item to apply the default alarm values to.
*/
- setDefaultValues: function cal_alarm_setDefaultValues(aItem) {
+ setDefaultValues: function(aItem) {
let type = cal.isEvent(aItem) ? "event" : "todo";
if (Preferences.get("calendar.alarms.onfor" + type + "s", 0) == 1) {
let alarmOffset = cal.createDuration();
let alarm = cal.createAlarm();
let units = Preferences.get("calendar.alarms." + type + "alarmunit", "minutes");
// Make sure the alarm pref is valid, default to minutes otherwise
if (!["weeks", "days", "hours", "minutes", "seconds"].includes(units)) {
@@ -49,17 +49,17 @@ cal.alarms = {
/**
* Calculate the alarm date for a calIAlarm.
*
* @param aItem The item used to calculate the alarm date.
* @param aAlarm The alarm to calculate the date for.
* @return The alarm date.
*/
- calculateAlarmDate: function cal_alarm_calculateAlarmDate(aItem, aAlarm) {
+ calculateAlarmDate: function(aItem, aAlarm) {
if (aAlarm.related == aAlarm.ALARM_RELATED_ABSOLUTE) {
return aAlarm.alarmDate;
} else {
let returnDate;
if (aAlarm.related == aAlarm.ALARM_RELATED_START) {
returnDate = aItem[cal.calGetStartDateProp(aItem)];
} else if (aAlarm.related == aAlarm.ALARM_RELATED_END) {
returnDate = aItem[cal.calGetEndDateProp(aItem)];
@@ -92,17 +92,17 @@ cal.alarms = {
* parameter.
*
* @param aItem The item to calculate the offset for.
* @param aAlarm The alarm to calculate the offset for.
* @param aRelated (optional) A relation constant from calIAlarm. If not
* passed, ALARM_RELATED_START will be assumed.
* @return The alarm offset.
*/
- calculateAlarmOffset: function cal_alarms_calculateAlarmOffset(aItem, aAlarm, aRelated) {
+ calculateAlarmOffset: function(aItem, aAlarm, aRelated) {
let offset = aAlarm.offset;
if (aAlarm.related == aAlarm.ALARM_RELATED_ABSOLUTE) {
let returnDate;
if (aRelated === undefined || aRelated == aAlarm.ALARM_RELATED_START) {
returnDate = aItem[cal.calGetStartDateProp(aItem)];
} else if (aRelated == aAlarm.ALARM_RELATED_END) {
returnDate = aItem[cal.calGetEndDateProp(aItem)];
}
@@ -116,17 +116,17 @@ cal.alarms = {
/**
* Adds reminder images to a given node, making sure only one icon per alarm
* action is added.
*
* @param aElement The element to add the images to.
* @param aReminders The set of reminders to add images for.
*/
- addReminderImages: function cal_alarms_addReminderImages(aElement, aReminders) {
+ addReminderImages: function(aElement, aReminders) {
function createOwnedXULNode(el) {
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
return aElement.ownerDocument.createElementNS(XUL_NS, el);
}
function setupActionImage(node, reminder) {
let image = node || createOwnedXULNode("image");
image.setAttribute("class", "reminder-icon");
--- a/calendar/base/modules/calAuthUtils.jsm
+++ b/calendar/base/modules/calAuthUtils.jsm
@@ -10,39 +10,35 @@ Components.utils.import("resource://gre/
* Authentication helper code
*/
this.EXPORTED_SYMBOLS = ["cal"]; // even though it's defined in calUtils.jsm, import needs this
cal.auth = {
/**
* Auth prompt implementation - Uses password manager if at all possible.
*/
- Prompt: function calPrompt() {
+ Prompt: function() {
this.mWindow = cal.getCalendarWindow();
this.mReturnedLogins = {};
},
/**
* Tries to get the username/password combination of a specific calendar name
* from the password manager or asks the user.
*
* @param in aTitle The dialog title.
* @param in aCalendarName The calendar name or url to look up. Can be null.
* @param inout aUsername The username that belongs to the calendar.
* @param inout aPassword The password that belongs to the calendar.
* @param inout aSavePassword Should the password be saved?
* @param in aFixedUsername Whether the user name is fixed or editable
* @return Could a password be retrieved?
*/
- getCredentials: function calGetCredentials(aTitle,
- aCalendarName,
- aUsername,
- aPassword,
- aSavePassword,
- aFixedUsername) {
+ getCredentials: function(aTitle, aCalendarName, aUsername, aPassword,
+ aSavePassword, aFixedUsername) {
if (typeof aUsername != "object" ||
typeof aPassword != "object" ||
typeof aSavePassword != "object") {
throw new Components.Exception("", Components.results.NS_ERROR_XPC_NEED_OUT_OBJECT);
}
let prompter = Services.ww.getNewPrompter(null);
@@ -74,17 +70,17 @@ cal.auth = {
/**
* Helper to insert/update an entry to the password manager.
*
* @param aUserName The username
* @param aPassword The corresponding password
* @param aHostName The corresponding hostname
* @param aRealm The password realm (unused on branch)
*/
- passwordManagerSave: function calPasswordManagerSave(aUsername, aPassword, aHostName, aRealm) {
+ passwordManagerSave: function(aUsername, aPassword, aHostName, aRealm) {
cal.ASSERT(aUsername);
cal.ASSERT(aPassword);
try {
let logins = Services.logins.findLogins({}, aHostName, null, aRealm);
let newLoginInfo = Components.classes["@mozilla.org/login-manager/loginInfo;1"]
.createInstance(Components.interfaces.nsILoginInfo);
@@ -105,17 +101,17 @@ cal.auth = {
* Helper to retrieve an entry from the password manager.
*
* @param in aUsername The username to search
* @param out aPassword The corresponding password
* @param aHostName The corresponding hostname
* @param aRealm The password realm (unused on branch)
* @return Does an entry exist in the password manager
*/
- passwordManagerGet: function calPasswordManagerGet(aUsername, aPassword, aHostName, aRealm) {
+ passwordManagerGet: function(aUsername, aPassword, aHostName, aRealm) {
cal.ASSERT(aUsername);
if (typeof aPassword != "object") {
throw new Components.Exception("", Components.results.NS_ERROR_XPC_NEED_OUT_OBJECT);
}
try {
if (!Services.logins.getLoginSavingEnabled(aUsername)) {
@@ -138,17 +134,17 @@ cal.auth = {
/**
* Helper to remove an entry from the password manager
*
* @param aUsername The username to remove.
* @param aHostName The corresponding hostname
* @param aRealm The password realm (unused on branch)
* @return Could the user be removed?
*/
- passwordManagerRemove: function calPasswordManagerRemove(aUsername, aHostName, aRealm) {
+ passwordManagerRemove: function(aUsername, aHostName, aRealm) {
cal.ASSERT(aUsername);
try {
let logins = Services.logins.findLogins({}, aHostName, null, aRealm);
for (let loginInfo of logins) {
if (loginInfo.username == aUsername) {
Services.logins.removeLogin(loginInfo);
return true;
@@ -169,17 +165,17 @@ cal.auth = {
* This implementation guarantees there are no request loops when an invalid
* password is stored in the login-manager.
*
* There is one instance of that object per calendar provider.
*/
cal.auth.Prompt.prototype = {
mProvider: null,
- getPasswordInfo: function capGPI(aPasswordRealm) {
+ getPasswordInfo: function(aPasswordRealm) {
let username;
let password;
let found = false;
let logins = Services.logins.findLogins({}, aPasswordRealm.prePath, null, aPasswordRealm.realm);
if (logins.length) {
username = logins[0].username;
password = logins[0].password;
@@ -228,17 +224,17 @@ cal.auth.Prompt.prototype = {
* object.
* @retval false
* Authentication should be cancelled, usually because the user did
* not provide username/password.
*
* @note Exceptions thrown from this function will be treated like a
* return value of false.
*/
- promptAuth: function capPA(aChannel, aLevel, aAuthInfo) {
+ promptAuth: function(aChannel, aLevel, aAuthInfo) {
let hostRealm = {};
hostRealm.prePath = aChannel.URI.prePath;
hostRealm.realm = aAuthInfo.realm;
let port = aChannel.URI.port;
if (port == -1) {
let handler = Services.io.getProtocolHandler(aChannel.URI.scheme)
.QueryInterface(Components.interfaces.nsIProtocolHandler);
port = handler.defaultPort;
@@ -270,22 +266,21 @@ cal.auth.Prompt.prototype = {
* Calling nsICancelable::cancel on the returned object SHOULD close the
* dialog and MUST call nsIAuthPromptCallback::onAuthCancelled on the provided
* callback.
*
* @throw NS_ERROR_NOT_IMPLEMENTED
* Asynchronous authentication prompts are not supported;
* the caller should fall back to promptUsernameAndPassword().
*/
- asyncPromptAuth: function capAPA(aChannel, // nsIChannel
- aCallback, // nsIAuthPromptCallback
- aContext, // nsISupports
- aLevel, // PRUint32
- aAuthInfo // nsIAuthInformation
- ) {
+ asyncPromptAuth: function(aChannel, // nsIChannel
+ aCallback, // nsIAuthPromptCallback
+ aContext, // nsISupports
+ aLevel, // PRUint32
+ aAuthInfo) { // nsIAuthInformation
let self = this;
let promptlistener = {
onPromptStart: function() {
res = self.promptAuth(aChannel, aLevel, aAuthInfo);
if (res) {
gAuthCache.setAuthInfo(hostKey, aAuthInfo);
this.onPromptAuthAvailable();
--- a/calendar/base/modules/calExtract.jsm
+++ b/calendar/base/modules/calExtract.jsm
@@ -53,17 +53,17 @@ function Extractor(fallbackLocale, daySt
}
}
Extractor.prototype = {
/**
* Removes confusing data like urls, timezones and phone numbers from email
* Also removes standard signatures and quoted content from previous emails
*/
- cleanup: function cleanup() {
+ cleanup: function() {
// XXX remove earlier correspondence
// ideally this should be considered with lower certainty to fill in
// missing information
// remove last line preceeding quoted message and first line of the quote
this.email = this.email.replace(/\r?\n[^>].*\r?\n>+.*$/m, "");
// remove the rest of quoted content
this.email = this.email.replace(/^>+.*$/gm, "");
@@ -78,46 +78,46 @@ Extractor.prototype = {
// remove standard signature
this.email = this.email.replace(/\r?\n-- \r?\n[\S\s]+$/, "");
// XXX remove timezone info, for now
this.email = this.email.replace(/gmt[+-]\d{2}:\d{2}/gi, "");
},
- checkBundle: function checkBundle(locale) {
+ checkBundle: function(locale) {
let path = this.bundleUrl.replace(/LOCALE/g, locale);
let bundle = Services.strings.createBundle(path);
try {
bundle.GetStringFromName("from.today");
return true;
} catch (ex) {
return false;
}
},
- avgNonAsciiCharCode: function avgNonAsciiCharCode() {
+ avgNonAsciiCharCode: function() {
let sum = 0;
let cnt = 0;
for (let i = 0; i < this.email.length; i++) {
let ch = this.email.charCodeAt(i);
if (ch > 128) {
sum += ch;
cnt++;
}
}
let nonAscii = sum / cnt || 0;
cal.LOG("[calExtract] Average non-ascii charcode: " + nonAscii);
return nonAscii;
},
- setLanguage: function setLanguage() {
+ setLanguage: function() {
let path;
if (this.fixedLang == true) {
if (this.checkBundle(this.fallbackLocale)) {
cal.LOG("[calExtract] Fixed locale was used to choose " +
this.fallbackLocale + " patterns.");
} else {
cal.LOG("[calExtract] " + this.fallbackLocale +
@@ -252,17 +252,17 @@ Extractor.prototype = {
* @param body email body
* @param now reference time against which relative times are interpreted,
* when null current time is used
* @param sel selection object of email content, when defined times
* outside selection are disgarded
* @param title email title
* @return sorted list of extracted datetime objects
*/
- extract: function extract(title, body, now, sel) {
+ extract: function(title, body, now, sel) {
let initial = {};
this.collected = [];
this.email = title + "\r\n" + body;
if (now != null) {
this.now = now;
}
initial.year = now.getFullYear();
@@ -355,17 +355,17 @@ Extractor.prototype = {
this.markSelected(sel, title);
}
this.markContained();
this.collected = this.collected.sort(this.sort);
return this.collected;
},
- extractDayMonthYear: function extractDayMonthYear(pattern, relation) {
+ extractDayMonthYear: function(pattern, relation) {
let alts = this.getRepPatterns(pattern, ["(\\d{1,2})", "(\\d{1,2})",
"(\\d{2,4})"]);
let res;
for (let alt in alts) {
let positions = alts[alt].positions;
let re = new RegExp(alts[alt].pattern, "ig");
while ((res = re.exec(this.email)) != null) {
@@ -380,17 +380,17 @@ Extractor.prototype = {
this.guess(year, month, day, null, null,
rev.start, rev.end, rev.pattern, rev.relation, pattern);
}
}
}
}
},
- extractDayMonthNameYear: function extractDayMonthNameYear(pattern, relation) {
+ extractDayMonthNameYear: function(pattern, relation) {
let alts = this.getRepPatterns(pattern, ["(\\d{1,2})",
"(" + this.allMonths + ")",
"(\\d{2,4})"]);
let res;
for (let alt in alts) {
let exp = alts[alt].pattern.split(this.marker).join("|");
let positions = alts[alt].positions;
let re = new RegExp(exp, "ig");
@@ -411,31 +411,31 @@ Extractor.prototype = {
}
}
}
}
}
}
},
- extractRelativeDay: function extractRelativeDay(pattern, relation, offset) {
+ extractRelativeDay: function(pattern, relation, offset) {
let re = new RegExp(this.getPatterns(pattern), "ig");
let res;
if ((res = re.exec(this.email)) != null) {
if (!this.limitChars(res, this.email)) {
let item = new Date(this.now.getTime() + 60 * 60 * 24 * 1000 * offset);
let rev = this.prefixSuffixStartEnd(res, relation, this.email);
this.guess(item.getFullYear(), item.getMonth() + 1, item.getDate(),
null, null,
rev.start, rev.end, rev.pattern, rev.relation, pattern);
}
}
},
- extractDayMonthName: function extractDayMonthName(pattern, relation) {
+ extractDayMonthName: function(pattern, relation) {
let alts = this.getRepPatterns(pattern,
["(\\d{1,2}" + this.marker + this.dailyNumbers + ")",
"(" + this.allMonths + ")"]);
let res;
for (let alt in alts) {
let exp = alts[alt].pattern.split(this.marker).join("|");
let positions = alts[alt].positions;
let re = new RegExp(exp, "ig");
@@ -470,17 +470,17 @@ Extractor.prototype = {
}
}
}
}
}
}
},
- extractDayMonth: function extractDayMonth(pattern, relation) {
+ extractDayMonth: function(pattern, relation) {
let alts = this.getRepPatterns(pattern, ["(\\d{1,2})", "(\\d{1,2})"]);
let res;
for (let alt in alts) {
let re = new RegExp(alts[alt].pattern, "ig");
let positions = alts[alt].positions;
while ((res = re.exec(this.email)) != null) {
if (!this.limitNums(res, this.email) && !this.limitChars(res, this.email)) {
@@ -507,17 +507,17 @@ Extractor.prototype = {
this.guess(date.year, date.month, date.day, null, null,
rev.start, rev.end, rev.pattern, rev.relation, pattern);
}
}
}
}
},
- extractDate: function extractDate(pattern, relation) {
+ extractDate: function(pattern, relation) {
let alts = this.getRepPatterns(pattern,
["(\\d{1,2}" + this.marker + this.dailyNumbers + ")"]);
let res;
for (let alt in alts) {
let exp = alts[alt].pattern.split(this.marker).join("|");
let re = new RegExp(exp, "ig");
while ((res = re.exec(this.email)) != null) {
@@ -541,17 +541,17 @@ Extractor.prototype = {
rev.start, rev.end,
rev.pattern, rev.relation, pattern, true);
}
}
}
}
},
- extractWeekDay: function extractWeekDay(pattern, relation) {
+ extractWeekDay: function(pattern, relation) {
let days = [];
for (let i = 0; i < 7; i++) {
days[i] = this.getPatterns(pattern + i);
let re = new RegExp(days[i], "ig");
let res = re.exec(this.email);
if (res) {
if (!this.limitChars(res, this.email)) {
let date = new Date();
@@ -567,17 +567,17 @@ Extractor.prototype = {
null, null,
rev.start, rev.end,
rev.pattern, rev.relation, pattern + i, true);
}
}
}
},
- extractHour: function extractHour(pattern, relation, meridiem) {
+ extractHour: function(pattern, relation, meridiem) {
let alts = this.getRepPatterns(pattern,
["(\\d{1,2}" + this.marker + this.hourlyNumbers + ")"]);
let res;
for (let alt in alts) {
let exp = alts[alt].pattern.split(this.marker).join("|");
let re = new RegExp(exp, "ig");
while ((res = re.exec(this.email)) != null) {
@@ -597,17 +597,17 @@ Extractor.prototype = {
this.guess(null, null, null, hour, 0,
rev.start, rev.end, rev.pattern, rev.relation, pattern, true);
}
}
}
}
},
- extractHalfHour: function extractHalfHour(pattern, relation, direction) {
+ extractHalfHour: function(pattern, relation, direction) {
let alts = this.getRepPatterns(pattern,
["(\\d{1,2}" + this.marker + this.hourlyNumbers + ")"]);
let res;
for (let alt in alts) {
let exp = alts[alt].pattern.split(this.marker).join("|");
let re = new RegExp(exp, "ig");
while ((res = re.exec(this.email)) != null) {
@@ -628,17 +628,17 @@ Extractor.prototype = {
this.guess(null, null, null, hour, 30,
rev.start, rev.end, rev.pattern, rev.relation, pattern, true);
}
}
}
}
},
- extractHourMinutes: function extractHourMinutes(pattern, relation, meridiem) {
+ extractHourMinutes: function(pattern, relation, meridiem) {
let alts = this.getRepPatterns(pattern, ["(\\d{1,2})", "(\\d{2})"]);
let res;
for (let alt in alts) {
let positions = alts[alt].positions;
let re = new RegExp(alts[alt].pattern, "ig");
while ((res = re.exec(this.email)) != null) {
if (!this.limitNums(res, this.email) && !this.limitChars(res, this.email)) {
@@ -658,29 +658,29 @@ Extractor.prototype = {
this.guess(null, null, null, hour, minute,
rev.start, rev.end, rev.pattern, rev.relation, pattern);
}
}
}
}
},
- extractTime: function extractTime(pattern, relation, hour, minute) {
+ extractTime: function(pattern, relation, hour, minute) {
let re = new RegExp(this.getPatterns(pattern), "ig");
let res;
if ((res = re.exec(this.email)) != null) {
if (!this.limitChars(res, this.email)) {
let rev = this.prefixSuffixStartEnd(res, relation, this.email);
this.guess(null, null, null, hour, minute,
rev.start, rev.end, rev.pattern, rev.relation, pattern);
}
}
},
- extractDuration: function extractDuration(pattern, unit) {
+ extractDuration: function(pattern, unit) {
let alts = this.getRepPatterns(pattern,
["(\\d{1,2}" + this.marker + this.dailyNumbers + ")"]);
let res;
for (let alt in alts) {
let exp = alts[alt].pattern.split(this.marker).join("|");
let re = new RegExp(exp, "ig");
while ((res = re.exec(this.email)) != null) {
@@ -695,17 +695,17 @@ Extractor.prototype = {
guess.relation = rev.relation;
guess.pattern = pattern;
this.collected.push(guess);
}
}
}
},
- markContained: function markContained() {
+ markContained: function() {
for (let outer = 0; outer < this.collected.length; outer++) {
for (let inner = 0; inner < this.collected.length; inner++) {
// included but not exactly the same
if (outer != inner &&
this.collected[outer].start && this.collected[outer].end &&
this.collected[inner].start && this.collected[inner].end &&
this.collected[inner].start >= this.collected[outer].start &&
this.collected[inner].end <= this.collected[outer].end &&
@@ -713,17 +713,17 @@ Extractor.prototype = {
this.collected[inner].end == this.collected[outer].end)) {
cal.LOG("[calExtract] " + this.collected[outer].str + " found as well, disgarding " + this.collected[inner].str);
this.collected[inner].relation = "notadatetime";
}
}
}
},
- markSelected: function markSelected(sel, title) {
+ markSelected: function(sel, title) {
if (sel.rangeCount > 0) {
// mark the ones to not use
for (let i = 0; i < sel.rangeCount; i++) {
cal.LOG("[calExtract] Selection " + i + " is " + sel);
for (let j = 0; j < this.collected.length; j++) {
let selection = sel.getRangeAt(i).toString();
if (!selection.includes(this.collected[j].str) &&
@@ -732,17 +732,17 @@ Extractor.prototype = {
cal.LOG("[calExtract] Marking " + JSON.stringify(this.collected[j]) + " as notadatetime");
this.collected[j].relation = "notadatetime";
}
}
}
}
},
- sort: function sort(one, two) {
+ sort: function(one, two) {
let rc;
// sort the guess from email date as the last one
if (one.start == null && two.start != null) {
return 1;
} else if (one.start != null && two.start == null) {
return -1;
} else if (one.start == null && two.start == null) {
return 0;
@@ -776,17 +776,17 @@ Extractor.prototype = {
},
/**
* Guesses start time from list of guessed datetimes
*
* @param isTask whether start time should be guessed for task or event
* @return datetime object for start time
*/
- guessStart: function guessStart(isTask) {
+ guessStart: function(isTask) {
let startTimes = this.collected.filter(val => val.relation == "start");
if (startTimes.length == 0) {
return {};
}
for (let val in startTimes) {
cal.LOG("[calExtract] Start: " + JSON.stringify(startTimes[val]));
}
@@ -851,17 +851,17 @@ Extractor.prototype = {
/**
* Guesses end time from list of guessed datetimes relative to start time
*
* @param start start time to consider when guessing
* @param isTask whether start time should be guessed for task or event
* @return datetime object for end time
*/
- guessEnd: function guessEnd(start, isTask) {
+ guessEnd: function(start, isTask) {
let guess = {};
let endTimes = this.collected.filter(val => val.relation == "end");
let durations = this.collected.filter(val => val.relation == "duration");
if (endTimes.length == 0 && durations.length == 0) {
return {};
} else {
for (let val in endTimes) {
cal.LOG("[calExtract] End: " + JSON.stringify(endTimes[val]));
@@ -975,17 +975,17 @@ Extractor.prototype = {
guess.minute = 0;
}
cal.LOG("[calExtract] End picked: " + JSON.stringify(guess));
return guess;
}
},
- getPatterns: function getPatterns(name) {
+ getPatterns: function(name) {
let value;
try {
value = this.bundle.GetStringFromName(name);
if (value.trim() == "") {
cal.LOG("[calExtract] Pattern not found: " + name);
return this.defPattern;
}
@@ -1026,17 +1026,17 @@ Extractor.prototype = {
} catch (ex) {
cal.LOG("[calExtract] Pattern not found: " + name);
// fake a value to avoid empty regexes creating endless loops
return this.defPattern;
}
},
- getRepPatterns: function getRepPatterns(name, replaceables) {
+ getRepPatterns: function(name, replaceables) {
let alts = [];
let patterns = [];
try {
let value = this.bundle.GetStringFromName(name);
if (value.trim() == "") {
cal.LOG("[calExtract] Pattern empty: " + name);
return alts;
@@ -1093,17 +1093,17 @@ Extractor.prototype = {
alts[val] = { pattern: patterns[val], positions: positions };
}
} catch (ex) {
cal.LOG("[calExtract] Pattern not found: " + name);
}
return alts;
},
- getPositionsFor: function getPositionsFor(s, name, count) {
+ getPositionsFor: function(s, name, count) {
let positions = [];
let re = /#(\d)/g;
let match;
let i = 0;
while ((match = re.exec(s))) {
i++;
positions[parseInt(match[1], 10)] = i;
}
@@ -1113,95 +1113,95 @@ Extractor.prototype = {
if (positions[i] === undefined) {
Components.utils.reportError("[calExtract] Faulty extraction pattern " + name +
", missing parameter #" + i);
}
}
return positions;
},
- cleanPatterns: function cleanPatterns(pattern) {
+ cleanPatterns: function(pattern) {
// remove whitespace around | if present
let value = pattern.replace(/\s*\|\s*/g, "|");
// allow matching for patterns with missing or excessive whitespace
return this.sanitize(value).replace(/\s+/g, "\\s*");
},
- isValidYear: function isValidYear(year) {
+ isValidYear: function(year) {
return (year >= 2000 && year <= 2050);
},
- isValidMonth: function isValidMonth(month) {
+ isValidMonth: function(month) {
return (month >= 1 && month <= 12);
},
- isValidDay: function isValidDay(day) {
+ isValidDay: function(day) {
return (day >= 1 && day <= 31);
},
- isValidHour: function isValidHour(hour) {
+ isValidHour: function(hour) {
return (hour >= 0 && hour <= 23);
},
- isValidMinute: function isValidMinute(minute) {
+ isValidMinute: function(minute) {
return (minute >= 0 && minute <= 59);
},
- isPastDate: function isPastDate(date, referenceDate) {
+ isPastDate: function(date, referenceDate) {
// avoid changing original refDate
let refDate = new Date(referenceDate.getTime());
refDate.setHours(0);
refDate.setMinutes(0);
refDate.setSeconds(0);
refDate.setMilliseconds(0);
let jsDate;
if (date.day != null) {
jsDate = new Date(date.year, date.month - 1, date.day);
}
return jsDate < refDate;
},
- normalizeHour: function normalizeHour(hour) {
+ normalizeHour: function(hour) {
if (hour < this.dayStart && hour <= 11) {
return hour + 12;
}
return hour;
},
- normalizeYear: function normalizeYear(year) {
+ normalizeYear: function(year) {
return (year.length == 2) ? "20" + year : year;
},
- limitNums: function limitNums(res, email) {
+ limitNums: function(res, email) {
let pattern = email.substring(res.index, res.index + res[0].length);
let before = email.charAt(res.index - 1);
let after = email.charAt(res.index + res[0].length);
let result = (/\d/.exec(before) && /\d/.exec(pattern.charAt(0))) ||
(/\d/.exec(pattern.charAt(pattern.length - 1)) && /\d/.exec(after));
return result != null;
},
- limitChars: function limitChars(res, email) {
+ limitChars: function(res, email) {
let alphabet = this.getPatterns("alphabet");
// for languages without regular alphabet surrounding characters are ignored
if (alphabet == this.defPattern) {
return false;
}
let pattern = email.substring(res.index, res.index + res[0].length);
let before = email.charAt(res.index - 1);
let after = email.charAt(res.index + res[0].length);
let w = new RegExp("[" + alphabet + "]");
let result = (w.exec(before) && w.exec(pattern.charAt(0))) ||
(w.exec(pattern.charAt(pattern.length - 1)) && w.exec(after));
return result != null;
},
- prefixSuffixStartEnd: function prefixSuffixStart(res, relation, email) {
+ prefixSuffixStartEnd: function(res, relation, email) {
let pattern = email.substring(res.index, res.index + res[0].length);
let prev = email.substring(0, res.index);
let next = email.substring(res.index + res[0].length);
let prefixSuffix = { start: res.index, end: res.index + res[0].length,
pattern: pattern, relation: relation };
let ch = "\\s*";
let psres;
@@ -1242,17 +1242,17 @@ Extractor.prototype = {
re = new RegExp("^" + ch + "(" + this.getPatterns("no.datetime.suffix") + ")", "ig");
if ((psres = re.exec(next)) != null) {
prefixSuffix.relation = "notadatetime";
}
return prefixSuffix;
},
- parseNumber: function parseNumber(number, numbers) {
+ parseNumber: function(number, numbers) {
let r = parseInt(number, 10);
// number comes in as plain text, numbers are already adjusted for usage
// in regular expression
number = this.cleanPatterns(number);
if (isNaN(r)) {
for (let i = 0; i <= 31; i++) {
let ns = numbers[i].split("|");
if (ns.includes(number.toLowerCase())) {
@@ -1260,18 +1260,18 @@ Extractor.prototype = {
}
}
return -1;
} else {
return r;
}
},
- guess: function guess(year, month, day, hour, minute, start, end, str,
- relation, pattern, ambiguous) {
+ guess: function(year, month, day, hour, minute, start, end, str,
+ relation, pattern, ambiguous) {
let dateGuess = {
year: year, month: month, day: day, hour: hour, minute: minute,
start: start, end: end, str: str, relation: relation,
pattern: pattern, ambiguous: ambiguous
};
// past dates are kept for containment checks
if (this.isPastDate(dateGuess, this.now)) {
guess.relation = "notadatetime";
--- a/calendar/base/modules/calHashedArray.jsm
+++ b/calendar/base/modules/calHashedArray.jsm
@@ -11,17 +11,17 @@ var EXPORTED_SYMBOLS = ["cal"]; // even
* retrieve the item by its hash id.
*
* Performance Considerations:
* - Accessing items is fast
* - Adding items is fast (they are added to the end)
* - Deleting items is O(n)
* - Modifying items is fast.
*/
-cal.HashedArray = function HashedArray() {
+cal.HashedArray = function() {
this.clear();
};
cal.HashedArray.prototype = {
mArray: null,
mHash: null,
mBatch: 0,
@@ -47,106 +47,106 @@ cal.HashedArray.prototype = {
},
/**
* Returns the item, given its index in the array
*
* @param index The index of the item to retrieve.
* @return The retrieved item.
*/
- itemByIndex: function itemByIndex(index) {
+ itemByIndex: function(index) {
return this.mArray[index];
},
/**
* Returns the item, given its hashId
*
* @param id The hashId of the item to retrieve.
* @return The retrieved item.
*/
- itemById: function itemById(id) {
+ itemById: function(id) {
if (this.mBatch > 0) {
throw "Accessing Array by ID not supported in batch mode ";
}
return (id in this.mHash ? this.mArray[this.mHash[id]] : null);
},
/**
* Returns the index of the given item. This function is cheap performance
* wise, since it uses the hash
*
* @param item The item to search for.
* @return The index of the item.
*/
- indexOf: function indexOf(item) {
+ indexOf: function(item) {
if (this.mBatch > 0) {
throw "Accessing Array Indexes not supported in batch mode";
}
let hashId = this.hashAccessor(item);
return (hashId in this.mHash ? this.mHash[hashId] : -1);
},
/**
* Remove the item with the given hashId.
*
* @param id The id of the item to be removed
*/
- removeById: function removeById(id) {
+ removeById: function(id) {
if (this.mBatch > 0) {
throw "Remvoing by ID in batch mode is not supported"; /* TODO */
}
let index = this.mHash[id];
delete this.mHash[id];
this.mArray.splice(index, 1);
this.reindex(index);
},
/**
* Remove the item at the given index.
*
* @param index The index of the item to remove.
*/
- removeByIndex: function removeByIndex(index) {
+ removeByIndex: function(index) {
delete this.mHash[this.hashAccessor(this.mArray[index])];
this.mArray.splice(index, 1);
this.reindex(index);
},
/**
* Clear the whole array, removing all items. This also resets batch mode.
*/
- clear: function clear() {
+ clear: function() {
this.mHash = {};
this.mArray = [];
this.mFirstDirty = -1;
this.mBatch = 0;
},
/**
* Add the item to the array
*
* @param item The item to add.
* @return The index of the added item.
*/
- addItem: function addItem(item) {
+ addItem: function(item) {
let index = this.mArray.length;
this.mArray.push(item);
this.reindex(index);
return index;
},
/**
* Modifies the item in the array. If the item is already in the array, then
* it is replaced by the passed item. Otherwise, the item is added to the
* array.
*
* @param item The item to modify.
* @return The (new) index.
*/
- modifyItem: function modifyItem(item) {
+ modifyItem: function(item) {
let hashId = this.hashAccessor(item);
if (hashId in this.mHash) {
let index = this.mHash[this.hashAccessor(item)];
this.mArray[index] = item;
return index;
} else {
return this.addItem(item);
}
@@ -157,17 +157,17 @@ cal.HashedArray.prototype = {
* internally. All parameters are inclusive. The ranges are automatically
* swapped if from > to.
*
* @param from (optional) The index to start indexing from. If left
* out, defaults to 0.
* @param to (optional) The index to end indexing on. If left out,
* defaults to the array length.
*/
- reindex: function reindex(from, to) {
+ reindex: function(from, to) {
if (this.mArray.length == 0) {
return;
}
from = (from === undefined ? 0 : from);
to = (to === undefined ? this.mArray.length - 1 : to);
from = Math.min(this.mArray.length - 1, Math.max(0, from));
@@ -185,65 +185,65 @@ cal.HashedArray.prototype = {
return;
}
for (let idx = from; idx <= to; idx++) {
this.mHash[this.hashAccessor(this.mArray[idx])] = idx;
}
},
- startBatch: function startBatch() {
+ startBatch: function() {
this.mBatch++;
},
- endBatch: function endBatch() {
+ endBatch: function() {
this.mBatch = Math.max(0, this.mBatch - 1);
if (this.mBatch == 0 && this.mFirstDirty > -1) {
this.reindex(this.mFirstDirty);
this.mFirstDirty = -1;
}
},
/**
* Iterator to allow iterating the hashed array object.
*/
- [Symbol.iterator]: function* iterator() {
+ [Symbol.iterator]: function* () {
yield* this.mArray;
}
};
/**
* Sorted hashed array. The array always stays sorted.
*
* Performance Considerations:
* - Accessing items is fast
* - Adding and deleting items is O(n)
* - Modifying items is fast.
*/
-cal.SortedHashedArray = function SortedHashedArray(comparator) {
+cal.SortedHashedArray = function(comparator) {
cal.HashedArray.apply(this, arguments);
if (!comparator) {
throw "Sorted Hashed Array needs a comparator";
}
this.mCompFunc = comparator;
};
cal.SortedHashedArray.prototype = {
__proto__: cal.HashedArray.prototype,
mCompFunc: null,
- addItem: function addItem(item) {
+ addItem: function(item) {
let newIndex = cal.binaryInsert(this.mArray, item, this.mCompFunc, false);
this.reindex(newIndex);
return newIndex;
},
- modifyItem: function modifyItem(item) {
+ modifyItem: function(item) {
let hashId = this.hashAccessor(item);
if (hashId in this.mHash) {
let cmp = this.mCompFunc(item, this.mArray[this.mHash[hashId]]);
if (cmp == 0) {
// The item will be at the same index, we just need to replace it
this.mArray[this.mHash[hashId]] = item;
return this.mHash[hashId];
} else {
--- a/calendar/base/modules/calItemUtils.jsm
+++ b/calendar/base/modules/calItemUtils.jsm
@@ -39,64 +39,64 @@ itemDiff.prototype = {
mDeletedItems: null,
/**
* Expect the difference engine to be in the given state.
*
* @param aState The state to be in
* @param aMethod The method name expecting the state
*/
- _expectState: function _expectState(aState, aMethod) {
+ _expectState: function(aState, aMethod) {
if ((this.state & aState) == 0) {
throw new Error("itemDiff method " + aMethod +
" called while in unexpected state " + this.state);
}
},
/**
* Load the difference engine with one item, see load.
*
* @param item The item to load
*/
- load1: function load1(item) {
+ load1: function(item) {
this.load([item]);
},
/**
* Loads an array of items. This step cannot be executed
* after calling the difference methods.
*
* @param items The array of items to load
*/
- load: function load(items) {
+ load: function(items) {
this._expectState(this.STATE_INITIAL | this.STATE_LOADING, "load");
for (let item of items) {
this.mInitialItems[item.hashId] = item;
}
this.state = this.STATE_LOADING;
},
/**
* Calculates the difference for the passed item, see difference.
*
* @param item The item to calculate difference with
*/
- difference1: function difference1(item) {
+ difference1: function(item) {
this.difference([item]);
},
/**
* Calculate the difference for the array of items. This method should be
* called after all load methods and before the complete method.
*
* @param items The array of items to calculate difference with
*/
- difference: function difference(items) {
+ difference: function(items) {
this._expectState(this.STATE_INITIAL | this.STATE_LOADING | this.STATE_DIFFERING, "difference");
this.mModifiedOldItems.startBatch();
this.mModifiedItems.startBatch();
this.mAddedItems.startBatch();
for (let item of items) {
if (item.hashId in this.mInitialItems) {
@@ -115,17 +115,17 @@ itemDiff.prototype = {
this.state = this.STATE_DIFFERING;
},
/**
* Tell the engine that all load and difference calls have been made, this
* makes sure that all item states are correctly returned.
*/
- complete: function complete() {
+ complete: function() {
this._expectState(this.STATE_INITIAL | this.STATE_LOADING | this.STATE_DIFFERING, "complete");
this.mDeletedItems.startBatch();
for (let hashId in this.mInitialItems) {
let item = this.mInitialItems[hashId];
this.mDeletedItems.addItem(item);
}
@@ -163,17 +163,17 @@ itemDiff.prototype = {
/** @return the number of loaded items */
get count() {
return Object.keys(this.mInitialItems).length;
},
/**
* Resets the difference engine to its initial state.
*/
- reset: function reset() {
+ reset: function() {
this.mInitialItems = {};
this.mModifiedItems = new cal.HashedArray();
this.mModifiedOldItems = new cal.HashedArray();
this.mAddedItems = new cal.HashedArray();
this.mDeletedItems = new cal.HashedArray();
this.state = this.STATE_INITIAL;
}
};
--- a/calendar/base/modules/calIteratorUtils.jsm
+++ b/calendar/base/modules/calIteratorUtils.jsm
@@ -9,17 +9,17 @@ Components.utils.import("resource://gre/
this.EXPORTED_SYMBOLS = ["cal"]; // even though it's defined in calUtils.jsm, import needs this
/**
* Iterates an array of items, i.e. the passed item including all
* overridden instances of a recurring series.
*
* @param items array of items
*/
-cal.itemIterator = function* cal_itemIterator(items) {
+cal.itemIterator = function* (items) {
for (let item of items) {
yield item;
let rec = item.recurrenceInfo;
if (rec) {
for (let exid of rec.getExceptionIds({})) {
yield rec.getExceptionFor(exid);
}
}
@@ -40,31 +40,31 @@ cal.itemIterator = function* cal_itemIte
* for each loop, use the optional completed() function.
*
* @param iter The Iterator or the plain Object to go through in this
* loop.
* @param body The function called for each iteration. Its parameter is
* the single item from the iterator.
* @param completed [optional] The function called after the loop completes.
*/
-cal.forEach = function cal_forEach(iterable, body, completed) {
+cal.forEach = function(iterable, body, completed) {
// This should be a const one day, lets keep it a pref for now though until we
// find a sane value.
let LATENCY = Preferences.get("calendar.threading.latency", 250);
if (typeof iterable == "object" && !iterable[Symbol.iterator]) {
iterable = Object.entries(iterable);
}
let ourIter = iterable[Symbol.iterator]();
let currentThread = Services.tm.currentThread;
// This is our dispatcher, it will be used for the iterations
let dispatcher = {
- run: function run() {
+ run: function() {
let startTime = (new Date()).getTime();
while (((new Date()).getTime() - startTime) < LATENCY) {
let next = ourIter.next();
let done = next.done;
if (!done) {
let rc = body(next.value);
if (rc == cal.forEach.BREAK) {
@@ -106,17 +106,17 @@ cal.ical = {
*
* This iterator can only be used in a for..of block:
* for (let component of cal.ical.calendarComponentIterator(aComp)) { ... }
*
* @param aComponent The component to iterate given the above rules.
* @param aCompType The type of item to iterate.
* @return The iterator that yields all items.
*/
- calendarComponentIterator: function* cal_ical_calendarComponentIterator(aComponent, aCompType) {
+ calendarComponentIterator: function* (aComponent, aCompType) {
let compType = (aCompType || "ANY");
if (aComponent && aComponent.componentType == "VCALENDAR") {
yield* cal.ical.subcomponentIterator(aComponent, compType);
} else if (aComponent && aComponent.componentType == "XROOT") {
for (let calComp of cal.ical.subcomponentIterator(aComponent, "VCALENDAR")) {
yield* cal.ical.subcomponentIterator(calComp, compType);
}
} else if (aComponent && (compType == "ANY" || compType == aComponent.componentType)) {
@@ -131,17 +131,17 @@ cal.ical = {
* This iterator can only be used in a for() block:
* for (let component in cal.ical.subcomponentIterator(aComp)) { ... }
*
* @param aComponent The component who's subcomponents to iterate.
* @param aSubcomp (optional) the specific subcomponent to
* enumerate. If not given, "ANY" will be used.
* @return An iterator object to iterate the properties.
*/
- subcomponentIterator: function* cal_ical_subcomponentIterator(aComponent, aSubcomp) {
+ subcomponentIterator: function* (aComponent, aSubcomp) {
let subcompName = (aSubcomp || "ANY");
for (let subcomp = aComponent.getFirstSubcomponent(subcompName);
subcomp;
subcomp = aComponent.getNextSubcomponent(subcompName)) {
yield subcomp;
}
},
@@ -150,17 +150,17 @@ cal.ical = {
* This iterator can only be used in a for() block:
* for (let property in cal.ical.propertyIterator(aComp)) { ... }
*
* @param aComponent The component to iterate.
* @param aProperty (optional) the specific property to enumerate.
* If not given, "ANY" will be used.
* @return An iterator object to iterate the properties.
*/
- propertyIterator: function* cal_ical_propertyIterator(aComponent, aProperty) {
+ propertyIterator: function* (aComponent, aProperty) {
let propertyName = (aProperty || "ANY");
for (let prop = aComponent.getFirstProperty(propertyName);
prop;
prop = aComponent.getNextProperty(propertyName)) {
yield prop;
}
},
@@ -169,17 +169,17 @@ cal.ical = {
* This iterator behaves similar to the object iterator. Possible uses:
* for (let paramName in cal.ical.paramIterator(prop)) { ... }
* or:
* for (let [paramName, paramValue] of cal.ical.paramIterator(prop)) { ... }
*
* @param aProperty The property to iterate.
* @return An iterator object to iterate the properties.
*/
- paramIterator: function* cal_ical_paramIterator(aProperty) {
+ paramIterator: function* (aProperty) {
let paramSet = new Set();
for (let paramName = aProperty.getFirstParameterName();
paramName;
paramName = aProperty.getNextParameterName()) {
// Workaround to avoid infinite loop when the property
// contains duplicate parameters (bug 875739 for libical)
if (!paramSet.has(paramName)) {
yield [paramName, aProperty.getParameter(paramName)];
--- a/calendar/base/modules/calItipUtils.jsm
+++ b/calendar/base/modules/calItipUtils.jsm
@@ -14,17 +14,17 @@ Components.utils.import("resource://gre/
*/
this.EXPORTED_SYMBOLS = ["cal"]; // even though it's defined in calUtils.jsm, import needs this
cal.itip = {
/**
* Gets the sequence/revision number, either of the passed item or
* the last received one of an attendee; see
* <http://tools.ietf.org/html/draft-desruisseaux-caldav-sched-04#section-7.1>.
*/
- getSequence: function cal_itip_getSequence(item) {
+ getSequence: function(item) {
let seq = null;
let wrappedItem = cal.wrapInstance(item, Components.interfaces.calIAttendee);
if (wrappedItem) {
seq = wrappedItem.getProperty("RECEIVED-SEQUENCE");
} else if (item) {
// Unless the below is standardized, we store the last original
// REQUEST/PUBLISH SEQUENCE in X-MOZ-RECEIVED-SEQUENCE to test against it
@@ -49,17 +49,17 @@ cal.itip = {
}
},
/**
* Gets the stamp date-time, either of the passed item or
* the last received one of an attendee; see
* <http://tools.ietf.org/html/draft-desruisseaux-caldav-sched-04#section-7.2>.
*/
- getStamp: function cal_itip_getStamp(item) {
+ getStamp: function(item) {
let dtstamp = null;
let wrappedItem = cal.wrapInstance(item, Components.interfaces.calIAttendee);
if (wrappedItem) {
let st = wrappedItem.getProperty("RECEIVED-DTSTAMP");
if (st) {
dtstamp = cal.createDateTime(st);
}
@@ -77,17 +77,17 @@ cal.itip = {
}
return dtstamp;
},
/**
* Compares sequences and/or stamps of two parties; returns -1, 0, +1.
*/
- compare: function cal_itip_compare(item1, item2) {
+ compare: function(item1, item2) {
let seq1 = cal.itip.getSequence(item1);
let seq2 = cal.itip.getSequence(item2);
if (seq1 > seq2) {
return 1;
} else if (seq1 < seq2) {
return -1;
} else {
let st1 = cal.itip.getStamp(item1);
@@ -106,32 +106,32 @@ cal.itip = {
/**
* Checks if the given calendar is a scheduling calendar. This means it
* needs an organizer id and an itip transport. It should also be writable.
*
* @param calendar The calendar to check
* @return True, if its a scheduling calendar.
*/
- isSchedulingCalendar: function isSchedulingCalendar(calendar) {
+ isSchedulingCalendar: function(calendar) {
return cal.isCalendarWritable(calendar) &&
calendar.getProperty("organizerId") &&
calendar.getProperty("itip.transport");
},
/**
* Scope: iTIP message receiver
*
* Given an nsIMsgDBHdr and an imipMethod, set up the given itip item.
*
* @param itipItem The item to set up
* @param imipMethod The received imip method
* @param aMsgHdr Information about the received email
*/
- initItemFromMsgData: function initItemFromMsgData(itipItem, imipMethod, aMsgHdr) {
+ initItemFromMsgData: function(itipItem, imipMethod, aMsgHdr) {
// Get the recipient identity and save it with the itip item.
itipItem.identity = cal.itip.getMessageRecipient(aMsgHdr);
// We are only called upon receipt of an invite, so ensure that isSend
// is false.
itipItem.isSend = false;
// XXX Get these from preferences
@@ -165,17 +165,17 @@ cal.itip = {
*
* Gets the suggested text to be shown when an imip item has been processed.
* This text is ready localized and can be displayed to the user.
*
* @param aStatus The status of the processing (i.e NS_OK, an error code)
* @param aOperationType An operation type from calIOperationListener
* @return The suggested text.
*/
- getCompleteText: function getCompleteText(aStatus, aOperationType) {
+ getCompleteText: function(aStatus, aOperationType) {
function _gs(strName, param) {
return cal.calGetString("lightning", strName, param, "lightning");
}
let text = "";
const cIOL = Components.interfaces.calIOperationListener;
if (Components.isSuccessCode(aStatus)) {
switch (aOperationType) {
@@ -193,17 +193,17 @@ cal.itip = {
* Scope: iTIP message receiver
*
* Gets a text describing the given itip method. The text is of the form
* "This Message contains a ... ".
*
* @param method The method to describe.
* @return The localized text about the method.
*/
- getMethodText: function getMethodtext(method) {
+ getMethodText: function(method) {
function _gs(strName) {
return cal.calGetString("lightning", strName, null, "lightning");
}
switch (method) {
case "REFRESH": return _gs("imipBarRefreshText");
case "REQUEST": return _gs("imipBarRequestText");
case "PUBLISH": return _gs("imipBarPublishText");
@@ -227,17 +227,17 @@ cal.itip = {
* hideMenuItem: ["imipXXXButton_Option", ...]
* }
*
* @see processItipItem This takes the same parameters as its optionFunc.
* @param itipItem The itipItem to query.
* @param rc The result of retrieving the item
* @param actionFunc The action function.
*/
- getOptionsText: function getOptionsText(itipItem, rc, actionFunc, foundItems) {
+ getOptionsText: function(itipItem, rc, actionFunc, foundItems) {
function _gs(strName) {
return cal.calGetString("lightning", strName, null, "lightning");
}
let imipLabel = null;
if (itipItem.receivedMethod) {
imipLabel = cal.itip.getMethodText(itipItem.receivedMethod);
}
let data = { label: imipLabel, buttons: [], hideMenuItems: [] };
@@ -333,17 +333,17 @@ cal.itip = {
/**
* Scope: iTIP message receiver
*
* Retrieves the intended recipient for this message.
*
* @param aMsgHdr The message to check.
* @return The email of the intended recipient.
*/
- getMessageRecipient: function getMessageRecipient(aMsgHdr) {
+ getMessageRecipient: function(aMsgHdr) {
if (!aMsgHdr) {
return null;
}
let identities;
let actMgr = MailServices.accounts;
if (aMsgHdr.accountKey) {
// First, check if the message has an account key. If so, we can use the
@@ -409,17 +409,17 @@ cal.itip = {
* calendar will be set on the passed itip item.
*
* @param aMethod The method to check.
* @param aItipItem The itip item to set the target calendar on.
* @param aWindow The window to open the dialog on.
* @return True, if a calendar was selected or no selection is
* needed.
*/
- promptCalendar: function promptCalendar(aMethod, aItipItem, aWindow) {
+ promptCalendar: function(aMethod, aItipItem, aWindow) {
let needsCalendar = false;
let targetCalendar = null;
switch (aMethod) {
// methods that don't require the calendar chooser:
case "REFRESH":
case "REQUEST:UPDATE":
case "REQUEST:UPDATE-MINOR":
case "PUBLISH:UPDATE":
@@ -455,17 +455,17 @@ cal.itip = {
} else if (calendars.length == 1) {
// There's only one calendar, so it's silly to ask what calendar
// the user wants to import into.
targetCalendar = calendars[0];
} else {
// Ask what calendar to import into
let args = {};
args.calendars = calendars;
- args.onOk = function selectCalendar(aCal) { targetCalendar = aCal; };
+ args.onOk = (aCal) => { targetCalendar = aCal; };
args.promptText = cal.calGetString("calendar", "importPrompt");
aWindow.openDialog("chrome://calendar/content/chooseCalendarDialog.xul",
"_blank", "chrome,titlebar,modal,resizable", args);
}
if (targetCalendar) {
aItipItem.targetCalendar = targetCalendar;
}
@@ -476,17 +476,17 @@ cal.itip = {
/**
* Clean up after the given iTIP item. This needs to be called once for each
* time processItipItem is called. May be called with a null itipItem in
* which case it will do nothing.
*
* @param itipItem The iTIP item to clean up for.
*/
- cleanupItipItem: function cleanupItipItem(itipItem) {
+ cleanupItipItem: function(itipItem) {
if (itipItem) {
let itemList = itipItem.getItemList({});
if (itemList.length > 0) {
// Again, we can assume the id is the same over all items per spec
ItipItemFinderFactory.cleanup(itemList[0].id);
}
}
},
@@ -504,17 +504,17 @@ cal.itip = {
* * PUBLISH -- initial publish, no reply (sent by organizer)
* * PUBLISH:UPDATE -- update of a published item (sent by organizer)
* * REQUEST -- initial invitation (sent by organizer)
* * REQUEST:UPDATE -- rescheduling invitation, has major change (sent by organizer)
* * REQUEST:UPDATE-MINOR -- update of invitation, minor change (sent by organizer)
* * REPLY -- invitation reply (sent by attendee(s))
* * CANCEL -- invitation cancel (sent by organizer)
*/
- processItipItem: function cal_itip_processItipItem(itipItem, optionsFunc) {
+ processItipItem: function(itipItem, optionsFunc) {
switch (itipItem.receivedMethod.toUpperCase()) {
case "REFRESH":
case "PUBLISH":
case "REQUEST":
case "CANCEL":
case "REPLY": {
// Per iTIP spec (new Draft 4), multiple items in an iTIP message MUST have
// same ID, this simplifies our searching, we can just look for Item[0].id
@@ -538,17 +538,17 @@ cal.itip = {
},
/**
* Scope: iTIP message sender
*
* Checks to see if e.g. attendees were added/removed or an item has been
* deleted and sends out appropriate iTIP messages.
*/
- checkAndSend: function cal_itip_checkAndSend(aOpType, aItem, aOriginalItem) {
+ checkAndSend: function(aOpType, aItem, aOriginalItem) {
// balance out parts of the modification vs delete confusion, deletion of occurrences
// are notified as parent modifications and modifications of occurrences are notified
// as mixed new-occurrence, old-parent (IIRC).
if (aOriginalItem && aItem.recurrenceInfo) {
if (aOriginalItem.recurrenceId && !aItem.recurrenceId) {
// sanity check: assure aItem doesn't refer to the master
aItem = aItem.recurrenceInfo.getOccurrenceFor(aOriginalItem.recurrenceId);
cal.ASSERT(aItem, "unexpected!");
@@ -773,17 +773,17 @@ cal.itip = {
sendMessage(cancelItem, "CANCEL", canceledAttendees, autoResponse);
}
}
},
/**
* Bumps the SEQUENCE in case of a major change; XXX todo may need more fine-tuning.
*/
- prepareSequence: function cal_itip_prepareSequence(newItem, oldItem) {
+ prepareSequence: function(newItem, oldItem) {
if (cal.isInvitation(newItem)) {
return newItem; // invitation copies don't bump the SEQUENCE
}
if (newItem.recurrenceId && !oldItem.recurrenceId && oldItem.recurrenceInfo) {
// XXX todo: there's still the bug that modifyItem is called with mixed occurrence/parent,
// find original occurrence
oldItem = oldItem.recurrenceInfo.getOccurrenceFor(newItem.recurrenceId);
@@ -834,17 +834,17 @@ cal.itip = {
/**
* Returns a copy of an itipItem with modified properties and items build from scratch
* Use itipItem.clone() instead if only a simple copy is required
*
* @param aItipItem ItipItem to derive a new one from
* @param aItems List of items to be contained in the new itipItem
* @param aProps List of properties to be different in the new itipItem
*/
- getModifiedItipItem: function cal_getModifiedItipItem(aItipItem, aItems=[], aProps={}) {
+ getModifiedItipItem: function(aItipItem, aItems=[], aProps={}) {
let itipItem = Components.classes["@mozilla.org/calendar/itip-item;1"]
.createInstance(Components.interfaces.calIItipItem);
let serializedItems = "";
for (let item of aItems) {
serializedItems += cal.getSerializedItem(item);
}
itipItem.init(serializedItems);
@@ -1073,39 +1073,30 @@ function sendMessage(aItem, aMethod, aRe
* @param oldItem the previous item before modification (if any)
*/
function ItipOpListener(opListener, oldItem) {
this.mOpListener = opListener;
this.mOldItem = oldItem;
}
ItipOpListener.prototype = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
- onOperationComplete: function ItipOpListener_onOperationComplete(aCalendar,
- aStatus,
- aOperationType,
- aId,
- aDetail) {
+ onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
cal.ASSERT(Components.isSuccessCode(aStatus), "error on iTIP processing");
if (Components.isSuccessCode(aStatus)) {
cal.itip.checkAndSend(aOperationType, aDetail, this.mOldItem);
}
if (this.mOpListener) {
this.mOpListener.onOperationComplete(aCalendar,
aStatus,
aOperationType,
aId,
aDetail);
}
},
- onGetResult: function ItipOpListener_onGetResult(aCalendar,
- aStatus,
- aItemType,
- aDetail,
- aCount,
- aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
}
};
/** local to this module file
* Add a parameter SCHEDULE-AGENT=CLIENT to the item before it is
* created or updated so that the providers knows scheduling will
* be handled by the client.
*
@@ -1127,30 +1118,30 @@ var ItipItemFinderFactory = {
/**
* Create an item finder and track its progress. Be sure to clean up the
* finder for this id at some point.
*
* @param aId The item id to search for
* @param aItipItem The iTIP item used for processing
* @param aOptionsFunc The options function used for processing the found item
*/
- findItem: function findItem(aId, aItipItem, aOptionsFunc) {
+ findItem: function(aId, aItipItem, aOptionsFunc) {
this.cleanup(aId);
let finder = new ItipItemFinder(aId, aItipItem, aOptionsFunc);
this._findMap[aId] = finder;
finder.findItem();
},
/**
* Clean up tracking for the given id. This needs to be called once for
* every time findItem is called.
*
* @param aId The item id to clean up for
*/
- cleanup: function cleanup(aId) {
+ cleanup: function(aId) {
if (aId in this._findMap) {
let finder = this._findMap[aId];
finder.destroy();
delete this._findMap[aId];
}
}
};
@@ -1173,49 +1164,49 @@ ItipItemFinder.prototype = {
Components.interfaces.calIOperationListener
]),
mSearchId: null,
mItipItem: null,
mOptionsFunc: null,
mFoundItems: null,
- findItem: function findItem() {
+ findItem: function() {
this.mFoundItems = [];
this._unobserveChanges();
this.mItipItem.targetCalendar.getItem(this.mSearchId, this);
},
- _observeChanges: function _observeChanges(aCalendar) {
+ _observeChanges: function(aCalendar) {
this._unobserveChanges();
this.mObservedCalendar = aCalendar;
if (this.mObservedCalendar) {
this.mObservedCalendar.addObserver(this);
}
},
- _unobserveChanges: function _unobserveChanges() {
+ _unobserveChanges: function() {
if (this.mObservedCalendar) {
this.mObservedCalendar.removeObserver(this);
this.mObservedCalendar = null;
}
},
onStartBatch: function() {},
onEndBatch: function() {},
onError: function() {},
onPropertyChanged: function() {},
onPropertyDeleting: function() {},
- onLoad: function onLoad(aCalendar) {
+ onLoad: function(aCalendar) {
// Its possible that the item was updated. We need to re-retrieve the
// items now.
this.findItem();
},
- onModifyItem: function onModifyItem(aNewItem, aOldItem) {
+ onModifyItem: function(aNewItem, aOldItem) {
let refItem = aOldItem || aNewItem;
if (refItem.id == this.mSearchId) {
// Check existing found items to see if it already exists
let found = false;
for (let [idx, item] in Iterator(this.mFoundItems)) {
if (item.id == refItem.id && item.calendar.id == refItem.calendar.id) {
if (aNewItem) {
this.mFoundItems.splice(idx, 1, aNewItem);
@@ -1230,39 +1221,35 @@ ItipItemFinder.prototype = {
// If it hasn't been found and there isto add a item, add it to the end
if (!found && aNewItem) {
this.mFoundItems.push(aNewItem);
}
this.processFoundItems();
}
},
- onAddItem: function onAddItem(aItem) {
+ onAddItem: function(aItem) {
// onModifyItem is set up to also handle additions
this.onModifyItem(aItem, null);
},
- onDeleteItem: function onDeleteItem(aItem) {
+ onDeleteItem: function(aItem) {
// onModifyItem is set up to also handle deletions
this.onModifyItem(null, aItem);
},
- onOperationComplete: function onOperationComplete(aCalendar,
- aStatus,
- aOperationType,
- aId,
- aDetail) {
+ onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
this.processFoundItems();
},
- destroy: function destroy() {
+ destroy: function() {
this._unobserveChanges();
},
- processFoundItems: function processFoundItems() {
+ processFoundItems: function() {
let rc = Components.results.NS_OK;
const method = this.mItipItem.receivedMethod.toUpperCase();
let actionMethod = method;
let operations = [];
if (this.mFoundItems.length > 0) {
// Save the target calendar on the itip item
this.mItipItem.targetCalendar = this.mFoundItems[0].calendar;
@@ -1517,34 +1504,29 @@ ItipItemFinder.prototype = {
break;
}
}
}
cal.LOG("iTIP operations: " + operations.length);
let actionFunc = null;
if (operations.length > 0) {
- actionFunc = function execOperations(opListener, partStat) {
+ actionFunc = function(opListener, partStat) {
for (let op of operations) {
try {
op(opListener, partStat);
} catch (exc) {
cal.ERROR(exc);
}
}
};
actionFunc.method = actionMethod;
}
this.mOptionsFunc(this.mItipItem, rc, actionFunc, this.mFoundItems);
},
- onGetResult: function onGetResult(aCalendar,
- aStatus,
- aItemType,
- aDetail,
- aCount,
- aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
if (Components.isSuccessCode(aStatus)) {
this.mFoundItems = this.mFoundItems.concat(aItems);
}
}
};
--- a/calendar/base/modules/calPrintUtils.jsm
+++ b/calendar/base/modules/calPrintUtils.jsm
@@ -10,30 +10,30 @@ this.EXPORTED_SYMBOLS = ["cal"]; // even
cal.print = {
/**
* Returns a simple key in the format YYYY-MM-DD for use in the table of
* dates to day boxes
*
* @param dt The date to translate
* @return YYYY-MM-DD
*/
- getDateKey: function getDateKey(dt) {
+ getDateKey: function(dt) {
return dt.year + "-" + dt.month + "-" + dt.day;
},
/**
* Add category styles to the document's "sheet" element. This is needed
* since the HTML created is serialized, so we can't dynamically set the
* styles and can be changed if the print formatter decides to return a
* DOM document instead.
*
* @param document The document that contains <style id="sheet"/>.
* @param categories Array of categories to insert rules for.
*/
- insertCategoryRules: function insertCategoryRules(document, categories) {
+ insertCategoryRules: function(document, categories) {
let sheet = document.getElementById("sheet");
sheet.insertedCategoryRules = sheet.insertedCategoryRules || {};
for (let category of categories) {
let prefName = cal.formatStringForCSSRule(category);
let color = Preferences.get("calendar.category.color." + prefName) || "transparent";
if (!(prefName in sheet.insertedCategoryRules)) {
sheet.insertedCategoryRules[prefName] = true;
@@ -48,17 +48,17 @@ cal.print = {
* Add calendar styles to the document's "sheet" element. This is needed
* since the HTML created is serialized, so we can't dynamically set the
* styles and can be changed if the print formatter decides to return a
* DOM document instead.
*
* @param document The document that contains <style id="sheet"/>.
* @param categories The calendar to insert a rule for.
*/
- insertCalendarRules: function insertCalendarRules(document, calendar) {
+ insertCalendarRules: function(document, calendar) {
let sheet = document.getElementById("sheet");
let color = calendar.getProperty("color") || "#A8C2E1";
sheet.insertedCalendarRules = sheet.insertedCalendarRules || {};
if (!(calendar.id in sheet.insertedCalendarRules)) {
sheet.insertedCalendarRules[calendar.id] = true;
let formattedId = cal.formatStringForCSSRule(calendar.id);
let ruleAdd = ' .calendar-color-box[calendar-id="' + formattedId + '"] { ' +
@@ -78,17 +78,17 @@ cal.print = {
* - .item-title gets the item title
* - .category-color-box gets a 2px solid border in category color
* - .calendar-color-box gets background color of the calendar
*
* @param document The DOM Document to set things on
* @param item The item to serialize
* @param dayContainer The DOM Node to insert the container in
*/
- addItemToDaybox: function addItemToDaybox(document, item, boxDate, dayContainer) {
+ addItemToDaybox: function(document, item, boxDate, dayContainer) {
// Clone our template
let itemNode = document.getElementById("item-template").cloneNode(true);
itemNode.removeAttribute("id");
itemNode.item = item;
// Fill in details of the item
let itemInterval = cal.print.getItemIntervalString(item, boxDate);
itemNode.querySelector(".item-interval").textContent = itemInterval;
@@ -123,17 +123,17 @@ cal.print = {
* - #task-list-box will have the "hidden" attribute removed.
* - #task-template will be cloned and filled, and modified:
* - .task-checkbox gets the "checked" attribute set, if completed
* - .task-title gets the item title.
*
* @param document The DOM Document to set things on
* @param item The item to serialize
*/
- addItemToDayboxNodate: function addItemToDayboxNodate(document, item) {
+ addItemToDayboxNodate: function(document, item) {
let taskContainer = document.getElementById("task-container");
let taskNode = document.getElementById("task-template").cloneNode(true);
taskNode.removeAttribute("id");
taskNode.item = item;
let taskListBox = document.getElementById("tasks-list-box");
if (taskListBox.hasAttribute("hidden")) {
let tasksTitle = document.getElementById("tasks-title");
@@ -153,17 +153,17 @@ cal.print = {
},
/**
* Get time interval string for the given item. Returns an empty string for all-day items.
*
* @param aItem The item providing the interval
* @return The string describing the interval
*/
- getItemIntervalString: function getItemIntervalString(aItem, aBoxDate) {
+ getItemIntervalString: function(aItem, aBoxDate) {
// omit time label for all-day items
let startDate = aItem[cal.calGetStartDateProp(aItem)];
let endDate = aItem[cal.calGetEndDateProp(aItem)];
if ((startDate && startDate.isDate) || (endDate && endDate.isDate)) {
return "";
}
// check for tasks without start and/or due date
--- a/calendar/base/modules/calProviderUtils.jsm
+++ b/calendar/base/modules/calProviderUtils.jsm
@@ -24,17 +24,17 @@ this.EXPORTED_SYMBOLS = ["cal"]; // even
* @param aUploadData Data to be uploaded, if any. This may be a
* nsIInputStream or string data. In the
* latter case the string will be converted
* to an input stream.
* @param aContentType Value for Content-Type header, if any
* @param aNotificationCallbacks Calendar using channel
* @param aExisting An existing channel to modify (optional)
*/
-cal.prepHttpChannel = function calPrepHttpChannel(aUri, aUploadData, aContentType, aNotificationCallbacks, aExisting) {
+cal.prepHttpChannel = function(aUri, aUploadData, aContentType, aNotificationCallbacks, aExisting) {
let channel = aExisting || Services.io.newChannelFromURI2(aUri,
null,
Services.scriptSecurityManager.getSystemPrincipal(),
null,
Components.interfaces.nsILoadInfo.SEC_NORMAL,
Components.interfaces.nsIContentPolicy.TYPE_OTHER);
let httpchannel = channel.QueryInterface(Components.interfaces.nsIHttpChannel);
@@ -66,27 +66,27 @@ cal.prepHttpChannel = function calPrepHt
/**
* calSendHttpRequest; send prepared HTTP request
*
* @param aStreamLoader streamLoader for request
* @param aChannel channel for request
* @param aListener listener for method completion
*/
-cal.sendHttpRequest = function calSendHttpRequest(aStreamLoader, aChannel, aListener) {
+cal.sendHttpRequest = function(aStreamLoader, aChannel, aListener) {
aStreamLoader.init(aListener);
aChannel.asyncOpen(aStreamLoader, aChannel);
};
-cal.createStreamLoader = function calCreateStreamLoader() {
+cal.createStreamLoader = function() {
return Components.classes["@mozilla.org/network/stream-loader;1"]
.createInstance(Components.interfaces.nsIStreamLoader);
};
-cal.convertByteArray = function calConvertByteArray(aResult, aResultLength, aCharset, aThrow) {
+cal.convertByteArray = function(aResult, aResultLength, aCharset, aThrow) {
try {
let resultConverter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
resultConverter.charset = aCharset || "UTF-8";
return resultConverter.convertFromByteArray(aResult, aResultLength);
} catch (e) {
if (aThrow) {
throw e;
@@ -108,17 +108,17 @@ cal.convertByteArray = function calConve
*
* NOTE: If the server only provides one realm for all calendars, be sure that
* the |this| object implements calICalendar. In this case the calendar name
* will be appended to the realm. If you need that feature disabled, see the
* capabilities section of calICalendar.idl
*
* @param aIID The interface ID to return
*/
-cal.InterfaceRequestor_getInterface = function calInterfaceRequestor_getInterface(aIID) {
+cal.InterfaceRequestor_getInterface = function(aIID) {
try {
// Try to query the this object for the requested interface but don't
// throw if it fails since that borks the network code.
return this.QueryInterface(aIID);
} catch (e) {
// Support Auth Prompt Interfaces
if (aIID.equals(Components.interfaces.nsIAuthPrompt2)) {
if (!this.calAuthPrompt) {
@@ -139,23 +139,23 @@ cal.InterfaceRequestor_getInterface = fu
}
return null;
};
/**
* Bad Certificate Handler for Network Requests. Shows the Network Exception
* Dialog if a certificate Problem occurs.
*/
-cal.BadCertHandler = function calBadCertHandler(thisProvider) {
+cal.BadCertHandler = function(thisProvider) {
this.thisProvider = thisProvider;
};
cal.BadCertHandler.prototype = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIBadCertListener2]),
- notifyCertProblem: function cBCL_notifyCertProblem(socketInfo, status, targetSite) {
+ notifyCertProblem: function(socketInfo, status, targetSite) {
// Unfortunately we can't pass js objects using the window watcher, so
// we'll just take the first available calendar window. We also need to
// do this on a timer so that the modal window doesn't block the
// network request.
let calWindow = cal.getCalendarWindow();
let timerCallback = {
thisProvider: this.thisProvider,
@@ -191,17 +191,17 @@ cal.BadCertHandler.prototype = {
* Freebusy interval implementation. All parameters are optional.
*
* @param aCalId The calendar id to set up with.
* @param aFreeBusyType The type from calIFreeBusyInterval.
* @param aStart The start of the interval.
* @param aEnd The end of the interval.
* @return The fresh calIFreeBusyInterval.
*/
-cal.FreeBusyInterval = function calFreeBusyInterval(aCalId, aFreeBusyType, aStart, aEnd) {
+cal.FreeBusyInterval = function(aCalId, aFreeBusyType, aStart, aEnd) {
this.calId = aCalId;
this.interval = Components.classes["@mozilla.org/calendar/period;1"]
.createInstance(Components.interfaces.calIPeriod);
this.interval.start = aStart;
this.interval.end = aEnd;
this.freeBusyType = aFreeBusyType || Components.interfaces.calIFreeBusyInterval.UNKNOWN;
};
@@ -210,32 +210,32 @@ cal.FreeBusyInterval.prototype = {
calId: null,
interval: null,
freeBusyType: Components.interfaces.calIFreeBusyInterval.UNKNOWN
};
/**
* Gets the iTIP/iMIP transport if the passed calendar has configured email.
*/
-cal.getImipTransport = function calGetImipTransport(aCalendar) {
+cal.getImipTransport = function(aCalendar) {
// assure an identity is configured for the calendar
return (aCalendar.getProperty("imip.identity")
? Components.classes["@mozilla.org/calendar/itip-transport;1?type=email"]
.getService(Components.interfaces.calIItipTransport)
: null);
};
/**
* Gets the configured identity and account of a particular calendar instance, or null.
*
* @param aCalendar Calendar instance
* @param outAccount Optional out value for account
* @return The configured identity
*/
-cal.getEmailIdentityOfCalendar = function calGetEmailIdentityOfCalendar(aCalendar, outAccount) {
+cal.getEmailIdentityOfCalendar = function(aCalendar, outAccount) {
cal.ASSERT(aCalendar, "no calendar!", Components.results.NS_ERROR_INVALID_ARG);
let key = aCalendar.getProperty("imip.identity.key");
if (key !== null) {
if (key.length == 0) { // i.e. "None"
return null;
}
let identity = null;
cal.calIterateEmailIdentities(
@@ -299,17 +299,17 @@ cal.getEmailIdentityOfCalendar = functio
/**
* fromRFC3339
* Convert a RFC3339 compliant Date string to a calIDateTime.
*
* @param aStr The RFC3339 compliant Date String
* @param aTimezone The timezone this date string is most likely in
* @return A calIDateTime object
*/
-cal.fromRFC3339 = function fromRFC3339(aStr, aTimezone) {
+cal.fromRFC3339 = function(aStr, aTimezone) {
// XXX I have not covered leapseconds (matches[8]), this might need to
// be done. The only reference to leap seconds I found is bug 227329.
//
// Create a DateTime instance (calUtils.js)
let dateTime = cal.createDateTime();
// Killer regex to parse RFC3339 dates
@@ -384,17 +384,17 @@ cal.fromRFC3339 = function fromRFC3339(a
/**
* toRFC3339
* Convert a calIDateTime to a RFC3339 compliant Date string
*
* @param aDateTime The calIDateTime object
* @return The RFC3339 compliant date string
*/
-cal.toRFC3339 = function toRFC3339(aDateTime) {
+cal.toRFC3339 = function(aDateTime) {
if (!aDateTime) {
return "";
}
let full_tzoffset = aDateTime.timezoneOffset;
let tzoffset_hr = Math.floor(Math.abs(full_tzoffset) / 3600);
let tzoffset_mn = ((Math.abs(full_tzoffset) / 3600).toFixed(2) -
@@ -420,69 +420,69 @@ cal.toRFC3339 = function toRFC3339(aDate
} else {
// ZULU Time, according to ISO8601's timezone-offset
str += "Z";
}
}
return str;
};
-cal.promptOverwrite = function cal_promptOverwrite(aMode, aItem) {
+cal.promptOverwrite = function(aMode, aItem) {
let window = cal.getCalendarWindow();
let args = { item: aItem,
mode: aMode,
overwrite: false };
window.openDialog("chrome://calendar/content/calendar-conflicts-dialog.xul",
"calendarConflictsDialog",
"chrome,titlebar,modal",
args);
return args.overwrite;
};
/**
* Observer bag implementation taking care to replay open batch notifications.
*/
-cal.ObserverBag = function calObserverBag(iid) {
+cal.ObserverBag = function(iid) {
this.init(iid);
};
cal.ObserverBag.prototype = {
__proto__: cal.calListenerBag.prototype,
mBatchCount: 0,
- notify: function calObserverBag_notify(func, args) {
+ notify: function(func, args) {
switch (func) {
case "onStartBatch":
++this.mBatchCount;
break;
case "onEndBatch":
--this.mBatchCount;
break;
}
return this.__proto__.__proto__.notify.apply(this, arguments);
},
- add: function calObserverBag_add(iface) {
+ add: function(iface) {
if (this.__proto__.__proto__.add.apply(this, arguments) && (this.mBatchCount > 0)) {
// Replay batch notifications, because the onEndBatch notifications are yet to come.
// We may think about doing the reverse on remove, though I currently see no need:
for (let i = this.mBatchCount; i--;) {
iface.onStartBatch();
}
}
}
};
/**
* Base prototype to be used implementing a provider.
*
* @see e.g. providers/gdata
*/
-cal.ProviderBase = function calProviderBase() {
+cal.ProviderBase = function() {
cal.ASSERT("This prototype should only be inherited!");
};
cal.ProviderBase.mTransientProperties = {
"cache.uncachedCalendar": true,
"currentStatus": true,
"itip.transport": true,
"imip.identity": true,
"imip.account": true,
@@ -497,17 +497,17 @@ cal.ProviderBase.prototype = {
]),
mID: null,
mUri: null,
mACLEntry: null,
mObservers: null,
mProperties: null,
- initProviderBase: function cPB_initProviderBase() {
+ initProviderBase: function() {
this.wrappedJSObject = this;
this.mObservers = new cal.ObserverBag(Components.interfaces.calIObserver);
this.mProperties = {};
this.mProperties.currentStatus = Components.results.NS_OK;
},
get observers() {
return this.mObservers;
@@ -605,52 +605,43 @@ cal.ProviderBase.prototype = {
// readonly attribute boolean canRefresh;
get canRefresh() {
return false;
},
// void startBatch();
mBatchCount: 0,
- startBatch: function cPB_startBatch() {
+ startBatch: function() {
if (this.mBatchCount++ == 0) {
this.mObservers.notify("onStartBatch");
}
},
- endBatch: function cPB_endBatch() {
+ endBatch: function() {
if (this.mBatchCount > 0) {
if (--this.mBatchCount == 0) {
this.mObservers.notify("onEndBatch");
}
} else {
cal.ASSERT(this.mBatchCount > 0, "unexepcted endBatch!");
}
},
- notifyPureOperationComplete: function cPB_notifyPureOperationComplete(aListener,
- aStatus,
- aOperationType,
- aId,
- aDetail) {
+ notifyPureOperationComplete: function(aListener, aStatus, aOperationType, aId, aDetail) {
if (aListener) {
try {
aListener.onOperationComplete(this.superCalendar, aStatus, aOperationType, aId, aDetail);
} catch (exc) {
cal.ERROR(exc);
}
}
},
- notifyOperationComplete: function cPB_notifyOperationComplete(aListener,
- aStatus,
- aOperationType,
- aId,
- aDetail,
- aExtraMessage) {
+ notifyOperationComplete: function(aListener, aStatus, aOperationType, aId, aDetail, aExtraMessage) {
this.notifyPureOperationComplete(aListener, aStatus, aOperationType, aId, aDetail);
if (aStatus == Components.interfaces.calIErrors.OPERATION_CANCELLED) {
return; // cancellation doesn't change current status, no notification
}
if (Components.isSuccessCode(aStatus)) {
this.setProperty("currentStatus", aStatus);
} else {
@@ -662,17 +653,17 @@ cal.ProviderBase.prototype = {
this.notifyError(aOperationType == Components.interfaces.calIOperationListener.GET
? Components.interfaces.calIErrors.READ_FAILED
: Components.interfaces.calIErrors.MODIFICATION_FAILED,
aExtraMessage || "");
}
},
// for convenience also callable with just an exception
- notifyError: function cPB_notifyError(aErrNo, aMessage) {
+ notifyError: function(aErrNo, aMessage) {
if (aErrNo == Components.interfaces.calIErrors.OPERATION_CANCELLED) {
return; // cancellation doesn't change current status, no notification
}
if (aErrNo instanceof Components.interfaces.nsIException) {
if (!aMessage) {
aMessage = aErrNo.message;
}
aErrNo = aErrNo.result;
@@ -685,17 +676,17 @@ cal.ProviderBase.prototype = {
get transientProperties() {
return this.mTransientPropertiesMode;
},
set transientProperties(value) {
return (this.mTransientPropertiesMode = value);
},
// nsIVariant getProperty(in AUTF8String aName);
- getProperty: function cPB_getProperty(aName) {
+ getProperty: function(aName) {
switch (aName) {
case "itip.transport": // iTIP/iMIP default:
return cal.getImipTransport(this);
case "itip.notify-replies": // iTIP/iMIP default:
return Preferences.get("calendar.itip.notify-replies", false);
// temporary hack to get the uncached calendar instance:
case "cache.uncachedCalendar":
return this;
@@ -749,17 +740,17 @@ cal.ProviderBase.prototype = {
}
this.mProperties[aName] = ret;
}
// cal.LOG("getProperty(\"" + aName + "\"): " + ret);
return ret;
},
// void setProperty(in AUTF8String aName, in nsIVariant aValue);
- setProperty: function cPB_setProperty(aName, aValue) {
+ setProperty: function(aName, aValue) {
let oldValue = this.getProperty(aName);
if (oldValue != aValue) {
this.mProperties[aName] = aValue;
switch (aName) {
case "imip.identity.key": // invalidate identity and account object if key is set:
delete this.mProperties["imip.identity"];
delete this.mProperties["imip.account"];
delete this.mProperties.organizerId;
@@ -773,39 +764,39 @@ cal.ProviderBase.prototype = {
}
this.mObservers.notify("onPropertyChanged",
[this.superCalendar, aName, aValue, oldValue]);
}
return aValue;
},
// void deleteProperty(in AUTF8String aName);
- deleteProperty: function cPB_deleteProperty(aName) {
+ deleteProperty: function(aName) {
this.mObservers.notify("onPropertyDeleting", [this.superCalendar, aName]);
delete this.mProperties[aName];
cal.getCalendarManager().deleteCalendarPref_(this, aName);
},
// calIOperation refresh
- refresh: function cPB_refresh() {
+ refresh: function() {
return null;
},
// void addObserver( in calIObserver observer );
- addObserver: function cPB_addObserver(aObserver) {
+ addObserver: function(aObserver) {
this.mObservers.add(aObserver);
},
// void removeObserver( in calIObserver observer );
- removeObserver: function cPB_removeObserver(aObserver) {
+ removeObserver: function(aObserver) {
this.mObservers.remove(aObserver);
},
// calISchedulingSupport: Implementation corresponding to our iTIP/iMIP support
- isInvitation: function cPB_isInvitation(aItem) {
+ isInvitation: function(aItem) {
if (!this.mACLEntry || !this.mACLEntry.hasAccessControl) {
// No ACL support - fallback to the old method
let id = this.getProperty("organizerId");
if (id) {
let org = aItem.organizer;
if (!org || !org.id || (org.id.toLowerCase() == id.toLowerCase())) {
return false;
}
@@ -842,17 +833,17 @@ cal.ProviderBase.prototype = {
if (aItem.getAttendeeById(identity) != null) {
return true;
}
}
return false;
},
- getInvitedAttendee: function cPB_getInvitedAttendee(aItem) {
+ getInvitedAttendee: function(aItem) {
let id = this.getProperty("organizerId");
let attendee = (id ? aItem.getAttendeeById(id) : null);
if (!attendee && this.mACLEntry && this.mACLEntry.hasAccessControl) {
let ownerIdentities = this.mACLEntry.getOwnerIdentities({});
if (ownerIdentities.length > 0) {
let identity;
for (let i = 0; !attendee && i < ownerIdentities.length; i++) {
@@ -860,12 +851,12 @@ cal.ProviderBase.prototype = {
attendee = aItem.getAttendeeById(identity);
}
}
}
return attendee;
},
- canNotify: function cPB_canNotify(aMethod, aItem) {
+ canNotify: function(aMethod, aItem) {
return false; // use outbound iTIP for all
}
};
--- a/calendar/base/modules/calUtils.jsm
+++ b/calendar/base/modules/calUtils.jsm
@@ -26,17 +26,17 @@ var cal = {
/**
* Loads an array of calendar scripts into the passed scope.
*
* @param scriptNames an array of calendar script names
* @param scope scope to load into
* @param baseDir base dir; defaults to calendar-js/
*/
- loadScripts: function cal_loadScripts(scriptNames, scope, baseDir) {
+ loadScripts: function(scriptNames, scope, baseDir) {
if (!baseDir) {
baseDir = __LOCATION__.parent.parent.clone();
baseDir.append("calendar-js");
}
for (let script of scriptNames) {
if (!script) {
// If the array element is null, then just skip this script.
@@ -49,33 +49,33 @@ var cal = {
Services.scriptloader.loadSubScript(scriptUrlSpec, scope);
} catch (exc) {
Components.utils.reportError(exc + " (" + scriptUrlSpec + ")");
}
}
},
loadingNSGetFactory: function(scriptNames, components, scope) {
- return function NSGetFactory(cid) {
+ return function(cid) {
if (!this.inner) {
let global = Components.utils.getGlobalForObject(scope);
cal.loadScripts(scriptNames, global);
if (typeof components == "function") {
components = components.call(global);
}
this.inner = XPCOMUtils.generateNSGetFactory(components);
}
return this.inner(cid);
};
},
/**
* Schedules execution of the passed function to the current thread's queue.
*/
- postPone: function cal_postPone(func) {
+ postPone: function(func) {
if (this.threadingEnabled) {
Services.tm.currentThread.dispatch({ run: func },
Components.interfaces.nsIEventTarget.DISPATCH_NORMAL);
} else {
func();
}
},
@@ -90,17 +90,17 @@ var cal = {
* clean adapter.
*
* Currently supported interfaces are:
* - calIObserver
* - calICalendarManagerObserver
* - calIOperationListener
* - calICompositeObserver
*/
- createAdapter: function createAdapter(iface, template) {
+ createAdapter: function(iface, template) {
let methods;
let adapter = template || {};
switch (iface.name || iface) {
case "calIObserver":
methods = ["onStartBatch", "onEndBatch", "onLoad", "onAddItem",
"onModifyItem", "onDeleteItem", "onError",
"onPropertyChanged", "onPropertyDeleting"];
break;
@@ -137,43 +137,43 @@ var cal = {
return gCalThreadingEnabled;
},
/*
* Checks whether a calendar supports events
*
* @param aCalendar
*/
- isEventCalendar: function cal_isEventCalendar(aCalendar) {
+ isEventCalendar: function(aCalendar) {
return (aCalendar.getProperty("capabilities.events.supported") !== false);
},
/*
* Checks whether a calendar supports tasks
*
* @param aCalendar
*/
- isTaskCalendar: function cal_isTaskCalendar(aCalendar) {
+ isTaskCalendar: function(aCalendar) {
return (aCalendar.getProperty("capabilities.tasks.supported") !== false);
},
/**
* Checks whether a timezone lacks a definition.
*/
- isPhantomTimezone: function cal_isPhantomTimezone(tz) {
+ isPhantomTimezone: function(tz) {
return (!tz.icalComponent && !tz.isUTC && !tz.isFloating);
},
/**
* Shifts an item by the given timely offset.
*
* @param item an item
* @param offset an offset (calIDuration)
*/
- shiftItem: function cal_shiftItem(item, offset) {
+ shiftItem: function(item, offset) {
// When modifying dates explicitly using the setters is important
// since those may triggers e.g. calIRecurrenceInfo::onStartDateChange
// or invalidate other properties. Moreover don't modify the date-time objects
// without cloning, because changes cannot be calculated if doing so.
if (cal.isEvent(item)) {
let date = item.startDate.clone();
date.addDuration(offset);
item.startDate = date;
@@ -221,27 +221,27 @@ var cal = {
item = item.makeImmutable();
}
return item;
},
/**
* Shortcut function to serialize an item (including all overridden items).
*/
- getSerializedItem: function cal_getSerializedItem(aItem) {
+ getSerializedItem: function(aItem) {
let serializer = Components.classes["@mozilla.org/calendar/ics-serializer;1"]
.createInstance(Components.interfaces.calIIcsSerializer);
serializer.addItems([aItem], 1);
return serializer.serializeToString();
},
/**
* Shortcut function to check whether an item is an invitation copy.
*/
- isInvitation: function cal_isInvitation(aItem) {
+ isInvitation: function(aItem) {
let isInvitation = false;
let calendar = cal.wrapInstance(aItem.calendar, Components.interfaces.calISchedulingSupport);
if (calendar) {
isInvitation = calendar.isInvitation(aItem);
}
return isInvitation;
},
@@ -301,17 +301,17 @@ var cal = {
},
/**
* Shortcut function to check whether an item is an invitation copy and
* has a participation status of either NEEDS-ACTION or TENTATIVE.
*
* @param aItem either calIAttendee or calIItemBase
*/
- isOpenInvitation: function cal_isOpenInvitation(aItem) {
+ isOpenInvitation: function(aItem) {
let wrappedItem = cal.wrapInstance(aItem, Components.interfaces.calIAttendee);
if (!wrappedItem) {
aItem = cal.getInvitedAttendee(aItem);
}
if (aItem) {
switch (aItem.participationStatus) {
case "NEEDS-ACTION":
case "TENTATIVE":
@@ -377,17 +377,17 @@ var cal = {
delegatees: delegatees.join(", "),
delegators: delegators.join(", ")
};
},
/**
* Shortcut function to get the invited attendee of an item.
*/
- getInvitedAttendee: function cal_getInvitedAttendee(aItem, aCalendar) {
+ getInvitedAttendee: function(aItem, aCalendar) {
if (!aCalendar) {
aCalendar = aItem.calendar;
}
let invitedAttendee = null;
let calendar = cal.wrapInstance(aCalendar, Components.interfaces.calISchedulingSupport);
if (calendar) {
invitedAttendee = calendar.getInvitedAttendee(aItem);
}
@@ -458,116 +458,116 @@ var cal = {
: "OPAQUE";
}
return transp;
},
// The below functions will move to some different place once the
// unifinder tress are consolidated.
- compareNativeTime: function cal_compareNativeTime(a, b) {
+ compareNativeTime: function(a, b) {
if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return 0;
}
},
- compareNativeTimeFilledAsc: function cal_compareNativeTimeFilledAsc(a, b) {
+ compareNativeTimeFilledAsc: function(a, b) {
if (a == b) {
return 0;
}
// In this filter, a zero time (not set) is always at the end.
if (a == -62168601600000000) { // value for (0000/00/00 00:00:00)
return 1;
}
if (b == -62168601600000000) { // value for (0000/00/00 00:00:00)
return -1;
}
return (a < b ? -1 : 1);
},
- compareNativeTimeFilledDesc: function cal_compareNativeTimeFilledDesc(a, b) {
+ compareNativeTimeFilledDesc: function(a, b) {
if (a == b) {
return 0;
}
// In this filter, a zero time (not set) is always at the end.
if (a == -62168601600000000) { // value for (0000/00/00 00:00:00)
return 1;
}
if (b == -62168601600000000) { // value for (0000/00/00 00:00:00)
return -1;
}
return (a < b ? 1 : -1);
},
- compareNumber: function cal_compareNumber(a, b) {
+ compareNumber: function(a, b) {
a = Number(a);
b = Number(b);
if (a < b) {
return -1;
} else if (a > b) {
return 1;
} else {
return 0;
}
},
- sortEntryComparer: function cal_sortEntryComparer(sortType, modifier) {
+ sortEntryComparer: function(sortType, modifier) {
switch (sortType) {
case "number":
- return function compareNumbers(sortEntryA, sortEntryB) {
+ return function(sortEntryA, sortEntryB) {
let nsA = cal.sortEntryKey(sortEntryA);
let nsB = cal.sortEntryKey(sortEntryB);
return cal.compareNumber(nsA, nsB) * modifier;
};
case "date":
- return function compareTimes(sortEntryA, sortEntryB) {
+ return function(sortEntryA, sortEntryB) {
let nsA = cal.sortEntryKey(sortEntryA);
let nsB = cal.sortEntryKey(sortEntryB);
return cal.compareNativeTime(nsA, nsB) * modifier;
};
case "date_filled":
- return function compareTimesFilled(sortEntryA, sortEntryB) {
+ return function(sortEntryA, sortEntryB) {
let nsA = cal.sortEntryKey(sortEntryA);
let nsB = cal.sortEntryKey(sortEntryB);
if (modifier == 1) {
return cal.compareNativeTimeFilledAsc(nsA, nsB);
} else {
return cal.compareNativeTimeFilledDesc(nsA, nsB);
}
};
case "string":
- return function compareStrings(sortEntryA, sortEntryB) {
+ return function(sortEntryA, sortEntryB) {
let sA = cal.sortEntryKey(sortEntryA);
let sB = cal.sortEntryKey(sortEntryB);
if (sA.length == 0 || sB.length == 0) {
// sort empty values to end (so when users first sort by a
// column, they can see and find the desired values in that
// column without scrolling past all the empty values).
return -(sA.length - sB.length) * modifier;
}
let collator = cal.createLocaleCollator();
let comparison = collator.compareString(0, sA, sB);
return comparison * modifier;
};
default:
- return function compareOther(sortEntryA, sortEntryB) {
+ return function(sortEntryA, sortEntryB) {
return 0;
};
}
},
- getItemSortKey: function cal_getItemSortKey(aItem, aKey, aStartTime) {
+ getItemSortKey: function(aItem, aKey, aStartTime) {
switch (aKey) {
case "priority":
return aItem.priority || 5;
case "title":
return aItem.title || "";
case "entryDate":
@@ -603,17 +603,17 @@ var cal = {
case "calendar":
return aItem.calendar.name || "";
default:
return null;
}
},
- getSortTypeForSortKey: function cal_getSortTypeForSortKey(aSortKey) {
+ getSortTypeForSortKey: function(aSortKey) {
switch (aSortKey) {
case "title":
case "categories":
case "location":
case "calendar":
return "string";
// All dates use "date_filled"
@@ -628,30 +628,30 @@ var cal = {
case "percentComplete":
case "status":
return "number";
default:
return "unknown";
}
},
- nativeTimeOrNow: function cal_nativeTimeOrNow(calDateTime, sortStartedTime) {
+ nativeTimeOrNow: function(calDateTime, sortStartedTime) {
// Treat null/0 as 'now' when sort started, so incomplete tasks stay current.
// Time is computed once per sort (just before sort) so sort is stable.
if (calDateTime == null) {
return sortStartedTime.nativeTime;
}
let ns = calDateTime.nativeTime;
if (ns == -62168601600000000) { // ns value for (0000/00/00 00:00:00)
return sortStartedTime;
}
return ns;
},
- nativeTime: function cal_nativeTime(calDateTime) {
+ nativeTime: function(calDateTime) {
if (calDateTime == null) {
return -62168601600000000; // ns value for (0000/00/00 00:00:00)
}
return calDateTime.nativeTime;
},
/**
* Returns a calIDateTime corresponding to a javascript Date.
@@ -660,17 +660,17 @@ var cal = {
* @param aTimezone (optional) a timezone that should be enforced
* @returns a calIDateTime
*
* @warning Use of this function is strongly discouraged. calIDateTime should
* be used directly whenever possible.
* If you pass a timezone, then the passed jsDate's timezone will be ignored,
* but only its local time portions are be taken.
*/
- jsDateToDateTime: function jsDateToDateTime(aDate, aTimezone) {
+ jsDateToDateTime: function(aDate, aTimezone) {
let newDate = cal.createDateTime();
if (aTimezone) {
newDate.resetTo(aDate.getFullYear(),
aDate.getMonth(),
aDate.getDate(),
aDate.getHours(),
aDate.getMinutes(),
aDate.getSeconds(),
@@ -692,54 +692,54 @@ var cal = {
if (cdt.timezone.isFloating) {
return new Date(cdt.year, cdt.month, cdt.day,
cdt.hour, cdt.minute, cdt.second);
} else {
return new Date(cdt.nativeTime / 1000);
}
},
- sortEntry: function cal_sortEntry(aItem) {
+ sortEntry: function(aItem) {
let key = cal.getItemSortKey(aItem, this.mSortKey, this.mSortStartedDate);
return { mSortKey: key, mItem: aItem };
},
- sortEntryItem: function cal_sortEntryItem(sortEntry) {
+ sortEntryItem: function(sortEntry) {
return sortEntry.mItem;
},
- sortEntryKey: function cal_sortEntryKey(sortEntry) {
+ sortEntryKey: function(sortEntry) {
return sortEntry.mSortKey;
},
- createLocaleCollator: function cal_createLocaleCollator() {
+ createLocaleCollator: function() {
return Components.classes["@mozilla.org/intl/collation-factory;1"]
.getService(Components.interfaces.nsICollationFactory)
.CreateCollation(Services.locale.getApplicationLocale());
},
/**
* Sort an array of strings according to the current locale.
* Modifies aStringArray, returning it sorted.
*/
- sortArrayByLocaleCollator: function cal_sortArrayByLocaleCollator(aStringArray) {
+ sortArrayByLocaleCollator: function(aStringArray) {
let localeCollator = cal.createLocaleCollator();
function compare(a, b) { return localeCollator.compareString(0, a, b); }
aStringArray.sort(compare);
return aStringArray;
},
/**
* Gets the month name string in the right form depending on a base string.
*
* @param aMonthNum The month numer to get, 1-based.
* @param aBundleName The Bundle to get the string from
* @param aStringBase The base string name, .monthFormat will be appended
*/
- formatMonth: function formatMonth(aMonthNum, aBundleName, aStringBase) {
+ formatMonth: function(aMonthNum, aBundleName, aStringBase) {
let monthForm = cal.calGetString(aBundleName, aStringBase + ".monthFormat") || "nominative";
if (monthForm == "nominative") {
// Fall back to the default name format
monthForm = "name";
}
return cal.calGetString("dateFormat", "month." + aMonthNum + "." + monthForm);
@@ -747,17 +747,17 @@ var cal = {
/**
* moves an item to another startDate
*
* @param aOldItem The Item to be modified
* @param aNewDate The date at which the new item is going to start
* @return The modified item
*/
- moveItem: function cal_moveItem(aOldItem, aNewDate) {
+ moveItem: function(aOldItem, aNewDate) {
let newItem = aOldItem.clone();
let start = (aOldItem[calGetStartDateProp(aOldItem)] ||
aOldItem[calGetEndDateProp(aOldItem)]).clone();
let isDate = start.isDate;
start.resetTo(aNewDate.year, aNewDate.month, aNewDate.day,
start.hour, start.minute, start.second,
start.timezone);
start.isDate = isDate;
@@ -779,17 +779,17 @@ var cal = {
/**
* sets the 'isDate' property of an item
*
* @param aItem The Item to be modified
* @param aIsDate True or false indicating the new value of 'isDate'
* @return The modified item
*/
- setItemToAllDay: function cal_setItemToAllDay(aItem, aIsDate) {
+ setItemToAllDay: function(aItem, aIsDate) {
let start = aItem[calGetStartDateProp(aItem)];
let end = aItem[calGetEndDateProp(aItem)];
if (start || end) {
let item = aItem.clone();
if (start && (start.isDate != aIsDate)) {
start = start.clone();
start.isDate = aIsDate;
item[calGetStartDateProp(item)] = start;
@@ -808,17 +808,17 @@ var cal = {
/**
* checks if the mousepointer of an event resides over a XULBox during an event
*
* @param aMouseEvent The event eg. a 'mouseout' or 'mousedown' event
* @param aXULBox The xul element
* @return true or false depending on whether the mouse pointer
* resides over the xulelement
*/
- isMouseOverBox: function cal_isMouseOverBox(aMouseEvent, aXULElement) {
+ isMouseOverBox: function(aMouseEvent, aXULElement) {
let boxObject = aXULElement.boxObject;
let boxWidth = boxObject.width;
let boxHeight = boxObject.height;
let boxScreenX = boxObject.screenX;
let boxScreenY = boxObject.screenY;
let mouseX = aMouseEvent.screenX;
let mouseY = aMouseEvent.screenY;
let xIsWithin = (mouseX >= boxScreenX) &&
@@ -830,17 +830,17 @@ var cal = {
/**
* removes those childnodes from a node that contain a specified attribute
* and where the value of this attribute matches a passed value
* @param aParentNode The parent node that contains the child nodes in question
* @param aAttribute The name of the attribute
* @param aAttribute The value of the attribute
*/
- removeChildElementsByAttribute: function removeChildElementsByAttribute(aParentNode, aAttribute, aValue) {
+ removeChildElementsByAttribute: function(aParentNode, aAttribute, aValue) {
let childNode = aParentNode.lastChild;
while (childNode) {
let prevChildNode = childNode.previousSibling;
if (!aAttribute || aAttribute === undefined) {
childNode.remove();
} else if (!aValue || aValue === undefined) {
childNode.remove();
} else if (childNode && childNode.hasAttribute(aAttribute) &&
@@ -849,31 +849,31 @@ var cal = {
}
childNode = prevChildNode;
}
},
/**
* Returns the most recent calendar window in an application independent way
*/
- getCalendarWindow: function cal_getCalendarWindow() {
+ getCalendarWindow: function() {
return Services.wm.getMostRecentWindow("calendarMainWindow") ||
Services.wm.getMostRecentWindow("mail:3pane");
},
/**
* Adds an observer listening for the topic.
*
* @param func function to execute on topic
* @param topic topic to listen for
* @param oneTime whether to listen only once
*/
- addObserver: function cal_addObserver(func, topic, oneTime) {
+ addObserver: function(func, topic, oneTime) {
let observer = { // nsIObserver:
- observe: function cal_addObserver_observe(subject, topic_, data) {
+ observe: function(subject, topic_, data) {
if (topic == topic_) {
if (oneTime) {
Services.obs.removeObserver(this, topic);
}
func(subject, topic, data);
}
}
};
@@ -895,34 +895,34 @@ var cal = {
* }
* // GOOD USAGE:
* foo = cal.wrapInstance(foo, Ci.nsIBar);
* if (foo) {
* foo.barMethod();
* }
*
*/
- wrapInstance: function wrapInstance(aObj, aInterface) {
+ wrapInstance: function(aObj, aInterface) {
if (!aObj) {
return null;
}
try {
return aObj.QueryInterface(aInterface);
} catch (e) {
return null;
}
},
/**
* Adds an xpcom shutdown observer.
*
* @param func function to execute
*/
- addShutdownObserver: function cal_addShutdownObserver(func) {
+ addShutdownObserver: function(func) {
cal.addObserver(func, "xpcom-shutdown", true /* one time */);
},
/**
* Due to wrapped js objects, some objects may have cyclic references.
* You can register properties of objects to be cleaned up on xpcom-shutdown.
*
* @param obj object
@@ -950,16 +950,17 @@ function shutdownCleanup(obj, prop) {
});
}
shutdownCleanup.mEntries.push({ mObj: obj, mProp: prop });
}
// local to this module;
// will be used to generate service accessor functions
function generateServiceAccessor(id, iface) {
+ // eslint-disable-next-line func-names
return function this_() {
if (!("mService" in this_)) {
this_.mService = Components.classes[id].getService(iface);
shutdownCleanup(this_, "mService");
}
return this_.mService;
};
}
--- a/calendar/base/modules/calXMLUtils.jsm
+++ b/calendar/base/modules/calXMLUtils.jsm
@@ -18,17 +18,17 @@ cal.xml = {} || cal.xml;
* - an array of strings or DOM elements
*
* @param aNode The context node to search from
* @param aExpr The XPath expression to search for
* @param aResolver (optional) The namespace resolver to use for the expression
* @param aType (optional) Force a result type, must be an XPathResult constant
* @return The result, see above for details.
*/
-cal.xml.evalXPath = function evaluateXPath(aNode, aExpr, aResolver, aType) {
+cal.xml.evalXPath = function(aNode, aExpr, aResolver, aType) {
const XPR = Components.interfaces.nsIDOMXPathResult;
let doc = (aNode.ownerDocument ? aNode.ownerDocument : aNode);
let resolver = aResolver || doc.createNSResolver(doc.documentElement);
let resultType = aType || XPR.ANY_TYPE;
let result = doc.evaluate(aExpr, aNode, resolver, resultType, null);
let returnResult, next;
switch (result.resultType) {
@@ -93,17 +93,17 @@ cal.xml.evalXPath = function evaluateXPa
* - A string, number, boolean or DOM Element value
*
* @param aNode The context node to search from
* @param aExpr The XPath expression to search for
* @param aResolver (optional) The namespace resolver to use for the expression
* @param aType (optional) Force a result type, must be an XPathResult constant
* @return The result, see above for details.
*/
-cal.xml.evalXPathFirst = function evalXPathFirst(aNode, aExpr, aResolver, aType) {
+cal.xml.evalXPathFirst = function(aNode, aExpr, aResolver, aType) {
let result = cal.xml.evalXPath(aNode, aExpr, aResolver, aType);
if (Array.isArray(result)) {
return result[0];
} else {
return result;
}
};
@@ -155,17 +155,17 @@ cal.xml.serializeDOM = function(doc) {
/**
* Escape a string for use in XML
*
* @param str The string to escape
* @param isAttribute If true, " and ' are also escaped
* @return The escaped string
*/
-cal.xml.escapeString = function escapeString(str, isAttribute) {
+cal.xml.escapeString = function(str, isAttribute) {
return str.replace(/[&<>'"]/g, function(chr) {
switch (chr) {
case "&": return "&";
case "<": return "<";
case ">": return ">";
case '"': return (isAttribute ? """ : chr);
case "'": return (isAttribute ? "'" : chr);
default: return chr;
--- a/calendar/base/src/calAlarm.js
+++ b/calendar/base/src/calAlarm.js
@@ -45,27 +45,27 @@ calAlarm.prototype = {
classDescription: "Describes a VALARM",
interfaces: calAlarmInterfaces
}),
/**
* calIAlarm
*/
- ensureMutable: function cA_ensureMutable() {
+ ensureMutable: function() {
if (this.mImmutable) {
throw Components.results.NS_ERROR_OBJECT_IS_IMMUTABLE;
}
},
get isMutable() {
return !this.mImmutable;
},
- makeImmutable: function cA_makeImmutable() {
+ makeImmutable: function() {
if (this.mImmutable) {
return;
}
const objectMembers = ["mAbsoluteDate",
"mOffset",
"mDuration",
"mLastAck"];
@@ -85,17 +85,17 @@ calAlarm.prototype = {
prop.value.makeImmutable();
}
}
}
this.mImmutable = true;
},
- clone: function cA_clone() {
+ clone: function() {
let m = new calAlarm();
m.mImmutable = false;
const simpleMembers = ["mAction",
"mSummary",
"mDescription",
"mRelated",
@@ -274,93 +274,93 @@ calAlarm.prototype = {
let alarmDate = this.mAbsoluteDate.clone();
// All Day events are handled as 00:00:00
alarmDate.isDate = false;
alarmDate.addDuration(this.mDuration);
return alarmDate;
},
- getAttendees: function getAttendees(aCount) {
+ getAttendees: function(aCount) {
let attendees;
if (this.action == "AUDIO" || this.action == "DISPLAY") {
attendees = [];
} else {
attendees = this.mAttendees.concat([]);
}
aCount.value = attendees.length;
return attendees;
},
- addAttendee: function addAttendee(aAttendee) {
+ addAttendee: function(aAttendee) {
// Make sure its not duplicate
this.deleteAttendee(aAttendee);
// Now check if its valid
if (this.action == "AUDIO" || this.action == "DISPLAY") {
throw new Error("Alarm type AUDIO/DISPLAY may not have attendees");
}
// And add it (again)
this.mAttendees.push(aAttendee);
},
- deleteAttendee: function deleteAttendee(aAttendee) {
+ deleteAttendee: function(aAttendee) {
let deleteId = aAttendee.id;
for (let i = 0; i < this.mAttendees.length; i++) {
if (this.mAttendees[i].id == deleteId) {
this.mAttendees.splice(i, 1);
break;
}
}
},
- clearAttendees: function clearAttendees() {
+ clearAttendees: function() {
this.mAttendees = [];
},
- getAttachments: function getAttachments(aCount) {
+ getAttachments: function(aCount) {
let attachments;
if (this.action == "AUDIO") {
attachments = (this.mAttachments.length ? [this.mAttachments[0]] : []);
} else if (this.action == "DISPLAY") {
attachments = [];
} else {
attachments = this.mAttachments.concat([]);
}
aCount.value = attachments.length;
return attachments;
},
- addAttachment: function addAttachment(aAttachment) {
+ addAttachment: function(aAttachment) {
// Make sure its not duplicate
this.deleteAttachment(aAttachment);
// Now check if its valid
if (this.action == "AUDIO" && this.mAttachments.length) {
throw new Error("Alarm type AUDIO may only have one attachment");
} else if (this.action == "DISPLAY") {
throw new Error("Alarm type DISPLAY may not have attachments");
}
// And add it (again)
this.mAttachments.push(aAttachment);
},
- deleteAttachment: function deleteAttachment(aAttachment) {
+ deleteAttachment: function(aAttachment) {
let deleteHash = aAttachment.hashId;
for (let i = 0; i < this.mAttachments.length; i++) {
if (this.mAttachments[i].hashId == deleteHash) {
this.mAttachments.splice(i, 1);
break;
}
}
},
- clearAttachments: function clearAttachments() {
+ clearAttachments: function() {
this.mAttachments = [];
},
get icalString() {
let comp = this.icalComponent;
return (comp ? comp.serializeToICS() : "");
},
set icalString(val) {
@@ -577,55 +577,55 @@ calAlarm.prototype = {
}
this.mPropertyParams[prop.propertyName][paramName] = param;
}
}
}
return aComp;
},
- hasProperty: function cA_hasProperty(aName) {
+ hasProperty: function(aName) {
return (this.getProperty(aName.toUpperCase()) != null);
},
- getProperty: function cA_getProperty(aName) {
+ getProperty: function(aName) {
let name = aName.toUpperCase();
if (name in this.promotedProps) {
return this[this.promotedProps[name]];
} else {
return this.mProperties.getProperty(name);
}
},
- setProperty: function cA_setProperty(aName, aValue) {
+ setProperty: function(aName, aValue) {
this.ensureMutable();
let name = aName.toUpperCase();
if (name in this.promotedProps) {
this[this.promotedProps[name]] = aValue;
} else {
this.mProperties.setProperty(name, aValue);
}
return aValue;
},
- deleteProperty: function cA_deleteProperty(aName) {
+ deleteProperty: function(aName) {
this.ensureMutable();
let name = aName.toUpperCase();
if (name in this.promotedProps) {
this[this.promotedProps[name]] = null;
} else {
this.mProperties.deleteProperty(name);
}
},
get propertyEnumerator() {
return this.mProperties.enumerator;
},
- toString: function cA_toString(aItem) {
+ toString: function(aItem) {
function getItemBundleStringName(aPrefix) {
if (!aItem || isEvent(aItem)) {
return aPrefix + "Event";
} else if (isToDo(aItem)) {
return aPrefix + "Task";
} else {
return aPrefix;
}
--- a/calendar/base/src/calAlarmMonitor.js
+++ b/calendar/base/src/calAlarmMonitor.js
@@ -48,33 +48,33 @@ calAlarmMonitor.prototype = {
classID: calAlarmMonitorClassID,
interfaces: calAlarmMonitorInterfaces,
flags: Components.interfaces.nsIClassInfo.SINGLETON
}),
/**
* nsIObserver
*/
- observe: function cAM_observe(aSubject, aTopic, aData) {
+ observe: function(aSubject, aTopic, aData) {
let alarmService = Components.classes["@mozilla.org/calendar/alarm-service;1"]
.getService(Components.interfaces.calIAlarmService);
switch (aTopic) {
case "alarm-service-startup":
alarmService.addObserver(this);
break;
case "alarm-service-shutdown":
alarmService.removeObserver(this);
break;
}
},
/**
* calIAlarmServiceObserver
*/
- onAlarm: function cAM_onAlarm(aItem, aAlarm) {
+ onAlarm: function(aItem, aAlarm) {
if (aAlarm.action != "DISPLAY") {
// This monitor only looks for DISPLAY alarms.
return;
}
this.mAlarms.push([aItem, aAlarm]);
if (Preferences.get("calendar.alarms.playsound", true)) {
@@ -127,55 +127,55 @@ calAlarmMonitor.prototype = {
"chrome,dialog=yes,all,resizable",
this);
}
if (!this.mWindowOpening) {
calAlarmWindow.addWidgetFor(aItem, aAlarm);
}
},
- window_onLoad: function cAM_window_onLoad() {
+ window_onLoad: function() {
let calAlarmWindow = this.mWindowOpening;
this.mWindowOpening = null;
if (this.mAlarms.length > 0) {
for (let [item, alarm] of this.mAlarms) {
calAlarmWindow.addWidgetFor(item, alarm);
}
} else {
// Uh oh, it seems the alarms were removed even before the window
// finished loading. Looks like we can close it again
calAlarmWindow.closeIfEmpty();
}
},
- onRemoveAlarmsByItem: function cAM_onRemoveAlarmsByItem(aItem) {
+ onRemoveAlarmsByItem: function(aItem) {
let calAlarmWindow = peekAlarmWindow();
this.mAlarms = this.mAlarms.filter(function(itemAlarm) {
let [thisItem, alarm] = itemAlarm;
let ret = (aItem.hashId != thisItem.hashId);
if (!ret && calAlarmWindow) { // window is open
calAlarmWindow.removeWidgetFor(thisItem, alarm);
}
return ret;
});
},
- onRemoveAlarmsByCalendar: function cAM_onRemoveAlarmsByCalendar(calendar) {
+ onRemoveAlarmsByCalendar: function(calendar) {
let calAlarmWindow = peekAlarmWindow();
this.mAlarms = this.mAlarms.filter(function(itemAlarm) {
let [thisItem, alarm] = itemAlarm;
let ret = (calendar.id != thisItem.calendar.id);
if (!ret && calAlarmWindow) { // window is open
calAlarmWindow.removeWidgetFor(thisItem, alarm);
}
return ret;
});
},
- onAlarmsLoaded: function cAM_onAlarmsLoaded(aCalendar) {
+ onAlarmsLoaded: function(aCalendar) {
// the alarm dialog won't close while alarms are loading, check again now
let calAlarmWindow = peekAlarmWindow();
if (calAlarmWindow && this.mAlarms.length == 0) {
calAlarmWindow.closeIfEmpty();
}
}
};
--- a/calendar/base/src/calAlarmService.js
+++ b/calendar/base/src/calAlarmService.js
@@ -36,17 +36,17 @@ function calAlarmService() {
this.calendarObserver = {
alarmService: this,
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIObserver]),
// calIObserver:
onStartBatch: function() { },
onEndBatch: function() { },
- onLoad: function co_onLoad(calendar) {
+ onLoad: function(calendar) {
// ignore any onLoad events until initial getItems() call of startup has finished:
if (calendar && this.alarmService.mLoadedCalendars[calendar.id]) {
// a refreshed calendar signals that it has been reloaded
// (and cannot notify detailed changes), thus reget all alarms of it:
this.alarmService.initAlarms([calendar]);
}
},
@@ -121,17 +121,17 @@ calAlarmService.prototype = {
classDescription: "Calendar Alarm Service",
interfaces: calAlarmServiceInterfaces,
flags: Components.interfaces.nsIClassInfo.SINGLETON
}),
/**
* nsIObserver
*/
- observe: function cAS_observe(aSubject, aTopic, aData) {
+ observe: function(aSubject, aTopic, aData) {
// This will also be called on app-startup, but nothing is done yet, to
// prevent unwanted dialogs etc. See bug 325476 and 413296
if (aTopic == "profile-after-change" || aTopic == "wake_notification") {
this.shutdown();
this.startup();
}
if (aTopic == "xpcom-shutdown") {
this.shutdown();
@@ -146,17 +146,17 @@ calAlarmService.prototype = {
// different than the default timezone?
return this.mTimezone || calendarDefaultTimezone();
},
set timezone(aTimezone) {
return (this.mTimezone = aTimezone);
},
- snoozeAlarm: function cAS_snoozeAlarm(aItem, aAlarm, aDuration) {
+ snoozeAlarm: function(aItem, aAlarm, aDuration) {
// Right now we only support snoozing all alarms for the given item for
// aDuration.
// Make sure we're working with the parent, otherwise we'll accidentally
// create an exception
let newEvent = aItem.parentItem.clone();
let alarmTime = nowUTC();
@@ -176,42 +176,42 @@ calAlarmService.prototype = {
} else {
newEvent.setProperty("X-MOZ-SNOOZE-TIME", alarmTime.icalString);
}
// calling modifyItem will cause us to get the right callback
// and update the alarm properly
return newEvent.calendar.modifyItem(newEvent, aItem.parentItem, null);
},
- dismissAlarm: function cAS_dismissAlarm(aItem, aAlarm) {
+ dismissAlarm: function(aItem, aAlarm) {
let now = nowUTC();
// We want the parent item, otherwise we're going to accidentally create an
// exception. We've relnoted (for 0.1) the slightly odd behavior this can
// cause if you move an event after dismissing an alarm
let oldParent = aItem.parentItem;
let newParent = oldParent.clone();
newParent.alarmLastAck = now;
// Make sure to clear out any snoozes that were here.
if (aItem.recurrenceId) {
newParent.deleteProperty("X-MOZ-SNOOZE-TIME-" + aItem.recurrenceId.nativeTime);
} else {
newParent.deleteProperty("X-MOZ-SNOOZE-TIME");
}
return newParent.calendar.modifyItem(newParent, oldParent, null);
},
- addObserver: function cAS_addObserver(aObserver) {
+ addObserver: function(aObserver) {
this.mObservers.add(aObserver);
},
- removeObserver: function cAS_removeObserver(aObserver) {
+ removeObserver: function(aObserver) {
this.mObservers.remove(aObserver);
},
- startup: function cAS_startup() {
+ startup: function() {
if (this.mStarted) {
return;
}
Services.obs.addObserver(this, "profile-after-change", false);
Services.obs.addObserver(this, "xpcom-shutdown", false);
Services.obs.addObserver(this, "wake_notification", false);
@@ -225,17 +225,17 @@ calAlarmService.prototype = {
for (let calendar of getCalendarManager().getCalendars({})) {
this.observeCalendar(calendar);
}
/* set up a timer to update alarms every N hours */
let timerCallback = {
alarmService: this,
- notify: function timer_notify() {
+ notify: function() {
let now = nowUTC();
let start;
if (!this.alarmService.mRangeEnd) {
// This is our first search for alarms. We're going to look for
// alarms +/- 1 month from now. If someone sets an alarm more than
// a month ahead of an event, or doesn't start Lightning
// for a month, they'll miss some, but that's a slim chance
start = now.clone();
@@ -259,17 +259,17 @@ calAlarmService.prototype = {
};
timerCallback.notify();
this.mUpdateTimer = newTimerWithCallback(timerCallback, kHoursBetweenUpdates * 3600000, true);
this.mStarted = true;
},
- shutdown: function cAS_shutdown() {
+ shutdown: function() {
if (!this.mStarted) {
return;
}
/* tell people that we're no longer running */
let notifier = Components.classes["@mozilla.org/embedcomp/appstartup-notifier;1"]
.getService(Components.interfaces.nsIObserver);
notifier.observe(null, "alarm-service-shutdown", null);
@@ -291,27 +291,27 @@ calAlarmService.prototype = {
Services.obs.removeObserver(this, "profile-after-change");
Services.obs.removeObserver(this, "xpcom-shutdown");
Services.obs.removeObserver(this, "wake_notification");
this.mStarted = false;
},
- observeCalendar: function cAS_observeCalendar(calendar) {
+ observeCalendar: function(calendar) {
calendar.addObserver(this.calendarObserver);
},
- unobserveCalendar: function cAS_unobserveCalendar(calendar) {
+ unobserveCalendar: function(calendar) {
calendar.removeObserver(this.calendarObserver);
this.disposeCalendarTimers([calendar]);
this.mObservers.notify("onRemoveAlarmsByCalendar", [calendar]);
},
- addAlarmsForItem: function cAS_addAlarmsForItem(aItem) {
+ addAlarmsForItem: function(aItem) {
if (cal.isToDo(aItem) && aItem.isCompleted) {
// If this is a task and it is completed, don't add the alarm.
return;
}
let showMissed = Preferences.get("calendar.alarms.showmissed", true);
let alarms = aItem.getAlarms({});
@@ -379,70 +379,70 @@ calAlarmService.prototype = {
} else {
// The alarm was not snoozed or dismissed, fire it now.
this.alarmFired(aItem, alarm);
}
}
}
},
- removeAlarmsForItem: function cAS_removeAlarmsForItem(aItem) {
+ removeAlarmsForItem: function(aItem) {
// make sure already fired alarms are purged out of the alarm window:
this.mObservers.notify("onRemoveAlarmsByItem", [aItem]);
// Purge alarms specifically for this item (i.e exception)
for (let alarm of aItem.getAlarms({})) {
this.removeTimer(aItem, alarm);
}
},
- getOccurrencesInRange: function cAS_getOccurrencesInRange(aItem) {
+ getOccurrencesInRange: function(aItem) {
// We search 1 month in each direction for alarms. Therefore,
// we need occurrences between initial start date and 1 month from now
let until = nowUTC();
until.month += 1;
if (aItem && aItem.recurrenceInfo) {
return aItem.recurrenceInfo.getOccurrences(this.mRangeStart, until, 0, {});
} else {
return cal.checkIfInRange(aItem, this.mRangeStart, until) ? [aItem] : [];
}
},
- addAlarmsForOccurrences: function cAS_addAlarmsForOccurrences(aParentItem) {
+ addAlarmsForOccurrences: function(aParentItem) {
let occs = this.getOccurrencesInRange(aParentItem);
// Add an alarm for each occurrence
occs.forEach(this.addAlarmsForItem, this);
},
- removeAlarmsForOccurrences: function cAS_removeAlarmsForOccurrences(aParentItem) {
+ removeAlarmsForOccurrences: function(aParentItem) {
let occs = this.getOccurrencesInRange(aParentItem);
// Remove alarm for each occurrence
occs.forEach(this.removeAlarmsForItem, this);
},
- addTimer: function cAS_addTimer(aItem, aAlarm, aTimeout) {
+ addTimer: function(aItem, aAlarm, aTimeout) {
this.mTimerMap[aItem.calendar.id] =
this.mTimerMap[aItem.calendar.id] || {};
this.mTimerMap[aItem.calendar.id][aItem.hashId] =
this.mTimerMap[aItem.calendar.id][aItem.hashId] || {};
let self = this;
let alarmTimerCallback = {
- notify: function aTC_notify() {
+ notify: function() {
self.alarmFired(aItem, aAlarm);
}
};
let timer = newTimerWithCallback(alarmTimerCallback, aTimeout, false);
this.mTimerMap[aItem.calendar.id][aItem.hashId][aAlarm.icalString] = timer;
},
- removeTimer: function cAS_removeTimers(aItem, aAlarm) {
+ removeTimer: function(aItem, aAlarm) {
/* Is the calendar in the timer map */
if (aItem.calendar.id in this.mTimerMap &&
/* ...and is the item in the calendar map */
aItem.hashId in this.mTimerMap[aItem.calendar.id] &&
/* ...and is the alarm in the item map ? */
aAlarm.icalString in this.mTimerMap[aItem.calendar.id][aItem.hashId]) {
// First cancel the existing timer
let timer = this.mTimerMap[aItem.calendar.id][aItem.hashId][aAlarm.icalString];
@@ -458,43 +458,39 @@ calAlarmService.prototype = {
// If the calendar map is empty, remove it from the timer map
if (this.mTimerMap[aItem.calendar.id].toSource() == "({})") {
delete this.mTimerMap[aItem.calendar.id];
}
}
},
- disposeCalendarTimers: function cAS_removeCalendarTimers(aCalendars) {
+ disposeCalendarTimers: function(aCalendars) {
for (let calendar of aCalendars) {
if (calendar.id in this.mTimerMap) {
for (let hashId in this.mTimerMap[calendar.id]) {
let itemTimerMap = this.mTimerMap[calendar.id][hashId];
for (let icalString in itemTimerMap) {
let timer = itemTimerMap[icalString];
timer.cancel();
}
}
delete this.mTimerMap[calendar.id];
}
}
},
- findAlarms: function cAS_findAlarms(aCalendars, aStart, aUntil) {
+ findAlarms: function(aCalendars, aStart, aUntil) {
let getListener = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
alarmService: this,
addRemovePromise: PromiseUtils.defer(),
batchCount: 0,
results: false,
- onOperationComplete: function cAS_fA_onOperationComplete(aCalendar,
- aStatus,
- aOperationType,
- aId,
- aDetail) {
+ onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
this.addRemovePromise.promise.then((aValue) => {
// calendar has been loaded, so until now, onLoad events can be ignored:
this.alarmService.mLoadedCalendars[aCalendar.id] = true;
// notify observers that the alarms for the calendar have been loaded
this.alarmService.mObservers.notify("onAlarmsLoaded", [aCalendar]);
}, (aReason) => {
Components.utils.reportError("Promise was rejected: " + aReason);
@@ -502,22 +498,17 @@ calAlarmService.prototype = {
this.alarmService.mObservers.notify("onAlarmsLoaded", [aCalendar]);
});
// if no results were returned we still need to resolve the promise
if (!this.results) {
this.addRemovePromise.resolve();
}
},
- onGetResult: function cAS_fA_onGetResult(aCalendar,
- aStatus,
- aItemType,
- aDetail,
- aCount,
- aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
let promise = this.addRemovePromise;
this.batchCount++;
this.results = true;
cal.forEach(aItems, (item) => {
try {
this.alarmService.removeAlarmsForItem(item);
this.alarmService.addAlarmsForItem(item);
@@ -545,17 +536,17 @@ calAlarmService.prototype = {
calendar.getItems(filter, 0, aStart, aUntil, getListener);
} else {
this.mLoadedCalendars[calendar.id] = true;
this.mObservers.notify("onAlarmsLoaded", [calendar]);
}
}
},
- initAlarms: function cAS_initAlarms(aCalendars) {
+ initAlarms: function(aCalendars) {
// Purge out all alarm timers belonging to the refreshed/loaded calendars
this.disposeCalendarTimers(aCalendars);
// Purge out all alarms from dialog belonging to the refreshed/loaded calendars
for (let calendar of aCalendars) {
this.mLoadedCalendars[calendar.id] = false;
this.mObservers.notify("onRemoveAlarmsByCalendar", [calendar]);
}
@@ -566,17 +557,17 @@ calAlarmService.prototype = {
// for a month, they'll miss some, but that's a slim chance
let start = nowUTC();
let until = start.clone();
start.month -= Components.interfaces.calIAlarmService.MAX_SNOOZE_MONTHS;
until.month += Components.interfaces.calIAlarmService.MAX_SNOOZE_MONTHS;
this.findAlarms(aCalendars, start, until);
},
- alarmFired: function cAS_alarmFired(aItem, aAlarm) {
+ alarmFired: function(aItem, aAlarm) {
if (!aItem.calendar.getProperty("suppressAlarms") &&
!aItem.calendar.getProperty("disabled") &&
aItem.getProperty("STATUS") != "CANCELLED") {
this.mObservers.notify("onAlarm", [aItem, aAlarm]);
}
},
get isLoading() {
--- a/calendar/base/src/calAttachment.js
+++ b/calendar/base/src/calAttachment.js
@@ -155,25 +155,25 @@ calAttachment.prototype = {
return this.mProperties.deleteProperty(aName);
}
},
deleteParameter: function(aName) {
this.mProperties.deleteProperty(aName);
},
- clone: function cA_clone() {
+ clone: function() {
let newAttachment = new calAttachment();
newAttachment.mData = this.mData;
newAttachment.mHashId = this.mHashId;
for (let [name, value] of this.mProperties) {
newAttachment.mProperties.setProperty(name, value);
}
return newAttachment;
},
- setData: function setData(aData) {
+ setData: function(aData) {
// Sets the data and invalidates the hash so it will be recalculated
this.mHashId = null;
this.mData = aData;
return this.mData;
}
};
--- a/calendar/base/src/calAttendee.js
+++ b/calendar/base/src/calAttendee.js
@@ -176,17 +176,17 @@ calAttendee.prototype = {
},
set id(aId) {
this.modify();
// RFC 1738 para 2.1 says we should be using lowercase mailto: urls
// we enforce prepending the mailto prefix for email type ids as migration code bug 1199942
return (this.mId = (aId ? cal.prependMailTo(aId) : null));
},
- toString: function calAttendee_toString() {
+ toString: function() {
const emailRE = new RegExp("^mailto:", "i");
let stringRep = (this.id || "").replace(emailRE, "");
let commonName = this.commonName;
if (commonName) {
stringRep = commonName + " <" + stringRep + ">";
}
--- a/calendar/base/src/calCachedCalendar.js
+++ b/calendar/base/src/calCachedCalendar.js
@@ -127,17 +127,17 @@ function calCachedCalendar(uncachedCalen
this.setupCachedCalendar();
if (this.supportsChangeLog) {
uncachedCalendar.offlineStorage = this.mCachedCalendar;
}
this.offlineCachedItems = {};
this.offlineCachedItemFlags = {};
}
calCachedCalendar.prototype = {
- QueryInterface: function cCC_QueryInterface(aIID) {
+ QueryInterface: function(aIID) {
if (aIID.equals(Components.interfaces.calISchedulingSupport) &&
this.mUncachedCalendar.QueryInterface(aIID)) {
// check whether uncached calendar supports it:
return this;
} else if (aIID.equals(Components.interfaces.calICalendar) ||
aIID.equals(Components.interfaces.nsISupports)) {
return this;
} else {
@@ -166,17 +166,17 @@ calCachedCalendar.prototype = {
}
};
this.mCachedCalendar.QueryInterface(Components.interfaces.calICalendarProvider)
.deleteCalendar(this.mCachedCalendar, listener);
}
},
- setupCachedCalendar: function cCC_setupCachedCalendar() {
+ setupCachedCalendar: function() {
try {
if (this.mCachedCalendar) { // this is actually a resetupCachedCalendar:
// Although this doesn't really follow the spec, we know the
// storage calendar's deleteCalendar method is synchronous.
// TODO put changes into a different calendar and delete
// afterwards.
this.mCachedCalendar.QueryInterface(Components.interfaces.calICalendarProvider)
.deleteCalendar(this.mCachedCalendar, null);
@@ -217,79 +217,79 @@ calCachedCalendar.prototype = {
cachedCalendar.addObserver(this.mCachedObserver);
this.mCachedCalendar = cachedCalendar;
}
} catch (exc) {
Components.utils.reportError(exc);
}
},
- getOfflineAddedItems: function cCC_getOfflineAddedItems(callbackFunc) {
+ getOfflineAddedItems: function(callbackFunc) {
let self = this;
self.offlineCachedItems = {};
let getListener = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
- onGetResult: function cCC_oOC_cL_onGetResult(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
for (let item of aItems) {
self.offlineCachedItems[item.hashId] = item;
self.offlineCachedItemFlags[item.hashId] = cICL.OFFLINE_FLAG_CREATED_RECORD;
}
},
- onOperationComplete: function cCC_oOC_cL_onOperationComplete(aCalendar, aStatus, aOpType, aId, aDetail) {
+ onOperationComplete: function(aCalendar, aStatus, aOpType, aId, aDetail) {
self.getOfflineModifiedItems(callbackFunc);
}
};
this.mCachedCalendar.getItems(calICalendar.ITEM_FILTER_ALL_ITEMS | calICalendar.ITEM_FILTER_OFFLINE_CREATED,
0, null, null, getListener);
},
- getOfflineModifiedItems: function cCC_getOfflineModifiedItems(callbackFunc) {
+ getOfflineModifiedItems: function(callbackFunc) {
let self = this;
let getListener = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
- onGetResult: function cCC_oOC_cL_onGetResult(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
for (let item of aItems) {
self.offlineCachedItems[item.hashId] = item;
self.offlineCachedItemFlags[item.hashId] = cICL.OFFLINE_FLAG_MODIFIED_RECORD;
}
},
- onOperationComplete: function cCC_oOC_cL_onOperationComplete(aCalendar, aStatus, aOpType, aId, aDetail) {
+ onOperationComplete: function(aCalendar, aStatus, aOpType, aId, aDetail) {
self.getOfflineDeletedItems(callbackFunc);
}
};
this.mCachedCalendar.getItems(calICalendar.ITEM_FILTER_OFFLINE_MODIFIED | calICalendar.ITEM_FILTER_ALL_ITEMS,
0, null, null, getListener);
},
- getOfflineDeletedItems: function cCC_getOfflineDeletedItems(callbackFunc) {
+ getOfflineDeletedItems: function(callbackFunc) {
let self = this;
let getListener = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
- onGetResult: function cCC_oOC_cL_onGetResult(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
for (let item of aItems) {
self.offlineCachedItems[item.hashId] = item;
self.offlineCachedItemFlags[item.hashId] = cICL.OFFLINE_FLAG_DELETED_RECORD;
}
},
- onOperationComplete: function cCC_oOC_cL_onOperationComplete(aCalendar, aStatus, aOpType, aId, aDetail) {
+ onOperationComplete: function(aCalendar, aStatus, aOpType, aId, aDetail) {
if (callbackFunc) {
callbackFunc();
}
}
};
this.mCachedCalendar.getItems(calICalendar.ITEM_FILTER_OFFLINE_DELETED | calICalendar.ITEM_FILTER_ALL_ITEMS,
0, null, null, getListener);
},
mPendingSync: null,
mSyncQueue: null,
- synchronize: function cCC_synchronize(respFunc) {
+ synchronize: function(respFunc) {
let self = this;
if (this.getProperty("disabled")) {
return emptyQueue(Components.results.NS_OK);
}
this.mSyncQueue.push(respFunc);
if (this.mSyncQueue.length > 1) { // don't use mPendingSync here
cal.LOG("[calCachedCalendar] sync in action/pending.");
@@ -342,53 +342,44 @@ calCachedCalendar.prototype = {
let completeListener = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIOperationListener]),
modifiedTimes: {},
hasRenewedCalendar: false,
getsCompleted: 0,
getsReceived: 0,
opCompleted: false,
- onGetResult: function cCC_oOC_cL_onGetResult(aCalendar,
- aStatus,
- aItemType,
- aDetail,
- aCount,
- aItems) {
+ onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
if (Components.isSuccessCode(aStatus)) {
if (!this.hasRenewedCalendar) {
// TODO instead of deleting the calendar and creating a new
// one, maybe we want to do a "real" sync between the
// existing local calendar and the remote calendar.
self.setupCachedCalendar();
this.hasRenewedCalendar = true;
}
this.getsReceived++;
cal.forEach(aItems, function(item) {
// Adding items recd from the Memory Calendar
// These may be different than what the cache has
completeListener.modifiedTimes[item.id] = item.lastModifiedTime;
self.mCachedCalendar.addItem(item, null);
- }, function completed() {
+ }, function() {
completeListener.getsCompleted++;
if (completeListener.opCompleted) {
// onOperationComplete was called, but we were not ready yet. call it now.
completeListener.onOperationComplete.apply(completeListener, completeListener.opCompleted);
completeListener.opCompleted = false;
}
});
}
},
- onOperationComplete: function cCC_oOC_cL_onOperationComplete(aCalendar,
- aStatus,
- aOpType,
- aId,
- aDetail) {
+ onOperationComplete: function(aCalendar, aStatus, aOpType, aId, aDetail) {
if (this.getsCompleted < this.getsReceived) {
// If not all of our gets have been processed, then save the
// arguments and finish processing later.
this.opCompleted = Array.slice(arguments);
return;
}
if (Components.isSuccessCode(aStatus)) {
@@ -429,18 +420,17 @@ calCachedCalendar.prototype = {
// ...and has not been modified. Delete it now.
self.deleteOfflineItem(item, null);
}
} else {
// Item has already been deleted from the server, no need to change anything.
}
break;
}
- },
- function completed() {
+ }, function() {
self.offlineCachedItems = {};
self.offlineCachedItemFlags = {};
self.playbackOfflineItems(() => emptyQueue(aStatus));
});
} else {
self.playbackOfflineItems(function() { self.mCachedObserver.onLoad(self.mCachedCalendar); });
emptyQueue(aStatus);
}
@@ -449,27 +439,27 @@ calCachedCalendar.prototype = {
this.getOfflineAddedItems(() => {
this.mPendingSync = this.mUncachedCalendar.getItems(Components.interfaces.calICalendar.ITEM_FILTER_ALL_ITEMS,
0, null, null, completeListener);
});
return this.mPendingSync;
},
- onOfflineStatusChanged: function cCC_onOfflineStatusChanged(aNewState) {
+ onOfflineStatusChanged: function(aNewState) {
if (aNewState) {
// Going offline: (XXX get items before going offline?) => we may ask the user to stay online a bit longer
} else {
// Going online (start replaying changes to the remote calendar)
this.refresh();
}
},
// aOldItem is already in the cache
- promptOverwrite: function cCC_promptOverwrite(aMethod, aItem, aListener, aOldItem) {
+ promptOverwrite: function(aMethod, aItem, aListener, aOldItem) {
let overwrite = cal.promptOverwrite(aMethod, aItem, aListener, aOldItem);
if (overwrite) {
if (aMethod == "modify") {
this.modifyOfflineItem(aItem, aOldItem, aListener);
} else {
this.deleteOfflineItem(aItem, aListener);
}
}
@@ -480,17 +470,17 @@ calCachedCalendar.prototype = {
*
* @param aCallback (optional) The function to be callled when playback is complete.
* @param aPlaybackType (optional) The starting operation type. This function will be
* called recursively through playback operations in the order of
* add, modify, delete. By default playback will start with the add
* operation. Valid values for this parameter are defined as
* OFFLINE_FLAG_XXX constants in the calIChangeLog interface.
*/
- playbackOfflineItems: function cCC_playbackOfflineItems(aCallback, aPlaybackType) {
+ playbackOfflineItems: function(aCallback, aPlaybackType) {
let self = this;
let storage = this.mCachedCalendar.QueryInterface(Components.interfaces.calIOfflineStorage);
let resetListener = gNoOpListener;
let itemQueue = [];
let debugOp;
let nextCallback;
let uncachedOp;
--- a/calendar/base/src/calCalendarManager.js
+++ b/calendar/base/src/calCalendarManager.js
@@ -36,17 +36,17 @@ calCalendarManager.prototype = {
flags: Components.interfaces.nsIClassInfo.SINGLETON
}),
get networkCalendarCount() { return this.mNetworkCalendarCount; },
get readOnlyCalendarCount() { return this.mReadonlyCalendarCount; },
get calendarCount() { return this.mCalendarCount; },
// calIStartupService:
- startup: function ccm_startup(aCompleteListener) {
+ startup: function(aCompleteListener) {
AddonManager.addAddonListener(gCalendarManagerAddonListener);
this.checkAndMigrateDB();
this.mCache = null;
this.mCalObservers = null;
this.mRefreshTimer = {};
this.setupOfflineObservers();
this.mNetworkCalendarCount = 0;
this.mReadonlyCalendarCount = 0;
@@ -58,17 +58,17 @@ calCalendarManager.prototype = {
// pref on startup to avoid checking for every http request
if (Preferences.get("calendar.network.multirealm", false)) {
Services.obs.addObserver(this, "http-on-examine-response", false);
}
aCompleteListener.onResult(null, Components.results.NS_OK);
},
- shutdown: function ccm_shutdown(aCompleteListener) {
+ shutdown: function(aCompleteListener) {
for (let id in this.mCache) {
let calendar = this.mCache[id];
calendar.removeObserver(this.mCalObservers[calendar.id]);
}
this.cleanupOfflineObservers();
Services.obs.removeObserver(this, "http-on-modify-request");
@@ -81,25 +81,25 @@ calCalendarManager.prototype = {
if (Preferences.get("calendar.network.multirealm", false)) {
Services.obs.removeObserver(this, "http-on-examine-response");
}
aCompleteListener.onResult(null, Components.results.NS_OK);
},
- setupOfflineObservers: function ccm_setupOfflineObservers() {
+ setupOfflineObservers: function() {
Services.obs.addObserver(this, "network:offline-status-changed", false);
},
- cleanupOfflineObservers: function ccm_cleanupOfflineObservers() {
+ cleanupOfflineObservers: function() {
Services.obs.removeObserver(this, "network:offline-status-changed");
},
- observe: function ccm_observe(aSubject, aTopic, aData) {
+ observe: function(aSubject, aTopic, aData) {
switch (aTopic) {
case "timer-callback":
// Refresh all the calendars that can be refreshed.
for (let calendar of this.getCalendars({})) {
if (!calendar.getProperty("disabled") && calendar.canRefresh) {
calendar.refresh();
}
}
@@ -247,17 +247,17 @@ calCalendarManager.prototype = {
// - Decouple schema version from storage calendar
// Create the new tables.
db.executeSimpleSQL("CREATE TABLE cal_calmgr_schema_version (version INTEGER);");
db.executeSimpleSQL("INSERT INTO cal_calmgr_schema_version VALUES(" + DB_SCHEMA_VERSION + ")");
}
}
},
- migrateDB: function calmgr_migrateDB(db) {
+ migrateDB: function(db) {
let selectCalendars = db.createStatement("SELECT * FROM cal_calendars");
let selectPrefs = db.createStatement("SELECT name, value FROM cal_calendars_prefs WHERE calendar = :calendar");
try {
let sortOrder = {};
while (selectCalendars.executeStep()) {
let id = cal.getUUID(); // use fresh uuids
Preferences.set(getPrefBranchFor(id) + "type", selectCalendars.row.type);
@@ -310,17 +310,17 @@ calCalendarManager.prototype = {
Preferences.set("calendar.list.sortOrder", sortOrderAr.join(" "));
flushPrefs();
} finally {
selectPrefs.reset();
selectCalendars.reset();
}
},
- checkAndMigrateDB: function calmgr_checkAndMigrateDB() {
+ checkAndMigrateDB: function() {
let storageSdb = Services.dirsvc.get("ProfD", Components.interfaces.nsILocalFile);
storageSdb.append("storage.sdb");
let db = Services.storage.openDatabase(storageSdb);
db.beginTransactionAs(Components.interfaces.mozIStorageConnection.TRANSACTION_EXCLUSIVE);
try {
if (db.tableExists("cal_calendars_prefs")) {
// Check if we need to upgrade:
@@ -353,17 +353,17 @@ calCalendarManager.prototype = {
db.close();
}
},
/**
* @return db schema version
* @exception various, depending on error
*/
- getSchemaVersion: function calMgrGetSchemaVersion(db) {
+ getSchemaVersion: function(db) {
let stmt;
let version = null;
let table;
if (db.tableExists("cal_calmgr_schema_version")) {
table = "cal_calmgr_schema_version";
} else {
// Fall back to the old schema table
@@ -392,17 +392,17 @@ calCalendarManager.prototype = {
throw table + " SELECT returned no results";
},
//
// / DB migration code ends here
//
- alertAndQuit: function cmgr_alertAndQuit() {
+ alertAndQuit: function() {
// We want to include the extension name in the error message rather
// than blaming Thunderbird.
let hostAppName = calGetString("brand", "brandShortName", null, "branding");
let calAppName = calGetString("lightning", "brandShortName", null, "lightning");
let errorBoxTitle = calGetString("calendar", "tooNewSchemaErrorBoxTitle", [calAppName]);
let errorBoxText = calGetString("calendar", "tooNewSchemaErrorBoxTextLightning", [calAppName, hostAppName]);
let errorBoxButtonLabel = calGetString("calendar", "tooNewSchemaButtonRestart", [hostAppName]);
@@ -418,27 +418,27 @@ calCalendarManager.prototype = {
errorBoxButtonFlags,
errorBoxButtonLabel,
null, // No second button text
null, // No third button text
null, // No checkbox
{ value: false }); // Unnecessary checkbox state
// Disable Lightning
- AddonManager.getAddonByID("{e2fda1a4-762b-4020-b5ad-a41df1933103}", function getLightningExt(aAddon) {
+ AddonManager.getAddonByID("{e2fda1a4-762b-4020-b5ad-a41df1933103}", function(aAddon) {
aAddon.userDisabled = true;
Services.startup.quit(Components.interfaces.nsIAppStartup.eRestart |
Components.interfaces.nsIAppStartup.eForceQuit);
});
},
/**
* calICalendarManager interface
*/
- createCalendar: function cmgr_createCalendar(type, uri) {
+ createCalendar: function(type, uri) {
try {
if (!Components.classes["@mozilla.org/calendar/calendar;1?type=" + type]) {
// Don't notify the user with an extra dialog if the provider
// interface is missing.
return null;
}
let calendar = Components.classes["@mozilla.org/calendar/calendar;1?type=" + type]
.createInstance(Components.interfaces.calICalendar);
@@ -508,17 +508,17 @@ calCalendarManager.prototype = {
if (!calendar.getProperty("disabled") && calendar.canRefresh) {
calendar.refresh();
}
this.notifyObservers("onCalendarRegistered", [calendar]);
},
- setupCalendar: function cmgr_setupCalendar(calendar) {
+ setupCalendar: function(calendar) {
this.mCache[calendar.id] = calendar;
// Add an observer to track readonly-mode triggers
let newObserver = new calMgrCalendarObserver(calendar, this);
calendar.addObserver(newObserver);
this.mCalObservers[calendar.id] = newObserver;
// Set up statistics
@@ -529,17 +529,17 @@ calCalendarManager.prototype = {
this.mReadonlyCalendarCount++;
}
this.mCalendarCount++;
// Set up the refresh timer
this.setupRefreshTimer(calendar);
},
- setupRefreshTimer: function setupRefreshTimer(aCalendar) {
+ setupRefreshTimer: function(aCalendar) {
// Add the refresh timer for this calendar
let refreshInterval = aCalendar.getProperty("refreshInterval");
if (refreshInterval === null) {
// Default to 30 minutes, in case the value is missing
refreshInterval = 30;
}
this.clearRefreshTimer(aCalendar);
@@ -551,17 +551,17 @@ calCalendarManager.prototype = {
this.mRefreshTimer[aCalendar.id]
.initWithCallback(new timerCallback(aCalendar),
refreshInterval * 60000,
Components.interfaces.nsITimer.TYPE_REPEATING_SLACK);
}
},
- clearRefreshTimer: function clearRefreshTimer(aCalendar) {
+ clearRefreshTimer: function(aCalendar) {
if (aCalendar.id in this.mRefreshTimer &&
this.mRefreshTimer[aCalendar.id]) {
this.mRefreshTimer[aCalendar.id].cancel();
delete this.mRefreshTimer[aCalendar.id];
}
},
unregisterCalendar: function(calendar) {
@@ -631,36 +631,36 @@ calCalendarManager.prototype = {
if (!wrappedCalendar) {
throw new Components.Exception("Calendar is missing a provider implementation for delete");
}
wrappedCalendar.deleteCalendar(calendar, null);
}
},
- getCalendarById: function cmgr_getCalendarById(aId) {
+ getCalendarById: function(aId) {
if (aId in this.mCache) {
return this.mCache[aId];
} else {
return null;
}
},
- getCalendars: function cmgr_getCalendars(count) {
+ getCalendars: function(count) {
this.assureCache();
let calendars = [];
for (let id in this.mCache) {
let calendar = this.mCache[id];
calendars.push(calendar);
}
count.value = calendars.length;
return calendars;
},
- assureCache: function cmgr_assureCache() {
+ assureCache: function() {
if (!this.mCache) {
this.mCache = {};
this.mCalObservers = {};
let allCals = {};
for (let key of Services.prefs.getChildList(REGISTRY_BRANCH)) { // merge down all keys
allCals[key.substring(0, key.indexOf(".", REGISTRY_BRANCH.length))] = true;
}
@@ -1012,17 +1012,17 @@ calMgrCalendarObserver.prototype = {
function calDummyCalendar(type) {
this.initProviderBase();
this.type = type;
}
calDummyCalendar.prototype = {
__proto__: cal.ProviderBase.prototype,
- getProperty: function calDummyCalendar_getProperty(aName) {
+ getProperty: function(aName) {
switch (aName) {
case "force-disabled":
return true;
default:
return this.__proto__.__proto__.getProperty.apply(this, arguments);
}
}
};
@@ -1042,17 +1042,17 @@ function flushPrefs() {
/**
* Callback object for the refresh timer. Should be called as an object, i.e
* let foo = new timerCallback(calendar);
*
* @param aCalendar The calendar to refresh on notification
*/
function timerCallback(aCalendar) {
- this.notify = function refreshNotify(aTimer) {
+ this.notify = function(aTimer) {
if (!aCalendar.getProperty("disabled") && aCalendar.canRefresh) {
aCalendar.refresh();
}
};
}
var gCalendarManagerAddonListener = {
onDisabling: function(aAddon, aNeedsRestart) {
--- a/calendar/base/src/calCalendarSearchService.js
+++ b/calendar/base/src/calCalendarSearchService.js
@@ -11,28 +11,28 @@ function calCalendarSearchListener(numOp
this.notifyResult(null);
});
}
calCalendarSearchListener.prototype = {
mFinalListener: null,
mNumOperations: 0,
opGroup: null,
- notifyResult: function calCalendarSearchListener_notifyResult(result) {
+ notifyResult: function(result) {
let listener = this.mFinalListener;
if (listener) {
if (!this.opGroup.isPending) {
this.mFinalListener = null;
}
listener.onResult(this.opGroup, result);
}
},
// calIGenericOperationListener:
- onResult: function calCalendarSearchListener_onResult(aOperation, aResult) {
+ onResult: function(aOperation, aResult) {
if (this.mFinalListener) {
if (!aOperation || !aOperation.isPending) {
--this.mNumOperations;
if (this.mNumOperations == 0) {
this.opGroup.notifyCompleted();
}
}
if (aResult) {
@@ -60,20 +60,17 @@ calCalendarSearchService.prototype = {
classID: calCalendarSearchServiceClassID,
contractID: "@mozilla.org/calendar/calendarsearch-service;1",
classDescription: "Calendar Search Service",
interfaces: calCalendarSearchServiceInterfaces,
flags: Components.interfaces.nsIClassInfo.SINGLETON
}),
// calICalendarSearchProvider:
- searchForCalendars: function calCalendarSearchService_searchForCalendars(aString,
- aHints,
- aMaxResults,
- aListener) {
+ searchForCalendars: function(aString, aHints, aMaxResults, aListener) {
let groupListener = new calCalendarSearchListener(this.mProviders.size, aListener);
function searchForCalendars_(provider) {
try {
groupListener.opGroup.add(provider.searchForCalendars(aString,
aHints,
aMaxResults,
groupListener));
} catch (exc) {
@@ -81,20 +78,20 @@ calCalendarSearchService.prototype = {
groupListener.onResult(null, []); // dummy to adopt mNumOperations
}
}
this.mProviders.forEach(searchForCalendars_);
return groupListener.opGroup;
},
// calICalendarSearchService:
- getProviders: function calCalendarSearchService_getProviders(out_aCount) {
+ getProviders: function(out_aCount) {
let ret = this.mProviders.interfaceArray;
out_aCount.value = ret.length;
return ret;
},
- addProvider: function calCalendarSearchService_addProvider(aProvider) {
+ addProvider: function(aProvider) {
this.mProviders.add(aProvider);
},
- removeProvider: function calCalendarSearchService_removeProvider(aProvider) {
+ removeProvider: function(aProvider) {
this.mProviders.remove(aProvider);
}
};
--- a/calendar/base/src/calDateTimeFormatter.js
+++ b/calendar/base/src/calDateTimeFormatter.js
@@ -73,31 +73,31 @@ calDateTimeFormatter.prototype = {
QueryInterface: XPCOMUtils.generateQI(calDateTimeFormatterInterfaces),
classInfo: XPCOMUtils.generateCI({
classID: calDateTimeFormatterClassID,
contractID: "@mozilla.org/calendar/datetime-formatter;1",
classDescription: "Formats Dates and Times",
interfaces: calDateTimeFormatterInterfaces,
}),
- formatDate: function formatDate(aDate) {
+ formatDate: function(aDate) {
// Format the date using user's format preference (long or short)
let format = Preferences.get("calendar.date.format", 0);
return (format == 0 ? this.formatDateLong(aDate) : this.formatDateShort(aDate));
},
- formatDateShort: function formatDateShort(aDate) {
+ formatDateShort: function(aDate) {
return this.mDateService.FormatDate("",
nsIScriptableDateFormat.dateFormatShort,
aDate.year,
aDate.month + 1,
aDate.day);
},
- formatDateLong: function formatDateLong(aDate) {
+ formatDateLong: function(aDate) {
let longDate;
if (this.mUseLongDateService) {
longDate = this.mDateService.FormatDate("",
nsIScriptableDateFormat.dateFormatLong,
aDate.year,
aDate.month + 1,
aDate.day);
// check whether weekday name appears as in Lightning localization. if not, this is
@@ -117,68 +117,68 @@ calDateTimeFormatter.prototype = {
[this.shortDayName(aDate.weekday),
this.formatDayWithOrdinal(aDate.day),
this.shortMonthName(aDate.month),
aDate.year]);
}
return longDate;
},
- formatDateWithoutYear: function formatDateWithoutYear(aDate) {
+ formatDateWithoutYear: function(aDate) {
// Doing this the hard way, because nsIScriptableDateFormat doesn't
// have a way to not include the year.
if (this.mMonthFirst) {
return this.shortMonthName(aDate.month) + " " + this.formatDayWithOrdinal(aDate.day);
} else {
return this.formatDayWithOrdinal(aDate.day) + " " + this.shortMonthName(aDate.month);
}
},
- formatTime: function formatTime(aDate) {
+ formatTime: function(aDate) {
if (aDate.isDate) {
return this.mDateStringBundle.GetStringFromName("AllDay");
}
return this.mDateService.FormatTime("",
nsIScriptableDateFormat.timeFormatNoSeconds,
aDate.hour,
aDate.minute,
0);
},
- formatDateTime: function formatDateTime(aDate) {
+ formatDateTime: function(aDate) {
let formattedDate = this.formatDate(aDate);
let formattedTime = this.formatTime(aDate);
let timeBeforeDate = Preferences.get("calendar.date.formatTimeBeforeDate", false);
if (timeBeforeDate) {
return formattedTime + " " + formattedDate;
} else {
return formattedDate + " " + formattedTime;
}
},
- formatTimeInterval: function formatTimeInterval(aStartDate, aEndDate) {
+ formatTimeInterval: function(aStartDate, aEndDate) {
if (!aStartDate && aEndDate) {
return this.formatTime(aEndDate);
}
if (!aEndDate && aStartDate) {
return this.formatTime(aStartDate);
}
if (!aStartDate && !aEndDate) {
return "";
}
// TODO do we need l10n for this?
// TODO should we check for the same day? The caller should know what
// he is doing...
return this.formatTime(aStartDate) + "\u2013" + this.formatTime(aEndDate);
},
- formatInterval: function formatInterval(aStartDate, aEndDate) {
+ formatInterval: function(aStartDate, aEndDate) {
// Check for tasks without start and/or due date
if (aEndDate == null && aStartDate == null) {
return calGetString("calendar", "datetimeIntervalTaskWithoutDate");
} else if (aEndDate == null) {
let startDateString = this.formatDate(aStartDate);
let startTime = this.formatTime(aStartDate);
return calGetString("calendar", "datetimeIntervalTaskWithoutDueDate", [startDateString, startTime]);
} else if (aStartDate == null) {
@@ -235,23 +235,23 @@ calDateTimeFormatter.prototype = {
// Spanning multiple days, so need to include date and time
// for start and end
// "5 Jan 2006 13:00 - 7 Jan 2006 9:00"
return calGetString("calendar", "datetimeIntervalOnSeveralDays", [startDateString, startTime, endDateString, endTime]);
}
}
},
- formatDayWithOrdinal: function formatDayWithOrdinal(aDay) {
+ formatDayWithOrdinal: function(aDay) {
let ordinalSymbols = this.mDateStringBundle.GetStringFromName("dayOrdinalSymbol").split(",");
let dayOrdinalSymbol = ordinalSymbols[aDay - 1] || ordinalSymbols[0];
return aDay + dayOrdinalSymbol;
},
- _getItemDates: function _getItemDates(aItem) {
+ _getItemDates: function(aItem) {
let start = aItem[calGetStartDateProp(aItem)];
let end = aItem[calGetEndDateProp(aItem)];
let kDefaultTimezone = calendarDefaultTimezone();
// Check for tasks without start and/or due date
if (start) {
start = start.getInTimezone(kDefaultTimezone);
}
if (end) {
@@ -261,36 +261,36 @@ calDateTimeFormatter.prototype = {
// to get into a format that's understandable.
if (start && start.isDate && end) {
end.day -= 1;
}
return [start, end];
},
- formatItemInterval: function formatItemInterval(aItem) {
+ formatItemInterval: function(aItem) {
return this.formatInterval.apply(this, this._getItemDates(aItem));
},
- formatItemTimeInterval: function formatItemTimeInterval(aItem) {
+ formatItemTimeInterval: function(aItem) {
return this.formatTimeInterval.apply(this, this._getItemDates(aItem));
},
- monthName: function monthName(aMonthIndex) {
+ monthName: function(aMonthIndex) {
let oneBasedMonthIndex = aMonthIndex + 1;
return this.mDateStringBundle.GetStringFromName("month." + oneBasedMonthIndex + ".name");
},
- shortMonthName: function shortMonthName(aMonthIndex) {
+ shortMonthName: function(aMonthIndex) {
let oneBasedMonthIndex = aMonthIndex + 1;
return this.mDateStringBundle.GetStringFromName("month." + oneBasedMonthIndex + ".Mmm");
},
- dayName: function dayName(aDayIndex) {
+ dayName: function(aDayIndex) {
let oneBasedDayIndex = aDayIndex + 1;
return this.mDateStringBundle.GetStringFromName("day." + oneBasedDayIndex + ".name");
},
- shortDayName: function shortDayName(aDayIndex) {
+ shortDayName: function(aDayIndex) {
let oneBasedDayIndex = aDayIndex + 1;
return this.mDateStringBundle.GetStringFromName("day." + oneBasedDayIndex + ".Mmm");
}
};
--- a/calendar/base/src/calDefaultACLManager.js
+++ b/calendar/base/src/calDefaultACLManager.js
@@ -24,32 +24,32 @@ calDefaultACLManager.prototype = {
classID: calDefaultACLManagerClassID,
contractID: "@mozilla.org/calendar/acl-manager;1?type=default",
classDescription: "Default Calendar ACL Provider",
interfaces: calDefaultACLManagerInterfaces,
flags: Components.interfaces.nsIClassInfo.SINGLETON
}),
/* calICalendarACLManager */
- _getCalendarEntryCached: function cDACLM__getCalendarEntryCached(aCalendar) {
+ _getCalendarEntryCached: function(aCalendar) {
let calUri = aCalendar.uri.spec;
if (!(calUri in this.mCalendarEntries)) {
this.mCalendarEntries[calUri] = new calDefaultCalendarACLEntry(this, aCalendar);
}
return this.mCalendarEntries[calUri];
},
- getCalendarEntry: function cDACLM_getCalendarEntry(aCalendar, aListener) {
+ getCalendarEntry: function(aCalendar, aListener) {
let entry = this._getCalendarEntryCached(aCalendar);
aListener.onOperationComplete(aCalendar, Components.results.NS_OK,
Components.interfaces.calIOperationListener.GET,
null,
entry);
},
- getItemEntry: function cDACLM_getItemEntry(aItem) {
+ getItemEntry: function(aItem) {
let calEntry = this._getCalendarEntryCached(aItem.calendar);
return new calDefaultItemACLEntry(calEntry);
},
};
function calDefaultCalendarACLEntry(aMgr, aCalendar) {
this.mACLManager = aMgr;
@@ -67,43 +67,43 @@ calDefaultCalendarACLEntry.prototype = {
return this.mACLManager;
},
hasAccessControl: false,
userIsOwner: true,
userCanAddItems: true,
userCanDeleteItems: true,
- _getIdentities: function calDefaultCalendarACLEntry_getUserAddresses(aCount) {
+ _getIdentities: function(aCount) {
let identities = [];
cal.calIterateEmailIdentities(function(id, ac) { identities.push(id); });
aCount.value = identities.length;
return identities;
},
- getUserAddresses: function calDefaultCalendarACLEntry_getUserAddresses(aCount) {
+ getUserAddresses: function(aCount) {
let identities = this.getUserIdentities(aCount);
let addresses = identities.map(id => id.email);
return addresses;
},
- getUserIdentities: function calDefaultCalendarACLEntry_getUserIdentities(aCount) {
+ getUserIdentities: function(aCount) {
let identity = cal.getEmailIdentityOfCalendar(this.mCalendar);
if (identity) {
aCount.value = 1;
return [identity];
} else {
return this._getIdentities(aCount);
}
},
- getOwnerIdentities: function calDefaultCalendarACLEntry_getOwnerIdentities(aCount) {
+ getOwnerIdentities: function(aCount) {
return this._getIdentities(aCount);
},
- refresh: function calDefaultCalendarACLEntry_refresh() {
+ refresh: function() {
}
};
function calDefaultItemACLEntry(aCalendarEntry) {
this.calendarEntry = aCalendarEntry;
}
calDefaultItemACLEntry.prototype = {
--- a/calendar/base/src/calDeletedItems.js
+++ b/calendar/base/src/calDeletedItems.js
@@ -44,23 +44,23 @@ calDeletedItems.prototype = {
DB_SCHEMA_VERSION: 1,
STALE_TIME: 30 * 24 * 60 * 60 / 1000, /* 30 days */
// To make the tests more failsafe, we have an internal notifier function.
// As the deleted items store is just meant to be a hint, this should not
// be used in real code.
completedNotifier: null,
- flush: function flush() {
+ flush: function() {
this.ensureStatements();
this.stmtFlush.params.stale_time = cal.now().nativeTime - this.STALE_TIME;
this.stmtFlush.executeAsync(this.completedNotifier);
},
- getDeletedDate: function calDeletedItems_getDeleted(aId, aCalId) {
+ getDeletedDate: function(aId, aCalId) {
this.ensureStatements();
let stmt;
if (aCalId) {
stmt = this.stmtGetWithCal;
stmt.params.calId = aCalId;
} else {
stmt = this.stmtGet;
}
@@ -75,32 +75,32 @@ calDeletedItems.prototype = {
} catch (e) {
cal.ERROR(e);
} finally {
stmt.reset();
}
return null;
},
- markDeleted: function calDeletedItems_markDeleted(aItem) {
+ markDeleted: function(aItem) {
this.ensureStatements();
this.stmtMarkDelete.params.calId = aItem.calendar.id;
this.stmtMarkDelete.params.id = aItem.id;
this.stmtMarkDelete.params.time = cal.now().nativeTime;
this.stmtMarkDelete.params.rid = (aItem.recurrenceId && aItem.recurrenceId.nativeTime) || "";
this.stmtMarkDelete.executeAsync(this.completedNotifier);
},
- unmarkDeleted: function calDeletedItems_unmarkDeleted(aItem) {
+ unmarkDeleted: function(aItem) {
this.ensureStatements();
this.stmtUnmarkDelete.params.id = aItem.id;
this.stmtUnmarkDelete.executeAsync(this.completedNotifier);
},
- initDB: function initDB() {
+ initDB: function() {
if (this.mDB) {
// Looks like we've already initialized, exit early
return;
}
let file = FileUtils.getFile("ProfD", ["calendar-data", "deleted.sqlite"]);
this.mDB = Services.storage.openDatabase(file);
@@ -116,25 +116,25 @@ calDeletedItems.prototype = {
}
// We will not init the statements now, we can still do that the
// first time this interface is used. What we should do though is
// to clean up at shutdown
cal.addShutdownObserver(this.shutdown.bind(this));
},
- observe: function observe(aSubject, aTopic, aData) {
+ observe: function(aSubject, aTopic, aData) {
if (aTopic == "profile-after-change") {
// Make sure to observe calendar changes so we know when things are
// deleted. We don't initialize the statements until first use.
cal.getCalendarManager().addCalendarObserver(this);
}
},
- ensureStatements: function ensureStatements() {
+ ensureStatements: function() {
if (!this.mDB) {
this.initDB();
}
if (!this.stmtMarkDelete) {
let stmt = "INSERT OR REPLACE INTO cal_deleted_items (cal_id, id, time_deleted, recurrence_id) VALUES(:calId, :id, :time, :rid)";
this.stmtMarkDelete = this.mDB.createStatement(stmt);
}
@@ -151,17 +151,17 @@ calDeletedItems.prototype = {
this.stmtGet = this.mDB.createStatement(stmt);
}
if (!this.stmtFlush) {
let stmt = "DELETE FROM cal_deleted_items WHERE time_deleted < :stale_time";
this.stmtFlush = this.mDB.createStatement(stmt);
}
},
- shutdown: function shutdown() {
+ shutdown: function() {
try {
let stmts = [
this.stmtMarkDelete, this.stmtUnmarkDelete, this.stmtGet,
this.stmtGetWithCal, this.stmtFlush
];
for (let stmt of stmts) {
stmt.finalize();
}
@@ -181,16 +181,16 @@ calDeletedItems.prototype = {
onError: function() {},
onPropertyChanged: function() {},
onPropertyDeleting: function() {},
onAddItem: function(aItem) {
this.unmarkDeleted(aItem);
},
- onDeleteItem: function onDeleteItem(aItem) {
+ onDeleteItem: function(aItem) {
this.markDeleted(aItem);
},
- onLoad: function onLoad() {
+ onLoad: function() {
this.flush();
}
};
--- a/calendar/base/src/calEvent.js
+++ b/calendar/base/src/calEvent.js
@@ -36,17 +36,17 @@ calEvent.prototype = {
}),
cloneShallow: function(aNewParent) {
let m = new calEvent();
this.cloneItemBaseInto(m, aNewParent);
return m;
},
- createProxy: function calEvent_createProxy(aRecurrenceId) {
+ createProxy: function(aRecurrenceId) {
cal.ASSERT(!this.mIsProxy, "Tried to create a proxy for an existing proxy!", true);
let m = new calEvent();
// override proxy's DTSTART/DTEND/RECURRENCE-ID
// before master is set (and item might get immutable):
let endDate = aRecurrenceId.clone();
endDate.addDuration(this.duration);
--- a/calendar/base/src/calFilter.js
+++ b/calendar/base/src/calFilter.js
@@ -118,37 +118,37 @@ calFilterProperties.prototype = {
end: null,
due: null,
status: null,
category: null,
occurrences: null,
onfilter: null,
- equals: function cFP_equals(aFilterProps) {
+ equals: function(aFilterProps) {
if (!(aFilterProps instanceof calFilterProperties)) {
return false;
}
let props = ["start", "end", "due", "status", "category", "occurrences", "onfilter"];
return props.every(function(prop) {
return (this[prop] == aFilterProps[prop]);
}, this);
},
- clone: function cFP_clone() {
+ clone: function() {
let cl = new calFilterProperties();
let props = ["start", "end", "due", "status", "category", "occurrences", "onfilter"];
props.forEach(function(prop) {
cl[prop] = this[prop];
}, this);
return cl;
},
- LOG: function cFP_LOG(aString) {
+ LOG: function(aString) {
cal.LOG("[calFilterProperties] " +
(aString || "") +
" start=" + this.start +
" end=" + this.end +
" status=" + this.status +
" due=" + this.due +
" category=" + this.category);
}
@@ -175,17 +175,17 @@ calFilter.prototype = {
mFilterProperties: null,
mToday: null,
mTomorrow: null,
mMaxIterations: 50,
/**
* Initializes the predefined filters.
*/
- initDefinedFilters: function cF_initDefinedFilters() {
+ initDefinedFilters: function() {
let filters = ["all", "notstarted", "overdue", "open", "completed", "throughcurrent",
"throughtoday", "throughsevendays", "today", "thisCalendarMonth",
"future", "current", "currentview"];
filters.forEach(function(filter) {
if (!(filter in this.mDefinedFilters)) {
this.defineFilter(filter, this.getPreDefinedFilterProperties(filter));
}
}, this);
@@ -193,17 +193,17 @@ calFilter.prototype = {
/**
* Gets the filter properties for a predefined filter.
*
* @param aFilter The name of the filter to retrieve the filter properties for.
* @result The filter properties for the specified filter, or null if the filter
* not predefined.
*/
- getPreDefinedFilterProperties: function cF_getPreDefinedFilterProperties(aFilter) {
+ getPreDefinedFilterProperties: function(aFilter) {
let props = new calFilterProperties();
if (!aFilter) {
return props;
}
switch (aFilter) {
@@ -291,64 +291,64 @@ calFilter.prototype = {
/**
* Defines a set of filter properties so that they may be applied by the filter name. If
* the specified filter name is already defined, it's associated filter properties will be
* replaced.
*
* @param aFilterName The name to define the filter properties as.
* @param aFilterProperties The filter properties to define.
*/
- defineFilter: function cF_defineFilter(aFilterName, aFilterProperties) {
+ defineFilter: function(aFilterName, aFilterProperties) {
if (!(aFilterProperties instanceof calFilterProperties)) {
return;
}
this.mDefinedFilters[aFilterName] = aFilterProperties;
},
/**
* Returns the set of filter properties that were previously defined by a filter name.
*
* @param aFilter The filter name of the defined filter properties.
* @return The properties defined by the filter name, or null if
* the filter name was not previously defined.
*/
- getDefinedFilterProperties: function cF_getDefinedFilterProperties(aFilter) {
+ getDefinedFilterProperties: function(aFilter) {
if (aFilter in this.mDefinedFilters) {
return this.mDefinedFilters[aFilter].clone();
} else {
return null;
}
},
/**
* Returns the filter name that a set of filter properties were previously defined as.
*
* @param aFilterProperties The filter properties previously defined.
* @return The name of the first filter name that the properties
* were defined as, or null if the filter properties were
* not previously defined.
*/
- getDefinedFilterName: function cF_getDefinedFilterName(aFilterProperties) {
+ getDefinedFilterName: function(aFilterProperties) {
for (filter in this.mDefinedFilters) {
if (this.mDefinedFilters[filter].equals(aFilterProperties)) {
return filter;
}
}
return null;
},
/**
* Checks if the item matches the current filter text
*
* @param aItem The item to check.
* @return Returns true if the item matches the filter text or no
* filter text has been set, false otherwise.
*/
- textFilter: function cF_filterByText(aItem) {
+ textFilter: function(aItem) {
if (!this.mFilterText) {
return true;
}
let searchText = this.mFilterText.toLowerCase();
if (!searchText.length || searchText.match(/^\s*$/)) {
return true;
@@ -369,29 +369,29 @@ calFilter.prototype = {
/**
* Checks if the item matches the current filter date range.
*
* @param aItem The item to check.
* @return Returns true if the item falls within the date range
* specified by mStartDate and mEndDate, false otherwise.
*/
- dateRangeFilter: function cF_dateRangeFilter(aItem) {
+ dateRangeFilter: function(aItem) {
return checkIfInRange(aItem, this.mStartDate, this.mEndDate);
},
/**
* Checks if the item matches the currently applied filter properties. Filter properties
* with a value of null or that are not applicable to the item's type are not tested.
*
* @param aItem The item to check.
* @return Returns true if the item matches the filter properties
* currently applied, false otherwise.
*/
- propertyFilter: function cF_propertyFilter(aItem) {
+ propertyFilter: function(aItem) {
let result;
let props = this.mFilterProperties;
if (!props) {
return false;
}
// the today and tomorrow properties are precalculated in the updateFilterDates function
// for better performance when filtering batches of items.
@@ -471,17 +471,17 @@ calFilter.prototype = {
* @param prop The value of the date filter property to calculate for. May
* be a constant specifying a relative date range, or a string
* representing a duration offset from the current date time.
* @param start If true, the function will return the date value for the
* start of the relative date range, otherwise it will return the
* date value for the end of the date range.
* @return The calculated date for the property.
*/
- getDateForProperty: function cF_getDateForProperty(prop, start) {
+ getDateForProperty: function(prop, start) {
let props = this.mFilterProperties || new calFilterProperties();
let result = null;
let selectedDate = this.mSelectedDate || currentView().selectedDay || cal.now();
let nowDate = cal.now();
if (typeof prop == "string") {
let duration = cal.createDuration(prop);
if (duration) {
@@ -539,17 +539,17 @@ calFilter.prototype = {
return result;
},
/**
* Calculates the current start and end dates for the currently applied filter.
*
* @return The current [startDate, endDate] for the applied filter.
*/
- getDatesForFilter: function cfp_getDatesForFilter() {
+ getDatesForFilter: function() {
let startDate = null;
let endDate = null;
if (this.mFilterProperties) {
startDate = this.getDateForProperty(this.mFilterProperties.start, true);
endDate = this.getDateForProperty(this.mFilterProperties.end, false);
// swap the start and end dates if necessary
@@ -659,17 +659,17 @@ calFilter.prototype = {
* Applies the specified filter.
*
* @param aFilter The filter to apply. May be one of the following types:
* - a calFilterProperties object specifying the filter properties
* - a String representing a previously defined filter name
* - a String representing a duration offset from now
* - a Function to use for the onfilter callback for a custom filter
*/
- applyFilter: function cF_applyFilter(aFilter) {
+ applyFilter: function(aFilter) {
this.mFilterProperties = null;
if (typeof aFilter == "string") {
if (aFilter in this.mDefinedFilters) {
this.mFilterProperties = this.getDefinedFilterProperties(aFilter);
} else {
let dur = cal.createDuration(aFilter);
if (dur.inSeconds > 0) {
@@ -697,17 +697,17 @@ calFilter.prototype = {
/**
* Calculates the current start and end dates for the currently applied filter, and updates
* the current filter start and end dates. This function can be used to update the date range
* for date range filters that are relative to the selected date or current date and time.
*
* @return The current [startDate, endDate] for the applied filter.
*/
- updateFilterDates: function cF_updateFilterDates() {
+ updateFilterDates: function() {
let [startDate, endDate] = this.getDatesForFilter();
this.mStartDate = startDate;
this.mEndDate = endDate;
// the today and tomorrow properties are precalculated here
// for better performance when filtering batches of items.
this.mToday = cal.now();
this.mToday.isDate = true;
@@ -723,17 +723,17 @@ calFilter.prototype = {
* the currently applied filter properties and text filter.
*
* @param aItems The array of items to check.
* @param aCallback An optional callback function to be called with each item and
* the result of it's filter test.
* @return A new array containing the items that match the filters, or
* null if no filter has been applied.
*/
- filterItems: function cF_filterItems(aItems, aCallback) {
+ filterItems: function(aItems, aCallback) {
if (!this.mFilterProperties) {
return null;
}
return aItems.filter(function(aItem) {
let result = this.propertyFilter(aItem) && this.textFilter(aItem);
if (aCallback && typeof aCallback == "function") {
@@ -746,29 +746,29 @@ calFilter.prototype = {
/**
* Checks if the item matches the currently applied filter properties and text filter.
*
* @param aItem The item to check.
* @return Returns true if the item matches the filters,
* false otherwise.
*/
- isItemInFilters: function cF_isItemInFilters(aItem) {
+ isItemInFilters: function(aItem) {
return this.propertyFilter(aItem) && this.textFilter(aItem);
},
/**
* Finds the next occurrence of a repeating item that matches the currently applied
* filter properties.
*
* @param aItem The parent item to find the next occurrence of.
* @return Returns the next occurrence that matches the filters,
* or null if no match is found.
*/
- getNextOccurrence: function cF_getNextOccurrence(aItem) {
+ getNextOccurrence: function(aItem) {
if (!aItem.recurrenceInfo) {
return this.isItemInFilters(aItem) ? aItem : null;
}
let count = 0;
let start = cal.now();
// If the base item matches the filter, we need to check each future occurrence.
@@ -808,17 +808,17 @@ calFilter.prototype = {
* Gets the occurrences of a repeating item that match the currently applied
* filter properties and date range.
*
* @param aItem The parent item to find occurrence of.
* @return Returns an array containing the occurrences that
* match the filters, an empty array if there are no
* matches, or null if the filter is not initialized.
*/
- getOccurrences: function cF_getOccurrences(aItem) {
+ getOccurrences: function(aItem) {
if (!this.mFilterProperties) {
return null;
}
let props = this.mFilterProperties;
let occs;
if (!aItem.recurrenceInfo || (!props.occurrences && !this.mEndDate) ||
props.occurrences == props.FILTER_OCCURRENCES_NONE) {
@@ -848,17 +848,17 @@ calFilter.prototype = {
* This function is asynchronous, and returns results to a calIOperationListener object.
*
* @param aCalendar The calendar to get items from.
* @param aItemType The type of items to get, as defined by the calICalendar
* interface ITEM_FILTER_TYPE_XXX constants.
* @param aListener The calIOperationListener object to return results to.
* @return the calIOperation handle to track the operation.
*/
- getItems: function cF_getItems(aCalendar, aItemType, aListener) {
+ getItems: function(aCalendar, aItemType, aListener) {
if (!this.mFilterProperties) {
return null;
}
let props = this.mFilterProperties;
// we use a local proxy listener for the calICalendar.getItems() call, and use it
// to handle occurrence expansion and filter the results before forwarding them to
// the listener passed in the aListener argument.
--- a/calendar/base/src/calFreeBusyService.js
+++ b/calendar/base/src/calFreeBusyService.js
@@ -14,28 +14,28 @@ function calFreeBusyListener(numOperatio
}
calFreeBusyListener.prototype = {
mFinalListener: null,
mNumOperations: 0,
opGroup: null,
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.calIGenericOperationListener]),
- notifyResult: function calFreeBusyListener_notifyResult(result) {
+ notifyResult: function(result) {
let listener = this.mFinalListener;
if (listener) {
if (!this.opGroup.isPending) {
this.mFinalListener = null;
}
listener.onResult(this.opGroup, result);
}
},
// calIGenericOperationListener:
- onResult: function calFreeBusyListener_onResult(aOperation, aResult) {
+ onResult: function(aOperation, aResult) {
if (this.mFinalListener) {
if (!aOperation || !aOperation.isPending) {
--this.mNumOperations;
if (this.mNumOperations == 0) {
this.opGroup.notifyCompleted();
}
}
let opStatus = aOperation ? aOperation.status : Components.results.NS_OK;
@@ -67,32 +67,28 @@ calFreeBusyService.prototype = {
classID: calFreeBusyServiceClassID,
contractID: "@mozilla.org/calendar/freebusy-service;1",
classDescription: "Calendar FreeBusy Service",
interfaces: calFreeBusyServiceInterfaces,
flags: Components.interfaces.nsIClassInfo.SINGLETON
}),
// calIFreeBusyProvider:
- getFreeBusyIntervals: function calFreeBusyService_getFreeBusyIntervals(aCalId,
- aRangeStart,
- aRangeEnd,
- aBusyTypes,
- aListener) {
+ getFreeBusyIntervals: function(aCalId, aRangeStart, aRangeEnd, aBusyTypes, aListener) {
let groupListener = new calFreeBusyListener(this.mProviders.size, aListener);
for (let provider of this.mProviders) {
let operation = provider.getFreeBusyIntervals(aCalId, aRangeStart,
aRangeEnd,
aBusyTypes,
groupListener);
groupListener.opGroup.add(operation);
}
return groupListener.opGroup;
},
// calIFreeBusyService:
- addProvider: function calFreeBusyListener_addProvider(aProvider) {
+ addProvider: function(aProvider) {
this.mProviders.add(aProvider);
},
- removeProvider: function calFreeBusyListener_removeProvider(aProvider) {
+ removeProvider: function(aProvider) {
this.mProviders.remove(aProvider);
}
};
--- a/calendar/base/src/calIcsParser.js
+++ b/calendar/base/src/calIcsParser.js
@@ -21,17 +21,17 @@ calIcsParser.prototype = {
classInfo: XPCOMUtils.generateCI({
classID: calIcsParserClassID,
contractID: "@mozilla.org/calendar/ics-parser;1",
classDescription: "Calendar ICS Parser",
interfaces: calIcsParserInterfaces,
flags: Components.interfaces.nsIClassInfo.THREADSAFE
}),
- processIcalComponent: function ip_processIcalComponent(rootComp, aAsyncParsing) {
+ processIcalComponent: function(rootComp, aAsyncParsing) {
let calComp;
// libical returns the vcalendar component if there is just one vcalendar.
// If there are multiple vcalendars, it returns an xroot component, with
// vcalendar children. We need to handle both cases.
if (rootComp) {
if (rootComp.componentType == "VCALENDAR") {
calComp = rootComp;
} else {
@@ -110,17 +110,17 @@ calIcsParser.prototype = {
self.mComponents = self.mComponents.concat(state.extraComponents);
if (aAsyncParsing) {
aAsyncParsing.onParsingComplete(Components.results.NS_OK, self);
}
});
},
- parseString: function ip_parseString(aICSString, aTzProvider, aAsyncParsing) {
+ parseString: function(aICSString, aTzProvider, aAsyncParsing) {
if (aAsyncParsing) {
let self = this;
// We are using two types of very similar listeners here:
// aAsyncParsing is a calIcsParsingListener that returns the ics
// parser containing the processed items.
// The listener passed to parseICSAsync is a calICsComponentParsingListener
// required by the ics service, that receives the parsed root component.
@@ -134,17 +134,17 @@ calIcsParser.prototype = {
}
}
});
} else {
this.processIcalComponent(cal.getIcsService().parseICS(aICSString, aTzProvider));
}
},
- parseFromStream: function ip_parseFromStream(aStream, aTzProvider, aAsyncParsing) {