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

Revision 7228, 24.5 KB checked in by douglas, 12 years ago (diff)

Ticket #0000 - Copiadas as alterações do Trunk. Versão final da 2.4.2.

  • 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                proxy_mensagens.delete_msgs(openTab.imapBox[currentTab], currentTab.substring(0, selMessageShortcut.indexOf("_r")), 'null');
326       
327        }
328       
329}
330,{'disable_in_input':true});
331
332shortcut.add("Ctrl+Up",function(){exec_msg_action('previous');/*select_msg('null', 'up');*/},{'disable_in_input':true});
333shortcut.add("Ctrl+Down",function(){exec_msg_action('next');/*select_msg('null', 'down');*/},{'disable_in_input':true});
334
335if (is_ie || is_webkit)
336{
337//**********************
338shortcut.add('up', function(e)
339{
340    if(currentTab == 0){
341        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
342        if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length)
343            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
344        $(".current_selected_shortcut_msg").addClass("selected_shortcut_msg").focus();
345    }
346},{'disable_in_input':true});
347
348
349shortcut.add('down', function(e)
350{
351    if(currentTab == 0){
352        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
353        if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length)
354            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
355        $(".current_selected_shortcut_msg").addClass("selected_shortcut_msg").focus();
356    }
357},{'disable_in_input':true});
358
359shortcut.add('space', function(e)
360{
361    if(currentTab == 0){
362        var allchecked = true;
363        $.each( $(".selected_shortcut_msg"), function(index, value){
364            if($(value).find(":checkbox").attr("checked") == undefined){
365                allchecked = false;
366            }
367        });
368        if(allchecked){
369            $(".selected_shortcut_msg").removeClass("selected_msg").find('input[type="checkbox"]').removeAttr("checked");
370        }else{
371            //$(".current_selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true);
372            $(".selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true);
373        }
374        $.each( $(".selected_shortcut_msg"), function(index, value){
375            updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id"));
376        });
377        $(".current_selected_shortcut_msg").focus();
378    }
379},{'disable_in_input':true});
380
381//****************
382
383shortcut.add("Shift+down",function()
384{   
385    if(currentTab == 0){           
386        //$(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
387        if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length)
388            if($(".current_selected_shortcut_msg").next().hasClass("selected_shortcut_msg"))
389                $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().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").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
392        $(".current_selected_shortcut_msg").focus();
393    }
394},{'disable_in_input':true, 'propagate':false});
395
396shortcut.add("Shift+up",function(){
397    if(currentTab == 0){           
398        //$(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
399        if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length)
400            if($(".current_selected_shortcut_msg").prev().hasClass("selected_shortcut_msg"))
401                $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
402            else
403                $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
404        $(".current_selected_shortcut_msg").focus();
405    }
406},{'disable_in_input':true, 'propagate':false});
407}
408else
409{
410    shortcut.add("Up",function(){
411        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
412        if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length)
413            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
414        $(".current_selected_shortcut_msg").focus();
415    },{'disable_in_input':true});
416
417    shortcut.add("Down",function(){
418        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
419        if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length)
420            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
421        $(".current_selected_shortcut_msg").focus();
422    },{'disable_in_input':true});
423
424    shortcut.add("Shift+down",function(){
425        if(currentTab == 0){           
426            if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length)
427                if($(".current_selected_shortcut_msg").next().hasClass("selected_shortcut_msg"))
428                    $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
429                else
430                    $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
431            $(".current_selected_shortcut_msg").focus();
432        }
433    },{'type':'keypress','disable_in_input':true, 'propagate':false});
434
435    shortcut.add("Shift+up",function(){
436        if(currentTab == 0){           
437            if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length)
438                if($(".current_selected_shortcut_msg").prev().hasClass("selected_shortcut_msg"))
439                    $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
440                else
441                    $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
442            $(".current_selected_shortcut_msg").focus();
443        }
444    },{'type':'keypress', 'disable_in_input':true, 'propagate':false});
445    shortcut.add('Space', function(e)
446    {
447        if(currentTab == 0){
448            var allchecked = true;
449            $.each( $(".selected_shortcut_msg"), function(index, value){
450                if($(value).find(":checkbox").attr("checked") == undefined){
451                    allchecked = false;
452                }
453            });
454            if(allchecked){
455               
456                $(".selected_shortcut_msg").removeClass("selected_msg").find('input[type="checkbox"]').removeAttr("checked");
457            }else{
458                //$(".current_selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true);
459                $(".selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true);
460            }
461
462            $.each( $(".selected_shortcut_msg"), function(index, value){
463                updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id"));
464            });
465        }
466    },{'disable_in_input':true});
467}
468
469shortcut.add("return",function(){
470    if ( Element('border_id_0').className==='menu-sel' )
471    {
472        all_messages = Element('tbody_box').childNodes;
473        for (var i=0; i < all_messages.length; i++)
474        {
475            if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
476            {
477                Element("td_from_" + all_messages[i].id).onclick();
478                return;
479            }
480        }
481    }
482},{'disable_in_input':true});
483
484shortcut.add("f9",function(){
485    Element("em_refresh_button").onclick();
486    return;
487},{'disable_in_input':false});
488
489function exec_msg_action(action)
490{
491    var msg_id = get_msg_id();
492    if (msg_id)
493    {
494        var msg_id = 'msg_opt_' + action + '_' + msg_id;
495        try {Element(msg_id).onclick();}
496    catch(e){/*alert(e);*/}
497}
498return;
499}
500
501function show_head_option()
502{
503    var msg_id = get_msg_id();
504    if (msg_id) {
505        var msg_id = 'option_hide_more_' + msg_id;
506        try {Element(msg_id).onclick();}
507    catch(e){/*alert(e);*/}
508}
509return;
510}
511
512function show_address_full()
513{
514    var toaddress = Element('div_toaddress_' + get_msg_id());   
515    var ccaddress = Element('div_ccaddress_' + get_msg_id());
516
517    if(toaddress &&  '' == toaddress.style.display) {
518        show_div_address_full(get_msg_id(),'to');
519    }
520    else {
521        if(toaddress)
522            toaddress.style.display = '';
523        var toaddress_full = Element('div_toaddress_full_' + get_msg_id());
524        if(toaddress_full)
525            toaddress_full.style.display = 'none';
526    }           
527    if(ccaddress &&  '' == ccaddress.style.display) {
528        show_div_address_full(get_msg_id(),'cc');
529    }
530    else {
531        if(ccaddress)
532            ccaddress.style.display = '';
533        var ccaddress_full = Element('div_ccaddress_full_' + get_msg_id());
534        if(ccaddress_full)
535            ccaddress_full.style.display = 'none';
536    }
537    return;
538}
539
540function get_msg_id()
541{
542    children = Element('border_tr').childNodes;
543
544    for (var i=0; i<children.length; i++)
545    {
546        if ( (children[i].nodeName==='TD') && (children[i].className==='menu-sel') && children[i].id != 'border_id_0')
547        {
548            var border_selected = children[i];
549            var msg_id = border_selected.id.replace("border_id_","");
550            return msg_id;
551        }
552    }
553    return false;
554}
555
556function select_msg(msg_number, keyboard_action, force_msg_selection)
557{
558/*
559** Se caso for limpado toda a caixa de email,
560** e adicionado um novo atalho de selecao.
561** main.js on function refrash and line 629.
562*/
563$("#table_box").find("tr").attr("tabindex", -1);
564$("#table_box").find("tr").css("outline", "none");
565
566if(keyboard_action == "reload_msg"){
567    if( $("#tbody_box .current_selected_shortcut_msg").length == 0 ){
568        $("#tbody_box tr:first").addClass("current_selected_shortcut_msg selected_shortcut_msg");       
569    }
570}
571
572shift_up_count = 0;
573shift_down_count = 0;
574
575if (msg_number != 'null') {
576
577    if(Element(msg_number)){
578        unselect_all_msgs();
579        $("#tbody_box tr").removeClass("current_selected_shortcut_msg selected_shortcut_msg");
580        $("#"+msg_number).addClass('current_selected_shortcut_msg selected_shortcut_msg');
581    }
582
583} else {
584    var scrollMain = Element('divScrollMain_0');
585    var selection_size = parseInt(preferences.line_height) + 10;
586
587    if( keyboard_action == 'down') {
588
589        if(!Element("chk_box_select_all_messages").checked){
590
591            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
592
593                if($(this).hasClass("selected_shortcut_msg") && $(this).next().length){
594                   
595                    $(this).next().addClass("selected_shortcut_msg current_selected_shortcut_msg");
596                    $(this).removeClass("selected_shortcut_msg");
597                    return false;
598                }
599
600            });
601
602        } else {
603
604            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
605
606                if($(this).hasClass("current_selected") && $(this).next().length){
607                    $(this).removeClass("current_selected");
608                    $(this).removeClass("selected_shortcut_msg");
609                    $(this).next().addClass("current_selected");
610                    $(this).next().addClass("selected_shortcut_msg");
611                    return false;
612                }
613
614            });
615            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
616                if(!$(this).hasClass("current_selected"))
617                    $(this).removeClass("selected_shortcut_msg");
618            });
619        }
620
621    } else if( keyboard_action == 'up') {
622
623        if(!Element("chk_box_select_all_messages").checked){
624
625            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
626
627                if($(this).hasClass("selected_shortcut_msg") && $(this).prev().length){
628                    $(this).prev().addClass("selected_shortcut_msg current_selected_shortcut_msg");
629                    $(this).removeClass("selected_shortcut_msg");
630                    return false;
631                }
632
633            });
634
635        } else {
636
637            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
638
639                if($(this).hasClass("current_selected") && $(this).prev().length){
640                    $(this).removeClass("current_selected");
641                    $(this).removeClass("selected_shortcut_msg");
642                    $(this).prev().addClass("current_selected");
643                    $(this).prev().addClass("selected_shortcut_msg");
644                    return false;
645                }
646
647            });
648            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
649                if(!$(this).hasClass("current_selected"))
650                    $(this).removeClass("selected_shortcut_msg");
651            });
652
653        }
654
655    }
656    return true;
657}
658}
659
660function select_bottom_msg()
661{
662    all_messages = Element('tbody_box').childNodes;
663
664    if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') )
665        return;
666
667    for (var i=all_messages.length-1; i >=0; i--)
668    {
669        if ( (exist_className(all_messages[i], 'selected_shortcut_msg')) && (i+1 <= all_messages.length-1) )
670        {
671            shift_down_count++;
672            add_className(all_messages[i+1], 'selected_msg');
673            break;
674        }
675    }
676}
677
678function select_top_msg()
679{
680    all_messages = Element('tbody_box').childNodes;
681
682    if ( exist_className(all_messages[0], 'selected_shortcut_msg') )
683        return;
684
685    for (var i=0; i <=all_messages.length-1; i++)
686    {
687        if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
688        {
689            shift_up_count++;
690            add_className(all_messages[i-1], 'selected_msg');
691            break;
692        }
693    }
694}
695
696function unselect_bottom_msg()
697{
698    all_messages = Element('tbody_box').childNodes;
699    for (var i=all_messages.length-1; i >=0; i--)
700    {
701        if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
702        {
703            shift_down_count--;
704            remove_className(all_messages[i], 'selected_msg');
705            break;
706        }
707    }
708}
709
710function unselect_top_msg()
711{
712    all_messages = Element('tbody_box').childNodes;
713    for (var i=0; i <=all_messages.length-1; i++)
714    {
715        if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
716        {
717            shift_up_count--;
718            remove_className(all_messages[i], 'selected_msg');
719            break;
720        }
721    }
722}
723
724function unselect_all_msgs()
725{
726    all_messages = Element('tbody_box').childNodes;
727    for (var i=0; i <=all_messages.length-1; i++)
728    {
729        remove_className(all_messages[i], 'selected_msg');
730    }
731}
Note: See TracBrowser for help on using the repository browser.