source: trunk/expressoMail1_2/js/shortcut.js @ 6930

Revision 6930, 24.2 KB checked in by gustavo, 12 years ago (diff)

Ticket #2954 - Merge de algumas novas funcionalidades da nova versão, #2953, #2971

  • 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                }
212                this.all_shortcuts[shortcut_combination] = {
213                        'callback':func,
214                        'target':ele,
215                        'event': opt['type']
216                };
217                //Attach the function with the event
218                if(ele.addEventListener) ele.addEventListener(opt['type'], func, false);
219                else if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);
220                else ele['on'+opt['type']] = func;
221        },
222
223        //Remove the shortcut - just specify the shortcut and I will remove the binding
224        'remove':function(shortcut_combination) {
225                shortcut_combination = shortcut_combination.toLowerCase();
226                var binding = this.all_shortcuts[shortcut_combination];
227                delete(this.all_shortcuts[shortcut_combination])
228                if(!binding) return;
229                var type = binding['event'];
230                var ele = binding['target'];
231                var callback = binding['callback'];
232
233                if(ele.detachEvent) ele.detachEvent('on'+type, callback);
234                else if(ele.removeEventListener) ele.removeEventListener(type, callback, false);
235                else ele['on'+type] = false;
236        }
237}
238
239/* ExpressMail Functions */
240
241var shift_up_count = 0;
242var shift_down_count = 0;
243var selMessageShortcut = "";
244
245shortcut.add("N",function(e)
246{
247        // avoids problem related at ticket #1011
248        e.preventDefault();
249        var search_in_focus = false;
250        var search_win = document.getElementById( 'QuickCatalogSearch_window_QuickCatalogSearch' );
251        if ( search_win && search_win.style.visibility != 'hidden' )
252                search_in_focus = true;
253
254        if ( ! search_in_focus )
255                new_message("new","null");
256},{'disable_in_input':true});
257
258shortcut.add("Esc",function(){
259        var window_closed = false;
260        var search_win = document.getElementById( 'window_QuickCatalogSearch' );
261       
262        for(var window in arrayJSWin)
263        {
264                if (arrayJSWin[window].visible)
265                {
266                    window_closed = true;
267                    if(search_win.style.visibility == 'hidden'){
268                        arrayJSWin[window].close();
269                    }
270                }
271        }
272        if((search_win) && (search_win.style.visibility == 'visible')){
273            search_win.style.visibility = 'hidden';
274            win.close();
275       }       
276
277        if (!window_closed)
278                delete_border(get_msg_id(), 'false');
279},{'disable_in_input':false});
280
281shortcut.add("I",function(){print_all();},{'disable_in_input':true});
282shortcut.add("E",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; exec_msg_action('forward');},{'disable_in_input':true});
283shortcut.add("R",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; exec_msg_action('reply');},{'disable_in_input':true});
284shortcut.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});
285shortcut.add("O",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; show_head_option();},{'disable_in_input':true});
286shortcut.add("M",function(e){ if(e.preventDefault) e.preventDefault(); else event.returnValue = false; show_address_full();},{'disable_in_input':true});
287
288shortcut.add("Delete",function(){
289       
290       
291        var selected_shortcut_msgs = '';
292        var tbody_box = Element('tbody_box');
293        all_messages = Element('tbody_box').childNodes;
294       
295        for ( var i=0; i < all_messages.length; i++ )
296        {
297                if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
298                {
299                        selected_shortcut_msgs += all_messages[i].id + ',';
300                       
301                        if( all_messages[i].nextSibling )
302                                selMessageShortcut = all_messages[i].nextSibling.id + "-" + "down";
303                        else if(all_messages[i].previousSibling)
304                                selMessageShortcut = all_messages[i].previousSibling.id + "-" + "up";
305                }
306        }
307       
308        selected_shortcut_msgs = selected_shortcut_msgs.substring(0,(selected_shortcut_msgs.length-1));
309       
310        if ( Element('border_id_0').className === 'menu-sel' )
311        {
312                proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null');
313        }
314        else
315        {
316                exec_msg_action('delete');
317                select_msg(selMessageShortcut.substring(0, selMessageShortcut.indexOf("-")),
318                                   selMessageShortcut.substring(selMessageShortcut.indexOf("-")), true );
319               
320                proxy_mensagens.delete_msgs(current_folder, selected_shortcut_msgs, 'null');
321        }
322       
323}
324,{'disable_in_input':true});
325
326shortcut.add("Ctrl+Up",function(){exec_msg_action('previous');/*select_msg('null', 'up');*/},{'disable_in_input':true});
327shortcut.add("Ctrl+Down",function(){exec_msg_action('next');/*select_msg('null', 'down');*/},{'disable_in_input':true});
328
329if (is_ie || is_webkit)
330{
331//**********************
332shortcut.add('up', function(e)
333{
334    if(currentTab == 0){
335        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
336        if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length)
337            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
338        $(".current_selected_shortcut_msg").addClass("selected_shortcut_msg").focus();
339    }
340},{'disable_in_input':true});
341
342
343shortcut.add('down', function(e)
344{
345    if(currentTab == 0){
346        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
347        if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length)
348            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
349        $(".current_selected_shortcut_msg").addClass("selected_shortcut_msg").focus();
350    }
351},{'disable_in_input':true});
352
353shortcut.add('space', function(e)
354{
355    if(currentTab == 0){
356        var allchecked = true;
357        $.each( $(".selected_shortcut_msg"), function(index, value){
358            if($(value).find(":checkbox").attr("checked") == undefined){
359                allchecked = false;
360            }
361        });
362        if(allchecked){
363            $(".selected_shortcut_msg").removeClass("selected_msg").find('input[type="checkbox"]').removeAttr("checked");
364        }else{
365            //$(".current_selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true);
366            $(".selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true);
367        }
368        $.each( $(".selected_shortcut_msg"), function(index, value){
369            updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id"));
370        });
371        $(".current_selected_shortcut_msg").focus();
372    }
373},{'disable_in_input':true});
374
375//****************
376
377shortcut.add("Shift+down",function()
378{   
379    if(currentTab == 0){           
380        //$(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
381        if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length)
382            if($(".current_selected_shortcut_msg").next().hasClass("selected_shortcut_msg"))
383                $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
384            else
385                $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
386        $(".current_selected_shortcut_msg").focus();
387    }
388},{'disable_in_input':true, 'propagate':false});
389
390shortcut.add("Shift+up",function(){
391    if(currentTab == 0){           
392        //$(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
393        if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length)
394            if($(".current_selected_shortcut_msg").prev().hasClass("selected_shortcut_msg"))
395                $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
396            else
397                $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
398        $(".current_selected_shortcut_msg").focus();
399    }
400},{'disable_in_input':true, 'propagate':false});
401}
402else
403{
404    shortcut.add("Up",function(){
405        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
406        if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length)
407            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").prev().addClass("current_selected_shortcut_msg selected_shortcut_msg");
408        $(".current_selected_shortcut_msg").focus();
409    },{'disable_in_input':true});
410
411    shortcut.add("Down",function(){
412        $(".selected_shortcut_msg").removeClass("selected_shortcut_msg");
413        if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length)
414            $(".current_selected_shortcut_msg").blur().removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
415        $(".current_selected_shortcut_msg").focus();
416    },{'disable_in_input':true});
417
418    shortcut.add("Shift+down",function(){
419        if(currentTab == 0){           
420            if($(".current_selected_shortcut_msg").next().parents("#tbody_box").length)
421                if($(".current_selected_shortcut_msg").next().hasClass("selected_shortcut_msg"))
422                    $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
423                else
424                    $(".current_selected_shortcut_msg").blur().addClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").next().addClass("current_selected_shortcut_msg selected_shortcut_msg");
425            $(".current_selected_shortcut_msg").focus();
426        }
427    },{'type':'keypress','disable_in_input':true, 'propagate':false});
428
429    shortcut.add("Shift+up",function(){
430        if(currentTab == 0){           
431            if($(".current_selected_shortcut_msg").prev().parents("#tbody_box").length)
432                if($(".current_selected_shortcut_msg").prev().hasClass("selected_shortcut_msg"))
433                    $(".current_selected_shortcut_msg").blur().removeClass("selected_shortcut_msg").removeClass("current_selected_shortcut_msg").prev().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").prev().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    shortcut.add('Space', function(e)
440    {
441        if(currentTab == 0){
442            var allchecked = true;
443            $.each( $(".selected_shortcut_msg"), function(index, value){
444                if($(value).find(":checkbox").attr("checked") == undefined){
445                    allchecked = false;
446                }
447            });
448            if(allchecked){
449               
450                $(".selected_shortcut_msg").removeClass("selected_msg").find('input[type="checkbox"]').removeAttr("checked");
451            }else{
452                //$(".current_selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true);
453                $(".selected_shortcut_msg").addClass("selected_msg").find('input[type="checkbox"]').attr("checked", true);
454            }
455
456            $.each( $(".selected_shortcut_msg"), function(index, value){
457                updateSelectedMsgs($(value).find(":checkbox").is(':checked'),$(value).attr("id"));
458            });
459        }
460    },{'disable_in_input':true});
461}
462
463shortcut.add("return",function(){
464    if ( Element('border_id_0').className==='menu-sel' )
465    {
466        all_messages = Element('tbody_box').childNodes;
467        for (var i=0; i < all_messages.length; i++)
468        {
469            if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
470            {
471                Element("td_from_" + all_messages[i].id).onclick();
472                return;
473            }
474        }
475    }
476},{'disable_in_input':true});
477
478shortcut.add("f9",function(){
479    Element("em_refresh_button").onclick();
480    return;
481},{'disable_in_input':false});
482
483function exec_msg_action(action)
484{
485    var msg_id = get_msg_id();
486    if (msg_id)
487    {
488        var msg_id = 'msg_opt_' + action + '_' + msg_id;
489        try {Element(msg_id).onclick();}
490    catch(e){/*alert(e);*/}
491}
492return;
493}
494
495function show_head_option()
496{
497    var msg_id = get_msg_id();
498    if (msg_id) {
499        var msg_id = 'option_hide_more_' + msg_id;
500        try {Element(msg_id).onclick();}
501    catch(e){/*alert(e);*/}
502}
503return;
504}
505
506function show_address_full()
507{
508    var toaddress = Element('div_toaddress_' + get_msg_id());   
509    var ccaddress = Element('div_ccaddress_' + get_msg_id());
510
511    if(toaddress &&  '' == toaddress.style.display) {
512        show_div_address_full(get_msg_id(),'to');
513    }
514    else {
515        if(toaddress)
516            toaddress.style.display = '';
517        var toaddress_full = Element('div_toaddress_full_' + get_msg_id());
518        if(toaddress_full)
519            toaddress_full.style.display = 'none';
520    }           
521    if(ccaddress &&  '' == ccaddress.style.display) {
522        show_div_address_full(get_msg_id(),'cc');
523    }
524    else {
525        if(ccaddress)
526            ccaddress.style.display = '';
527        var ccaddress_full = Element('div_ccaddress_full_' + get_msg_id());
528        if(ccaddress_full)
529            ccaddress_full.style.display = 'none';
530    }
531    return;
532}
533
534function get_msg_id()
535{
536    children = Element('border_tr').childNodes;
537
538    for (var i=0; i<children.length; i++)
539    {
540        if ( (children[i].nodeName==='TD') && (children[i].className==='menu-sel') && children[i].id != 'border_id_0')
541        {
542            var border_selected = children[i];
543            var msg_id = border_selected.id.replace("border_id_","");
544            return msg_id;
545        }
546    }
547    return false;
548}
549
550function select_msg(msg_number, keyboard_action, force_msg_selection)
551{
552/*
553** Se caso for limpado toda a caixa de email,
554** e adicionado um novo atalho de selecao.
555** main.js on function refrash and line 629.
556*/
557$("#table_box").find("tr").attr("tabindex", -1);
558
559if(keyboard_action == "reload_msg"){
560    if( $("#tbody_box .current_selected_shortcut_msg").length == 0 ){
561        $("#tbody_box tr:first").addClass("current_selected_shortcut_msg selected_shortcut_msg");       
562    }
563}
564
565shift_up_count = 0;
566shift_down_count = 0;
567
568if (msg_number != 'null') {
569
570    if(Element(msg_number)){
571        unselect_all_msgs();
572        $("#tbody_box tr").removeClass("current_selected_shortcut_msg selected_shortcut_msg");
573        $("#"+msg_number).addClass('current_selected_shortcut_msg selected_shortcut_msg');
574    }
575
576} else {
577    var scrollMain = Element('divScrollMain_0');
578    var selection_size = parseInt(preferences.line_height) + 10;
579
580    if( keyboard_action == 'down') {
581
582        if(!Element("chk_box_select_all_messages").checked){
583
584            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
585
586                if($(this).hasClass("selected_shortcut_msg") && $(this).next().length){
587                    $(this).next().addClass("selected_shortcut_msg");
588                    $(this).removeClass("selected_shortcut_msg");
589                    return false;
590                }
591
592            });
593
594        } else {
595
596            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
597
598                if($(this).hasClass("current_selected") && $(this).next().length){
599                    $(this).removeClass("current_selected");
600                    $(this).removeClass("selected_shortcut_msg");
601                    $(this).next().addClass("current_selected");
602                    $(this).next().addClass("selected_shortcut_msg");
603                    return false;
604                }
605
606            });
607            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
608                if(!$(this).hasClass("current_selected"))
609                    $(this).removeClass("selected_shortcut_msg");
610            });
611        }
612
613    } else if( keyboard_action == 'up') {
614
615        if(!Element("chk_box_select_all_messages").checked){
616
617            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
618
619                if($(this).hasClass("selected_shortcut_msg") && $(this).prev().length){
620                    $(this).prev().addClass("selected_shortcut_msg");
621                    $(this).removeClass("selected_shortcut_msg");
622                    return false;
623                }
624
625            });
626
627        } else {
628
629            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
630
631                if($(this).hasClass("current_selected") && $(this).prev().length){
632                    $(this).removeClass("current_selected");
633                    $(this).removeClass("selected_shortcut_msg");
634                    $(this).prev().addClass("current_selected");
635                    $(this).prev().addClass("selected_shortcut_msg");
636                    return false;
637                }
638
639            });
640            $("#divScrollMain_0").find("#tbody_box").find("tr").each(function(){
641                if(!$(this).hasClass("current_selected"))
642                    $(this).removeClass("selected_shortcut_msg");
643            });
644
645        }
646
647    }
648    return true;
649}
650}
651
652function select_bottom_msg()
653{
654    all_messages = Element('tbody_box').childNodes;
655
656    if ( exist_className(all_messages[all_messages.length-1], 'selected_shortcut_msg') )
657        return;
658
659    for (var i=all_messages.length-1; i >=0; i--)
660    {
661        if ( (exist_className(all_messages[i], 'selected_shortcut_msg')) && (i+1 <= all_messages.length-1) )
662        {
663            shift_down_count++;
664            add_className(all_messages[i+1], 'selected_msg');
665            break;
666        }
667    }
668}
669
670function select_top_msg()
671{
672    all_messages = Element('tbody_box').childNodes;
673
674    if ( exist_className(all_messages[0], 'selected_shortcut_msg') )
675        return;
676
677    for (var i=0; i <=all_messages.length-1; i++)
678    {
679        if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
680        {
681            shift_up_count++;
682            add_className(all_messages[i-1], 'selected_msg');
683            break;
684        }
685    }
686}
687
688function unselect_bottom_msg()
689{
690    all_messages = Element('tbody_box').childNodes;
691    for (var i=all_messages.length-1; i >=0; i--)
692    {
693        if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
694        {
695            shift_down_count--;
696            remove_className(all_messages[i], 'selected_msg');
697            break;
698        }
699    }
700}
701
702function unselect_top_msg()
703{
704    all_messages = Element('tbody_box').childNodes;
705    for (var i=0; i <=all_messages.length-1; i++)
706    {
707        if ( exist_className(all_messages[i], 'selected_shortcut_msg') )
708        {
709            shift_up_count--;
710            remove_className(all_messages[i], 'selected_msg');
711            break;
712        }
713    }
714}
715
716function unselect_all_msgs()
717{
718    all_messages = Element('tbody_box').childNodes;
719    for (var i=0; i <=all_messages.length-1; i++)
720    {
721        remove_className(all_messages[i], 'selected_msg');
722    }
723}
Note: See TracBrowser for help on using the repository browser.