1
/* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Mozilla Public License Version
6
* 1.1 (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/MPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is edsintegration.
17
* The Initial Developer of the Original Code is
19
* Portions created by the Initial Developer are Copyright (C) 2011
20
* the Initial Developer. All Rights Reserved.
23
* Mike Conley <mconley@mozilla.com>
25
* Alternatively, the contents of this file may be used under the terms of
26
* either the GNU General Public License Version 2 or later (the "GPL"), or
27
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
* in which case the provisions of the GPL or the LGPL are applicable instead
29
* of those above. If you wish to allow use of your version of this file only
30
* under the terms of either the GPL or the LGPL, and not to allow others to
31
* use your version of this file under the terms of the MPL, indicate your
32
* decision by deleting the provisions above and replace them with the notice
33
* and other provisions required by the GPL or the LGPL. If you do not delete
34
* the provisions above, a recipient may use your version of this file under
35
* the terms of any one of the MPL, the GPL or the LGPL.
37
* ***** END LICENSE BLOCK ***** */
39
Components.utils.import("resource://gre/modules/Services.jsm");
40
Components.utils.import("resource:///modules/mailServices.js");
41
Components.utils.import("resource://edsintegration/nsAbEDSCommon.jsm");
42
Components.utils.import("resource:///modules/iteratorUtils.jsm");
44
var EDSMailingListEditor = {
52
this._bundle = Services.strings.createBundle("chrome://edsintegration/locale/contactEditor.properties");
56
getString: function EDSMLE_getString(aStringName) {
58
return this.bundle.GetStringFromName(aStringName);
61
Services.console.logStringMessage(e.message);
66
onLoad: function EDSMLE_onLoad(aDocument) {
67
RegisterLoadListener(EDSMailingListEditor.onLoadList);
68
LOG("Done loading EDSMailingListEditor");
71
goInert: function EDSMLE_goInert(aDocument) {
72
LOG("Attempting to set EDSMailingListEditor to inert.");
73
if (this._active == false) {
74
LOG("EDSMailingListEditor is already inert.");
77
LOG("EDSMailingListEditor going inert.");
78
// Unregister save listener;
79
UnregisterSaveListener(EDSMailingListEditor.onSaveList);
80
aDocument.getElementById("ListNickNameContainer").collapsed = false;
81
aDocument.getElementById("ListDescriptionContainer").collapsed = false;
82
aDocument.getElementById("HidesRecipientsContainer").collapsed = true;
83
aDocument.defaultView.sizeToContent();
87
goActive: function EDSMLE_goActive(aDocument, aDirectory) {
89
LOG("EDSMailingListEditor is already active.");
92
LOG("EDSMailingListEditor going active.");
93
RegisterSaveListener(EDSMailingListEditor.onSaveList);
94
aDocument.getElementById("ListNickNameContainer").collapsed = true;
95
aDocument.getElementById("ListDescriptionContainer").collapsed = true;
96
aDocument.getElementById("HidesRecipientsContainer").collapsed = false;
97
aDocument.defaultView.sizeToContent();
101
onLoadList: function EDSMLE_onLoadList(aList, aDocument) {
102
// If we're editing an EDS Mailing List, or creating a new
103
// mailing list under an nsIAbEDSDirectory, then aList should
104
// query to nsIAbEDSDirectory.
107
edsList = aList.QueryInterface(Components.interfaces
110
// It isn't, bail out
111
EDSMailingListEditor.goInert(aDocument);
115
// Gah, have to set gListCard to null, otherwise the double-clicked
116
// entry for editing will get its displayName overwritten. Ugh.
118
EDSMailingListEditor.goActive(aDocument, edsList.parentDirectory);
119
var hideRecips = aDocument.getElementById("HidesRecipients");
120
hideRecips.checked = aList.getBoolValue("HidesRecipients", false);
123
onSaveList: function EDSMLE_onSaveList(aList, aDocument) {
124
LOG("OnSaveList called");
128
let edsList = aList.QueryInterface(Components.interfaces
129
.nsIAbEDSMailingList);
130
let hideRecips = aDocument.getElementById("HidesRecipients");
131
edsList.setBoolValue("HidesRecipients", hideRecips.checked);
134
// Notify the ABManager that some cards have been changed...
137
populateEDSFields: function EDSMLE_PopulateEDSFields(aList, aDocument) {
138
if (aList.getBoolValue("HidesRecipients", false)) {
139
let hideRecips = aDocument.getElementById("HidesRecipients");
140
hideRecips.checked = true;
145
EDSMailingListEditor.onLoad(document);