source: branches/2.4/expressoMail1_2/js/shortcut.js @ 7417

Revision 7417, 24.7 KB checked in by eduardow, 11 years ago (diff)

Ticket #3159 - Foco duplo de mensagens no Expresso Mail

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