2 Copyright (C) 2005 SKYRIX Software AG
4 This file is part of OpenGroupware.org.
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 /* JavaScript for SOGo Mailer */
24 DOM ids available in mail list view:
32 bool: resizable, scrollbars, toolbar, location, directories, status,
38 function openMessageWindow(sender, msguid, url) {
39 return window.open(url, "SOGo_msg_" + msguid,
40 "width=640,height=480,resizable=1,scrollbars=1,toolbar=0," +
41 "location=0,directories=0,status=0,menubar=0,copyhistory=0")
44 function clickedUid(sender, msguid) {
45 resetSelection(window);
46 openMessageWindow(sender, msguid, msguid + "/tb.view");
49 function doubleClickedUid(sender, msguid) {
50 alert("DOUBLE Clicked " + msguid);
55 function toggleMailSelect(sender) {
57 row = document.getElementById(sender.name);
58 row.className = sender.checked ? "tableview_selected" : "tableview";
60 function collectSelectedRows() {
61 var pageform = document.forms['pageform'];
62 var rows = new Array();
64 for (key in pageform) {
65 if (key.indexOf("row_") != 0)
68 if (!pageform[key].checked)
71 rows[rows.length] = key.substring(4, key.length);
76 function clearSearch(sender) {
77 var searchField = window.document.getElementById("search");
78 if (searchField) searchField.value="";
84 function clickedCompose(sender) {
88 window.open(urlstr, "SOGo_compose",
89 "width=680,height=480,resizable=1,scrollbars=1,toolbar=0," +
90 "location=0,directories=0,status=0,menubar=0,copyhistory=0");
91 return false; /* stop following the link */
96 function validateEditorInput(sender) {
100 field = document.pageform.subject;
101 if (field.value == "")
102 errortext = errortext + "Missing Subject\n";
104 if (errortext.length > 0) {
105 alert("validation failed:\n" + errortext);
111 function clickedEditorSend(sender) {
112 if (!validateEditorInput(sender))
115 // TODO: validate whether we have a recipient! (#1220)
117 document.pageform.action="send";
118 document.pageform.submit();
119 // if everything is ok, close the window
123 function clickedEditorAttach(sender) {
126 urlstr = "viewAttachments";
127 window.open(urlstr, "SOGo_attach",
128 "width=320,height=320,resizable=1,scrollbars=1,toolbar=0," +
129 "location=0,directories=0,status=0,menubar=0,copyhistory=0");
130 return false; /* stop following the link */
133 function clickedEditorSave(sender) {
134 document.pageform.action="save";
135 document.pageform.submit();
140 function clickedEditorDelete(sender) {
141 document.pageform.action="delete";
142 document.pageform.submit();
148 /* addressbook helpers */
150 function openAnais(sender) {
154 var w = window.open(urlstr, "Anais",
155 "width=350,height=600,left=10,top=10,toolbar=no," +
156 "dependent=yes,menubar=no,location=no,resizable=yes," +
157 "scrollbars=yes,directories=no,status=no");
161 function openAddressbook(sender) {
164 urlstr = "addressbook";
165 var w = window.open(urlstr, "Addressbook",
166 "width=600,height=400,left=10,top=10,toolbar=no," +
167 "dependent=yes,menubar=no,location=no,resizable=yes," +
168 "scrollbars=yes,directories=no,status=no");
174 function clickedFilter(sender, scriptname) {
177 urlstr = scriptname + "/edit";
178 window.open(urlstr, "SOGo_filter_" + scriptname,
179 "width=640,height=480,resizable=1,scrollbars=1,toolbar=0," +
180 "location=0,directories=0,status=0,menubar=0,copyhistory=0")
184 function clickedNewFilter(sender) {
188 window.open(urlstr, "SOGo_filter",
189 "width=680,height=480,resizable=1,scrollbars=1,toolbar=0," +
190 "location=0,directories=0,status=0,menubar=0,copyhistory=0");
191 return false; /* stop following the link */
194 /* mail list DOM changes */
196 function markMailInWindow(win, msguid, markread) {
199 msgDiv = win.document.getElementById("div_" + msguid);
202 msgDiv.className = "mailer_readmailsubject";
204 msgDiv = win.document.getElementById("unreaddiv_" + msguid);
205 if (msgDiv) msgDiv.style.display = "none";
206 msgDiv = win.document.getElementById("readdiv_" + msguid);
207 if (msgDiv) msgDiv.style.display = "block";
210 msgDiv.className = "mailer_unreadmailsubject";
212 msgDiv = win.document.getElementById("readdiv_" + msguid);
213 if (msgDiv) msgDiv.style.display = "none";
214 msgDiv = win.document.getElementById("unreaddiv_" + msguid);
215 if (msgDiv) msgDiv.style.display = "block";
222 function markMailReadInWindow(win, msguid) {
223 return markMailInWindow(win, msguid, true);
228 function reopenToRemoveLocationBar() {
229 // we cannot really use this, see below at the close comment
230 if (window.locationbar && window.locationbar.visible) {
231 newwin = window.open(window.location.href, "SOGo",
232 "width=800,height=600,resizable=1,scrollbars=1," +
233 "toolbar=0,location=0,directories=0,status=0," +
234 "menubar=0,copyhistory=0");
236 window.close(); // this does only work for windows opened by scripts!
245 /* mail list reply */
247 function openMessageWindowsForSelection(sender, action) {
248 var rows = collectSelectedRows();
251 for (var i = 0; i < rows.length; i++)
252 win = openMessageWindow(sender, rows[i], rows[i] + "/" + action);
255 function mailListMarkMessage(sender, action, msguid, markread) {
257 var http = createHTTPClient();
259 url = action + "?uid=" + msguid;
262 // TODO: add parameter to signal that we are only interested in OK
263 http.open("GET", url + "&jsonly=1", false);
265 if (http.status != 200) {
266 // TODO: refresh page?
267 alert("Message Mark Failed: " + http.statusText);
268 window.opener.location.reload();
271 markMailInWindow(window, msguid, markread);
275 window.opener.location.href = url;
279 /* maillist row highlight */
281 var oldMaillistHighlight = null; // to remember deleted/selected style
283 function ml_highlight(sender) {
284 oldMaillistHighlight = sender.className;
285 if (oldMaillistHighlight == "tableview_highlight")
286 oldMaillistHighlight = null;
287 sender.className = "tableview_highlight";
289 function ml_lowlight(sender) {
290 if (oldMaillistHighlight) {
291 sender.className = oldMaillistHighlight;
292 oldMaillistHighlight = null;
295 sender.className = "tableview";
299 /* folder operations */
301 function ctxFolderAdd(sender) {
304 folderName = prompt("Foldername: ");
305 if (folderName == undefined)
307 if (folderName == "")
310 window.location.href = "createFolder?name=" + escape(folderName);
314 function ctxFolderDelete(sender) {
315 if (!confirm("Delete current folder?"))
318 window.location.href = "deleteFolder";