Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).keydown( function(event) {
- if($("#content tr.sel").length >= 1) {
- var id = $("#content tr.sel").attr("id");
- } else if($("#content tr:first").length >=1 ) {
- $("#content").scrollTo(0);
- $("#content tr:first").addClass("sel");
- }
- key = event.keyCode;
- switch(key) {
- case 40:
- if($("#"+id).next().length > 0 ) {
- var position = $("#"+id).position();
- $("#"+id).removeClass("sel use");
- $("#"+id).next().addClass("sel");
- if(position.top > $("#content").outerHeight(true)/2) {
- keyNav = true;
- $("#content").scrollTo('+='+$("#"+id).outerHeight(true)+'px',{ 'onAfter': function() { keyNav=false; } });
- }
- }
- break;
- case 38:
- if($("#"+id).prev().length > 0 ) {
- var position = $("#"+id).position();
- $("#"+id).removeClass("sel use");
- $("#"+id).prev().addClass("sel");
- if(position.top < $("#content").outerHeight(true)/2) {
- keyNav = true;
- $("#content").scrollTo('-='+$("#"+id).outerHeight(true)+'px',{ 'onAfter': function() { keyNav=false; } });
- }
- }
- break;
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement