[128] | 1 | /** |
---|
| 2 | * http://www.openjs.com/scripts/events/keyboard_shortcuts/ |
---|
| 3 | * Version : 2.01.A |
---|
| 4 | * By Binny V A |
---|
| 5 | * License : BSD |
---|
| 6 | */ |
---|
| 7 | shortcut = { |
---|
| 8 | 'all_shortcuts':{},//All the shortcuts are stored in this array |
---|
| 9 | 'add': function(shortcut_combination,callback,opt) { |
---|
| 10 | //Provide a set of default options |
---|
| 11 | var default_options = { |
---|
| 12 | 'type':'keydown', |
---|
| 13 | 'propagate':false, |
---|
| 14 | 'disable_in_input':false, |
---|
| 15 | 'target':document, |
---|
| 16 | 'keycode':false |
---|
| 17 | } |
---|
| 18 | if(!opt) opt = default_options; |
---|
| 19 | else { |
---|
| 20 | for(var dfo in default_options) { |
---|
| 21 | if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo]; |
---|
| 22 | } |
---|
| 23 | } |
---|
[1390] | 24 | |
---|
[5134] | 25 | var ele = opt.target; |
---|
[128] | 26 | if(typeof opt.target == 'string') ele = document.getElementById(opt.target); |
---|
| 27 | var ths = this; |
---|
| 28 | shortcut_combination = shortcut_combination.toLowerCase(); |
---|
| 29 | |
---|
| 30 | //The function to be called at keypress |
---|
| 31 | var func = function(e) { |
---|
| 32 | e = e || window.event; |
---|
| 33 | |
---|
| 34 | if(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields |
---|
| 35 | var element; |
---|
| 36 | if(e.target) element=e.target; |
---|
| 37 | else if(e.srcElement) element=e.srcElement; |
---|
| 38 | if(element.nodeType==3) element=element.parentNode; |
---|
| 39 | |
---|
| 40 | if(element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | //Find Which key is pressed |
---|
| 44 | if (e.keyCode) code = e.keyCode; |
---|
| 45 | else if (e.which) code = e.which; |
---|
| 46 | var character = String.fromCharCode(code).toLowerCase(); |
---|
| 47 | |
---|
| 48 | if(code == 188) character=","; //If the user presses , when the type is onkeydown |
---|
| 49 | if(code == 190) character="."; //If the user presses , when the type is onkeydown |
---|
| 50 | |
---|
| 51 | var keys = shortcut_combination.split("+"); |
---|
| 52 | //Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked |
---|
| 53 | var kp = 0; |
---|
| 54 | |
---|
| 55 | //Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken |
---|
| 56 | var shift_nums = { |
---|
| 57 | "`":"~", |
---|
| 58 | "1":"!", |
---|
| 59 | "2":"@", |
---|
| 60 | "3":"#", |
---|
| 61 | "4":"$", |
---|
| 62 | "5":"%", |
---|
| 63 | "6":"^", |
---|
| 64 | "7":"&", |
---|
| 65 | "8":"*", |
---|
| 66 | "9":"(", |
---|
| 67 | "0":")", |
---|
| 68 | "-":"_", |
---|
| 69 | "=":"+", |
---|
| 70 | ";":":", |
---|
| 71 | "'":"\"", |
---|
| 72 | ",":"<", |
---|
| 73 | ".":">", |
---|
| 74 | "/":"?", |
---|
| 75 | "\\":"|" |
---|
| 76 | } |
---|
| 77 | //Special Keys - and their codes |
---|
| 78 | var special_keys = { |
---|
| 79 | 'esc':27, |
---|
| 80 | 'escape':27, |
---|
| 81 | 'tab':9, |
---|
| 82 | 'space':32, |
---|
| 83 | 'return':13, |
---|
| 84 | 'enter':13, |
---|
| 85 | 'backspace':8, |
---|
| 86 | |
---|
| 87 | 'scrolllock':145, |
---|
| 88 | 'scroll_lock':145, |
---|
| 89 | 'scroll':145, |
---|
| 90 | 'capslock':20, |
---|
| 91 | 'caps_lock':20, |
---|
| 92 | 'caps':20, |
---|
| 93 | 'numlock':144, |
---|
| 94 | 'num_lock':144, |
---|
| 95 | 'num':144, |
---|
| 96 | |
---|
| 97 | 'pause':19, |
---|
| 98 | 'break':19, |
---|
| 99 | |
---|
| 100 | 'insert':45, |
---|
| 101 | 'home':36, |
---|
| 102 | 'delete':46, |
---|
| 103 | 'end':35, |
---|
| 104 | |
---|
| 105 | 'pageup':33, |
---|
| 106 | 'page_up':33, |
---|
| 107 | 'pu':33, |
---|
| 108 | |
---|
| 109 | 'pagedown':34, |
---|
| 110 | 'page_down':34, |
---|
| 111 | 'pd':34, |
---|
| 112 | |
---|
| 113 | 'left':37, |
---|
| 114 | 'up':38, |
---|
| 115 | 'right':39, |
---|
| 116 | 'down':40, |
---|
| 117 | |
---|
| 118 | 'f1':112, |
---|
| 119 | 'f2':113, |
---|
| 120 | 'f3':114, |
---|
| 121 | 'f4':115, |
---|
| 122 | 'f5':116, |
---|
| 123 | 'f6':117, |
---|
| 124 | 'f7':118, |
---|
| 125 | 'f8':119, |
---|
| 126 | 'f9':120, |
---|
| 127 | 'f10':121, |
---|
| 128 | 'f11':122, |
---|
| 129 | 'f12':123 |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | var modifiers = { |
---|
[4761] | 133 | shift: {wanted:false, pressed:false}, |
---|
| 134 | ctrl : {wanted:false, pressed:false}, |
---|
| 135 | alt : {wanted:false, pressed:false}, |
---|
| 136 | meta : {wanted:false, pressed:false} //Meta is Mac specific |
---|
[128] | 137 | }; |
---|
| 138 | |
---|
| 139 | if(e.ctrlKey) modifiers.ctrl.pressed = true; |
---|
| 140 | if(e.shiftKey) modifiers.shift.pressed = true; |
---|
| 141 | if(e.altKey) modifiers.alt.pressed = true; |
---|
| 142 | if(e.metaKey) modifiers.meta.pressed = true; |
---|
| 143 | |
---|
| 144 | for(var i=0; k=keys[i],i<keys.length; i++) { |
---|
| 145 | //Modifiers |
---|
| 146 | if(k == 'ctrl' || k == 'control') { |
---|
| 147 | kp++; |
---|
| 148 | modifiers.ctrl.wanted = true; |
---|
| 149 | |
---|
| 150 | } else if(k == 'shift') { |
---|
| 151 | kp++; |
---|
| 152 | modifiers.shift.wanted = true; |
---|
| 153 | |
---|
| 154 | } else if(k == 'alt') { |
---|
| 155 | kp++; |
---|
| 156 | modifiers.alt.wanted = true; |
---|
| 157 | } else if(k == 'meta') { |
---|
| 158 | kp++; |
---|
| 159 | modifiers.meta.wanted = true; |
---|
| 160 | } else if(k.length > 1) { //If it is a special key |
---|
| 161 | if(special_keys[k] == code) kp++; |
---|
| 162 | |
---|
| 163 | } else if(opt['keycode']) { |
---|
| 164 | if(opt['keycode'] == code) kp++; |
---|
| 165 | |
---|
| 166 | } else { //The special keys did not match |
---|
| 167 | if(character == k) kp++; |
---|
| 168 | else { |
---|
| 169 | if(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase |
---|
| 170 | character = shift_nums[character]; |
---|
| 171 | if(character == k) kp++; |
---|
| 172 | } |
---|
| 173 | } |
---|
| 174 | } |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | if(kp == keys.length && |
---|
| 178 | modifiers.ctrl.pressed == modifiers.ctrl.wanted && |
---|
| 179 | modifiers.shift.pressed == modifiers.shift.wanted && |
---|
| 180 | modifiers.alt.pressed == modifiers.alt.wanted && |
---|
| 181 | modifiers.meta.pressed == modifiers.meta.wanted) { |
---|
| 182 | callback(e); |
---|
| 183 | |
---|
| 184 | if(!opt['propagate']) { //Stop the event |
---|
| 185 | //e.cancelBubble is supported by IE - this will kill the bubbling process. |
---|
[5338] | 186 | if ( Element('border_id_0') && Element('border_id_0').className != 'menu-sel' ){ |
---|
| 187 | return false; |
---|
| 188 | } |
---|
[128] | 189 | e.cancelBubble = true; |
---|
| 190 | e.returnValue = false; |
---|
| 191 | |
---|
[5338] | 192 | |
---|
[128] | 193 | //e.stopPropagation works in Firefox. |
---|
| 194 | if (e.stopPropagation) { |
---|
[5338] | 195 | if ( Element('border_id_0') && Element('border_id_0').className != 'menu-sel' ){ |
---|
| 196 | return false; |
---|
| 197 | } |
---|
| 198 | |
---|
[128] | 199 | e.stopPropagation(); |
---|
| 200 | e.preventDefault(); |
---|
| 201 | } |
---|
| 202 | return false; |
---|
| 203 | } |
---|
[5338] | 204 | |
---|
[128] | 205 | } |
---|
| 206 | } |
---|
| 207 | this.all_shortcuts[shortcut_combination] = { |
---|
| 208 | 'callback':func, |
---|
| 209 | 'target':ele, |
---|
| 210 | 'event': opt['type'] |
---|
| 211 | }; |
---|
| 212 | //Attach the function with the event |
---|
| 213 | if(ele.addEventListener) ele.addEventListener(opt['type'], func, false); |
---|
| 214 | else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func); |
---|
| 215 | else ele['on'+opt['type']] = func; |
---|
| 216 | }, |
---|
| 217 | |
---|
| 218 | //Remove the shortcut - just specify the shortcut and I will remove the binding |
---|
| 219 | 'remove':function(shortcut_combination) { |
---|
| 220 | shortcut_combination = shortcut_combination.toLowerCase(); |
---|
| 221 | var binding = this.all_shortcuts[shortcut_combination]; |
---|
| 222 | delete(this.all_shortcuts[shortcut_combination]) |
---|
| 223 | if(!binding) return; |
---|
| 224 | var type = binding['event']; |
---|
| 225 | var ele = binding['target']; |
---|
| 226 | var callback = binding['callback']; |
---|
| 227 | |
---|
| 228 | if(ele.detachEvent) ele.detachEvent('on'+type, callback); |
---|
| 229 | else if(ele.removeEventListener) ele.removeEventListener(type, callback, false); |
---|
| 230 | else ele['on'+type] = false; |
---|
| 231 | } |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | /* ExpressMail Functions */ |
---|
[5338] | 235 | |
---|
[139] | 236 | var shift_up_count = 0; |
---|
| 237 | var shift_down_count = 0; |
---|
[1390] | 238 | var selMessageShortcut = ""; |
---|
| 239 | |
---|
[5939] | 240 | shortcut.add("N",function(e) |
---|
[3194] | 241 | { |
---|
| 242 | // avoids problem related at ticket #1011 |
---|
[5975] | 243 | e.preventDefault(); |
---|
[3194] | 244 | var search_in_focus = false; |
---|
| 245 | var search_win = document.getElementById( 'QuickCatalogSearch_window_QuickCatalogSearch' ); |
---|
| 246 | if ( search_win && search_win.style.visibility != 'hidden' ) |
---|
| 247 | search_in_focus = true; |
---|
[139] | 248 | |
---|
[3194] | 249 | if ( ! search_in_focus ) |
---|
| 250 | new_message("new","null"); |
---|
| 251 | },{'disable_in_input':true}); |
---|
| 252 | |
---|
[139] | 253 | shortcut.add("Esc",function(){ |
---|
| 254 | var window_closed = false; |
---|
[4787] | 255 | var search_win = document.getElementById( 'window_QuickCatalogSearch' ); |
---|
| 256 | |
---|
| 257 | for(var window in arrayJSWin) |
---|
| 258 | { |
---|
| 259 | if (arrayJSWin[window].visible) |
---|
| 260 | { |
---|
| 261 | window_closed = true; |
---|
| 262 | if(search_win.style.visibility == 'hidden'){ |
---|
[4761] | 263 | arrayJSWin[window].close(); |
---|
[4787] | 264 | } |
---|
| 265 | } |
---|
| 266 | } |
---|
| 267 | if((search_win) && (search_win.style.visibility == 'visible')){ |
---|
| 268 | search_win.style.visibility = 'hidden'; |
---|
| 269 | win.close(); |
---|
| 270 | } |
---|
| 271 | |
---|
[139] | 272 | if (!window_closed) |
---|
| 273 | delete_border(get_msg_id(), 'false'); |
---|
| 274 | },{'disable_in_input':false}); |
---|
| 275 | |
---|
[4761] | 276 | shortcut.add("I",function(){print_all();},{'disable_in_input':true}); |
---|
[6070] | 277 | shortcut.add("E",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; exec_msg_action('forward');},{'disable_in_input':true}); |
---|
| 278 | shortcut.add("R",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; exec_msg_action('reply');},{'disable_in_input':true}); |
---|
| 279 | shortcut.add("T",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; var msg_id = get_msg_id(); if(msg_id) new_message("reply_to_all_with_history",msg_id);},{'disable_in_input':true}); |
---|
| 280 | shortcut.add("O",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; show_head_option();},{'disable_in_input':true}); |
---|
| 281 | shortcut.add("M",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; show_address_full();},{'disable_in_input':true}); |
---|
[1390] | 282 | |
---|
[128] | 283 | shortcut.add("Delete",function(){ |
---|
[1390] | 284 | |
---|
[5891] | 285 | |
---|
[1390] | 286 | var selected_shortcut_msgs = ''; |
---|
| 287 | var tbody_box = Element('tbody_box'); |
---|
| 288 | all_messages = Element('tbody_box').childNodes; |
---|
| 289 | |
---|
| 290 | for ( var i=0; i < all_messages.length; i++ ) |
---|
[128] | 291 | { |
---|
[1390] | 292 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[163] | 293 | { |
---|
[1390] | 294 | selected_shortcut_msgs += all_messages[i].id + ','; |
---|
| 295 | |
---|
| 296 | if( all_messages[i].nextSibling ) |
---|
| 297 | selMessageShortcut = all_messages[i].nextSibling.id + "-" + "down"; |
---|
| 298 | else if(all_messages[i].previousSibling) |
---|
| 299 | selMessageShortcut = all_messages[i].previousSibling.id + "-" + "up"; |
---|
[163] | 300 | } |
---|
[1390] | 301 | } |
---|
[3683] | 302 | |
---|
[1390] | 303 | selected_shortcut_msgs = selected_shortcut_msgs.substring(0,(selected_shortcut_msgs.length-1)); |
---|
| 304 | |
---|
[3683] | 305 | if ( Element('border_id_0').className === 'menu-sel' ) |
---|
[1390] | 306 | { |
---|
[689] | 307 | proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null'); |
---|
[128] | 308 | } |
---|
| 309 | else |
---|
[1390] | 310 | { |
---|
[128] | 311 | exec_msg_action('delete'); |
---|
[1390] | 312 | select_msg(selMessageShortcut.substring(0, selMessageShortcut.indexOf("-")), |
---|
| 313 | selMessageShortcut.substring(selMessageShortcut.indexOf("-")), true ); |
---|
[3683] | 314 | |
---|
| 315 | proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null'); |
---|
[1390] | 316 | } |
---|
[5891] | 317 | |
---|
[128] | 318 | } |
---|
| 319 | ,{'disable_in_input':true}); |
---|
| 320 | |
---|
[5635] | 321 | shortcut.add("Ctrl+Up",function(){exec_msg_action('previous');/*select_msg('null', 'up');*/},{'disable_in_input':true}); |
---|
| 322 | shortcut.add("Ctrl+Down",function(){exec_msg_action('next');/*select_msg('null', 'down');*/},{'disable_in_input':true}); |
---|
[536] | 323 | |
---|
[6197] | 324 | if (is_ie || is_webkit) |
---|
[536] | 325 | { |
---|
[4761] | 326 | //********************** |
---|
[5911] | 327 | shortcut.add('up', function(e) |
---|
[4761] | 328 | { |
---|
| 329 | var search_in_focus = false; |
---|
| 330 | var search_win = document.getElementById( 'window_QuickCatalogSearch' ); |
---|
| 331 | if ( search_win && search_win.style.visibility == 'visible' ) |
---|
| 332 | search_in_focus = true; |
---|
| 333 | |
---|
[5631] | 334 | if ( !search_in_focus && currentTab == 0 ) |
---|
[4761] | 335 | select_msg('null', 'up'); |
---|
| 336 | else |
---|
| 337 | shortcut.remove('up'); |
---|
[5250] | 338 | e.stopPropagation(); |
---|
| 339 | e.preventDefault(); |
---|
[4761] | 340 | },{'disable_in_input':false}); |
---|
| 341 | |
---|
| 342 | |
---|
[5911] | 343 | shortcut.add('down', function(e) |
---|
[4761] | 344 | { |
---|
| 345 | var search_in_focus = false; |
---|
| 346 | var search_win = document.getElementById( 'window_QuickCatalogSearch' ); |
---|
| 347 | if ( search_win && search_win.style.visibility == 'visible' ) |
---|
| 348 | search_in_focus = true; |
---|
| 349 | |
---|
[5631] | 350 | if ( !search_in_focus && currentTab == 0 ) |
---|
[4761] | 351 | select_msg('null', 'down'); |
---|
| 352 | else |
---|
| 353 | shortcut.remove('down'); |
---|
[5250] | 354 | e.stopPropagation(); |
---|
| 355 | e.preventDefault(); |
---|
[4761] | 356 | },{'disable_in_input':false}); |
---|
| 357 | |
---|
| 358 | //**************** |
---|
| 359 | |
---|
[139] | 360 | shortcut.add("Shift+down",function(){ |
---|
[536] | 361 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 362 | { |
---|
| 363 | if (shift_up_count > 0) |
---|
| 364 | unselect_top_msg(); |
---|
| 365 | else |
---|
| 366 | select_bottom_msg(); |
---|
| 367 | } |
---|
| 368 | },{'disable_in_input':true, 'propagate':false}); |
---|
| 369 | |
---|
[139] | 370 | shortcut.add("Shift+up",function(){ |
---|
[536] | 371 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 372 | { |
---|
| 373 | if (shift_down_count > 0) |
---|
| 374 | unselect_bottom_msg(); |
---|
| 375 | else |
---|
| 376 | select_top_msg(); |
---|
| 377 | } |
---|
| 378 | },{'disable_in_input':true, 'propagate':false}); |
---|
[139] | 379 | } |
---|
[536] | 380 | else |
---|
| 381 | { |
---|
[5338] | 382 | shortcut.add("Up",function(){ |
---|
[5631] | 383 | if (currentTab == 0) |
---|
[5338] | 384 | select_msg('null', 'up'); |
---|
| 385 | },{'disable_in_input':false}); |
---|
[536] | 386 | |
---|
[5338] | 387 | shortcut.add("Down",function(){ |
---|
[5631] | 388 | if (currentTab == 0) |
---|
[5338] | 389 | select_msg('null', 'down'); |
---|
| 390 | |
---|
| 391 | },{'disable_in_input':false}); |
---|
| 392 | |
---|
[536] | 393 | shortcut.add("Shift+down",function(){ |
---|
| 394 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 395 | { |
---|
| 396 | if (shift_up_count > 0) |
---|
| 397 | unselect_top_msg(); |
---|
| 398 | else |
---|
| 399 | select_bottom_msg(); |
---|
| 400 | } |
---|
| 401 | },{'type':'keypress','disable_in_input':true, 'propagate':false}); |
---|
| 402 | |
---|
| 403 | shortcut.add("Shift+up",function(){ |
---|
| 404 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 405 | { |
---|
| 406 | if (shift_down_count > 0) |
---|
| 407 | unselect_bottom_msg(); |
---|
| 408 | else |
---|
| 409 | select_top_msg(); |
---|
| 410 | } |
---|
| 411 | },{'type':'keypress', 'disable_in_input':true, 'propagate':false}); |
---|
[139] | 412 | } |
---|
[128] | 413 | |
---|
| 414 | shortcut.add("return",function(){ |
---|
| 415 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 416 | { |
---|
| 417 | all_messages = Element('tbody_box').childNodes; |
---|
| 418 | for (var i=0; i < all_messages.length; i++) |
---|
| 419 | { |
---|
[163] | 420 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[128] | 421 | { |
---|
[4771] | 422 | Element("td_from_" + all_messages[i].id).onclick(); |
---|
[128] | 423 | return; |
---|
| 424 | } |
---|
| 425 | } |
---|
| 426 | } |
---|
[4761] | 427 | },{'disable_in_input':true}); |
---|
[128] | 428 | |
---|
[139] | 429 | shortcut.add("f9",function(){ |
---|
| 430 | Element("em_refresh_button").onclick(); |
---|
| 431 | return; |
---|
| 432 | },{'disable_in_input':true}); |
---|
[128] | 433 | |
---|
| 434 | function exec_msg_action(action) |
---|
| 435 | { |
---|
| 436 | var msg_id = get_msg_id(); |
---|
| 437 | if (msg_id) |
---|
| 438 | { |
---|
| 439 | var msg_id = 'msg_opt_' + action + '_' + msg_id; |
---|
| 440 | try {Element(msg_id).onclick();} |
---|
| 441 | catch(e){/*alert(e);*/} |
---|
| 442 | } |
---|
| 443 | return; |
---|
| 444 | } |
---|
| 445 | |
---|
[3168] | 446 | function show_head_option() |
---|
| 447 | { |
---|
| 448 | var msg_id = get_msg_id(); |
---|
| 449 | if (msg_id) { |
---|
| 450 | var msg_id = 'option_hide_more_' + msg_id; |
---|
| 451 | try {Element(msg_id).onclick();} |
---|
| 452 | catch(e){/*alert(e);*/} |
---|
| 453 | } |
---|
| 454 | return; |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | function show_address_full() |
---|
| 458 | { |
---|
| 459 | var toaddress = Element('div_toaddress_' + get_msg_id()); |
---|
| 460 | var ccaddress = Element('div_ccaddress_' + get_msg_id()); |
---|
| 461 | |
---|
| 462 | if(toaddress && '' == toaddress.style.display) { |
---|
| 463 | show_div_address_full(get_msg_id(),'to'); |
---|
| 464 | } |
---|
| 465 | else { |
---|
| 466 | if(toaddress) |
---|
| 467 | toaddress.style.display = ''; |
---|
| 468 | var toaddress_full = Element('div_toaddress_full_' + get_msg_id()); |
---|
| 469 | if(toaddress_full) |
---|
| 470 | toaddress_full.style.display = 'none'; |
---|
| 471 | } |
---|
| 472 | if(ccaddress && '' == ccaddress.style.display) { |
---|
| 473 | show_div_address_full(get_msg_id(),'cc'); |
---|
| 474 | } |
---|
| 475 | else { |
---|
| 476 | if(ccaddress) |
---|
| 477 | ccaddress.style.display = ''; |
---|
| 478 | var ccaddress_full = Element('div_ccaddress_full_' + get_msg_id()); |
---|
| 479 | if(ccaddress_full) |
---|
| 480 | ccaddress_full.style.display = 'none'; |
---|
| 481 | } |
---|
| 482 | return; |
---|
| 483 | } |
---|
| 484 | |
---|
[128] | 485 | function get_msg_id() |
---|
| 486 | { |
---|
| 487 | children = Element('border_tr').childNodes; |
---|
| 488 | |
---|
| 489 | for (var i=0; i<children.length; i++) |
---|
| 490 | { |
---|
| 491 | if ( (children[i].nodeName==='TD') && (children[i].className==='menu-sel') && children[i].id != 'border_id_0') |
---|
| 492 | { |
---|
| 493 | var border_selected = children[i]; |
---|
| 494 | var msg_id = border_selected.id.replace("border_id_",""); |
---|
| 495 | return msg_id; |
---|
| 496 | } |
---|
| 497 | } |
---|
| 498 | return false; |
---|
| 499 | } |
---|
| 500 | |
---|
[163] | 501 | function select_msg(msg_number, keyboard_action, force_msg_selection) |
---|
[128] | 502 | { |
---|
[5891] | 503 | /* |
---|
| 504 | ** Se caso for limpado toda a caixa de email, |
---|
| 505 | ** é adicionado um novo atalho de seleção. |
---|
| 506 | ** main.js on function refrash and line 629. |
---|
| 507 | */ |
---|
| 508 | |
---|
| 509 | if(keyboard_action == "reload_msg"){ |
---|
[5904] | 510 | if( $("#tbody_box .selected_shortcut_msg").length == 0 ) |
---|
| 511 | $("#tbody_box tr:first").addClass("selected_shortcut_msg"); |
---|
[5891] | 512 | } |
---|
| 513 | |
---|
[139] | 514 | shift_up_count = 0; |
---|
| 515 | shift_down_count = 0; |
---|
| 516 | |
---|
[128] | 517 | if (msg_number != 'null') |
---|
| 518 | { |
---|
[5250] | 519 | if(Element(msg_number)){ |
---|
| 520 | unselect_all_msgs(); |
---|
| 521 | add_className(Element(msg_number), 'selected_shortcut_msg'); |
---|
| 522 | } |
---|
[128] | 523 | } |
---|
| 524 | else |
---|
| 525 | { |
---|
[1403] | 526 | var scrollMain = Element('divScrollMain_0'); |
---|
| 527 | var selection_size = parseInt(preferences.line_height) + 10; |
---|
| 528 | |
---|
[1390] | 529 | if( keyboard_action == 'down') |
---|
[128] | 530 | { |
---|
[139] | 531 | for (var i=all_messages.length-1; i >=0; i--) |
---|
[128] | 532 | { |
---|
[163] | 533 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[128] | 534 | { |
---|
[163] | 535 | add_className(all_messages[i+1], 'selected_shortcut_msg') |
---|
[350] | 536 | var mailPos = i; |
---|
[139] | 537 | break; |
---|
[128] | 538 | } |
---|
[139] | 539 | } |
---|
[1390] | 540 | |
---|
[139] | 541 | for (; i>=0; i--) |
---|
| 542 | { |
---|
[1390] | 543 | if( all_messages[i].nextSibling ) |
---|
| 544 | remove_className(all_messages[i], 'selected_shortcut_msg'); |
---|
[139] | 545 | } |
---|
[1403] | 546 | if ((mailPos) && (parseInt(scrollMain.style.height.substr(0,scrollMain.style.height.length-2)) + scrollMain.scrollTop) < (all_messages[mailPos].offsetTop + selection_size)) |
---|
| 547 | scrollMain.scrollTop += selection_size; |
---|
| 548 | |
---|
[139] | 549 | } |
---|
[1390] | 550 | else if( keyboard_action == 'up') |
---|
[139] | 551 | { |
---|
| 552 | for (var i=0; i < all_messages.length; i++) |
---|
| 553 | { |
---|
[163] | 554 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[128] | 555 | { |
---|
[1390] | 556 | if( all_messages[i].previousSibling ) |
---|
| 557 | { |
---|
| 558 | add_className(all_messages[i-1], 'selected_shortcut_msg') |
---|
| 559 | var mailPos = i; |
---|
| 560 | break; |
---|
| 561 | } |
---|
[139] | 562 | } |
---|
[128] | 563 | } |
---|
[1390] | 564 | |
---|
[139] | 565 | for (; i< all_messages.length; i++) |
---|
| 566 | { |
---|
[163] | 567 | remove_className(all_messages[i], 'selected_shortcut_msg') |
---|
[139] | 568 | } |
---|
[1403] | 569 | if (typeof(all_messages[mailPos]) != 'undefined' && all_messages[mailPos].offsetTop <= scrollMain.scrollTop) |
---|
| 570 | scrollMain.scrollTop -= selection_size+10; |
---|
[350] | 571 | } |
---|
[1390] | 572 | |
---|
| 573 | return true; |
---|
[128] | 574 | } |
---|
[1390] | 575 | } |
---|
[139] | 576 | |
---|
| 577 | function select_bottom_msg() |
---|
| 578 | { |
---|
| 579 | all_messages = Element('tbody_box').childNodes; |
---|
| 580 | |
---|
[163] | 581 | if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) |
---|
[139] | 582 | return; |
---|
| 583 | |
---|
| 584 | for (var i=all_messages.length-1; i >=0; i--) |
---|
| 585 | { |
---|
[163] | 586 | if ( (exist_className(all_messages[i], 'selected_shortcut_msg')) && (i+1 <= all_messages.length-1) ) |
---|
[139] | 587 | { |
---|
| 588 | shift_down_count++; |
---|
[163] | 589 | add_className(all_messages[i+1], 'selected_shortcut_msg'); |
---|
[139] | 590 | break; |
---|
| 591 | } |
---|
| 592 | } |
---|
| 593 | } |
---|
| 594 | |
---|
| 595 | function select_top_msg() |
---|
| 596 | { |
---|
| 597 | all_messages = Element('tbody_box').childNodes; |
---|
[350] | 598 | |
---|
[163] | 599 | if ( exist_className(all_messages[0], 'selected_shortcut_msg') ) |
---|
[139] | 600 | return; |
---|
| 601 | |
---|
| 602 | for (var i=0; i <=all_messages.length-1; i++) |
---|
| 603 | { |
---|
[163] | 604 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[139] | 605 | { |
---|
| 606 | shift_up_count++; |
---|
[163] | 607 | add_className(all_messages[i-1], 'selected_shortcut_msg'); |
---|
[139] | 608 | break; |
---|
| 609 | } |
---|
| 610 | } |
---|
| 611 | } |
---|
| 612 | |
---|
| 613 | function unselect_bottom_msg() |
---|
| 614 | { |
---|
| 615 | all_messages = Element('tbody_box').childNodes; |
---|
| 616 | for (var i=all_messages.length-1; i >=0; i--) |
---|
| 617 | { |
---|
[163] | 618 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[139] | 619 | { |
---|
| 620 | shift_down_count--; |
---|
[163] | 621 | remove_className(all_messages[i], 'selected_shortcut_msg'); |
---|
[139] | 622 | break; |
---|
| 623 | } |
---|
| 624 | } |
---|
| 625 | } |
---|
| 626 | |
---|
| 627 | function unselect_top_msg() |
---|
| 628 | { |
---|
| 629 | all_messages = Element('tbody_box').childNodes; |
---|
| 630 | for (var i=0; i <=all_messages.length-1; i++) |
---|
| 631 | { |
---|
[163] | 632 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[139] | 633 | { |
---|
| 634 | shift_up_count--; |
---|
[163] | 635 | remove_className(all_messages[i], 'selected_shortcut_msg'); |
---|
[139] | 636 | break; |
---|
| 637 | } |
---|
| 638 | } |
---|
[163] | 639 | } |
---|
| 640 | |
---|
| 641 | function unselect_all_msgs() |
---|
| 642 | { |
---|
| 643 | all_messages = Element('tbody_box').childNodes; |
---|
| 644 | for (var i=0; i <=all_messages.length-1; i++) |
---|
| 645 | { |
---|
| 646 | remove_className(all_messages[i], 'selected_shortcut_msg'); |
---|
| 647 | } |
---|
[6070] | 648 | } |
---|