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
) {
18 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
)
36 // 3.1 ... with DOM compatible browsers except Opera that does not return
37 // valid values with "getAttribute"
38 if (typeof(window
.opera
) == 'undefined'
39 && typeof(theRow
.getAttribute
) != 'undefined'
40 && theRow
.getAttribute('className') ) {
41 rowClass
= theRow
.getAttribute('className');
43 // 3.2 ... with other browsers
45 rowClass
= theRow
.className
;
52 * Sets a new CSS class for the given row. Browser-specific.
54 function setCSSClass (obj
, newClass
) {
55 if (typeof(window
.opera
) == 'undefined' && typeof(obj
.getAttribute
) != 'undefined' && obj
.getAttribute('className') ) {
56 obj
.setAttribute('className', newClass
, 0);
59 obj
.className
= newClass
;
64 * This function is used to initialize the orig_row_color array so we do not
65 * need to predefine the entire array
67 function rowOver(chkboxName
) {
68 chkbox
= document
.getElementById(chkboxName
);
70 if (!orig_row_colors
[chkboxName
]) {
71 rowClass
= getCSSClass(chkbox
.parentNode
.parentNode
);
72 if (rowClass
.indexOf("clicked_") == 0)
73 rowClass
= rowClass
.substring(8, rowClass
.length
);
74 orig_row_colors
[chkboxName
] = rowClass
;
76 rowClass
= orig_row_colors
[chkboxName
];
78 rowNum
= chkboxName
.substring(chkboxName
.length
- 1, chkboxName
.length
);
81 * The mouseover and clicked CSS classes are always the same name!
83 overClass
= 'mouse_over';
84 clickedClass
= 'clicked';
85 setPointer(chkbox
.parentNode
.parentNode
, rowNum
, 'over' , rowClass
, overClass
, clickedClass
);
90 * (un)Checks all checkboxes for the message list from a specific form
91 * when it gets clicked.
93 * @param string the id of the form where all checkboxes should be (un)checked
94 * @param boolean use fancy row coloring when a checkbox is checked
95 * @param string new color of the checked rows
97 function toggle_all(formname
, fancy
) {
98 TargetForm
= document
.getElementById(formname
);
100 for (var i
= 0; i
< TargetForm
.elements
.length
; i
++) {
101 if (TargetForm
.elements
[i
].type
== 'checkbox' && TargetForm
.elements
[i
].name
.substring(0,3) == 'msg') {
103 array_key
= TargetForm
.elements
[i
].getAttribute('id');
104 // initialize orig_row_color if not defined already
105 if (!orig_row_colors
[array_key
]) {
106 rowClass
= getCSSClass(TargetForm
.elements
[i
].parentNode
.parentNode
);
107 if (rowClass
.indexOf("clicked_") == 0)
108 rowClass
= rowClass
.substring(8, rowClass
.length
);
109 orig_row_colors
[array_key
] = rowClass
;
111 origClass
= orig_row_colors
[array_key
];
112 clickedClass
= 'clicked';
113 setPointer(TargetForm
.elements
[i
].parentNode
.parentNode
, j
,'click' , origClass
, origClass
, clickedClass
);
116 TargetForm
.elements
[i
].checked
= !(TargetForm
.elements
[i
].checked
);
122 * Sets/unsets the pointer and marker in browse mode
124 * @param object theRow the table row
125 * @param integer theRowNum the row number
126 * @param string theAction the action calling this script (over, out or click)
127 * @param string defaultClass the default background CSS class
128 * @param string mouseoverClass the CSS class to use for mouseover
129 * @param string clickedClass the CSS class to use for marking a row
131 * @return boolean whether pointer is set or not
133 function setPointer(theRow
, theRowNum
, theAction
, defaultClass
, mouseoverClass
, clickedClass
)
135 // 1. Pointer and mark feature are disabled or the browser can't get the
137 if ((mouseoverClass
== '' && clickedClass
== '')
138 || typeof(theRow
.className
) == 'undefined') {
142 // 2. Verify we can get the current row or exit
143 if (typeof(document
.getElementsByTagName
) != 'undefined') {
146 else if (typeof(theRow
) != 'undefined') {
153 // 3. Gets the current CSS class...
155 var currentClass
= getCSSClass(theRow
);
156 if (currentClass
.indexOf("clicked_") == 0)
157 currentClass
= 'clicked';
159 // 4. Defines the new class
160 // 4.1 Current class is the default one
161 if (currentClass
== ''
162 || currentClass
.toLowerCase() == defaultClass
.toLowerCase()) {
163 if (theAction
== 'over' && mouseoverClass
!= '') {
164 newClass
= mouseoverClass
;
166 else if (theAction
== 'click' && clickedClass
!= '') {
167 newClass
= clickedClass
;
168 marked_row
[theRowNum
] = true;
169 // deactivated onclick marking of the checkbox because it's also executed
170 // when an action (clicking on the checkbox itself) on a single item is
171 // performed. Then the checkbox would get deactived, even though we need
172 // it activated. Maybe there is a way to detect if the row was clicked,
173 // and not an item therein...
174 //document.getElementById('msg[' + theRowNum + ']').checked = true;
177 // 4.1.2 Current class is the mouseover one
178 else if (currentClass
.toLowerCase() == mouseoverClass
.toLowerCase()
179 && (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])) {
180 if (theAction
== 'out') {
181 newClass
= defaultClass
;
183 else if (theAction
== 'click' && clickedClass
!= '') {
184 newClass
= clickedClass
;
185 marked_row
[theRowNum
] = true;
186 //document.getElementById('msg[' + theRowNum + ']').checked = true;
189 // 4.1.3 Current color is the clicked one
190 else if (currentClass
.toLowerCase() == clickedClass
.toLowerCase()) {
191 if (theAction
== 'click') {
192 newClass
= (mouseoverClass
!= '')
195 marked_row
[theRowNum
] = false;
196 //document.getElementById('msg[' + theRowNum + ']').checked = false;
200 // 5. Sets the new color...
202 setCSSClass(theRow
, newClass
);
206 } // end of the 'setPointer()' function
208 function comp_in_new_form(comp_uri
, button
, myform
, iWidth
, iHeight
) {
209 comp_uri
+= "&" + button
.name
+ "=1";
210 for ( var i
=0; i
< myform
.elements
.length
; i
++ ) {
211 if ( myform
.elements
[i
].type
== "checkbox" && myform
.elements
[i
].checked
)
212 comp_uri
+= "&" + myform
.elements
[i
].name
+ "=1";
214 if (!iWidth
) iWidth
= 640;
215 if (!iHeight
) iHeight
= 550;
216 sArg
= "width=" + iWidth
+ ",height=" + iHeight
+ ",scrollbars=yes,resizable=yes,status=yes";
217 var newwin
= window
.open(comp_uri
, "_blank", sArg
);
220 function comp_in_new(comp_uri
, iWidth
, iHeight
) {
221 if (!iWidth
) iWidth
= 640;
222 if (!iHeight
) iHeight
= 550;
223 sArg
= "width=" + iWidth
+ ",height=" + iHeight
+ ",scrollbars=yes,resizable=yes,status=yes";
224 var newwin
= window
.open(comp_uri
, "_blank", sArg
);
228 * Reload the read_body screen on sending an mdn receipt
231 mdnuri
=window
.location
+'&sendreceipt=1';
232 window
.location
= mdnuri
;
235 var alreadyFocused
= false;
236 function checkForm(smaction
) {
238 if (alreadyFocused
) return;
241 * this part is used for setting the focus in the compose screen
244 if (smaction
== "select") {
245 document
.forms
['compose'].body
.select();
246 } else if (smaction
== "focus") {
247 document
.forms
['compose'].body
.focus();
251 * All other forms that need to set the focus
253 var f
= document
.forms
.length
;
256 while( pos
== -1 && i
< f
) {
257 var e
= document
.forms
[i
].elements
.length
;
259 while( pos
== -1 && j
< e
) {
260 if ( document
.forms
[i
].elements
[j
].type
== 'text' || document
.forms
[i
].elements
[j
].type
== 'password' ) {
268 document
.forms
[i
-1].elements
[pos
].focus();