]> err.no Git - scalable-opengroupware.org/blob - SOGo/UI/Mailer/mailer.js
fixed maillist refresh on delete/mark read
[scalable-opengroupware.org] / SOGo / UI / Mailer / mailer.js
1 /* JavaScript for SOGo Mailer */
2
3 /*
4   Window Properties:
5     width, height
6     bool: resizable, scrollbars, toolbar, location, directories, status,
7           menubar, copyhistory
8 */
9
10 function clickedUid(sender, msguid) {
11   var urlstr, cburl;
12   
13   cburl  = "markMessageRead?uid=" + msguid;
14   urlstr = msguid + "/view?openerurl=" + encodeURIComponent(cburl);
15   window.open(urlstr, "SOGo_msg_" + msguid,
16               "width=640,height=480,resizable=1,scrollbars=1,toolbar=0," +
17               "location=0,directories=0,status=0,menubar=0,copyhistory=0")
18   return true;
19 }
20 function doubleClickedUid(sender, msguid) {
21   alert("DOUBLE Clicked " + msguid);
22
23   return false;
24 }
25
26 function highlightUid(sender, msguid) {
27   // var row = document.getElementById(msguid);
28   // row.className="mailer_readmailsubject_high";
29   return true;
30 }
31 function lowlightUid(sender, msguid) {
32   // var row = document.getElementById(msguid);
33   // row.className="mailer_readmailsubject";
34   return true;
35 }
36
37 function clickedCompose(sender) {
38   var urlstr;
39   
40   urlstr = "compose";
41   window.open(urlstr, "SOGo_compose",
42               "width=680,height=480,resizable=1,scrollbars=1,toolbar=0," +
43               "location=0,directories=0,status=0,menubar=0,copyhistory=0");
44   return false; /* stop following the link */
45 }
46
47 /* mail editor */
48
49 function validateEditorInput(sender) {
50   var errortext = "";
51   var field;
52   
53   field = document.pageform.subject;
54   if (field.value == "")
55     errortext = errortext + "Missing Subject\n";
56   
57   if (errortext.length > 0) {
58     alert("validation failed:\n" + errortext);
59     return false;
60   }
61   return true;
62 }
63
64 function clickedEditorSend(sender) {
65   if (!validateEditorInput(sender))
66     return false;
67
68   // TODO: validate whether we have a recipient! (#1220)
69   
70   document.pageform.action="send";
71   document.pageform.submit();
72   // if everything is ok, close the window
73   return true;
74 }
75
76 function clickedEditorAttach(sender) {
77   var urlstr;
78   
79   urlstr = "viewAttachments";
80   window.open(urlstr, "SOGo_attach",
81               "width=320,height=320,resizable=1,scrollbars=1,toolbar=0," +
82               "location=0,directories=0,status=0,menubar=0,copyhistory=0");
83   return false; /* stop following the link */
84 }
85
86 function clickedEditorSave(sender) {
87   document.pageform.action="save";
88   document.pageform.submit();
89   return true;
90 }
91
92 function clickedEditorDelete(sender) {
93   document.pageform.action="delete";
94   document.pageform.submit();
95   window.close();
96   return true;
97 }
98
99 /* addressbook helpers */
100
101 function openAnais(sender) {
102   var urlstr;
103
104   urlstr = "anais";
105   var w = window.open(urlstr, "Anais",
106                       "width=350,height=600,left=10,top=10,toolbar=no," +
107                       "dependent=yes,menubar=no,location=no,resizable=yes," +
108                       "scrollbars=yes,directories=no,status=no");
109   w.focus();
110 }
111
112 function openAddressbook(sender) {
113   var urlstr;
114   
115   urlstr = "addressbook";
116   var w = window.open(urlstr, "Addressbook",
117                       "width=600,height=400,left=10,top=10,toolbar=no," +
118                       "dependent=yes,menubar=no,location=no,resizable=yes," +
119                       "scrollbars=yes,directories=no,status=no");
120   w.focus();
121 }
122
123 /* filters */
124
125 function clickedFilter(sender, scriptname) {
126   var urlstr;
127   
128   urlstr = scriptname + "/edit";
129   window.open(urlstr, "SOGo_filter_" + scriptname,
130               "width=640,height=480,resizable=1,scrollbars=1,toolbar=0," +
131               "location=0,directories=0,status=0,menubar=0,copyhistory=0")
132   return true;
133 }
134
135 function clickedNewFilter(sender) {
136   var urlstr;
137   
138   urlstr = "create";
139   window.open(urlstr, "SOGo_filter",
140               "width=680,height=480,resizable=1,scrollbars=1,toolbar=0," +
141               "location=0,directories=0,status=0,menubar=0,copyhistory=0");
142   return false; /* stop following the link */
143 }
144
145 /* generic stuff */
146
147 function refreshOpener() {
148   if (window.opener && !window.opener.closed) {
149     window.opener.location.reload();
150   }
151 }
152
153 function getQueryParaArray(s) {
154   if (s.charAt(0) == "?") s = s.substr(1, s.length - 1);
155   return s.split("&");
156 }
157 function getQueryParaValue(s, name) {
158   var t;
159   
160   t = getQueryParaArray(s);
161   for (var i = 0; i < t.length; i++) {
162     var s = t[i];
163     
164     if (s.indexOf(name) != 0)
165       continue;
166     
167     s = s.substr(name.length, s.length - name.length);
168     return decodeURIComponent(s);
169   }
170   return None;
171 }
172
173 function triggerOpenerCallback() {
174   /* this code has some issue if the folder has no proper trailing slash! */
175   if (window.opener && !window.opener.closed) {
176     var t, cburl;
177     
178     t = getQueryParaValue(window.location.search, "openerurl=");
179     cburl = window.opener.window.location.href;
180     if (cburl[cburl.length - 1] != "/") {
181       cburl = cburl.substr(0, cburl.lastIndexOf("/") + 1);
182     }
183     cburl = cburl + t;
184     window.opener.window.location.href = cburl;
185   }
186 }