##// END OF EJS Templates
keyboard-shortcuts: fixed missing go to pull requests shortcut.
marcink -
r4084:7f5b3569 default
parent child Browse files
Show More
@@ -1,133 +1,137 b''
1 // Global keyboard bindings
1 // Global keyboard bindings
2
2
3 function setRCMouseBindings(repoName, repoLandingRev) {
3 function setRCMouseBindings(repoName, repoLandingRev) {
4
4
5 /** custom callback for supressing mousetrap from firing */
5 /** custom callback for supressing mousetrap from firing */
6 Mousetrap.stopCallback = function(e, element) {
6 Mousetrap.stopCallback = function(e, element) {
7 // if the element has the class "mousetrap" then no need to stop
7 // if the element has the class "mousetrap" then no need to stop
8 if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
8 if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
9 return false;
9 return false;
10 }
10 }
11
11
12 // stop for input, select, and textarea
12 // stop for input, select, and textarea
13 return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
13 return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
14 };
14 };
15
15
16 // general help "?"
16 // general help "?"
17 Mousetrap.bind(['?'], function(e) {
17 Mousetrap.bind(['?'], function(e) {
18 $('#help_kb').modal({});
18 $('#help_kb').modal({});
19 });
19 });
20
20
21 // / open the quick filter
21 // / open the quick filter
22 Mousetrap.bind(['/'], function(e) {
22 Mousetrap.bind(['/'], function(e) {
23 $('#main_filter').get(0).focus();
23 $('#main_filter').get(0).focus();
24
24
25 // return false to prevent default browser behavior
25 // return false to prevent default browser behavior
26 // and stop event from bubbling
26 // and stop event from bubbling
27 return false;
27 return false;
28 });
28 });
29
29
30 // ctrl/command+b, show the the main bar
30 // ctrl/command+b, show the the main bar
31 Mousetrap.bind(['command+b', 'ctrl+b'], function(e) {
31 Mousetrap.bind(['command+b', 'ctrl+b'], function(e) {
32 var $headerInner = $('#header-inner'),
32 var $headerInner = $('#header-inner'),
33 $content = $('#content');
33 $content = $('#content');
34 if ($headerInner.hasClass('hover') && $content.hasClass('hover')) {
34 if ($headerInner.hasClass('hover') && $content.hasClass('hover')) {
35 $headerInner.removeClass('hover');
35 $headerInner.removeClass('hover');
36 $content.removeClass('hover');
36 $content.removeClass('hover');
37 } else {
37 } else {
38 $headerInner.addClass('hover');
38 $headerInner.addClass('hover');
39 $content.addClass('hover');
39 $content.addClass('hover');
40 }
40 }
41 return false;
41 return false;
42 });
42 });
43
43
44 // general nav g + action
44 // general nav g + action
45 Mousetrap.bind(['g h'], function(e) {
45 Mousetrap.bind(['g h'], function(e) {
46 window.location = pyroutes.url('home');
46 window.location = pyroutes.url('home');
47 });
47 });
48 Mousetrap.bind(['g g'], function(e) {
48 Mousetrap.bind(['g g'], function(e) {
49 window.location = pyroutes.url('gists_show', {'private': 1});
49 window.location = pyroutes.url('gists_show', {'private': 1});
50 });
50 });
51 Mousetrap.bind(['g G'], function(e) {
51 Mousetrap.bind(['g G'], function(e) {
52 window.location = pyroutes.url('gists_show', {'public': 1});
52 window.location = pyroutes.url('gists_show', {'public': 1});
53 });
53 });
54
54
55 Mousetrap.bind(['g 0'], function(e) {
55 Mousetrap.bind(['g 0'], function(e) {
56 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 0});
56 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 0});
57 });
57 });
58 Mousetrap.bind(['g 1'], function(e) {
58 Mousetrap.bind(['g 1'], function(e) {
59 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 1});
59 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 1});
60 });
60 });
61 Mousetrap.bind(['g 2'], function(e) {
61 Mousetrap.bind(['g 2'], function(e) {
62 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 2});
62 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 2});
63 });
63 });
64 Mousetrap.bind(['g 3'], function(e) {
64 Mousetrap.bind(['g 3'], function(e) {
65 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 3});
65 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 3});
66 });
66 });
67 Mousetrap.bind(['g 4'], function(e) {
67 Mousetrap.bind(['g 4'], function(e) {
68 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 4});
68 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 4});
69 });
69 });
70 Mousetrap.bind(['g 5'], function(e) {
70 Mousetrap.bind(['g 5'], function(e) {
71 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 5});
71 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 5});
72 });
72 });
73 Mousetrap.bind(['g 6'], function(e) {
73 Mousetrap.bind(['g 6'], function(e) {
74 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 6});
74 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 6});
75 });
75 });
76 Mousetrap.bind(['g 7'], function(e) {
76 Mousetrap.bind(['g 7'], function(e) {
77 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 7});
77 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 7});
78 });
78 });
79 Mousetrap.bind(['g 8'], function(e) {
79 Mousetrap.bind(['g 8'], function(e) {
80 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 8});
80 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 8});
81 });
81 });
82 Mousetrap.bind(['g 9'], function(e) {
82 Mousetrap.bind(['g 9'], function(e) {
83 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 9});
83 window.location = pyroutes.url('my_account_goto_bookmark', {'bookmark_id': 9});
84 });
84 });
85
85
86 Mousetrap.bind(['n g'], function(e) {
86 Mousetrap.bind(['n g'], function(e) {
87 window.location = pyroutes.url('gists_new');
87 window.location = pyroutes.url('gists_new');
88 });
88 });
89 Mousetrap.bind(['n r'], function(e) {
89 Mousetrap.bind(['n r'], function(e) {
90 window.location = pyroutes.url('repo_new');
90 window.location = pyroutes.url('repo_new');
91 });
91 });
92
92
93 if (repoName && repoName !== '') {
93 if (repoName && repoName !== '') {
94 // nav in repo context
94 // nav in repo context
95 Mousetrap.bind(['g s'], function(e) {
95 Mousetrap.bind(['g s'], function(e) {
96 window.location = pyroutes.url(
96 window.location = pyroutes.url(
97 'repo_summary', {'repo_name': repoName});
97 'repo_summary', {'repo_name': repoName});
98 });
98 });
99 Mousetrap.bind(['g c'], function(e) {
99 Mousetrap.bind(['g c'], function(e) {
100 window.location = pyroutes.url(
100 window.location = pyroutes.url(
101 'repo_commits', {'repo_name': repoName});
101 'repo_commits', {'repo_name': repoName});
102 });
102 });
103 Mousetrap.bind(['g F'], function(e) {
103 Mousetrap.bind(['g F'], function(e) {
104 window.location = pyroutes.url(
104 window.location = pyroutes.url(
105 'repo_files',
105 'repo_files',
106 {
106 {
107 'repo_name': repoName,
107 'repo_name': repoName,
108 'commit_id': repoLandingRev,
108 'commit_id': repoLandingRev,
109 'f_path': '',
109 'f_path': '',
110 'search': '1'
110 'search': '1'
111 });
111 });
112 });
112 });
113 Mousetrap.bind(['g f'], function(e) {
113 Mousetrap.bind(['g f'], function(e) {
114 window.location = pyroutes.url(
114 window.location = pyroutes.url(
115 'repo_files',
115 'repo_files',
116 {
116 {
117 'repo_name': repoName,
117 'repo_name': repoName,
118 'commit_id': repoLandingRev,
118 'commit_id': repoLandingRev,
119 'f_path': ''
119 'f_path': ''
120 });
120 });
121 });
121 });
122 Mousetrap.bind(['g p'], function(e) {
123 window.location = pyroutes.url(
124 'pullrequest_show_all', {'repo_name': repoName});
125 });
122 Mousetrap.bind(['g o'], function(e) {
126 Mousetrap.bind(['g o'], function(e) {
123 window.location = pyroutes.url(
127 window.location = pyroutes.url(
124 'edit_repo', {'repo_name': repoName});
128 'edit_repo', {'repo_name': repoName});
125 });
129 });
126 Mousetrap.bind(['g O'], function(e) {
130 Mousetrap.bind(['g O'], function(e) {
127 window.location = pyroutes.url(
131 window.location = pyroutes.url(
128 'edit_repo_perms', {'repo_name': repoName});
132 'edit_repo_perms', {'repo_name': repoName});
129 });
133 });
130 }
134 }
131 }
135 }
132
136
133 setRCMouseBindings(templateContext.repo_name, templateContext.repo_landing_commit);
137 setRCMouseBindings(templateContext.repo_name, templateContext.repo_landing_commit);
General Comments 0
You need to be logged in to leave comments. Login now