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
38000164
Commit
38000164
authored
Sep 13, 2018
by
Mike Greiling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move shortcuts instantiation into behaviors
parent
2aa29872
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
32 deletions
+37
-32
app/assets/javascripts/behaviors/index.js
app/assets/javascripts/behaviors/index.js
+2
-0
app/assets/javascripts/behaviors/shortcuts.js
app/assets/javascripts/behaviors/shortcuts.js
+35
-0
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+0
-32
No files found.
app/assets/javascripts/behaviors/index.js
View file @
38000164
...
...
@@ -7,9 +7,11 @@ import './details_behavior';
import
installGlEmojiElement
from
'
./gl_emoji
'
;
import
'
./quick_submit
'
;
import
'
./requires_input
'
;
import
initPageShortcuts
from
'
./shortcuts
'
;
import
'
./toggler_behavior
'
;
import
'
./preview_markdown
'
;
installGlEmojiElement
();
initCopyAsGFM
();
initCopyToClipboard
();
initPageShortcuts
();
app/assets/javascripts/behaviors/shortcuts.js
0 → 100644
View file @
38000164
import
Shortcuts
from
'
../shortcuts
'
;
export
default
function
initPageShortcuts
()
{
const
{
page
}
=
document
.
body
.
dataset
;
const
pagesWithCustomShortcuts
=
[
'
projects:activity
'
,
'
projects:artifacts:browse
'
,
'
projects:artifacts:file
'
,
'
projects:blame:show
'
,
'
projects:blob:show
'
,
'
projects:commit:show
'
,
'
projects:commits:show
'
,
'
projects:find_file:show
'
,
'
projects:issues:edit
'
,
'
projects:issues:index
'
,
'
projects:issues:new
'
,
'
projects:issues:show
'
,
'
projects:merge_requests:creations:diffs
'
,
'
projects:merge_requests:creations:new
'
,
'
projects:merge_requests:edit
'
,
'
projects:merge_requests:index
'
,
'
projects:merge_requests:show
'
,
'
projects:network:show
'
,
'
projects:show
'
,
'
projects:tree:show
'
,
'
groups:show
'
,
];
// the pages above have their own shortcuts sub-classes instantiated elsewhere
// TODO: replace this whitelist with something more automated/maintainable
if
(
page
&&
!
pagesWithCustomShortcuts
.
includes
(
page
))
{
return
new
Shortcuts
();
}
return
false
;
}
app/assets/javascripts/dispatcher.js
View file @
38000164
...
...
@@ -3,37 +3,6 @@
import
$
from
'
jquery
'
;
import
GfmAutoComplete
from
'
./gfm_auto_complete
'
;
import
{
convertPermissionToBoolean
}
from
'
./lib/utils/common_utils
'
;
import
Shortcuts
from
'
./shortcuts
'
;
function
initPageShortcuts
(
page
)
{
const
pagesWithCustomShortcuts
=
[
'
projects:activity
'
,
'
projects:artifacts:browse
'
,
'
projects:artifacts:file
'
,
'
projects:blame:show
'
,
'
projects:blob:show
'
,
'
projects:commit:show
'
,
'
projects:commits:show
'
,
'
projects:find_file:show
'
,
'
projects:issues:edit
'
,
'
projects:issues:index
'
,
'
projects:issues:new
'
,
'
projects:issues:show
'
,
'
projects:merge_requests:creations:diffs
'
,
'
projects:merge_requests:creations:new
'
,
'
projects:merge_requests:edit
'
,
'
projects:merge_requests:index
'
,
'
projects:merge_requests:show
'
,
'
projects:network:show
'
,
'
projects:show
'
,
'
projects:tree:show
'
,
'
groups:show
'
,
];
if
(
pagesWithCustomShortcuts
.
indexOf
(
page
)
===
-
1
)
{
new
Shortcuts
();
}
}
function
initGFMInput
()
{
$
(
'
.js-gfm-input:not(.js-vue-textarea)
'
).
each
((
i
,
el
)
=>
{
...
...
@@ -57,7 +26,6 @@ function initGFMInput() {
export
default
()
=>
{
const
page
=
$
(
'
body
'
).
attr
(
'
data-page
'
);
if
(
page
)
{
initPageShortcuts
(
page
);
initGFMInput
();
}
};
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