Ignore:
Timestamp:
07/19/12 16:47:42 (12 years ago)
Author:
gustavo
Message:

Ticket #2954 - Melhoria nos atalhos do expresso mail, novo atalho

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sandbox/2.4.2-expresso2/expressoMail1_2/js/shortcut.js

    r6707 r6823  
    11/** 
    2  * http://www.openjs.com/scripts/events/keyboard_shortcuts/ 
    3  * Version : 2.01.A 
    4  * By Binny V A 
    5  * License : BSD 
    6  */ 
     2* http://www.openjs.com/scripts/events/keyboard_shortcuts/ 
     3* Version : 2.01.A 
     4* By Binny V A 
     5* License : BSD 
     6*/ 
    77shortcut = { 
    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                 } 
    24                  
    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                                         if ( Element('border_id_0') && Element('border_id_0').className != 'menu-sel' ){ 
    187                                                 return false; 
    188                                         } 
    189                                         e.cancelBubble = true; 
    190                                         e.returnValue = false; 
    191          
    192                                          
    193                                         //e.stopPropagation works in Firefox. 
    194                                         if (e.stopPropagation) { 
    195                                         if ( Element('border_id_0') && Element('border_id_0').className != 'menu-sel' ){ 
    196                                                 return false; 
    197                                         } 
    198                                                  
    199                                                 e.stopPropagation(); 
    200                                                 e.preventDefault(); 
    201                                         } 
    202                                         return false; 
    203                                 } 
    204                                  
    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         } 
     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 
     11var default_options = { 
     12    'type':'keydown', 
     13    'propagate':false, 
     14    'disable_in_input':false, 
     15    'target':document, 
     16    'keycode':false 
     17} 
     18if(!opt) opt = default_options; 
     19else { 
     20    for(var dfo in default_options) { 
     21        if(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo]; 
     22    } 
     23} 
     24 
     25var ele = opt.target; 
     26if(typeof opt.target == 'string') ele = document.getElementById(opt.target); 
     27var ths = this; 
     28shortcut_combination = shortcut_combination.toLowerCase(); 
     29 
     30//The function to be called at keypress 
     31var func = function(e) { 
     32    e = e || window.event; 
     33 
     34if(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields 
     35    var element; 
     36if(e.target) element=e.target; 
     37else if(e.srcElement) element=e.srcElement; 
     38if(element.nodeType==3) element=element.parentNode; 
     39 
     40if(element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return; 
     41} 
     42 
     43//Find Which key is pressed 
     44if (e.keyCode) code = e.keyCode; 
     45else if (e.which) code = e.which; 
     46var character = String.fromCharCode(code).toLowerCase(); 
     47 
     48if(code == 188) character=","; //If the user presses , when the type is onkeydown 
     49if(code == 190) character="."; //If the user presses , when the type is onkeydown 
     50 
     51var 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 
     53var kp = 0; 
     54 
     55//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken 
     56var 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 
     78var 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 
     132var modifiers = {  
     133    shift: {wanted:false, pressed:false}, 
     134    ctrl : {wanted:false, pressed:false}, 
     135    alt  : {wanted:false, pressed:false}, 
     136meta : {wanted:false, pressed:false}    //Meta is Mac specific 
     137}; 
     138 
     139if(e.ctrlKey)   modifiers.ctrl.pressed = true; 
     140if(e.shiftKey)  modifiers.shift.pressed = true; 
     141if(e.altKey)    modifiers.alt.pressed = true; 
     142if(e.metaKey)   modifiers.meta.pressed = true; 
     143 
     144for(var i=0; k=keys[i],i<keys.length; i++) { 
     145//Modifiers 
     146if(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 { 
     169if(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 
     177if(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 
     184if(!opt['propagate']) { //Stop the event 
     185//e.cancelBubble is supported by IE - this will kill the bubbling process. 
     186if ( Element('border_id_0') && Element('border_id_0').className != 'menu-sel' ){ 
     187    return false; 
     188} 
     189e.cancelBubble = true; 
     190e.returnValue = false; 
     191 
     192 
     193//e.stopPropagation works in Firefox. 
     194if (e.stopPropagation) { 
     195    if ( Element('border_id_0') && Element('border_id_0').className != 'menu-sel' ){ 
     196        return false; 
     197    } 
     198 
     199    e.stopPropagation(); 
     200    e.preventDefault(); 
     201} 
     202return false; 
     203} 
     204 
     205} 
     206} 
     207this.all_shortcuts[shortcut_combination] = { 
     208    'callback':func,  
     209    'target':ele,  
     210    'event': opt['type'] 
     211}; 
     212//Attach the function with the event 
     213if(ele.addEventListener) ele.addEventListener(opt['type'], func, false); 
     214else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func); 
     215else 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} 
    232232} 
    233233 
     
    240240shortcut.add("N",function(e) 
    241241{ 
    242         // avoids problem related at ticket #1011 
    243         e.preventDefault(); 
    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; 
    248  
    249         if ( ! search_in_focus ) 
    250                 new_message("new","null"); 
     242// avoids problem related at ticket #1011 
     243e.preventDefault(); 
     244var search_in_focus = false; 
     245var search_win = document.getElementById( 'QuickCatalogSearch_window_QuickCatalogSearch' ); 
     246if ( search_win && search_win.style.visibility != 'hidden' ) 
     247    search_in_focus = true; 
     248 
     249if ( ! search_in_focus ) 
     250    new_message("new","null"); 
    251251},{'disable_in_input':true}); 
    252252 
    253253shortcut.add("Esc",function(){ 
    254         var window_closed = false; 
    255         var search_win = document.getElementById( 'window_QuickCatalogSearch' ); 
    256          
    257         for(var window in arrayJSWin) 
     254    var window_closed = false; 
     255    var search_win = document.getElementById( 'window_QuickCatalogSearch' ); 
     256 
     257    for(var window in arrayJSWin) 
     258    { 
     259        if (arrayJSWin[window].visible) 
    258260        { 
    259                 if (arrayJSWin[window].visible) 
    260                 { 
    261                     window_closed = true; 
    262                     if(search_win.style.visibility == 'hidden'){ 
    263                         arrayJSWin[window].close(); 
    264                     } 
    265                 } 
    266         } 
    267         if((search_win) && (search_win.style.visibility == 'visible')){ 
    268             search_win.style.visibility = 'hidden'; 
    269             win.close(); 
    270        }         
    271  
    272         if (!window_closed) 
    273                 delete_border(get_msg_id(), 'false'); 
     261            window_closed = true; 
     262            if(search_win.style.visibility == 'hidden'){ 
     263                arrayJSWin[window].close(); 
     264            } 
     265        } 
     266    } 
     267    if((search_win) && (search_win.style.visibility == 'visible')){ 
     268        search_win.style.visibility = 'hidden'; 
     269        win.close(); 
     270    }         
     271 
     272    if (!window_closed) 
     273        delete_border(get_msg_id(), 'false'); 
    274274},{'disable_in_input':false}); 
    275  
     275/* 
    276276shortcut.add("I",function(){print_all();},{'disable_in_input':true}); 
    277277shortcut.add("E",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; exec_msg_action('forward');},{'disable_in_input':true}); 
     
    280280shortcut.add("O",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; show_head_option();},{'disable_in_input':true}); 
    281281shortcut.add("M",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; show_address_full();},{'disable_in_input':true}); 
    282  
     282*/ 
    283283shortcut.add("Delete",function(){ 
    284          
    285          
    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++ ) 
    291         { 
    292                 if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
    293                 { 
    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"; 
    300                 } 
    301         } 
    302          
    303         selected_shortcut_msgs = selected_shortcut_msgs.substring(0,(selected_shortcut_msgs.length-1)); 
    304          
    305         if ( Element('border_id_0').className === 'menu-sel' ) 
    306         { 
    307                 proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null'); 
    308         } 
    309         else 
    310         { 
    311                 exec_msg_action('delete'); 
    312                 select_msg(selMessageShortcut.substring(0, selMessageShortcut.indexOf("-")), 
    313                                    selMessageShortcut.substring(selMessageShortcut.indexOf("-")), true ); 
    314                  
    315                 proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null'); 
    316         } 
    317          
     284 
     285 
     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++ ) 
     291    { 
     292        if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
     293        { 
     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"; 
     300        } 
     301    } 
     302 
     303    selected_shortcut_msgs = selected_shortcut_msgs.substring(0,(selected_shortcut_msgs.length-1)); 
     304 
     305    if ( Element('border_id_0').className === 'menu-sel' ) 
     306    { 
     307        proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null'); 
     308    } 
     309    else 
     310    { 
     311        exec_msg_action('delete'); 
     312        select_msg(selMessageShortcut.substring(0, selMessageShortcut.indexOf("-")), 
     313            selMessageShortcut.substring(selMessageShortcut.indexOf("-")), true ); 
     314 
     315        proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null'); 
     316    } 
     317 
    318318} 
    319319,{'disable_in_input':true}); 
    320320 
    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}); 
     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}); 
    323323 
    324324if (is_ie || is_webkit) 
     
    326326//********************** 
    327327shortcut.add('up', function(e) 
     328{ 
     329    if(currentTab == 0){ 
     330        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); 
     331        if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length) 
     332            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     333        $(".current_selected_shortcut_msg").focus(); 
     334    } 
     335},{'disable_in_input':true}); 
     336 
     337 
     338shortcut.add('down', function(e) 
     339{ 
     340    if(currentTab == 0){ 
     341        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); 
     342        if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length) 
     343            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     344        $(".current_selected_shortcut_msg").focus(); 
     345    } 
     346},{'disable_in_input':true}); 
     347 
     348shortcut.add('space', function(e) 
     349{ 
     350    if(currentTab == 0){ 
     351        var allchecked = true; 
     352        $.each( $(".selected_shortcut_msg"), function(index, value){ 
     353            if($(value).find(":checkbox").attr("checked") == undefined){ 
     354                allchecked = false; 
     355            } 
     356        }); 
     357        if(allchecked){ 
     358            $(".selected_shortcut_msg").removeClass("selected_msg").find('input[type="checkbox"]').removeAttr("checked"); 
     359        }else{ 
     360            //$(".current_selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true); 
     361            $(".selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true); 
     362        } 
     363        $.each( $(".selected_shortcut_msg"), function(index, value){ 
     364            updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id")); 
     365        }); 
     366    } 
     367},{'disable_in_input':true}); 
     368 
     369//**************** 
     370 
     371shortcut.add("Shift+down",function() 
     372{     
     373    if(currentTab == 0){             
     374        //$(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); 
     375        if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length) 
     376            if($(".current_selected_shortcut_msg").next().hasClass("selected_shortcut_msg")) 
     377                $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     378            else 
     379                $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     380        $(".current_selected_shortcut_msg").focus(); 
     381    } 
     382},{'disable_in_input':true, 'propagate':false}); 
     383 
     384shortcut.add("Shift+up",function(){ 
     385    if(currentTab == 0){             
     386        //$(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); 
     387        if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length) 
     388            if($(".current_selected_shortcut_msg").prev().hasClass("selected_shortcut_msg")) 
     389                $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     390            else 
     391                $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     392        $(".current_selected_shortcut_msg").focus(); 
     393    } 
     394},{'disable_in_input':true, 'propagate':false}); 
     395} 
     396else 
     397{ 
     398    shortcut.add("Up",function(){ 
     399        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); 
     400        if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length) 
     401            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     402        $(".current_selected_shortcut_msg").focus(); 
     403    },{'disable_in_input':true}); 
     404 
     405    shortcut.add("Down",function(){ 
     406        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg"); 
     407        if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length) 
     408            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     409        $(".current_selected_shortcut_msg").focus(); 
     410    },{'disable_in_input':true}); 
     411 
     412    shortcut.add("Shift+down",function(){ 
     413        if(currentTab == 0){             
     414            if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length) 
     415                if($(".current_selected_shortcut_msg").next().hasClass("selected_shortcut_msg")) 
     416                    $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     417                else 
     418                    $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     419            $(".current_selected_shortcut_msg").focus(); 
     420        } 
     421    },{'type':'keypress','disable_in_input':true, 'propagate':false}); 
     422 
     423    shortcut.add("Shift+up",function(){ 
     424        if(currentTab == 0){             
     425            if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length) 
     426                if($(".current_selected_shortcut_msg").prev().hasClass("selected_shortcut_msg")) 
     427                    $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     428                else 
     429                    $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     430            $(".current_selected_shortcut_msg").focus(); 
     431        } 
     432    },{'type':'keypress', 'disable_in_input':true, 'propagate':false}); 
     433    shortcut.add('Space', function(e) 
     434    { 
     435        if(currentTab == 0){ 
     436            var allchecked = true; 
     437            $.each( $(".selected_shortcut_msg"), function(index, value){ 
     438                if($(value).find(":checkbox").attr("checked") == undefined){ 
     439                    allchecked = false; 
     440                } 
     441            }); 
     442            if(allchecked){ 
     443                 
     444                $(".selected_shortcut_msg").removeClass("selected_msg").find('input[type="checkbox"]').removeAttr("checked"); 
     445            }else{ 
     446                //$(".current_selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true); 
     447                $(".selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true); 
     448            } 
     449 
     450            $.each( $(".selected_shortcut_msg"), function(index, value){ 
     451                updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id")); 
     452            }); 
     453        } 
     454    },{'disable_in_input':true}); 
     455} 
     456 
     457shortcut.add("return",function(){ 
     458    if ( Element('border_id_0').className==='menu-sel' ) 
     459    { 
     460        all_messages = Element('tbody_box').childNodes; 
     461        for (var i=0; i < all_messages.length; i++) 
    328462        { 
    329                  
    330                 var search_in_focus = false; 
    331                 var search_win = document.getElementById( 'window_QuickCatalogSearch' ); 
    332                 if ( search_win && search_win.style.visibility == 'visible' ) 
    333                         search_in_focus = true; 
    334  
    335                 if ( !search_in_focus && currentTab == 0 ) 
    336                     select_msg('null', 'up'); 
    337                 // Ao usuario pressionar o 'up' em uma outra aba, não pode ser removido o 'up'. 
    338                                 else{} 
    339                    // shortcut.remove('up'); 
    340                                 e.stopPropagation(); 
    341                                 e.preventDefault(); 
    342         },{'disable_in_input':false}); 
    343  
    344  
    345         shortcut.add('down', function(e) 
     463            if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
     464            { 
     465                Element("td_from_" + all_messages[i].id).onclick(); 
     466                return; 
     467            } 
     468        } 
     469    } 
     470},{'disable_in_input':true}); 
     471 
     472shortcut.add("f5",function(){ 
     473    Element("em_refresh_button").onclick(); 
     474    return; 
     475},{'disable_in_input':true}); 
     476 
     477function exec_msg_action(action) 
     478{ 
     479    var msg_id = get_msg_id(); 
     480    if (msg_id) 
     481    { 
     482        var msg_id = 'msg_opt_' + action + '_' + msg_id; 
     483        try {Element(msg_id).onclick();} 
     484    catch(e){/*alert(e);*/} 
     485} 
     486return; 
     487} 
     488 
     489function show_head_option() 
     490{ 
     491    var msg_id = get_msg_id(); 
     492    if (msg_id) { 
     493        var msg_id = 'option_hide_more_' + msg_id; 
     494        try {Element(msg_id).onclick();} 
     495    catch(e){/*alert(e);*/} 
     496} 
     497return; 
     498} 
     499 
     500function show_address_full() 
     501{ 
     502    var toaddress = Element('div_toaddress_' + get_msg_id());    
     503    var ccaddress = Element('div_ccaddress_' + get_msg_id()); 
     504 
     505    if(toaddress &&  '' == toaddress.style.display) { 
     506        show_div_address_full(get_msg_id(),'to'); 
     507    } 
     508    else { 
     509        if(toaddress) 
     510            toaddress.style.display = ''; 
     511        var toaddress_full = Element('div_toaddress_full_' + get_msg_id()); 
     512        if(toaddress_full) 
     513            toaddress_full.style.display = 'none'; 
     514    }            
     515    if(ccaddress &&  '' == ccaddress.style.display) { 
     516        show_div_address_full(get_msg_id(),'cc'); 
     517    } 
     518    else { 
     519        if(ccaddress) 
     520            ccaddress.style.display = ''; 
     521        var ccaddress_full = Element('div_ccaddress_full_' + get_msg_id()); 
     522        if(ccaddress_full) 
     523            ccaddress_full.style.display = 'none'; 
     524    } 
     525    return; 
     526} 
     527 
     528function get_msg_id() 
     529{ 
     530    children = Element('border_tr').childNodes; 
     531 
     532    for (var i=0; i<children.length; i++) 
     533    { 
     534        if ( (children[i].nodeName==='TD') && (children[i].className==='menu-sel') && children[i].id != 'border_id_0') 
    346535        { 
    347                 var search_in_focus = false; 
    348                 var search_win = document.getElementById( 'window_QuickCatalogSearch' ); 
    349                 if ( search_win && search_win.style.visibility == 'visible' ) 
    350                         search_in_focus = true; 
    351  
    352                 if ( !search_in_focus && currentTab == 0 ) 
    353                     select_msg('null', 'down'); 
    354                                 // Ao usuario pressionar o 'down' em uma outra aba, não pode ser removido o 'down'.  
    355                 else{} 
    356                    // shortcut.remove('down'); 
    357                                 e.stopPropagation(); 
    358                                 e.preventDefault(); 
    359         },{'disable_in_input':false}); 
    360  
    361 //**************** 
    362  
    363         shortcut.add("Shift+down",function(){ 
    364                 if ( Element('border_id_0').className==='menu-sel' ) 
    365                 { 
    366                         if (shift_up_count > 0) 
    367                                 unselect_top_msg(); 
    368                         else 
    369                                 select_bottom_msg(); 
    370                 } 
    371         },{'disable_in_input':true, 'propagate':false}); 
    372          
    373         shortcut.add("Shift+up",function(){ 
    374                 if ( Element('border_id_0').className==='menu-sel' ) 
    375                 { 
    376                         if (shift_down_count > 0) 
    377                                 unselect_bottom_msg(); 
    378                         else 
    379                                 select_top_msg(); 
    380                 } 
    381         },{'disable_in_input':true, 'propagate':false}); 
    382 } 
    383 else 
    384 { 
    385         shortcut.add("Up",function(){ 
    386                 if (currentTab == 0) 
    387                   select_msg('null', 'up'); 
    388         },{'disable_in_input':false}); 
    389          
    390         shortcut.add("Down",function(){ 
    391  
    392                 if (currentTab == 0) 
    393                   select_msg('null', 'down'); 
    394                  
    395         },{'disable_in_input':false}); 
    396          
    397         shortcut.add("Shift+down",function(){ 
    398                 if ( Element('border_id_0').className==='menu-sel' ) 
    399                 { 
    400                         if (shift_up_count > 0) 
    401                                 unselect_top_msg(); 
    402                         else 
    403                                 select_bottom_msg(); 
    404                 } 
    405         },{'type':'keypress','disable_in_input':true, 'propagate':false}); 
    406          
    407         shortcut.add("Shift+up",function(){ 
    408                 if ( Element('border_id_0').className==='menu-sel' ) 
    409                 { 
    410                         if (shift_down_count > 0) 
    411                                 unselect_bottom_msg(); 
    412                         else 
    413                                 select_top_msg(); 
    414                 } 
    415         },{'type':'keypress', 'disable_in_input':true, 'propagate':false}); 
    416 } 
    417  
    418 shortcut.add("return",function(){ 
    419         if ( Element('border_id_0').className==='menu-sel' ) 
    420         { 
    421                 all_messages = Element('tbody_box').childNodes; 
    422                 for (var i=0; i < all_messages.length; i++) 
    423                 { 
    424                         if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
    425                         { 
    426                                 Element("td_from_" + all_messages[i].id).onclick(); 
    427                                 return; 
    428                         } 
    429                 } 
    430         } 
    431 },{'disable_in_input':true}); 
    432  
    433 shortcut.add("f9",function(){ 
    434         Element("em_refresh_button").onclick(); 
    435         return; 
    436 },{'disable_in_input':true}); 
    437  
    438 function exec_msg_action(action) 
    439 { 
    440         var msg_id = get_msg_id(); 
    441         if (msg_id) 
    442         { 
    443                 var msg_id = 'msg_opt_' + action + '_' + msg_id; 
    444                 try {Element(msg_id).onclick();} 
    445                 catch(e){/*alert(e);*/} 
    446         } 
    447         return; 
    448 } 
    449  
    450 function show_head_option() 
    451 { 
    452         var msg_id = get_msg_id(); 
    453     if (msg_id) { 
    454                 var msg_id = 'option_hide_more_' + msg_id; 
    455                 try {Element(msg_id).onclick();} 
    456                 catch(e){/*alert(e);*/} 
    457     } 
    458         return; 
    459 } 
    460  
    461 function show_address_full() 
    462 { 
    463         var toaddress = Element('div_toaddress_' + get_msg_id());        
    464         var ccaddress = Element('div_ccaddress_' + get_msg_id()); 
    465          
    466         if(toaddress &&  '' == toaddress.style.display) { 
    467                 show_div_address_full(get_msg_id(),'to'); 
    468         } 
    469         else { 
    470                 if(toaddress) 
    471                         toaddress.style.display = ''; 
    472                 var toaddress_full = Element('div_toaddress_full_' + get_msg_id()); 
    473                 if(toaddress_full) 
    474                         toaddress_full.style.display = 'none'; 
    475         }                
    476         if(ccaddress &&  '' == ccaddress.style.display) { 
    477                 show_div_address_full(get_msg_id(),'cc'); 
    478         } 
    479         else { 
    480                 if(ccaddress) 
    481                         ccaddress.style.display = ''; 
    482                 var ccaddress_full = Element('div_ccaddress_full_' + get_msg_id()); 
    483                 if(ccaddress_full) 
    484                         ccaddress_full.style.display = 'none'; 
    485         } 
    486         return; 
    487 } 
    488  
    489 function get_msg_id() 
    490 { 
    491         children = Element('border_tr').childNodes; 
    492          
    493         for (var i=0; i<children.length; i++) 
    494         { 
    495                 if ( (children[i].nodeName==='TD') && (children[i].className==='menu-sel') && children[i].id != 'border_id_0') 
    496                 { 
    497                         var border_selected = children[i]; 
    498                         var msg_id = border_selected.id.replace("border_id_",""); 
    499                         return msg_id; 
    500                 } 
    501         } 
    502         return false; 
     536            var border_selected = children[i]; 
     537            var msg_id = border_selected.id.replace("border_id_",""); 
     538            return msg_id; 
     539        } 
     540    } 
     541    return false; 
    503542} 
    504543 
    505544function select_msg(msg_number, keyboard_action, force_msg_selection) 
    506545{ 
    507     /* 
    508           ** Se caso for limpado toda a caixa de email, 
    509           ** é adicionado um novo atalho de seleção. 
    510           ** main.js on function refrash and line 629. 
    511         */ 
    512          
    513         if(keyboard_action == "reload_msg"){ 
    514            if( $("#tbody_box .selected_shortcut_msg").length == 0 ) 
    515                 $("#tbody_box tr:first").addClass("selected_shortcut_msg");      
    516         } 
    517          
    518         shift_up_count = 0; 
    519         shift_down_count = 0; 
    520  
    521         if (msg_number != 'null') { 
    522          
    523                 if(Element(msg_number)){ 
    524                         unselect_all_msgs(); 
    525                         add_className(Element(msg_number), 'selected_shortcut_msg'); 
    526                 } 
    527                  
    528         } else { 
    529                 var scrollMain = Element('divScrollMain_0'); 
    530                 var selection_size = parseInt(preferences.line_height) + 10;  
    531                  
    532                         if( keyboard_action == 'down') { 
    533                          
    534                                 if(!Element("chk_box_select_all_messages").checked){ 
    535                                          
    536                                         $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
    537                                          
    538                                                 if($(this).hasClass("selected_shortcut_msg") && $(this).next().length){ 
    539                                                         $(this).next().addClass("selected_shortcut_msg"); 
    540                                                         $(this).removeClass("selected_shortcut_msg"); 
    541                                                         return false; 
    542                                                 } 
    543                                                  
    544                                         }); 
    545                                          
    546                                 } else { 
    547                                  
    548                                         $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
    549                                                  
    550                                                 if($(this).hasClass("current_selected") && $(this).next().length){ 
    551                                                         $(this).removeClass("current_selected"); 
    552                                                         $(this).removeClass("selected_shortcut_msg"); 
    553                                                         $(this).next().addClass("current_selected"); 
    554                                                         $(this).next().addClass("selected_shortcut_msg"); 
    555                                                         return false; 
    556                                                 } 
    557                                          
    558                                         }); 
    559                                         $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
    560                                                                 if(!$(this).hasClass("current_selected")) 
    561                                                                         $(this).removeClass("selected_shortcut_msg"); 
    562                                         }); 
    563                                 } 
    564                          
    565                         } else if( keyboard_action == 'up') { 
    566                          
    567                                 if(!Element("chk_box_select_all_messages").checked){ 
    568                                  
    569                                         $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
    570                                          
    571                                                 if($(this).hasClass("selected_shortcut_msg") && $(this).prev().length){ 
    572                                                                 $(this).prev().addClass("selected_shortcut_msg"); 
    573                                                                 $(this).removeClass("selected_shortcut_msg"); 
    574                                                                 return false; 
    575                                                 } 
    576                                                  
    577                                         }); 
    578                                          
    579                                 } else { 
    580                                          
    581                                         $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
    582                                                  
    583                                                 if($(this).hasClass("current_selected") && $(this).prev().length){ 
    584                                                         $(this).removeClass("current_selected"); 
    585                                                         $(this).removeClass("selected_shortcut_msg"); 
    586                                                         $(this).prev().addClass("current_selected"); 
    587                                                         $(this).prev().addClass("selected_shortcut_msg"); 
    588                                                         return false; 
    589                                                 } 
    590                                          
    591                                         }); 
    592                                         $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
    593                                                                 if(!$(this).hasClass("current_selected")) 
    594                                                                         $(this).removeClass("selected_shortcut_msg"); 
    595                                         }); 
    596                                  
    597                                 } 
    598                    
    599                         } 
    600                 return true; 
    601         } 
     546/* 
     547** Se caso for limpado toda a caixa de email, 
     548** é adicionado um novo atalho de seleção. 
     549** main.js on function refrash and line 629. 
     550*/ 
     551$("#table_box").find("tr").attr("tabindex", -1); 
     552 
     553if(keyboard_action == "reload_msg"){ 
     554    if( $("#tbody_box .current_selected_shortcut_msg").length == 0 ){ 
     555        $("#tbody_box tr:first").addClass("current_selected_shortcut_msg selected_shortcut_msg");        
     556    } 
     557} 
     558 
     559shift_up_count = 0; 
     560shift_down_count = 0; 
     561 
     562if (msg_number != 'null') { 
     563 
     564    if(Element(msg_number)){ 
     565        unselect_all_msgs(); 
     566        $("#tbody_box tr").removeClass("current_selected_shortcut_msg selected_shortcut_msg"); 
     567        $("#"+msg_number).addClass('current_selected_shortcut_msg selected_shortcut_msg'); 
     568    } 
     569 
     570} else { 
     571    var scrollMain = Element('divScrollMain_0'); 
     572    var selection_size = parseInt(preferences.line_height) + 10;  
     573 
     574    if( keyboard_action == 'down') { 
     575 
     576        if(!Element("chk_box_select_all_messages").checked){ 
     577 
     578            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
     579 
     580                if($(this).hasClass("selected_shortcut_msg") && $(this).next().length){ 
     581                    $(this).next().addClass("selected_shortcut_msg"); 
     582                    $(this).removeClass("selected_shortcut_msg"); 
     583                    return false; 
     584                } 
     585 
     586            }); 
     587 
     588        } else { 
     589 
     590            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
     591 
     592                if($(this).hasClass("current_selected") && $(this).next().length){ 
     593                    $(this).removeClass("current_selected"); 
     594                    $(this).removeClass("selected_shortcut_msg"); 
     595                    $(this).next().addClass("current_selected"); 
     596                    $(this).next().addClass("selected_shortcut_msg"); 
     597                    return false; 
     598                } 
     599 
     600            }); 
     601            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
     602                if(!$(this).hasClass("current_selected")) 
     603                    $(this).removeClass("selected_shortcut_msg"); 
     604            }); 
     605        } 
     606 
     607    } else if( keyboard_action == 'up') { 
     608 
     609        if(!Element("chk_box_select_all_messages").checked){ 
     610 
     611            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
     612 
     613                if($(this).hasClass("selected_shortcut_msg") && $(this).prev().length){ 
     614                    $(this).prev().addClass("selected_shortcut_msg"); 
     615                    $(this).removeClass("selected_shortcut_msg"); 
     616                    return false; 
     617                } 
     618 
     619            }); 
     620 
     621        } else { 
     622 
     623            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
     624 
     625                if($(this).hasClass("current_selected") && $(this).prev().length){ 
     626                    $(this).removeClass("current_selected"); 
     627                    $(this).removeClass("selected_shortcut_msg"); 
     628                    $(this).prev().addClass("current_selected"); 
     629                    $(this).prev().addClass("selected_shortcut_msg"); 
     630                    return false; 
     631                } 
     632 
     633            }); 
     634            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){ 
     635                if(!$(this).hasClass("current_selected")) 
     636                    $(this).removeClass("selected_shortcut_msg"); 
     637            }); 
     638 
     639        } 
     640 
     641    } 
     642    return true; 
     643} 
    602644} 
    603645 
    604646function select_bottom_msg() 
    605647{ 
    606         all_messages = Element('tbody_box').childNodes; 
    607          
    608         if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) 
    609                 return; 
    610          
    611         for (var i=all_messages.length-1; i >=0; i--) 
    612         { 
    613                 if ( (exist_className(all_messages[i], 'selected_shortcut_msg')) && (i+1 <= all_messages.length-1) ) 
    614                 { 
    615                         shift_down_count++; 
    616                         add_className(all_messages[i+1], 'selected_shortcut_msg'); 
    617                         break; 
    618                 } 
    619         } 
     648    all_messages = Element('tbody_box').childNodes; 
     649 
     650    if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') ) 
     651        return; 
     652 
     653    for (var i=all_messages.length-1; i >=0; i--) 
     654    { 
     655        if ( (exist_className(all_messages[i], 'selected_shortcut_msg')) && (i+1 <= all_messages.length-1) ) 
     656        { 
     657            shift_down_count++; 
     658            add_className(all_messages[i+1], 'selected_msg'); 
     659            break; 
     660        } 
     661    } 
    620662} 
    621663 
    622664function select_top_msg() 
    623665{ 
    624         all_messages = Element('tbody_box').childNodes; 
    625                  
    626         if ( exist_className(all_messages[0], 'selected_shortcut_msg') ) 
    627                 return; 
    628          
    629         for (var i=0; i <=all_messages.length-1; i++) 
    630         { 
    631                 if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
    632                 { 
    633                         shift_up_count++; 
    634                         add_className(all_messages[i-1], 'selected_shortcut_msg'); 
    635                         break; 
    636                 } 
    637         } 
     666    all_messages = Element('tbody_box').childNodes; 
     667 
     668    if ( exist_className(all_messages[0], 'selected_shortcut_msg') ) 
     669        return; 
     670 
     671    for (var i=0; i <=all_messages.length-1; i++) 
     672    { 
     673        if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
     674        { 
     675            shift_up_count++; 
     676            add_className(all_messages[i-1], 'selected_msg'); 
     677            break; 
     678        } 
     679    } 
    638680} 
    639681 
    640682function unselect_bottom_msg() 
    641683{ 
    642         all_messages = Element('tbody_box').childNodes; 
    643         for (var i=all_messages.length-1; i >=0; i--) 
    644         { 
    645                 if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
    646                 { 
    647                         shift_down_count--; 
    648                         remove_className(all_messages[i], 'selected_shortcut_msg'); 
    649                         break; 
    650                 } 
    651         } 
     684    all_messages = Element('tbody_box').childNodes; 
     685    for (var i=all_messages.length-1; i >=0; i--) 
     686    { 
     687        if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
     688        { 
     689            shift_down_count--; 
     690            remove_className(all_messages[i], 'selected_msg'); 
     691            break; 
     692        } 
     693    } 
    652694} 
    653695 
    654696function unselect_top_msg() 
    655697{ 
    656         all_messages = Element('tbody_box').childNodes; 
    657         for (var i=0; i <=all_messages.length-1; i++) 
    658         { 
    659                 if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
    660                 { 
    661                         shift_up_count--; 
    662                         remove_className(all_messages[i], 'selected_shortcut_msg'); 
    663                         break; 
    664                 } 
    665         } 
     698    all_messages = Element('tbody_box').childNodes; 
     699    for (var i=0; i <=all_messages.length-1; i++) 
     700    { 
     701        if ( exist_className(all_messages[i], 'selected_shortcut_msg') ) 
     702        { 
     703            shift_up_count--; 
     704            remove_className(all_messages[i], 'selected_msg'); 
     705            break; 
     706        } 
     707    } 
    666708} 
    667709 
    668710function unselect_all_msgs() 
    669711{ 
    670         all_messages = Element('tbody_box').childNodes; 
    671         for (var i=0; i <=all_messages.length-1; i++) 
    672         { 
    673                 remove_className(all_messages[i], 'selected_shortcut_msg'); 
    674         } 
    675 } 
     712    all_messages = Element('tbody_box').childNodes; 
     713    for (var i=0; i <=all_messages.length-1; i++) 
     714    { 
     715        remove_className(all_messages[i], 'selected_msg'); 
     716    } 
     717} 
Note: See TracChangeset for help on using the changeset viewer.