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 @@
...
@@ -24,7 +24,6 @@
/* global Search */
/* global Search */
/* global Admin */
/* global Admin */
/* global NamespaceSelects */
/* global NamespaceSelects */
/* global ShortcutsDashboardNavigation */
/* global Project */
/* global Project */
/* global ProjectAvatar */
/* global ProjectAvatar */
/* global CompareAutocomplete */
/* global CompareAutocomplete */
...
@@ -378,7 +377,6 @@ const ShortcutsBlob = require('./shortcuts_blob');
...
@@ -378,7 +377,6 @@ const ShortcutsBlob = require('./shortcuts_blob');
break
;
break
;
case
'
dashboard
'
:
case
'
dashboard
'
:
case
'
root
'
:
case
'
root
'
:
shortcut_handler
=
new
ShortcutsDashboardNavigation
();
new
UserCallout
();
new
UserCallout
();
break
;
break
;
case
'
groups
'
:
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 */
/* 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 */
/* global findFileURL */
import
findAndFollowLink
from
'
./shortcuts_dashboard_navigation
'
;
(
function
()
{
(
function
()
{
var
bind
=
function
(
fn
,
me
)
{
return
function
()
{
return
fn
.
apply
(
me
,
arguments
);
};
};
var
bind
=
function
(
fn
,
me
)
{
return
function
()
{
return
fn
.
apply
(
me
,
arguments
);
};
};
...
@@ -14,47 +15,27 @@
...
@@ -14,47 +15,27 @@
}
}
Mousetrap
.
bind
(
'
?
'
,
this
.
onToggleHelp
);
Mousetrap
.
bind
(
'
?
'
,
this
.
onToggleHelp
);
Mousetrap
.
bind
(
'
s
'
,
Shortcuts
.
focusSearch
);
Mousetrap
.
bind
(
'
s
'
,
Shortcuts
.
focusSearch
);
Mousetrap
.
bind
(
'
f
'
,
(
function
(
_this
)
{
Mousetrap
.
bind
(
'
f
'
,
(
e
=>
this
.
focusFilter
(
e
)));
return
function
(
e
)
{
return
_this
.
focusFilter
(
e
);
};
})(
this
));
const
globalDropdownMenu
=
$
(
'
.global-dropdown-menu
'
);
const
globalDropdownMenu
=
$
(
'
.global-dropdown-menu
'
);
$
(
'
.global-dropdown
'
).
on
(
'
hide.bs.dropdown
'
,
function
()
{
$
(
'
.global-dropdown
'
).
on
(
'
hide.bs.dropdown
'
,
()
=>
{
globalDropdownMenu
.
remov
eClass
(
'
shortcuts
'
);
globalDropdownMenu
.
toggl
eClass
(
'
shortcuts
'
);
});
});
Mousetrap
.
bind
(
'
n
'
,
function
()
{
Mousetrap
.
bind
(
'
n
'
,
()
=>
{
globalDropdownMenu
.
add
Class
(
'
shortcuts
'
);
globalDropdownMenu
.
toggle
Class
(
'
shortcuts
'
);
$
(
'
.global-dropdown-toggle
'
).
trigger
(
'
click
'
);
$
(
'
.global-dropdown-toggle
'
).
trigger
(
'
click
'
);
});
});
Mousetrap
.
bind
(
'
shift+t
'
,
function
()
{
Mousetrap
.
bind
(
'
shift+t
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-todos
'
));
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.shortcuts-todos
'
);
Mousetrap
.
bind
(
'
shift+a
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-activity
'
));
});
Mousetrap
.
bind
(
'
shift+i
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-issues
'
));
Mousetrap
.
bind
(
'
shift+a
'
,
function
()
{
Mousetrap
.
bind
(
'
shift+m
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-merge_requests
'
));
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.dashboard-shortcuts-activity
'
);
Mousetrap
.
bind
(
'
shift+p
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-projects
'
));
});
Mousetrap
.
bind
(
'
shift+g
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-groups
'
));
Mousetrap
.
bind
(
'
shift+i
'
,
function
()
{
Mousetrap
.
bind
(
'
shift+l
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-milestones
'
));
return
ShortcutsDashboardNavigation
.
findAndFollowLink
(
'
.dashboard-shortcuts-issues
'
);
Mousetrap
.
bind
(
'
shift+s
'
,
()
=>
findAndFollowLink
(
'
.dashboard-shortcuts-snippets
'
));
});
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
([
'
ctrl+shift+p
'
,
'
command+shift+p
'
],
this
.
toggleMarkdownPreview
);
Mousetrap
.
bind
([
'
ctrl+shift+p
'
,
'
command+shift+p
'
],
this
.
toggleMarkdownPreview
);
if
(
typeof
findFileURL
!==
"
undefined
"
&&
findFileURL
!==
null
)
{
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 */
* Helper function that finds the href of the fiven selector and updates the location.
/* global Shortcuts */
*
* @param {String} selector
require
(
'
./shortcuts
'
);
*/
export
default
(
selector
)
=>
{
(
function
()
{
const
link
=
document
.
querySelector
(
selector
).
getAttribute
(
'
href
'
);
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
;
if
(
link
)
{
window
.
location
=
link
;
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
);
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