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();
13 * (un)Checks checkbox for the row that the current table cell is in
14 * when it gets clicked.
16 * @param string the name of the checkbox that should be (un)checked
18 function row_click(chkboxName
) {
19 chkbox
= document
.getElementById(chkboxName
);
21 // initialize orig_row_color if not defined already
22 if (!orig_row_colors
[chkboxName
]) {
23 orig_row_colors
[chkboxName
] = chkbox
.parentNode
.getAttribute('bgcolor');
25 chkbox
.checked
= (chkbox
.checked
? false : true);
29 * This function is used to initialize the orig_row_color array so we do not
30 * need to predefine the entire array
32 function rowOver(chkboxName
, overColor
, clickedColor
) {
33 chkbox
= document
.getElementById(chkboxName
);
35 if (!orig_row_colors
[chkboxName
]) {
36 bgColor
= chkbox
.parentNode
.getAttribute('bgcolor');
37 orig_row_colors
[chkboxName
] = bgColor
;
39 bgColor
= orig_row_colors
[chkboxName
];
41 j
= chkbox
.name
.length
- 1
42 setPointer(chkbox
.parentNode
.parentNode
, j
,'over' , bgColor
, overColor
, clickedColor
);
47 * (un)Checks all checkboxes for the message list from a specific form
48 * when it gets clicked.
50 * @param string the id of the form where all checkboxes should be (un)checked
51 * @param boolean use fancy row coloring when a checkbox is checked
52 * @param string new color of the checked rows
54 function toggle_all(formname
, fancy
, clickedColor
) {
55 TargetForm
= document
.getElementById(formname
);
57 for (var i
= 0; i
< TargetForm
.elements
.length
; i
++) {
58 if (TargetForm
.elements
[i
].type
== 'checkbox' && TargetForm
.elements
[i
].name
.substring(0,3) == 'msg') {
60 array_key
= TargetForm
.elements
[i
].getAttribute('id');
61 if (TargetForm
.elements
[i
].checked
== false) {
62 // initialize orig_row_color if not defined already
63 if (!orig_row_colors
[array_key
]) {
64 orig_row_colors
[array_key
] = TargetForm
.elements
[i
].parentNode
.getAttribute('bgcolor');
67 origColor
= orig_row_colors
[array_key
];
68 setPointer(TargetForm
.elements
[i
].parentNode
.parentNode
, j
,'click' , origColor
, origColor
, clickedColor
);
71 TargetForm
.elements
[i
].checked
= !(TargetForm
.elements
[i
].checked
);
77 * Sets/unsets the pointer and marker in browse mode
79 * @param object the table row
80 * @param integer the row number
81 * @param string the action calling this script (over, out or click)
82 * @param string the default background color
83 * @param string the color to use for mouseover
84 * @param string the color to use for marking a row
86 * @return boolean whether pointer is set or not
88 function setPointer(theRow
, theRowNum
, theAction
, theDefaultColor
, thePointerColor
, theMarkColor
)
92 // 1. Pointer and mark feature are disabled or the browser can't get the
94 if ((thePointerColor
== '' && theMarkColor
== '')
95 || typeof(theRow
.style
) == 'undefined') {
99 // 2. Gets the current row and exits if the browser can't get it
100 if (typeof(document
.getElementsByTagName
) != 'undefined') {
101 theCells
= theRow
.getElementsByTagName('td');
103 else if (typeof(theRow
.cells
) != 'undefined') {
104 theCells
= theRow
.cells
;
110 // 3. Gets the current color...
111 var rowCellsCnt
= theCells
.length
;
112 var domDetect
= null;
113 var currentColor
= null;
115 // 3.1 ... with DOM compatible browsers except Opera that does not return
116 // valid values with "getAttribute"
117 if (typeof(window
.opera
) == 'undefined'
118 && typeof(theCells
[0].getAttribute
) != 'undefined') {
119 currentColor
= theCells
[0].getAttribute('bgcolor');
122 // 3.2 ... with other browsers
124 currentColor
= theCells
[0].style
.backgroundColor
;
128 // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
129 if (currentColor
.indexOf("rgb") >= 0)
131 var rgbStr
= currentColor
.slice(currentColor
.indexOf('(') + 1,
132 currentColor
.indexOf(')'));
133 var rgbValues
= rgbStr
.split(",");
135 var hexChars
= "0123456789ABCDEF";
136 for (var i
= 0; i
< 3; i
++)
138 var v
= rgbValues
[i
].valueOf();
139 currentColor
+= hexChars
.charAt(v
/16) + hexChars
.charAt(v
%16);
143 // 4. Defines the new color
144 // 4.1 Current color is the default one
145 if (currentColor
== ''
146 || currentColor
.toLowerCase() == theDefaultColor
.toLowerCase()) {
147 if (theAction
== 'over' && thePointerColor
!= '') {
148 newColor
= thePointerColor
;
150 else if (theAction
== 'click' && theMarkColor
!= '') {
151 newColor
= theMarkColor
;
152 marked_row
[theRowNum
] = true;
153 // deactivated onclick marking of the checkbox because it's also executed
154 // when an action (clicking on the checkbox itself) on a single item is
155 // performed. Then the checkbox would get deactived, even though we need
156 // it activated. Maybe there is a way to detect if the row was clicked,
157 // and not an item therein...
158 //document.getElementById('msg[' + theRowNum + ']').checked = true;
161 // 4.1.2 Current color is the pointer one
162 else if (currentColor
.toLowerCase() == thePointerColor
.toLowerCase()
163 && (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])) {
164 if (theAction
== 'out') {
165 newColor
= theDefaultColor
;
167 else if (theAction
== 'click' && theMarkColor
!= '') {
168 newColor
= theMarkColor
;
169 marked_row
[theRowNum
] = true;
170 //document.getElementById('msg[' + theRowNum + ']').checked = true;
173 // 4.1.3 Current color is the marker one
174 else if (currentColor
.toLowerCase() == theMarkColor
.toLowerCase()) {
175 if (theAction
== 'click') {
176 newColor
= (thePointerColor
!= '')
179 marked_row
[theRowNum
] = (typeof(marked_row
[theRowNum
]) == 'undefined' || !marked_row
[theRowNum
])
182 //document.getElementById('msg[' + theRowNum + ']').checked = false;
186 // 5. Sets the new color...
189 // 5.1 ... with DOM compatible browsers except Opera
191 for (c
= 0; c
< rowCellsCnt
; c
++) {
192 theCells
[c
].setAttribute('bgcolor', newColor
, 0);
195 // 5.2 ... with other browsers
197 for (c
= 0; c
< rowCellsCnt
; c
++) {
198 theCells
[c
].style
.backgroundColor
= newColor
;
204 } // end of the 'setPointer()' function
206 function comp_in_new_form(comp_uri
, button
, myform
, iWidth
, iHeight
) {
207 comp_uri
+= "&" + button
.name
+ "=1";
208 for ( var i
=0; i
< myform
.elements
.length
; i
++ ) {
209 if ( myform
.elements
[i
].type
== "checkbox" && myform
.elements
[i
].checked
)
210 comp_uri
+= "&" + myform
.elements
[i
].name
+ "=1";
212 if (!iWidth
) iWidth
= 640;
213 if (!iHeight
) iHeight
= 550;
214 sArg
= "width=" + iWidth
+ ",height=" + iHeight
+ ",scrollbars=yes,resizable=yes,status=yes";
215 var newwin
= window
.open(comp_uri
, "_blank", sArg
);
218 function comp_in_new(comp_uri
, iWidth
, iHeight
) {
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
);
226 * Reload the read_body screen on sending an mdn receipt
229 mdnuri
=window
.location
+'&sendreceipt=1';
230 var newwin
= window
.open(mdnuri
,'right');
233 var alreadyFocused
= false;
234 function checkForm(smaction
) {
236 if (alreadyFocused
) return;
239 * this part is used for setting the focus in the compose screen
242 if (smaction
== "select") {
243 document
.forms
['compose'].body
.select();
244 } else if (smaction
== "focus") {
245 document
.forms
['compose'].body
.focus();
249 * All other forms that need to set the focus
251 var f
= document
.forms
.length
;
254 while( pos
== -1 && i
< f
) {
255 var e
= document
.forms
[i
].elements
.length
;
257 while( pos
== -1 && j
< e
) {
258 if ( document
.forms
[i
].elements
[j
].type
== 'text' || document
.forms
[i
].elements
[j
].type
== 'password' ) {
266 document
.forms
[i
-1].elements
[pos
].focus();