[Pkg-mozext-commits] [gcontactsync] 47/88: Issue #27 - Added an anniversary field to Thunderbird.
David Prévot
taffit at moszumanska.debian.org
Thu Sep 18 20:52:29 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository gcontactsync.
commit ab43fefc013eaa7f21400b767d94676bdabcb73a
Author: Josh Geenen <joshgeenen at gmail.com>
Date: Mon May 26 12:52:19 2014 -0500
Issue #27 - Added an anniversary field to Thunderbird.
---
src/content/ABOverlay.js | 27 ++++++++++++++++
src/content/CardDialogOverlay.js | 55 ++++++++++++++++++++++++++++++++
src/content/CardDialogOverlay.xul | 19 ++++++++++-
src/locale/en-US/gcontactsync.properties | 2 ++
src/locale/en-US/overlay.dtd | 4 +++
5 files changed, 106 insertions(+), 1 deletion(-)
diff --git a/src/content/ABOverlay.js b/src/content/ABOverlay.js
index 3ab1616..21deb78 100644
--- a/src/content/ABOverlay.js
+++ b/src/content/ABOverlay.js
@@ -309,6 +309,29 @@ com.gContactSync.ABOverlay = {
"Relation2",
"Relation3"],
visible, true);
+
+ var day = aCard.getProperty("AnniversaryDay", null);
+ var month = aCard.getProperty("AnniversaryMonth", null);
+ var year = aCard.getProperty("AnniversaryYear", null);
+ var dateStr = null;
+ if (day > 0 && day < 32 && month > 0 && month < 13) {
+ var date = new Date(year, month - 1, day);
+ // if the year exists, just use Date.toLocaleString
+ if (year) {
+ date.setFullYear(year);
+ dateStr = date.toLocaleDateString();
+ } else {
+ // if the year doesn't exist, display Month DD (ex. January 01)
+ dateStr = date.toLocaleFormat(
+ gAddressBookBundle.getString("dateFormatMonthDay")
+ );
+ }
+ } else if (year) {
+ dateStr = year;
+ }
+ visible = cvSetNodeWithLabel(cvData.cvAnniversary,
+ com.gContactSync.StringBundle.getStr("anniversary"),
+ dateStr) || visible;
cvSetVisible(cvData.cvhOther, visible);
cvSetVisible(cvData.cvbOther, visible);
// Phone section (add OtherNumber and HomeFaxNumber)
@@ -477,6 +500,10 @@ com.gContactSync.ABOverlay = {
otherVbox.appendChild(cvData["cvRelation" + i]);
}
+ // Anniversary
+ cvData.cvAnniversary = com.gContactSync.ABOverlay.makeDescElement("Anniversary", "CardViewText");
+ vbox.insertBefore(cvData.cvAnniversary, document.getElementById("cvBirthday").nextSibling);
+
// Other Number and HomeFaxNumber
cvData.cvOtherNumber = com.gContactSync.ABOverlay.makeDescElement("OtherNumber", "CardViewText");
cvData.cvHomeFaxNumber = com.gContactSync.ABOverlay.makeDescElement("HomeFaxNumber", "CardViewText");
diff --git a/src/content/CardDialogOverlay.js b/src/content/CardDialogOverlay.js
index 1d3cbcc..ec06491 100644
--- a/src/content/CardDialogOverlay.js
+++ b/src/content/CardDialogOverlay.js
@@ -319,7 +319,15 @@ com.gContactSync.CardDialogOverlay = {
document.getElementById("HomeFaxNumber").readOnly = true;
document.getElementById("OtherNumber").readOnly = true;
document.getElementById("Relation").readOnly = true;
+ document.getElementById("Anniversary").readOnly = true;
}
+
+ // Copy certain functions from the birthday datepicker (but show the year element)
+ var anniversaryElem = document.getElementById("Anniversary");
+ var birthdayElem = document.getElementById("Birthday");
+ anniversaryElem._constrainValue = birthdayElem._constrainValue;
+ anniversaryElem._setFieldValue = birthdayElem._setFieldValue;
+
// fix the width of the dialog
window.sizeToContent();
@@ -413,6 +421,20 @@ com.gContactSync.CardDialogOverlay = {
com.gContactSync.alertError("Error in com.gContactSync.CheckAndSetCardValues: " + attr + "\n" + e);
}
}
+
+ // get the anniversary information from the dialog
+ var anniversaryElem = aDoc.getElementById("Anniversary");
+ var anniversaryMonth = anniversaryElem.monthField.value;
+ var anniversaryDay = anniversaryElem.dateField.value;
+ var anniversaryYear = anniversaryElem.yearField.value;
+
+ com.gContactSync.LOGGER.VERBOSE_LOG("Anniversary: " + anniversaryYear + "-" + anniversaryMonth + "-" + anniversaryDay);
+
+ // set the anniversary day, month, and year properties
+ contact.setValue("AnniversaryDay", anniversaryDay);
+ contact.setValue("AnniversaryMonth", anniversaryMonth);
+ contact.setValue("AnniversaryYear", anniversaryYear);
+
if (!contact.mContact.getProperty && gEditCard.abURI) {
if (contact.mContact.editCardToDatabase) { // Thunderbird 2
contact.mContact.editCardToDatabase(gEditCard.abURI);
@@ -423,6 +445,7 @@ com.gContactSync.CardDialogOverlay = {
}
}
}
+
// ensure that every contact edited through this dialog has at least a dummy
// e-mail address if necessary
var primEmailElem = aDoc.getElementById("PrimaryEmail");
@@ -496,6 +519,38 @@ com.gContactSync.CardDialogOverlay = {
} catch (e) { com.gContactSync.alertError("Error in com.gContactSync.GetCardValues: " + attr + "\n" + e); }
}
+ // Anniversary
+ var anniversaryElem = document.getElementById("Anniversary");
+ var year, month, day;
+ if (aCard.getProperty) { // post Bug 413260
+ year = aCard.getProperty("AnniversaryYear", null);
+ month = aCard.getProperty("AnniversaryMonth", null);
+ day = aCard.getProperty("AnniversaryDay", null);
+ } else { // pre Bug 413260
+ year = aCard.getStringAttribute("AnniversaryYear");
+ month = aCard.getStringAttribute("AnniversaryMonth");
+ day = aCard.getStringAttribute("AnniversaryDay");
+ }
+
+ // Default the year to 2000 (a leap year)
+ if (year && year < 10000 && year > 0) {
+ anniversaryElem.year = year;
+ anniversaryElem.yearField.value = year;
+ } else {
+ anniversaryElem.year = 2000;
+ anniversaryElem.yearField.value = null;
+ }
+ if (month > 0 && month < 13) {
+ anniversaryElem.month = month - 1;
+ } else {
+ anniversaryElem.monthField.value = null;
+ }
+ if (day > 0 && day < 32) {
+ anniversaryElem.date = day;
+ } else {
+ anniversaryElem.dateField.value = null;
+ }
+
// In TB 10 the way photos are saved changed and now requires two copies of
// each photo. One persistent copy is required as TB will copy it to the
// Photos directory and delete the previous copy when the contact is edited.
diff --git a/src/content/CardDialogOverlay.xul b/src/content/CardDialogOverlay.xul
index dbbe648..9caa1a1 100644
--- a/src/content/CardDialogOverlay.xul
+++ b/src/content/CardDialogOverlay.xul
@@ -35,7 +35,12 @@
-
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
-<!DOCTYPE overlay SYSTEM "chrome://gContactSync/locale/overlay.dtd">
+<!DOCTYPE overlay [
+ <!ENTITY % gcsOverlayDTD SYSTEM "chrome://gcontactsync/locale/overlay.dtd">
+ %gcsOverlayDTD;
+ <!ENTITY % tbDTD SYSTEM "chrome://messenger/locale/addressbook/abCardOverlay.dtd">
+ %tbDTD;
+]>
<overlay id="gContactSync-abEditCardDialogOverlay"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@@ -70,6 +75,18 @@
</tabs>
<tabpanels id="abTabPanels" flex="1">
+
+ <vbox id="abHomeTab">
+ <hbox id="anniversaryField" align="center" after="birthdayField">
+ <spacer flex="1"/>
+ <label control="Anniversary" value="&Anniversary.label;"
+ accesskey="&Anniversary.accesskey;"/>
+ <hbox class="AddressCardEditWidth" align="center">
+ <datepicker id="Anniversary" type="popup"/>
+ </hbox>
+ </hbox>
+ </vbox>
+
<vbox flex="1">
<hbox>
<vbox>
diff --git a/src/locale/en-US/gcontactsync.properties b/src/locale/en-US/gcontactsync.properties
index ab263de..9ad37af 100644
--- a/src/locale/en-US/gcontactsync.properties
+++ b/src/locale/en-US/gcontactsync.properties
@@ -254,6 +254,8 @@ confirmABReset=The adress book should be 'reset' in order to save these changes.
finishedPrefClean=gContactSync has finished cleaning %d unused preference(s).
#LOCALIZATION NOTE: '%d' will be replaced with the number of old/unused contact photos that were deleted (from deleted address books)
finishedPhotoClean=gContactSync has finished deleting %d unused contact photo(s).
+# Anniversary label
+anniversary=Anniversary
# Before multiple contacts are about to be deleted from one source gContactSync will ask the user for permission
diff --git a/src/locale/en-US/overlay.dtd b/src/locale/en-US/overlay.dtd
index d79495b..7ea6c70 100644
--- a/src/locale/en-US/overlay.dtd
+++ b/src/locale/en-US/overlay.dtd
@@ -23,6 +23,10 @@
<!-- A label for extra phone number fields -->
<!ENTITY numbers.box "Additional Numbers">
+<!-- Anniversary-related fields -->
+<!ENTITY Anniversary.label "Anniversary">
+<!ENTITY Anniversary.accesskey "y">
+
<!-- This can be blank or something like "Click on Sync to begin" -->
<!ENTITY initialStatus.label "">
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/gcontactsync.git
More information about the Pkg-mozext-commits
mailing list