1b540556a0abdc094e9a713ea42df5ea78587df7
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 * This function is used to initialize the orig_row_color array so we do not
51 * need to predefine the entire array
53 function rowOver(chkboxName
) {
54 chkbox
= document
.getElementById(chkboxName
);
56 if (!orig_row_colors
[chkboxName
]) {
57 rowClass
= getCSSClass(chkbox
.parentNode
.parentNode
);
58 orig_row_colors
[chkboxName
] = rowClass
;
60 rowClass
= orig_row_colors
[chkboxName
];
62 j
= chkbox
.name
.length
- 1
65 * The mouseover and clicked CSS classes are always the same name!
67 overClass
= 'mouse_over';
68 clickedClass
= 'clicked';
69 setPointer(chkbox
.parentNode
.parentNode
, j
,'over' , rowClass
, overClass
, clickedClass
);
74 * (un)Checks all checkboxes for the message list from a specific form
75 * when it gets clicked.
77 * @param string the id of the form where all checkboxes should be (un)checked
78 * @param boolean use fancy row coloring when a checkbox is checked
79 * @param string new color of the checked rows
81 function toggle_all(formname
, fancy
) {
82 TargetForm
= document
.getElementById(formname
);
84 for (var i
= 0; i
< TargetForm
.elements
.length
; i
++) {
85 if (TargetForm
.elements
[i
].type
== 'checkbox' && TargetForm
.elements
[i
].name
.substring(0,3) == 'msg') {
87 array_key
= TargetForm
.elements
[i
].getAttribute('id');
88 if (TargetForm
.elements
[i
].checked
== false) {
89 // initialize orig_row_color if not defined already
90 if (!orig_row_colors
[array_key
]) {
91 rowClass
= getCSSClass(TargetForm
.elements
[i
].parentNode
.parentNode
);
92 orig_row_colors
[array_key
] = rowClass
;
95 origClass
= orig_row_colors
[array_key
];
96 clickedClass
= 'clicked';
97 setPointer(TargetForm
.elements
[i
].parentNode
.parentNode
, j
,'click' , origClass
, origClass
, clickedClass
);
100 TargetForm
.elements
[i
].checked
= !(TargetForm
.elements
[i
].checked
);
106 * Sets/unsets the pointer and marker in browse mode
108 * @param object the table row
109 * @param integer the row number
110 * @param string the action calling this script (over, out or click)
111 * @param string the default background CSS class
112 * @param string the CSS class to use for mouseover
113 * @param string the CSS class to use for marking a row
115 * @return boolean whether pointer is set or not
117 function setPointer(theRow
, theRowNum
, theAction
, theDefaultClass
, thePointerClass
, theMarkClass
)
119 // 1. Pointer and mark feature are disabled or the browser can't get the
121 if ((thePointerClass
== '' && theMarkClass
== '')
122 || typeof(theRow
.className
) == 'undefined') {
126 // 2. Verify we can get the current row or exit
127 if (typeof(document
.getElementsByTagName
) != 'undefined') {
130 else if (typeof(theRow
) != 'undefined') {
137 // 3. Gets the current CSS class...
138 var domDetect
= null;
140 var currentClass
= getCSSClass(theRow
);
142 // domDetect is needed later...
143 // 3.1 ... with DOM compatible browsers except Opera that does not return
144 // valid values with "getAttribute"
145 if (typeof(window
.opera
) == 'undefined'
146 && typeof(theRow
.getAttribute
) != 'undefined'
147 && theRow
.getAttribute('className') ) {
150 // 3.2 ... with other browsers
155 // 4. Defines the new class
156 // 4.1 Current class is the default one
157 if (currentClass
== ''
158 || currentClass
.toLowerCase() == theDefaultClass
.toLowerCase()) {
159 if (theAction
== 'over' && thePointerClass
!= '') {
160 newClass
= thePointerClass
;
162 else if (theAction
== 'click' && theMarkClass
!= '') {
163 newClass
= theMarkClass
;
164 marked_row
[theRowNum
] = true;
165 // deactivated onclick marking of the checkbox because it's also executed
166 // when an action (clicking on the checkbox itself) on a single item is
167 // performed. Then the checkbox would get deactived, even though we need
168 // it activated. Maybe there is a way to detect if the row was clicked,
169 // and not an item therein...
170 //document.getElementById('msg[' + theRowNum + ']').checked = true;
173 // 4.1.2 Current class is the pointer one
174 else if (currentClass
.toLowerCase() == thePointerClass
.toLowerCase()
175 && (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])) {
176 if (theAction
== 'out') {
177 newClass
= theDefaultClass
;
179 else if (theAction
== 'click' && theMarkClass
!= '') {
180 newClass
= theMarkClass
;
181 marked_row
[theRowNum
] = true;
182 //document.getElementById('msg[' + theRowNum + ']').checked = true;
185 // 4.1.3 Current color is the marker one
186 else if (currentClass
.toLowerCase() == theMarkClass
.toLowerCase()) {
187 if (theAction
== 'click') {
188 newClass
= (thePointerClass
!= '')
191 marked_row
[theRowNum
] = (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])
194 //document.getElementById('msg[' + theRowNum + ']').checked = false;
198 // 5. Sets the new color...
200 // 5.1 ... with DOM compatible browsers except Opera
202 theRow
.setAttribute('className', newClass
, 0);
204 // 5.2 ... with other browsers
206 theRow
.className
= newClass
;
211 } // end of the 'setPointer()' function
213 function comp_in_new_form(comp_uri
, button
, myform
, iWidth
, iHeight
) {
214 comp_uri
+= "&" + button
.name
+ "=1";
215 for ( var i
=0; i
< myform
.elements
.length
; i
++ ) {
216 if ( myform
.elements
[i
].type
== "checkbox" && myform
.elements
[i
].checked
)
217 comp_uri
+= "&" + myform
.elements
[i
].name
+ "=1";
219 if (!iWidth
) iWidth
= 640;
220 if (!iHeight
) iHeight
= 550;
221 sArg
= "width=" + iWidth
+ ",height=" + iHeight
+ ",scrollbars=yes,resizable=yes,status=yes";
222 var newwin
= window
.open(comp_uri
, "_blank", sArg
);
225 function comp_in_new(comp_uri
, iWidth
, iHeight
) {
226 if (!iWidth
) iWidth
= 640;
227 if (!iHeight
) iHeight
= 550;
228 sArg
= "width=" + iWidth
+ ",height=" + iHeight
+ ",scrollbars=yes,resizable=yes,status=yes";
229 var newwin
= window
.open(comp_uri
, "_blank", sArg
);
233 * Reload the read_body screen on sending an mdn receipt
236 mdnuri
=window
.location
+'&sendreceipt=1';
237 var newwin
= window
.open(mdnuri
,'right');
240 var alreadyFocused
= false;
241 function checkForm(smaction
) {
243 if (alreadyFocused
) return;
246 * this part is used for setting the focus in the compose screen
249 if (smaction
== "select") {
250 document
.forms
['compose'].body
.select();
251 } else if (smaction
== "focus") {
252 document
.forms
['compose'].body
.focus();
256 * All other forms that need to set the focus
258 var f
= document
.forms
.length
;
261 while( pos
== -1 && i
< f
) {
262 var e
= document
.forms
[i
].elements
.length
;
264 while( pos
== -1 && j
< e
) {
265 if ( document
.forms
[i
].elements
[j
].type
== 'text' || document
.forms
[i
].elements
[j
].type
== 'password' ) {
273 document
.forms
[i
-1].elements
[pos
].focus();