[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 | |
---|
[128] | 25 | var ele = opt.target |
---|
| 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 = { |
---|
| 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 |
---|
| 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. |
---|
| 186 | e.cancelBubble = true; |
---|
| 187 | e.returnValue = false; |
---|
| 188 | |
---|
| 189 | //e.stopPropagation works in Firefox. |
---|
| 190 | if (e.stopPropagation) { |
---|
| 191 | e.stopPropagation(); |
---|
| 192 | e.preventDefault(); |
---|
| 193 | } |
---|
| 194 | return false; |
---|
| 195 | } |
---|
| 196 | } |
---|
| 197 | } |
---|
| 198 | this.all_shortcuts[shortcut_combination] = { |
---|
| 199 | 'callback':func, |
---|
| 200 | 'target':ele, |
---|
| 201 | 'event': opt['type'] |
---|
| 202 | }; |
---|
| 203 | //Attach the function with the event |
---|
| 204 | if(ele.addEventListener) ele.addEventListener(opt['type'], func, false); |
---|
| 205 | else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func); |
---|
| 206 | else ele['on'+opt['type']] = func; |
---|
| 207 | }, |
---|
| 208 | |
---|
| 209 | //Remove the shortcut - just specify the shortcut and I will remove the binding |
---|
| 210 | 'remove':function(shortcut_combination) { |
---|
| 211 | shortcut_combination = shortcut_combination.toLowerCase(); |
---|
| 212 | var binding = this.all_shortcuts[shortcut_combination]; |
---|
| 213 | delete(this.all_shortcuts[shortcut_combination]) |
---|
| 214 | if(!binding) return; |
---|
| 215 | var type = binding['event']; |
---|
| 216 | var ele = binding['target']; |
---|
| 217 | var callback = binding['callback']; |
---|
| 218 | |
---|
| 219 | if(ele.detachEvent) ele.detachEvent('on'+type, callback); |
---|
| 220 | else if(ele.removeEventListener) ele.removeEventListener(type, callback, false); |
---|
| 221 | else ele['on'+type] = false; |
---|
| 222 | } |
---|
| 223 | } |
---|
| 224 | |
---|
| 225 | /* ExpressMail Functions */ |
---|
[139] | 226 | var shift_up_count = 0; |
---|
| 227 | var shift_down_count = 0; |
---|
[1390] | 228 | var selMessageShortcut = ""; |
---|
| 229 | |
---|
[3194] | 230 | shortcut.add("N",function() |
---|
| 231 | { |
---|
| 232 | // avoids problem related at ticket #1011 |
---|
| 233 | var search_in_focus = false; |
---|
| 234 | var search_win = document.getElementById( 'QuickCatalogSearch_window_QuickCatalogSearch' ); |
---|
| 235 | if ( search_win && search_win.style.visibility != 'hidden' ) |
---|
| 236 | search_in_focus = true; |
---|
[139] | 237 | |
---|
[3194] | 238 | if ( ! search_in_focus ) |
---|
| 239 | new_message("new","null"); |
---|
| 240 | },{'disable_in_input':true}); |
---|
| 241 | |
---|
[139] | 242 | shortcut.add("Esc",function(){ |
---|
| 243 | var window_closed = false; |
---|
| 244 | for(var window in arrayJSWin) |
---|
| 245 | { |
---|
| 246 | if (arrayJSWin[window].visible) |
---|
| 247 | { |
---|
| 248 | arrayJSWin[window].close(); |
---|
| 249 | window_closed = true; |
---|
| 250 | } |
---|
| 251 | } |
---|
| 252 | if (!window_closed) |
---|
| 253 | delete_border(get_msg_id(), 'false'); |
---|
| 254 | },{'disable_in_input':false}); |
---|
| 255 | |
---|
[1497] | 256 | shortcut.add("I",function(){ print_all(); },{'disable_in_input':true}); |
---|
[128] | 257 | shortcut.add("E",function(){ exec_msg_action('forward'); },{'disable_in_input':true}); |
---|
| 258 | shortcut.add("R",function(){ exec_msg_action('reply'); },{'disable_in_input':true}); |
---|
[3168] | 259 | shortcut.add("O",function(){ show_head_option(); },{'disable_in_input':true}); |
---|
| 260 | shortcut.add("M",function(){ show_address_full(); },{'disable_in_input':true}); |
---|
[1390] | 261 | |
---|
[128] | 262 | shortcut.add("Delete",function(){ |
---|
[1390] | 263 | |
---|
| 264 | var selected_shortcut_msgs = ''; |
---|
| 265 | var tbody_box = Element('tbody_box'); |
---|
| 266 | all_messages = Element('tbody_box').childNodes; |
---|
| 267 | |
---|
| 268 | for ( var i=0; i < all_messages.length; i++ ) |
---|
[128] | 269 | { |
---|
[1390] | 270 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[163] | 271 | { |
---|
[1390] | 272 | selected_shortcut_msgs += all_messages[i].id + ','; |
---|
| 273 | |
---|
| 274 | if( all_messages[i].nextSibling ) |
---|
| 275 | selMessageShortcut = all_messages[i].nextSibling.id + "-" + "down"; |
---|
| 276 | else if(all_messages[i].previousSibling) |
---|
| 277 | selMessageShortcut = all_messages[i].previousSibling.id + "-" + "up"; |
---|
[163] | 278 | } |
---|
[1390] | 279 | } |
---|
[3683] | 280 | |
---|
[1390] | 281 | selected_shortcut_msgs = selected_shortcut_msgs.substring(0,(selected_shortcut_msgs.length-1)); |
---|
| 282 | |
---|
[3683] | 283 | if ( Element('border_id_0').className === 'menu-sel' ) |
---|
[1390] | 284 | { |
---|
[689] | 285 | proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null'); |
---|
[128] | 286 | } |
---|
| 287 | else |
---|
[1390] | 288 | { |
---|
[128] | 289 | exec_msg_action('delete'); |
---|
[1390] | 290 | select_msg(selMessageShortcut.substring(0, selMessageShortcut.indexOf("-")), |
---|
| 291 | selMessageShortcut.substring(selMessageShortcut.indexOf("-")), true ); |
---|
[3683] | 292 | |
---|
| 293 | proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null'); |
---|
[1390] | 294 | } |
---|
[128] | 295 | } |
---|
| 296 | ,{'disable_in_input':true}); |
---|
| 297 | |
---|
[163] | 298 | shortcut.add("Ctrl+Up",function(){ exec_msg_action('previous'); select_msg('null', 'up', true);},{'disable_in_input':true}); |
---|
| 299 | shortcut.add("Ctrl+Down",function(){ exec_msg_action('next'); select_msg('null', 'down', true);},{'disable_in_input':true}); |
---|
[536] | 300 | |
---|
| 301 | if (is_ie) |
---|
| 302 | { |
---|
[139] | 303 | shortcut.add("down",function(){ select_msg('null', 'down'); },{'disable_in_input':false}); |
---|
[350] | 304 | shortcut.add("up",function(){ select_msg('null', 'up'); },{'disable_in_input':false}); |
---|
[536] | 305 | |
---|
[139] | 306 | shortcut.add("Shift+down",function(){ |
---|
[536] | 307 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 308 | { |
---|
| 309 | if (shift_up_count > 0) |
---|
| 310 | unselect_top_msg(); |
---|
| 311 | else |
---|
| 312 | select_bottom_msg(); |
---|
| 313 | } |
---|
| 314 | },{'disable_in_input':true, 'propagate':false}); |
---|
| 315 | |
---|
[139] | 316 | shortcut.add("Shift+up",function(){ |
---|
[536] | 317 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 318 | { |
---|
| 319 | if (shift_down_count > 0) |
---|
| 320 | unselect_bottom_msg(); |
---|
| 321 | else |
---|
| 322 | select_top_msg(); |
---|
| 323 | } |
---|
| 324 | },{'disable_in_input':true, 'propagate':false}); |
---|
[139] | 325 | } |
---|
[536] | 326 | else |
---|
| 327 | { |
---|
[163] | 328 | shortcut.add("down",function(){ select_msg('null', 'down');},{'type':'keypress', 'disable_in_input':false}); |
---|
[1390] | 329 | shortcut.add("up",function(){ select_msg('null', 'up');},{'type':'keypress', 'disable_in_input':false}); |
---|
[536] | 330 | |
---|
| 331 | shortcut.add("Shift+down",function(){ |
---|
| 332 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 333 | { |
---|
| 334 | if (shift_up_count > 0) |
---|
| 335 | unselect_top_msg(); |
---|
| 336 | else |
---|
| 337 | select_bottom_msg(); |
---|
| 338 | } |
---|
| 339 | },{'type':'keypress','disable_in_input':true, 'propagate':false}); |
---|
| 340 | |
---|
| 341 | shortcut.add("Shift+up",function(){ |
---|
| 342 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 343 | { |
---|
| 344 | if (shift_down_count > 0) |
---|
| 345 | unselect_bottom_msg(); |
---|
| 346 | else |
---|
| 347 | select_top_msg(); |
---|
| 348 | } |
---|
| 349 | },{'type':'keypress', 'disable_in_input':true, 'propagate':false}); |
---|
[139] | 350 | } |
---|
[128] | 351 | |
---|
| 352 | shortcut.add("return",function(){ |
---|
| 353 | if ( Element('border_id_0').className==='menu-sel' ) |
---|
| 354 | { |
---|
| 355 | all_messages = Element('tbody_box').childNodes; |
---|
| 356 | for (var i=0; i < all_messages.length; i++) |
---|
| 357 | { |
---|
[163] | 358 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[128] | 359 | { |
---|
| 360 | Element("td_who_" + all_messages[i].id).onclick(); |
---|
| 361 | return; |
---|
| 362 | } |
---|
| 363 | } |
---|
| 364 | } |
---|
| 365 | } |
---|
| 366 | ,{'disable_in_input':true}); |
---|
| 367 | |
---|
[139] | 368 | shortcut.add("f9",function(){ |
---|
| 369 | Element("em_refresh_button").onclick(); |
---|
| 370 | return; |
---|
| 371 | },{'disable_in_input':true}); |
---|
[128] | 372 | |
---|
| 373 | function exec_msg_action(action) |
---|
| 374 | { |
---|
| 375 | var msg_id = get_msg_id(); |
---|
| 376 | if (msg_id) |
---|
| 377 | { |
---|
| 378 | var msg_id = 'msg_opt_' + action + '_' + msg_id; |
---|
| 379 | try {Element(msg_id).onclick();} |
---|
| 380 | catch(e){/*alert(e);*/} |
---|
| 381 | } |
---|
| 382 | return; |
---|
| 383 | } |
---|
| 384 | |
---|
[3168] | 385 | function show_head_option() |
---|
| 386 | { |
---|
| 387 | var msg_id = get_msg_id(); |
---|
| 388 | if (msg_id) { |
---|
| 389 | var msg_id = 'option_hide_more_' + msg_id; |
---|
| 390 | try {Element(msg_id).onclick();} |
---|
| 391 | catch(e){/*alert(e);*/} |
---|
| 392 | } |
---|
| 393 | return; |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | function show_address_full() |
---|
| 397 | { |
---|
| 398 | var toaddress = Element('div_toaddress_' + get_msg_id()); |
---|
| 399 | var ccaddress = Element('div_ccaddress_' + get_msg_id()); |
---|
| 400 | |
---|
| 401 | if(toaddress && '' == toaddress.style.display) { |
---|
| 402 | show_div_address_full(get_msg_id(),'to'); |
---|
| 403 | } |
---|
| 404 | else { |
---|
| 405 | if(toaddress) |
---|
| 406 | toaddress.style.display = ''; |
---|
| 407 | var toaddress_full = Element('div_toaddress_full_' + get_msg_id()); |
---|
| 408 | if(toaddress_full) |
---|
| 409 | toaddress_full.style.display = 'none'; |
---|
| 410 | } |
---|
| 411 | if(ccaddress && '' == ccaddress.style.display) { |
---|
| 412 | show_div_address_full(get_msg_id(),'cc'); |
---|
| 413 | } |
---|
| 414 | else { |
---|
| 415 | if(ccaddress) |
---|
| 416 | ccaddress.style.display = ''; |
---|
| 417 | var ccaddress_full = Element('div_ccaddress_full_' + get_msg_id()); |
---|
| 418 | if(ccaddress_full) |
---|
| 419 | ccaddress_full.style.display = 'none'; |
---|
| 420 | } |
---|
| 421 | return; |
---|
| 422 | } |
---|
| 423 | |
---|
[128] | 424 | function get_msg_id() |
---|
| 425 | { |
---|
| 426 | children = Element('border_tr').childNodes; |
---|
| 427 | |
---|
| 428 | for (var i=0; i<children.length; i++) |
---|
| 429 | { |
---|
| 430 | if ( (children[i].nodeName==='TD') && (children[i].className==='menu-sel') && children[i].id != 'border_id_0') |
---|
| 431 | { |
---|
| 432 | var border_selected = children[i]; |
---|
| 433 | var msg_id = border_selected.id.replace("border_id_",""); |
---|
| 434 | return msg_id; |
---|
| 435 | } |
---|
| 436 | } |
---|
| 437 | return false; |
---|
| 438 | } |
---|
| 439 | |
---|
[163] | 440 | function select_msg(msg_number, keyboard_action, force_msg_selection) |
---|
[128] | 441 | { |
---|
[163] | 442 | //Select msg, even if the focus isn't the border_id_0 |
---|
| 443 | if ( (Element('border_id_0').className != 'menu-sel') && (!force_msg_selection) ) |
---|
[139] | 444 | return; |
---|
[350] | 445 | |
---|
[139] | 446 | shift_up_count = 0; |
---|
| 447 | shift_down_count = 0; |
---|
| 448 | |
---|
[128] | 449 | if (msg_number != 'null') |
---|
| 450 | { |
---|
[163] | 451 | unselect_all_msgs(); |
---|
| 452 | add_className(Element(msg_number), 'selected_shortcut_msg') |
---|
[128] | 453 | } |
---|
| 454 | else |
---|
| 455 | { |
---|
[1403] | 456 | var scrollMain = Element('divScrollMain_0'); |
---|
| 457 | var selection_size = parseInt(preferences.line_height) + 10; |
---|
| 458 | |
---|
[1390] | 459 | if( keyboard_action == 'down') |
---|
[128] | 460 | { |
---|
[139] | 461 | for (var i=all_messages.length-1; i >=0; i--) |
---|
[128] | 462 | { |
---|
[163] | 463 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[128] | 464 | { |
---|
[163] | 465 | add_className(all_messages[i+1], 'selected_shortcut_msg') |
---|
[350] | 466 | var mailPos = i; |
---|
[139] | 467 | break; |
---|
[128] | 468 | } |
---|
[139] | 469 | } |
---|
[1390] | 470 | |
---|
[139] | 471 | for (; i>=0; i--) |
---|
| 472 | { |
---|
[1390] | 473 | if( all_messages[i].nextSibling ) |
---|
| 474 | remove_className(all_messages[i], 'selected_shortcut_msg'); |
---|
[139] | 475 | } |
---|
[1403] | 476 | if ((mailPos) && (parseInt(scrollMain.style.height.substr(0,scrollMain.style.height.length-2)) + scrollMain.scrollTop) < (all_messages[mailPos].offsetTop + selection_size)) |
---|
| 477 | scrollMain.scrollTop += selection_size; |
---|
| 478 | |
---|
[139] | 479 | } |
---|
[1390] | 480 | else if( keyboard_action == 'up') |
---|
[139] | 481 | { |
---|
| 482 | for (var i=0; i < all_messages.length; i++) |
---|
| 483 | { |
---|
[163] | 484 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[128] | 485 | { |
---|
[1390] | 486 | if( all_messages[i].previousSibling ) |
---|
| 487 | { |
---|
| 488 | add_className(all_messages[i-1], 'selected_shortcut_msg') |
---|
| 489 | var mailPos = i; |
---|
| 490 | break; |
---|
| 491 | } |
---|
[139] | 492 | } |
---|
[128] | 493 | } |
---|
[1390] | 494 | |
---|
[139] | 495 | for (; i< all_messages.length; i++) |
---|
| 496 | { |
---|
[163] | 497 | remove_className(all_messages[i], 'selected_shortcut_msg') |
---|
[139] | 498 | } |
---|
[1403] | 499 | if (typeof(all_messages[mailPos]) != 'undefined' && all_messages[mailPos].offsetTop <= scrollMain.scrollTop) |
---|
| 500 | scrollMain.scrollTop -= selection_size+10; |
---|
[350] | 501 | } |
---|
[1390] | 502 | |
---|
| 503 | return true; |
---|
[128] | 504 | } |
---|
[1390] | 505 | } |
---|
[139] | 506 | |
---|
| 507 | function select_bottom_msg() |
---|
| 508 | { |
---|
| 509 | all_messages = Element('tbody_box').childNodes; |
---|
| 510 | |
---|
[163] | 511 | if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) |
---|
[139] | 512 | return; |
---|
| 513 | |
---|
| 514 | for (var i=all_messages.length-1; i >=0; i--) |
---|
| 515 | { |
---|
[163] | 516 | if ( (exist_className(all_messages[i], 'selected_shortcut_msg')) && (i+1 <= all_messages.length-1) ) |
---|
[139] | 517 | { |
---|
| 518 | shift_down_count++; |
---|
[163] | 519 | add_className(all_messages[i+1], 'selected_shortcut_msg'); |
---|
[139] | 520 | break; |
---|
| 521 | } |
---|
| 522 | } |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | function select_top_msg() |
---|
| 526 | { |
---|
| 527 | all_messages = Element('tbody_box').childNodes; |
---|
[350] | 528 | |
---|
[163] | 529 | if ( exist_className(all_messages[0], 'selected_shortcut_msg') ) |
---|
[139] | 530 | return; |
---|
| 531 | |
---|
| 532 | for (var i=0; i <=all_messages.length-1; i++) |
---|
| 533 | { |
---|
[163] | 534 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[139] | 535 | { |
---|
| 536 | shift_up_count++; |
---|
[163] | 537 | add_className(all_messages[i-1], 'selected_shortcut_msg'); |
---|
[139] | 538 | break; |
---|
| 539 | } |
---|
| 540 | } |
---|
| 541 | } |
---|
| 542 | |
---|
| 543 | function unselect_bottom_msg() |
---|
| 544 | { |
---|
| 545 | all_messages = Element('tbody_box').childNodes; |
---|
| 546 | for (var i=all_messages.length-1; i >=0; i--) |
---|
| 547 | { |
---|
[163] | 548 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[139] | 549 | { |
---|
| 550 | shift_down_count--; |
---|
[163] | 551 | remove_className(all_messages[i], 'selected_shortcut_msg'); |
---|
[139] | 552 | break; |
---|
| 553 | } |
---|
| 554 | } |
---|
| 555 | } |
---|
| 556 | |
---|
| 557 | function unselect_top_msg() |
---|
| 558 | { |
---|
| 559 | all_messages = Element('tbody_box').childNodes; |
---|
| 560 | for (var i=0; i <=all_messages.length-1; i++) |
---|
| 561 | { |
---|
[163] | 562 | if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) |
---|
[139] | 563 | { |
---|
| 564 | shift_up_count--; |
---|
[163] | 565 | remove_className(all_messages[i], 'selected_shortcut_msg'); |
---|
[139] | 566 | break; |
---|
| 567 | } |
---|
| 568 | } |
---|
[163] | 569 | } |
---|
| 570 | |
---|
| 571 | function unselect_all_msgs() |
---|
| 572 | { |
---|
| 573 | all_messages = Element('tbody_box').childNodes; |
---|
| 574 | for (var i=0; i <=all_messages.length-1; i++) |
---|
| 575 | { |
---|
| 576 | remove_className(all_messages[i], 'selected_shortcut_msg'); |
---|
| 577 | } |
---|
[631] | 578 | } |
---|