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');
24 chkbox
.checked
= (chkbox
.checked
? false : true);
29 * Gets the current class of the requested row. This is a browser specific function.
30 * Code shamelessly ripped from setPointer() below.
32 function getCSSClass (theRow
)
34 // 3.1 ... with DOM compatible browsers except Opera that does not return
35 // valid values with "getAttribute"
36 if (typeof(window
.opera
) == 'undefined'
37 && typeof(theRow
.getAttribute
) != 'undefined'
38 && theRow
.getAttribute('className') ) {
39 rowClass
= theRow
.getAttribute('className');
41 // 3.2 ... with other browsers
43 rowClass
= theRow
.className
;
50 * Sets a new CSS class for the given row. Browser-specific.
52 function setCSSClass (obj
, newClass
) {
53 if (typeof(window
.opera
) == 'undefined' && typeof(obj
.getAttribute
) != 'undefined' && obj
.getAttribute('className') ) {
54 obj
.setAttribute('className', newClass
, 0);
57 obj
.className
= newClass
;
62 * This function is used to initialize the orig_row_color array so we do not
63 * need to predefine the entire array
65 function rowOver(chkboxName
) {
66 chkbox
= document
.getElementById(chkboxName
);
68 if (!orig_row_colors
[chkboxName
]) {
69 rowClass
= getCSSClass(chkbox
.parentNode
.parentNode
);
70 orig_row_colors
[chkboxName
] = rowClass
;
72 rowClass
= orig_row_colors
[chkboxName
];
74 j
= chkbox
.name
.length
- 1
77 * The mouseover and clicked CSS classes are always the same name!
79 overClass
= 'mouse_over';
80 clickedClass
= 'clicked';
81 setPointer(chkbox
.parentNode
.parentNode
, j
,'over' , rowClass
, overClass
, clickedClass
);
86 * (un)Checks all checkboxes for the message list from a specific form
87 * when it gets clicked.
89 * @param string the id of the form where all checkboxes should be (un)checked
90 * @param boolean use fancy row coloring when a checkbox is checked
91 * @param string new color of the checked rows
93 function toggle_all(formname
, fancy
) {
94 TargetForm
= document
.getElementById(formname
);
96 for (var i
= 0; i
< TargetForm
.elements
.length
; i
++) {
97 if (TargetForm
.elements
[i
].type
== 'checkbox' && TargetForm
.elements
[i
].name
.substring(0,3) == 'msg') {
99 array_key
= TargetForm
.elements
[i
].getAttribute('id');
100 if (TargetForm
.elements
[i
].checked
== false) {
101 // initialize orig_row_color if not defined already
102 if (!orig_row_colors
[array_key
]) {
103 rowClass
= getCSSClass(TargetForm
.elements
[i
].parentNode
.parentNode
);
104 orig_row_colors
[array_key
] = rowClass
;
107 origClass
= orig_row_colors
[array_key
];
108 clickedClass
= 'clicked';
109 setPointer(TargetForm
.elements
[i
].parentNode
.parentNode
, j
,'click' , origClass
, origClass
, clickedClass
);
112 TargetForm
.elements
[i
].checked
= !(TargetForm
.elements
[i
].checked
);
118 * Sets/unsets the pointer and marker in browse mode
120 * @param object the table row
121 * @param integer the row number
122 * @param string the action calling this script (over, out or click)
123 * @param string the default background CSS class
124 * @param string the CSS class to use for mouseover
125 * @param string the CSS class to use for marking a row
127 * @return boolean whether pointer is set or not
129 function setPointer(theRow
, theRowNum
, theAction
, theDefaultClass
, thePointerClass
, theMarkClass
)
131 // 1. Pointer and mark feature are disabled or the browser can't get the
133 if ((thePointerClass
== '' && theMarkClass
== '')
134 || typeof(theRow
.className
) == 'undefined') {
138 // 2. Verify we can get the current row or exit
139 if (typeof(document
.getElementsByTagName
) != 'undefined') {
142 else if (typeof(theRow
) != 'undefined') {
149 // 3. Gets the current CSS class...
151 var currentClass
= getCSSClass(theRow
);
153 // 4. Defines the new class
154 // 4.1 Current class is the default one
155 if (currentClass
== ''
156 || currentClass
.toLowerCase() == theDefaultClass
.toLowerCase()) {
157 if (theAction
== 'over' && thePointerClass
!= '') {
158 newClass
= thePointerClass
;
160 else if (theAction
== 'click' && theMarkClass
!= '') {
161 newClass
= theMarkClass
;
162 marked_row
[theRowNum
] = true;
163 // deactivated onclick marking of the checkbox because it's also executed
164 // when an action (clicking on the checkbox itself) on a single item is
165 // performed. Then the checkbox would get deactived, even though we need
166 // it activated. Maybe there is a way to detect if the row was clicked,
167 // and not an item therein...
168 //document.getElementById('msg[' + theRowNum + ']').checked = true;
171 // 4.1.2 Current class is the pointer one
172 else if (currentClass
.toLowerCase() == thePointerClass
.toLowerCase()
173 && (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])) {
174 if (theAction
== 'out') {
175 newClass
= theDefaultClass
;
177 else if (theAction
== 'click' && theMarkClass
!= '') {
178 newClass
= theMarkClass
;
179 marked_row
[theRowNum
] = true;
180 //document.getElementById('msg[' + theRowNum + ']').checked = true;
183 // 4.1.3 Current color is the marker one
184 else if (currentClass
.toLowerCase() == theMarkClass
.toLowerCase()) {
185 if (theAction
== 'click') {
186 newClass
= (thePointerClass
!= '')
189 marked_row
[theRowNum
] = (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])
192 //document.getElementById('msg[' + theRowNum + ']').checked = false;
196 // 5. Sets the new color...
198 setCSSClass(theRow
, newClass
);
202 } // end of the 'setPointer()' function
204 function comp_in_new_form(comp_uri
, button
, myform
, iWidth
, iHeight
) {
205 comp_uri
+= "&" + button
.name
+ "=1";
206 for ( var i
=0; i
< myform
.elements
.length
; i
++ ) {
207 if ( myform
.elements
[i
].type
== "checkbox" && myform
.elements
[i
].checked
)
208 comp_uri
+= "&" + myform
.elements
[i
].name
+ "=1";
210 if (!iWidth
) iWidth
= 640;
211 if (!iHeight
) iHeight
= 550;
212 sArg
= "width=" + iWidth
+ ",height=" + iHeight
+ ",scrollbars=yes,resizable=yes,status=yes";
213 var newwin
= window
.open(comp_uri
, "_blank", sArg
);
216 function comp_in_new(comp_uri
, iWidth
, iHeight
) {
217 if (!iWidth
) iWidth
= 640;
218 if (!iHeight
) iHeight
= 550;
219 sArg
= "width=" + iWidth
+ ",height=" + iHeight
+ ",scrollbars=yes,resizable=yes,status=yes";
220 var newwin
= window
.open(comp_uri
, "_blank", sArg
);
224 * Reload the read_body screen on sending an mdn receipt
227 mdnuri
=window
.location
+'&sendreceipt=1';
228 var newwin
= window
.open(mdnuri
,'right');
231 var alreadyFocused
= false;
232 function checkForm(smaction
) {
234 if (alreadyFocused
) return;
237 * this part is used for setting the focus in the compose screen
240 if (smaction
== "select") {
241 document
.forms
['compose'].body
.select();
242 } else if (smaction
== "focus") {
243 document
.forms
['compose'].body
.focus();
247 * All other forms that need to set the focus
249 var f
= document
.forms
.length
;
252 while( pos
== -1 && i
< f
) {
253 var e
= document
.forms
[i
].elements
.length
;
255 while( pos
== -1 && j
< e
) {
256 if ( document
.forms
[i
].elements
[j
].type
== 'text' || document
.forms
[i
].elements
[j
].type
== 'password' ) {
264 document
.forms
[i
-1].elements
[pos
].focus();