@@ -33,7 +33,7 @@ RepoViewer = {
33
33
} ,
34
34
35
35
attachCommitClickEvents : function ( ) {
36
- $ ( ".commit" ) . click ( function ( e ) {
36
+ function activated ( e ) {
37
37
e . preventDefault ( )
38
38
var id = $ ( e . target ) . attr ( "id" )
39
39
if ( id . split ( "-" ) [ 0 ] == "commit" ) {
@@ -47,7 +47,10 @@ RepoViewer = {
47
47
RepoViewer . highlightCommit ( sha )
48
48
RepoViewer . clearFileView ( )
49
49
}
50
- } )
50
+ }
51
+ $ ( ".commit" ) . click ( activated ) . keydown ( function ( e ) {
52
+ if ( 13 === e . keyCode ) activated ( e ) ;
53
+ } ) ;
51
54
} ,
52
55
53
56
displayCommitDiffInfo : function ( commit ) {
@@ -96,10 +99,11 @@ RepoViewer = {
96
99
} ,
97
100
98
101
attachMoreCommitsEvents : function ( ) {
99
- $ ( ".more-commits" ) . click ( function ( e ) {
102
+ function activated ( e ) {
100
103
e . preventDefault ( )
101
- $ ( e . target ) . parent ( ) . parent ( ) . parent ( ) . remove ( )
102
- var id = $ ( e . target ) . parent ( ) . attr ( "id" )
104
+ var id = $ ( e . target ) . closest ( '[id]' ) . attr ( "id" ) ;
105
+ $ ( e . target ) . closest ( 'tr' ) . prev ( 'tr' ) . find ( '[tabindex]' ) . focus ( )
106
+ $ ( e . target ) . closest ( 'tr' ) . remove ( ) ;
103
107
if ( id . split ( "-" ) [ 0 ] == "more" ) {
104
108
var sha = id . split ( "-" ) [ 1 ]
105
109
RepoViewer . repo . getObject ( sha , function ( err , commit ) {
@@ -108,13 +112,16 @@ RepoViewer = {
108
112
} )
109
113
} )
110
114
}
111
- } )
115
+ }
116
+ $ ( ".more-commits" ) . click ( activated ) . keydown ( function ( e ) {
117
+ if ( 13 === e . keyCode ) activated ( e ) ;
118
+ } ) ;
112
119
} ,
113
120
114
121
displayCommit : function ( commit ) {
115
122
if ( $ ( "#commit-" + commit . sha ) . length == 0 ) {
116
123
var row = "<tr>"
117
- row += "<td class=\"commit\" id=\"commit-" + commit . sha + "\">" + commit . message . split ( "\n" ) [ 0 ] + "</td>"
124
+ row += "<td class=\"commit\" id=\"commit-" + commit . sha + "\" tabindex=0 >" + commit . message . split ( "\n" ) [ 0 ] + "</td>"
118
125
row += "<td>" + commit . author . name + "</td>"
119
126
120
127
row += "<td>" + commit . author . date . toUTCString ( ) + "</td>"
@@ -127,7 +134,7 @@ RepoViewer = {
127
134
this . displayCommit ( commit )
128
135
if ( max == 0 ) {
129
136
this . attachCommitClickEvents ( )
130
- var row = "<tr><td><a class='more-commits' id='more-" + commit . sha + "'><em>More...</em></a></td></tr>"
137
+ var row = "<tr><td><a class='more-commits' id='more-" + commit . sha + "' tabindex=0 ><em>More...</em></a></td></tr>"
131
138
$ ( "#commits table" ) . append ( row )
132
139
this . attachMoreCommitsEvents ( )
133
140
if ( callback ) { callback ( ) }
0 commit comments