!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is Mozilla addressbook.
15 *
16 * The Initial Developer of the Original Code is
17 * Seth Spitzer <sspitzer@netscape.com>.
18 * Portions created by the Initial Developer are Copyright (C) 2001
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 *
23 * Alternatively, the contents of this file may be used under the terms of
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26 * in which case the provisions of the GPL or the LGPL are applicable instead
27 * of those above. If you wish to allow use of your version of this file only
28 * under the terms of either the GPL or the LGPL, and not to allow others to
29 * use your version of this file under the terms of the MPL, indicate your
30 * decision by deleting the provisions above and replace them with the notice
31 * and other provisions required by the GPL or the LGPL. If you do not delete
32 * the provisions above, a recipient may use your version of this file under
33 * the terms of any one of the MPL, the GPL or the LGPL.
34 *
35 * ***** END LICENSE BLOCK ***** */
36
GetAbViewListener
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
37 function GetAbViewListener()
38 {
39 // the ab panel doesn't care if the total changes, or if the selection changes
40 return null;
41 }
42
43
contactsListDoubleClick
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
44 function contactsListDoubleClick(event)
45 {
46 // we only care about button 0 (left click) events
47 if (event.button != 0)
48 return;
49
50 var contactsTree = document.getElementById("abResultsTree");
51 var row = contactsTree.treeBoxObject.getRowAt(event.clientX, event.clientY);
52 if (row == -1 || row > contactsTree.view.rowCount-1 || event.originalTarget.localName != "treechildren")
53 {
54 // double clicking on a non valid row should not open the edit filter dialog
55 return;
56 }
57
58 // ok, go ahead and add the entry
59 addSelectedAddresses('addr_to');
60 }
61
addSelectedAddresses
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
62 function addSelectedAddresses(recipientType)
63 {
64 var cards = GetSelectedAbCards();
65 var count = cards.length;
66
67
68 for (var i = 0; i < count; i++)
69 {
70 // turn each card into a properly formatted address
71 var address = GenerateAddressFromCard(cards[i]);
72 if (address != "")
73 parent.AddRecipient(recipientType, address);
74 }
75 }
76
77 var gAddressBookPanelAbListener = {
onItemAdded
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
78 onItemAdded: function(parentDir, item) {
79 // will not be called
80 },
onItemRemoved
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
81 onItemRemoved: function(parentDir, item) {
82 // will only be called when an addressbook is deleted
83 try {
84 var directory = item.QueryInterface(Components.interfaces.nsIAbDirectory);
85 // check if the item being removed is the directory
86 // that we are showing in the addressbook sidebar
87 // if so, select the person addressbook (it can't be removed)
88 if (directory == GetAbView().directory) {
89 var abPopup = document.getElementById('addressbookList');
90 abPopup.value = kPersonalAddressbookURI;
91 LoadPreviouslySelectedAB();
92 }
93 }
94 catch (ex) {
95 }
96 },
onItemPropertyChanged
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
97 onItemPropertyChanged: function(item, property, oldValue, newValue) {
98 try {
99 var directory = item.QueryInterface(Components.interfaces.nsIAbDirectory);
100 // check if the item being changed is the directory
101 // that we are showing in the addressbook sidebar
102 if (directory == GetAbView().directory) {
103 LoadPreviouslySelectedAB();
104 }
105 }
106 catch (ex) {
107 }
108 }
109 };
110
111
112 // XXX todo
113 // can we combine some common code? see OnLoadNewMailList()
114 // set popup with address book names
LoadPreviouslySelectedAB
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
115 function LoadPreviouslySelectedAB()
116 {
117 var abPopup = document.getElementById('addressbookList');
118 var value = abPopup.value || kPersonalAddressbookURI;
119 abPopup.selectedItem = null;
120 abPopup.value = value;
121 ChangeDirectoryByURI(abPopup.selectedItem.id);
122 }
123
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
124 function AddressBookMenuListChange()
125 {
126 if (gSearchInput.value && !gSearchInput.showingSearchCriteria)
127 onEnterInSearchBar();
128 else
129 {
130 var abPopup = document.getElementById('addressbookList');
131 ChangeDirectoryByURI(abPopup.selectedItem.id);
132 }
133 }
134
AbPanelOnComposerClose
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
135 function AbPanelOnComposerClose()
136 {
137 CloseAbView();
138 onClearSearch();
139 }
140
AbPanelOnComposerReOpen
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
141 function AbPanelOnComposerReOpen()
142 {
143 SetAbView(GetSelectedDirectory(), true);
144 }
145
AbPanelLoad
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
146 function AbPanelLoad()
147 {
148 InitCommonJS();
149
150 document.title = parent.document.getElementById("sidebar-title").value;
151
152 LoadPreviouslySelectedAB();
153
154 // Add a listener, so we can switch directories if the current directory is
155 // deleted, and change the name if the selected directory's name is modified.
156 // This listener only cares when a directory is removed or modified.
157 Components.classes["@mozilla.org/abmanager;1"]
158 .getService(Components.interfaces.nsIAbManager)
159 .addAddressBookListener(gAddressBookAbListener,
160 nsIAbListener.directoryRemoved |
161 nsIAbListener.itemChanged);
162
163 parent.document.getElementById("msgcomposeWindow").addEventListener('compose-window-close', AbPanelOnComposerClose, true);
164 parent.document.getElementById("msgcomposeWindow").addEventListener('compose-window-reopen', AbPanelOnComposerReOpen, true);
165 gSearchInput = document.getElementById("searchInput");
166 }
167
AbPanelUnload
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
168 function AbPanelUnload()
169 {
170 Components.classes["@mozilla.org/abmanager;1"]
171 .getService(Components.interfaces.nsIAbManager)
172 .removeAddressBookListener(gAddressBookPanelAbListener);
173
174 parent.document.getElementById("msgcomposeWindow").removeEventListener('compose-window-close', AbPanelOnComposerClose, true);
175 parent.document.getElementById("msgcomposeWindow").removeEventListener('compose-window-reopen', AbPanelOnComposerReOpen, true);
176
177 CloseAbView();
178 }
179
AbPanelNewCard
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
180 function AbPanelNewCard()
181 {
182 goNewCardDialog(abList.selectedItem.getAttribute('id'));
183 }
184
AbPanelNewList
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
185 function AbPanelNewList()
186 {
187 goNewListDialog(abList.selectedItem.getAttribute('id'));
188 }
189
ResultsPaneSelectionChanged
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
190 function ResultsPaneSelectionChanged()
191 {
192 // do nothing for ab panel
193 }
194
OnClickedCard
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
195 function OnClickedCard()
196 {
197 // do nothing for ab panel
198 }
199
AbResultsPaneDoubleClick
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
200 function AbResultsPaneDoubleClick(card)
201 {
202 // double click for ab panel means "send mail to this person / list"
203 AbNewMessage();
204 }
205
UpdateCardView
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
206 function UpdateCardView()
207 {
208 // do nothing for ab panel
209 }
210
onEnterInSearchBar
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
211 function onEnterInSearchBar()
212 {
213 if (!gQueryURIFormat)
214 gQueryURIFormat = gPrefs.getComplexValue("mail.addr_book.quicksearchquery.format",
215 Components.interfaces.nsIPrefLocalizedString).data;
216
217 var sortColumn = gAbResultsTree.getAttribute("sortCol");
218 var sortDirection = document.getElementById(sortColumn).getAttribute("sortDirection");
219 var searchURI = GetSelectedDirectory();
220
221 if (gSearchInput.value != "")
222 searchURI += gQueryURIFormat.replace(/@V/g, encodeURIComponent(gSearchInput.value));
223
224 SetAbView(searchURI, true, sortColumn, sortDirection);
225 }