source: branches/2.5/expressoMail1_2/js/shortcut.js @ 8232

Revision 8232, 23.5 KB checked in by douglas, 10 years ago (diff)

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

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