Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e9025c25
Commit
e9025c25
authored
Mar 30, 2017
by
Filipa Lacerda
Committed by
Jacob Schatz
Apr 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve shortcuts code
parent
d9ed9c6d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
64 deletions
+27
-64
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+0
-2
app/assets/javascripts/shortcuts.js
app/assets/javascripts/shortcuts.js
+15
-34
app/assets/javascripts/shortcuts_dashboard_navigation.js
app/assets/javascripts/shortcuts_dashboard_navigation.js
+12
-28
No files found.
app/assets/javascripts/dispatcher.js
View file @
e9025c25
...
...
@@ -24,7 +24,6 @@
/* global Search */
/* global Admin */
/* global NamespaceSelects */
/* global ShortcutsDashboardNavigation */
/* global Project */
/* global ProjectAvatar */
/* global CompareAutocomplete */
...
...
@@ -378,7 +377,6 @@ const ShortcutsBlob = require('./shortcuts_blob');
break
;
case
'
dashboard
'
:
case
'
root
'
:
shortcut_handler
=
new
ShortcutsDashboardNavigation
();
new
UserCallout
();
break
;
case
'
groups
'
:
...
...
app/assets/javascripts/shortcuts.js
View file @
e9025c25
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-rest-params, wrap-iife, quotes, prefer-arrow-callback, consistent-return, object-shorthand, no-unused-vars, one-var, one-var-declaration-per-line, no-else-return, comma-dangle, max-len */
/* global Mousetrap
, ShortcutsDashboardNavigation
*/
/* global Mousetrap */
/* global findFileURL */
import
findAndFollowLink
from
'
./shortcuts_dashboard_navigation
'
;
(
function
()
{
var
bind
=
function
(
fn
,
me
)
{
return
function
()
{
return
fn
.
apply
(
me
,
arguments
);
};
};
...
...
@@ -14,47 +15,27 @@
}
Mousetrap
.
bind
(
'
?
'
,
this
.
onToggleHelp
);
Mousetrap
.
bind
(
'
s
'
,
Shortcuts
.
focusSearch
);
Mousetrap
.
bind
(
'
f
'
,
(
function
(
_this
)
{
return
function
(
e
)
{
return
_this
.
focusFilter
(
e
);
};
})(
this
));
Mousetrap
.
bind
(
'
f
'
,
(
e
=>
this
.
focusFilter
(
e
)));
const
globalDropdownMenu
=
$
(
'
.global-dropdown-menu
'
);
$
(
'
.global-dropdown
'
).
on
(
'
hide.bs.dropdown
'
,
function
()
{
globalDropdownMenu
.
remov
eClass
(
'
shortcuts
'
);
$
(
'
.global-dropdown
'
).
on
(
'
hide.bs.dropdown
'
,
()
=>
{
globalDropdownMenu
.
toggl
eClass
(
'
shortcuts
'
);
});
Mousetrap
.
bind
(
'
n
'
,
function
()
{
globalDropdownMenu
.
add
Class
(
'
shortcuts
'
);
Mousetrap
.
bind
(
'
n
'
,
()
=>
{
globalDropdownMenu
.
toggle
Class
(
'
shortcuts
'
);
$
(
'
.global-dropdown-toggle
'
).
trigger
(
'
click
'
);
});
Mousetrap
.
bind
(
'
shift+t
'
,
function
()
{
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.shortcuts-todos
'
);
});
Mousetrap
.
bind
(
'
shift+a
'
,
function
()
{
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.dashboard-shortcuts-activity
'
);
});
Mousetrap
.
bind
(
'
shift+i
'
,
function
()
{
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.dashboard-shortcuts-issues
'
);
});
Mousetrap
.
bind
(
'
shift+m
'
,
function
()
{
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.dashboard-shortcuts-merge_requests
'
);
});
Mousetrap
.
bind
(
'
shift+p
'
,
function
()
{
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.dashboard-shortcuts-projects
'
);
});
Mousetrap
.
bind
(
'
shift+g
'
,
function
()
{
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.dashboard-shortcuts-groups
'
);
});
Mousetrap
.
bind
(
'
shift+l
'
,
function
()
{
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.dashboard-shortcuts-milestones
'
);
});
Mousetrap
.
bind
(
'
shift+s
'
,
function
()
{
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.dashboard-shortcuts-snippets
'
);
});
Mousetrap
.
bind
(
'
shift+t
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-todos
'
));
Mousetrap
.
bind
(
'
shift+a
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-activity
'
));
Mousetrap
.
bind
(
'
shift+i
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-issues
'
));
Mousetrap
.
bind
(
'
shift+m
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-merge_requests
'
));
Mousetrap
.
bind
(
'
shift+p
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-projects
'
));
Mousetrap
.
bind
(
'
shift+g
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-groups
'
));
Mousetrap
.
bind
(
'
shift+l
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-milestones
'
));
Mousetrap
.
bind
(
'
shift+s
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-snippets
'
));
Mousetrap
.
bind
([
'
ctrl+shift+p
'
,
'
command+shift+p
'
],
this
.
toggleMarkdownPreview
);
if
(
typeof
findFileURL
!==
"
undefined
"
&&
findFileURL
!==
null
)
{
...
...
app/assets/javascripts/shortcuts_dashboard_navigation.js
View file @
e9025c25
/* eslint-disable func-names, space-before-function-paren, max-len, one-var, no-var, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, prefer-arrow-callback, consistent-return, no-return-assign */
/* global Mousetrap */
/* global Shortcuts */
require
(
'
./shortcuts
'
);
(
function
()
{
var
extend
=
function
(
child
,
parent
)
{
for
(
var
key
in
parent
)
{
if
(
hasProp
.
call
(
parent
,
key
))
child
[
key
]
=
parent
[
key
];
}
function
ctor
()
{
this
.
constructor
=
child
;
}
ctor
.
prototype
=
parent
.
prototype
;
child
.
prototype
=
new
ctor
();
child
.
__super__
=
parent
.
prototype
;
return
child
;
},
hasProp
=
{}.
hasOwnProperty
;
this
.
ShortcutsDashboardNavigation
=
(
function
(
superClass
)
{
extend
(
ShortcutsDashboardNavigation
,
superClass
);
function
ShortcutsDashboardNavigation
()
{
ShortcutsDashboardNavigation
.
__super__
.
constructor
.
call
(
this
);
}
ShortcutsDashboardNavigation
.
findAndFollowLink
=
function
(
selector
)
{
var
link
;
link
=
$
(
selector
).
attr
(
'
href
'
);
if
(
link
)
{
return
window
.
location
=
link
;
}
};
return
ShortcutsDashboardNavigation
;
})(
Shortcuts
);
}).
call
(
window
);
/**
* Helper function that finds the href of the fiven selector and updates the location.
*
* @param {String} selector
*/
export
default
(
selector
)
=>
{
const
link
=
document
.
querySelector
(
selector
).
getAttribute
(
'
href
'
);
if
(
link
)
{
window
.
location
=
link
;
}
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment