2 * This array is used to remember mark status of rows in browse mode
4 * @copyright © 2005-2006 The SquirrelMail Project Team
5 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 var marked_row
= new Array
;
9 var orig_row_colors
= new Array();
12 * (un)Checks checkbox for the row that the current table cell is in
13 * when it gets clicked.
15 * @param string the name of the checkbox that should be (un)checked
17 function row_click(chkboxName
, event
) {
18 var chkbox
= document
.getElementById(chkboxName
);
20 // initialize orig_row_color if not defined already
21 if (!orig_row_colors
[chkboxName
]) {
22 orig_row_colors
[chkboxName
] = chkbox
.parentNode
.getAttribute('bgcolor');
23 if (orig_row_colors
[chkboxName
].indexOf("clicked_") == 0)
24 orig_row_colors
[chkboxName
] = orig_row_colors
[chkboxName
].substring(8, orig_row_colors
[chkboxName
].length
);
26 chkbox
.checked
= (chkbox
.checked
? false : true);
31 * Gets the current class of the requested row. This is a browser specific function.
32 * Code shamelessly ripped from setPointer() below.
34 function getCSSClass (theRow
)
37 // 3.1 ... with DOM compatible browsers except Opera that does not return
38 // valid values with "getAttribute"
39 if (typeof(window
.opera
) == 'undefined'
40 && typeof(theRow
.getAttribute
) != 'undefined'
41 && theRow
.getAttribute('className') ) {
42 rowClass
= theRow
.getAttribute('className');
44 // 3.2 ... with other browsers
46 rowClass
= theRow
.className
;
53 * Sets a new CSS class for the given row. Browser-specific.
55 function setCSSClass (obj
, newClass
) {
56 if (typeof(window
.opera
) == 'undefined' && typeof(obj
.getAttribute
) != 'undefined' && obj
.getAttribute('className') ) {
57 obj
.setAttribute('className', newClass
, 0);
60 obj
.className
= newClass
;
65 * This function is used to initialize the orig_row_color array so we do not
66 * need to predefine the entire array
68 function rowOver(chkboxName
) {
69 var chkbox
= document
.getElementById(chkboxName
);
70 var rowClass
, rowNum
, overClass
, clickedClass
;
72 if (!orig_row_colors
[chkboxName
]) {
73 rowClass
= getCSSClass(chkbox
.parentNode
.parentNode
);
74 if (rowClass
.indexOf("clicked_") == 0)
75 rowClass
= rowClass
.substring(8, rowClass
.length
);
76 orig_row_colors
[chkboxName
] = rowClass
;
78 rowClass
= orig_row_colors
[chkboxName
];
80 rowNum
= chkboxName
.substring(chkboxName
.length
- 1, chkboxName
.length
);
83 * The mouseover and clicked CSS classes are always the same name!
85 overClass
= 'mouse_over';
86 clickedClass
= 'clicked';
87 setPointer(chkbox
.parentNode
.parentNode
, rowNum
, 'over' , rowClass
, overClass
, clickedClass
);
92 * (un)Checks all checkboxes for the message list from a specific form
93 * when it gets clicked.
95 * @param string the id of the form where all checkboxes should be (un)checked
96 * @param boolean use fancy row coloring when a checkbox is checked
97 * @param string new color of the checked rows
99 function toggle_all(formname
, fancy
) {
100 var TargetForm
= document
.getElementById(formname
);
102 for (var i
= 0; i
< TargetForm
.elements
.length
; i
++) {
103 if (TargetForm
.elements
[i
].type
== 'checkbox' && TargetForm
.elements
[i
].name
.substring(0,3) == 'msg') {
105 array_key
= TargetForm
.elements
[i
].getAttribute('id');
106 // initialize orig_row_color if not defined already
107 if (!orig_row_colors
[array_key
]) {
108 rowClass
= getCSSClass(TargetForm
.elements
[i
].parentNode
.parentNode
);
109 if (rowClass
.indexOf("clicked_") == 0)
110 rowClass
= rowClass
.substring(8, rowClass
.length
);
111 orig_row_colors
[array_key
] = rowClass
;
113 origClass
= orig_row_colors
[array_key
];
114 clickedClass
= 'clicked';
115 setPointer(TargetForm
.elements
[i
].parentNode
.parentNode
, j
,'click' , origClass
, origClass
, clickedClass
);
118 TargetForm
.elements
[i
].checked
= !(TargetForm
.elements
[i
].checked
);
124 * Sets/unsets the pointer and marker in browse mode
126 * @param object theRow the table row
127 * @param integer theRowNum the row number
128 * @param string theAction the action calling this script (over, out or click)
129 * @param string defaultClass the default background CSS class
130 * @param string mouseoverClass the CSS class to use for mouseover
131 * @param string clickedClass the CSS class to use for marking a row
133 * @return boolean whether pointer is set or not
135 function setPointer(theRow
, theRowNum
, theAction
, defaultClass
, mouseoverClass
, clickedClass
)
137 // 1. Pointer and mark feature are disabled or the browser can't get the
139 if ((mouseoverClass
== '' && clickedClass
== '')
140 || typeof(theRow
.className
) == 'undefined') {
144 // 2. Verify we can get the current row or exit
145 if (typeof(document
.getElementsByTagName
) != 'undefined') {
148 else if (typeof(theRow
) != 'undefined') {
155 // 3. Gets the current CSS class...
157 var currentClass
= getCSSClass(theRow
);
158 if (currentClass
.indexOf("clicked_") == 0)
159 currentClass
= 'clicked';
161 // 4. Defines the new class
162 // 4.1 Current class is the default one
163 if (currentClass
== ''
164 || currentClass
.toLowerCase() == defaultClass
.toLowerCase()) {
165 if (theAction
== 'over' && mouseoverClass
!= '') {
166 newClass
= mouseoverClass
;
168 else if (theAction
== 'click' && clickedClass
!= '') {
169 newClass
= clickedClass
;
170 marked_row
[theRowNum
] = true;
171 // deactivated onclick marking of the checkbox because it's also executed
172 // when an action (clicking on the checkbox itself) on a single item is
173 // performed. Then the checkbox would get deactived, even though we need
174 // it activated. Maybe there is a way to detect if the row was clicked,
175 // and not an item therein...
176 //document.getElementById('msg[' + theRowNum + ']').checked = true;
179 // 4.1.2 Current class is the mouseover one
180 else if (currentClass
.toLowerCase() == mouseoverClass
.toLowerCase()
181 && (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])) {
182 if (theAction
== 'out') {
183 newClass
= defaultClass
;
185 else if (theAction
== 'click' && clickedClass
!= '') {
186 newClass
= clickedClass
;
187 marked_row
[theRowNum
] = true;
188 //document.getElementById('msg[' + theRowNum + ']').checked = true;
191 // 4.1.3 Current color is the clicked one
192 else if (currentClass
.toLowerCase() == clickedClass
.toLowerCase()) {
193 if (theAction
== 'click') {
194 newClass
= (mouseoverClass
!= '')
197 marked_row
[theRowNum
] = false;
198 //document.getElementById('msg[' + theRowNum + ']').checked = false;
202 // 5. Sets the new color...
204 setCSSClass(theRow
, newClass
);
208 } // end of the 'setPointer()' function
210 function comp_in_new_form(comp_uri
, button
, myform
, iWidth
, iHeight
) {
211 comp_uri
+= "&" + button
.name
+ "=1";
212 for ( var i
=0; i
< myform
.elements
.length
; i
++ ) {
213 if ( myform
.elements
[i
].type
== "checkbox" && myform
.elements
[i
].checked
)
214 comp_uri
+= "&" + myform
.elements
[i
].name
+ "=1";
216 if (!iWidth
) iWidth
= 640;
217 if (!iHeight
) iHeight
= 550;
218 var sArg
= "width=" + iWidth
+ ",height=" + iHeight
+ ",scrollbars=yes,resizable=yes,status=yes";
219 var newwin
= window
.open(comp_uri
, "_blank", sArg
);
222 function comp_in_new(comp_uri
, iWidth
, iHeight
) {
223 if (!iWidth
) iWidth
= 640;
224 if (!iHeight
) iHeight
= 550;
225 sArg
= "width=" + iWidth
+ ",height=" + iHeight
+ ",scrollbars=yes,resizable=yes,status=yes";
226 var newwin
= window
.open(comp_uri
, "_blank", sArg
);
230 * Reload the read_body screen on sending an mdn receipt
233 var mdnuri
=window
.location
+'&sendreceipt=1';
234 window
.location
= mdnuri
;
237 var alreadyFocused
= false;
238 function checkForm(smaction
) {
240 if (alreadyFocused
) return;
243 * this part is used for setting the focus in the compose screen
246 if (smaction
== "select") {
247 document
.forms
['compose'].body
.select();
248 } else if (smaction
== "focus") {
249 document
.forms
['compose'].body
.focus();
253 * All other forms that need to set the focus
255 var f
= document
.forms
.length
;
258 while( pos
== -1 && i
< f
) {
259 var e
= document
.forms
[i
].elements
.length
;
261 while( pos
== -1 && j
< e
) {
262 if ( document
.forms
[i
].elements
[j
].type
== 'text' || document
.forms
[i
].elements
[j
].type
== 'password' ) {
270 document
.forms
[i
-1].elements
[pos
].focus();