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