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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
b76e971b
Commit
b76e971b
authored
Oct 13, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EE version of ph-shortcut-js-modules
parent
fa0b1253
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
242 additions
and
323 deletions
+242
-323
app/assets/javascripts/dispatcher.js
app/assets/javascripts/dispatcher.js
+4
-6
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-9
app/assets/javascripts/network/network_bundle.js
app/assets/javascripts/network/network_bundle.js
+1
-1
app/assets/javascripts/shortcuts.js
app/assets/javascripts/shortcuts.js
+106
-118
app/assets/javascripts/shortcuts_blob.js
app/assets/javascripts/shortcuts_blob.js
+1
-2
app/assets/javascripts/shortcuts_find_file.js
app/assets/javascripts/shortcuts_find_file.js
+24
-32
app/assets/javascripts/shortcuts_issuable.js
app/assets/javascripts/shortcuts_issuable.js
+65
-91
app/assets/javascripts/shortcuts_navigation.js
app/assets/javascripts/shortcuts_navigation.js
+21
-30
app/assets/javascripts/shortcuts_network.js
app/assets/javascripts/shortcuts_network.js
+13
-24
app/assets/javascripts/shortcuts_wiki.js
app/assets/javascripts/shortcuts_wiki.js
+1
-1
spec/javascripts/shortcuts_issuable_spec.js
spec/javascripts/shortcuts_issuable_spec.js
+1
-3
spec/javascripts/shortcuts_spec.js
spec/javascripts/shortcuts_spec.js
+5
-6
No files found.
app/assets/javascripts/dispatcher.js
View file @
b76e971b
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */
/* eslint-disable func-names, space-before-function-paren, no-var, prefer-arrow-callback, wrap-iife, no-shadow, consistent-return, one-var, one-var-declaration-per-line, camelcase, default-case, no-new, quotes, no-duplicate-case, no-case-declarations, no-fallthrough, max-len */
/* global ProjectSelect */
/* global ProjectSelect */
/* global ShortcutsNavigation */
/* global IssuableIndex */
/* global IssuableIndex */
/* global ShortcutsIssuable */
/* global Milestone */
/* global Milestone */
/* global IssuableForm */
/* global IssuableForm */
/* global LabelsSelect */
/* global LabelsSelect */
...
@@ -32,13 +30,9 @@ import CILintEditor from './ci_lint_editor';
...
@@ -32,13 +30,9 @@ import CILintEditor from './ci_lint_editor';
/* global ProjectImport */
/* global ProjectImport */
import
Labels
from
'
./labels
'
;
import
Labels
from
'
./labels
'
;
import
LabelManager
from
'
./label_manager
'
;
import
LabelManager
from
'
./label_manager
'
;
/* global Shortcuts */
/* global ShortcutsFindFile */
/* global Sidebar */
/* global Sidebar */
/* global WeightSelect */
/* global WeightSelect */
/* global AdminEmailSelect */
/* global AdminEmailSelect */
/* global ShortcutsWiki */
import
CommitsList
from
'
./commits
'
;
import
CommitsList
from
'
./commits
'
;
import
Issue
from
'
./issue
'
;
import
Issue
from
'
./issue
'
;
import
BindInOut
from
'
./behaviors/bind_in_out
'
;
import
BindInOut
from
'
./behaviors/bind_in_out
'
;
...
@@ -84,6 +78,10 @@ import initChangesDropdown from './init_changes_dropdown';
...
@@ -84,6 +78,10 @@ import initChangesDropdown from './init_changes_dropdown';
import
AbuseReports
from
'
./abuse_reports
'
;
import
AbuseReports
from
'
./abuse_reports
'
;
import
{
ajaxGet
,
convertPermissionToBoolean
}
from
'
./lib/utils/common_utils
'
;
import
{
ajaxGet
,
convertPermissionToBoolean
}
from
'
./lib/utils/common_utils
'
;
import
AjaxLoadingSpinner
from
'
./ajax_loading_spinner
'
;
import
AjaxLoadingSpinner
from
'
./ajax_loading_spinner
'
;
import
Shortcuts
from
'
./shortcuts
'
;
import
ShortcutsNavigation
from
'
./shortcuts_navigation
'
;
import
ShortcutsFindFile
from
'
./shortcuts_find_file
'
;
import
ShortcutsIssuable
from
'
./shortcuts_issuable
'
;
import
U2FAuthenticate
from
'
./u2f/authenticate
'
;
import
U2FAuthenticate
from
'
./u2f/authenticate
'
;
// EE-only
// EE-only
...
...
app/assets/javascripts/main.js
View file @
b76e971b
...
@@ -21,15 +21,6 @@ window._ = _;
...
@@ -21,15 +21,6 @@ window._ = _;
window
.
Dropzone
=
Dropzone
;
window
.
Dropzone
=
Dropzone
;
window
.
Sortable
=
Sortable
;
window
.
Sortable
=
Sortable
;
// shortcuts
import
'
./shortcuts
'
;
import
'
./shortcuts_blob
'
;
import
'
./shortcuts_dashboard_navigation
'
;
import
'
./shortcuts_navigation
'
;
import
'
./shortcuts_find_file
'
;
import
'
./shortcuts_issuable
'
;
import
'
./shortcuts_network
'
;
// templates
// templates
import
'
./templates/issuable_template_selector
'
;
import
'
./templates/issuable_template_selector
'
;
import
'
./templates/issuable_template_selectors
'
;
import
'
./templates/issuable_template_selectors
'
;
...
...
app/assets/javascripts/network/network_bundle.js
View file @
b76e971b
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, quotes, no-var, vars-on-top, camelcase, comma-dangle, consistent-return, max-len */
/* eslint-disable func-names, space-before-function-paren, prefer-arrow-callback, quotes, no-var, vars-on-top, camelcase, comma-dangle, consistent-return, max-len */
/* global ShortcutsNetwork */
import
ShortcutsNetwork
from
'
../shortcuts_network
'
;
import
Network
from
'
./network
'
;
import
Network
from
'
./network
'
;
$
(
function
()
{
$
(
function
()
{
...
...
app/assets/javascripts/shortcuts.js
View file @
b76e971b
/* 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 */
import
Cookies
from
'
js-cookie
'
;
import
Cookies
from
'
js-cookie
'
;
import
Mousetrap
from
'
mousetrap
'
;
import
Mousetrap
from
'
mousetrap
'
;
import
findAndFollowLink
from
'
./shortcuts_dashboard_navigation
'
;
import
findAndFollowLink
from
'
./shortcuts_dashboard_navigation
'
;
(
function
()
{
const
defaultStopCallback
=
Mousetrap
.
stopCallback
;
this
.
Shortcuts
=
(
function
()
{
Mousetrap
.
stopCallback
=
(
e
,
element
,
combo
)
=>
{
function
Shortcuts
(
skipResetBindings
)
{
if
([
'
ctrl+shift+p
'
,
'
command+shift+p
'
].
indexOf
(
combo
)
!==
-
1
)
{
this
.
onToggleHelp
=
this
.
onToggleHelp
.
bind
(
this
);
return
false
;
this
.
enabledHelp
=
[];
}
if
(
!
skipResetBindings
)
{
Mousetrap
.
reset
();
return
defaultStopCallback
(
e
,
element
,
combo
);
}
};
Mousetrap
.
bind
(
'
?
'
,
this
.
onToggleHelp
);
Mousetrap
.
bind
(
'
s
'
,
Shortcuts
.
focusSearch
);
export
default
class
Shortcuts
{
Mousetrap
.
bind
(
'
f
'
,
(
e
=>
this
.
focusFilter
(
e
)));
constructor
(
skipResetBindings
)
{
Mousetrap
.
bind
(
'
p b
'
,
this
.
onTogglePerfBar
);
this
.
onToggleHelp
=
this
.
onToggleHelp
.
bind
(
this
);
this
.
enabledHelp
=
[];
const
findFileURL
=
document
.
body
.
dataset
.
findFile
;
if
(
!
skipResetBindings
)
{
Mousetrap
.
reset
();
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
)
{
Mousetrap
.
bind
(
'
t
'
,
function
()
{
return
gl
.
utils
.
visitUrl
(
findFileURL
);
});
}
}
}
Mousetrap
.
bind
(
'
?
'
,
this
.
onToggleHelp
);
Mousetrap
.
bind
(
'
s
'
,
Shortcuts
.
focusSearch
);
Mousetrap
.
bind
(
'
f
'
,
this
.
focusFilter
.
bind
(
this
));
Mousetrap
.
bind
(
'
p b
'
,
Shortcuts
.
onTogglePerfBar
);
Shortcuts
.
prototype
.
onToggleHelp
=
function
(
e
)
{
const
findFileURL
=
document
.
body
.
dataset
.
findFile
;
e
.
preventDefault
();
return
Shortcuts
.
toggleHelp
(
this
.
enabledHelp
);
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
'
],
Shortcuts
.
toggleMarkdownPreview
);
Shortcuts
.
prototype
.
onTogglePerfBar
=
function
(
e
)
{
if
(
typeof
findFileURL
!==
'
undefined
'
&&
findFileURL
!==
null
)
{
Mousetrap
.
bind
(
'
t
'
,
()
=>
{
gl
.
utils
.
visitUrl
(
findFileURL
);
});
}
$
(
document
).
on
(
'
click.more_help
'
,
'
.js-more-help-button
'
,
function
clickMoreHelp
(
e
)
{
$
(
this
).
remove
();
$
(
'
.hidden-shortcut
'
).
show
();
e
.
preventDefault
();
e
.
preventDefault
();
const
performanceBarCookieName
=
'
perf_bar_enabled
'
;
});
if
(
Cookies
.
get
(
performanceBarCookieName
)
===
'
true
'
)
{
}
Cookies
.
remove
(
performanceBarCookieName
,
{
path
:
'
/
'
});
}
else
{
onToggleHelp
(
e
)
{
Cookies
.
set
(
performanceBarCookieName
,
'
true
'
,
{
path
:
'
/
'
});
e
.
preventDefault
();
}
Shortcuts
.
toggleHelp
(
this
.
enabledHelp
);
gl
.
utils
.
refreshCurrentPage
();
}
};
static
onTogglePerfBar
(
e
)
{
Shortcuts
.
prototype
.
toggleMarkdownPreview
=
function
(
e
)
{
e
.
preventDefault
();
// Check if short-cut was triggered while in Write Mode
const
performanceBarCookieName
=
'
perf_bar_enabled
'
;
const
$target
=
$
(
e
.
target
);
if
(
Cookies
.
get
(
performanceBarCookieName
)
===
'
true
'
)
{
const
$form
=
$target
.
closest
(
'
form
'
);
Cookies
.
remove
(
performanceBarCookieName
,
{
path
:
'
/
'
});
}
else
{
if
(
$target
.
hasClass
(
'
js-note-text
'
))
{
Cookies
.
set
(
performanceBarCookieName
,
'
true
'
,
{
path
:
'
/
'
});
$
(
'
.js-md-preview-button
'
,
$form
).
focus
();
}
}
gl
.
utils
.
refreshCurrentPage
();
return
$
(
document
).
triggerHandler
(
'
markdown-preview:toggle
'
,
[
e
]);
}
};
static
toggleMarkdownPreview
(
e
)
{
Shortcuts
.
toggleHelp
=
function
(
location
)
{
// Check if short-cut was triggered while in Write Mode
var
$modal
;
const
$target
=
$
(
e
.
target
);
$modal
=
$
(
'
#modal-shortcuts
'
);
const
$form
=
$target
.
closest
(
'
form
'
);
if
(
$modal
.
length
)
{
$modal
.
modal
(
'
toggle
'
);
if
(
$target
.
hasClass
(
'
js-note-text
'
))
{
return
;
$
(
'
.js-md-preview-button
'
,
$form
).
focus
();
}
}
return
$
.
ajax
({
$
(
document
).
triggerHandler
(
'
markdown-preview:toggle
'
,
[
e
]);
url
:
gon
.
shortcuts_path
,
}
dataType
:
'
script
'
,
success
:
function
(
e
)
{
static
toggleHelp
(
location
)
{
var
i
,
l
,
len
,
results
;
const
$modal
=
$
(
'
#modal-shortcuts
'
);
if
(
location
&&
location
.
length
>
0
)
{
results
=
[];
if
(
$modal
.
length
)
{
for
(
i
=
0
,
len
=
location
.
length
;
i
<
len
;
i
+=
1
)
{
$modal
.
modal
(
'
toggle
'
);
l
=
location
[
i
];
}
results
.
push
(
$
(
l
).
show
());
}
$
.
ajax
({
return
results
;
url
:
gon
.
shortcuts_path
,
}
else
{
dataType
:
'
script
'
,
$
(
'
.hidden-shortcut
'
).
show
();
success
()
{
return
$
(
'
.js-more-help-button
'
).
remove
();
if
(
location
&&
location
.
length
>
0
)
{
const
results
=
[];
for
(
let
i
=
0
,
len
=
location
.
length
;
i
<
len
;
i
+=
1
)
{
results
.
push
(
$
(
location
[
i
]).
show
());
}
}
return
results
;
}
}
});
};
$
(
'
.hidden-shortcut
'
).
show
();
return
$
(
'
.js-more-help-button
'
).
remove
();
Shortcuts
.
prototype
.
focusFilter
=
function
(
e
)
{
},
if
(
this
.
filterInput
==
null
)
{
});
this
.
filterInput
=
$
(
'
input[type=search]
'
,
'
.nav-controls
'
);
}
}
this
.
filterInput
.
focus
();
focusFilter
(
e
)
{
return
e
.
preventDefault
();
if
(
!
this
.
filterInput
)
{
};
this
.
filterInput
=
$
(
'
input[type=search]
'
,
'
.nav-controls
'
);
}
Shortcuts
.
focusSearch
=
function
(
e
)
{
this
.
filterInput
.
focus
();
$
(
'
#search
'
).
focus
();
e
.
preventDefault
();
return
e
.
preventDefault
();
}
};
static
focusSearch
(
e
)
{
return
Shortcuts
;
$
(
'
#search
'
).
focus
();
})();
e
.
preventDefault
();
}
$
(
document
).
on
(
'
click.more_help
'
,
'
.js-more-help-button
'
,
function
(
e
)
{
}
$
(
this
).
remove
();
$
(
'
.hidden-shortcut
'
).
show
();
return
e
.
preventDefault
();
});
Mousetrap
.
stopCallback
=
(
function
()
{
var
defaultStopCallback
;
defaultStopCallback
=
Mousetrap
.
stopCallback
;
return
function
(
e
,
element
,
combo
)
{
// allowed shortcuts if textarea, input, contenteditable are focused
if
([
'
ctrl+shift+p
'
,
'
command+shift+p
'
].
indexOf
(
combo
)
!==
-
1
)
{
return
false
;
}
else
{
return
defaultStopCallback
.
apply
(
this
,
arguments
);
}
};
})();
}).
call
(
window
);
app/assets/javascripts/shortcuts_blob.js
View file @
b76e971b
/* global Mousetrap */
/* global Mousetrap */
/* global Shortcuts */
import
'
./shortcuts
'
;
import
Shortcuts
from
'
./shortcuts
'
;
const
defaults
=
{
const
defaults
=
{
skipResetBindings
:
false
,
skipResetBindings
:
false
,
...
...
app/assets/javascripts/shortcuts_find_file.js
View file @
b76e971b
/* 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 */
/* global Mousetrap */
/* global Mousetrap */
/* global ShortcutsNavigation */
import
'
./shortcuts_navigation
'
;
import
ShortcutsNavigation
from
'
./shortcuts_navigation
'
;
(
function
()
{
export
default
class
ShortcutsFindFile
extends
ShortcutsNavigation
{
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
;
},
constructor
(
projectFindFile
)
{
hasProp
=
{}.
hasOwnProperty
;
super
()
;
this
.
ShortcutsFindFile
=
(
function
(
superClass
)
{
const
oldStopCallback
=
Mousetrap
.
stopCallback
;
extend
(
ShortcutsFindFile
,
superClass
)
;
this
.
projectFindFile
=
projectFindFile
;
function
ShortcutsFindFile
(
projectFindFile
)
{
Mousetrap
.
stopCallback
=
(
e
,
element
,
combo
)
=>
{
var
_oldStopCallback
;
if
(
this
.
projectFindFile
=
projectFindFile
;
element
===
this
.
projectFindFile
.
inputElement
[
0
]
&&
ShortcutsFindFile
.
__super__
.
constructor
.
call
(
this
);
(
combo
===
'
up
'
||
combo
===
'
down
'
||
combo
===
'
esc
'
||
combo
===
'
enter
'
)
_oldStopCallback
=
Mousetrap
.
stopCallback
;
)
{
Mousetrap
.
stopCallback
=
(
function
(
_this
)
{
// when press up/down key in textbox, cusor prevent to move to home/end
// override to fire shortcuts action when focus in textbox
event
.
preventDefault
();
return
function
(
event
,
element
,
combo
)
{
return
false
;
if
(
element
===
_this
.
projectFindFile
.
inputElement
[
0
]
&&
(
combo
===
'
up
'
||
combo
===
'
down
'
||
combo
===
'
esc
'
||
combo
===
'
enter
'
))
{
}
// when press up/down key in textbox, cusor prevent to move to home/end
event
.
preventDefault
();
return
false
;
}
return
_oldStopCallback
(
event
,
element
,
combo
);
};
})(
this
);
Mousetrap
.
bind
(
'
up
'
,
this
.
projectFindFile
.
selectRowUp
);
Mousetrap
.
bind
(
'
down
'
,
this
.
projectFindFile
.
selectRowDown
);
Mousetrap
.
bind
(
'
esc
'
,
this
.
projectFindFile
.
goToTree
);
Mousetrap
.
bind
(
'
enter
'
,
this
.
projectFindFile
.
goToBlob
);
}
return
ShortcutsFindFile
;
return
oldStopCallback
(
e
,
element
,
combo
);
})(
ShortcutsNavigation
);
};
}).
call
(
window
);
Mousetrap
.
bind
(
'
up
'
,
this
.
projectFindFile
.
selectRowUp
);
Mousetrap
.
bind
(
'
down
'
,
this
.
projectFindFile
.
selectRowDown
);
Mousetrap
.
bind
(
'
esc
'
,
this
.
projectFindFile
.
goToTree
);
Mousetrap
.
bind
(
'
enter
'
,
this
.
projectFindFile
.
goToBlob
);
}
}
app/assets/javascripts/shortcuts_issuable.js
View file @
b76e971b
/* eslint-disable func-names, space-before-function-paren, max-len, no-var, one-var, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, one-var-declaration-per-line, quotes, prefer-arrow-callback, consistent-return, prefer-template, no-mixed-operators */
/* global Mousetrap */
/* global Mousetrap */
/* global ShortcutsNavigation */
/* global sidebar */
/* global sidebar */
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
'
mousetrap
'
;
import
'
mousetrap
'
;
import
'
./shortcuts_navigation
'
;
import
ShortcutsNavigation
from
'
./shortcuts_navigation
'
;
(
function
()
{
export
default
class
ShortcutsIssuable
extends
ShortcutsNavigation
{
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
;
},
constructor
(
isMergeRequest
)
{
hasProp
=
{}.
hasOwnProperty
;
super
();
this
.
ShortcutsIssuable
=
(
function
(
superClass
)
{
this
.
$replyField
=
isMergeRequest
?
$
(
'
.js-main-target-form #note_note
'
)
:
$
(
'
.js-main-target-form .js-vue-comment-form
'
);
extend
(
ShortcutsIssuable
,
superClass
);
this
.
editBtn
=
document
.
querySelector
(
'
.issuable-edit
'
);
function
ShortcutsIssuable
(
isMergeRequest
)
{
Mousetrap
.
bind
(
'
a
'
,
()
=>
ShortcutsIssuable
.
openSidebarDropdown
(
'
assignee
'
));
ShortcutsIssuable
.
__super__
.
constructor
.
call
(
this
);
Mousetrap
.
bind
(
'
m
'
,
()
=>
ShortcutsIssuable
.
openSidebarDropdown
(
'
milestone
'
));
Mousetrap
.
bind
(
'
a
'
,
this
.
openSidebarDropdown
.
bind
(
this
,
'
assignee
'
));
Mousetrap
.
bind
(
'
l
'
,
()
=>
ShortcutsIssuable
.
openSidebarDropdown
(
'
labels
'
));
Mousetrap
.
bind
(
'
m
'
,
this
.
openSidebarDropdown
.
bind
(
this
,
'
milestone
'
));
Mousetrap
.
bind
(
'
r
'
,
this
.
replyWithSelectedText
.
bind
(
this
));
Mousetrap
.
bind
(
'
r
'
,
(
function
(
_this
)
{
Mousetrap
.
bind
(
'
e
'
,
this
.
editIssue
.
bind
(
this
));
return
function
()
{
_this
.
replyWithSelectedText
(
isMergeRequest
);
if
(
isMergeRequest
)
{
return
false
;
this
.
enabledHelp
.
push
(
'
.hidden-shortcut.merge_requests
'
);
};
}
else
{
})(
this
));
this
.
enabledHelp
.
push
(
'
.hidden-shortcut.issues
'
);
Mousetrap
.
bind
(
'
e
'
,
(
function
(
_this
)
{
return
function
()
{
_this
.
editIssue
();
return
false
;
};
})(
this
));
Mousetrap
.
bind
(
'
l
'
,
this
.
openSidebarDropdown
.
bind
(
this
,
'
labels
'
));
if
(
isMergeRequest
)
{
this
.
enabledHelp
.
push
(
'
.hidden-shortcut.merge_requests
'
);
}
else
{
this
.
enabledHelp
.
push
(
'
.hidden-shortcut.issues
'
);
}
}
}
}
replyWithSelectedText
()
{
const
documentFragment
=
window
.
gl
.
utils
.
getSelectedFragment
();
if
(
!
documentFragment
)
{
this
.
$replyField
.
focus
();
return
false
;
}
const
el
=
window
.
gl
.
CopyAsGFM
.
transformGFMSelection
(
documentFragment
.
cloneNode
(
true
));
const
selected
=
window
.
gl
.
CopyAsGFM
.
nodeToGFM
(
el
);
ShortcutsIssuable
.
prototype
.
replyWithSelectedText
=
function
(
isMergeRequest
)
{
if
(
selected
.
trim
()
===
''
)
{
var
quote
,
documentFragment
,
el
,
selected
,
separator
;
let
replyField
;
if
(
isMergeRequest
)
{
replyField
=
$
(
'
.js-main-target-form #note_note
'
);
}
else
{
replyField
=
$
(
'
.js-main-target-form .js-vue-comment-form
'
);
}
documentFragment
=
window
.
gl
.
utils
.
getSelectedFragment
();
if
(
!
documentFragment
)
{
replyField
.
focus
();
return
;
}
el
=
window
.
gl
.
CopyAsGFM
.
transformGFMSelection
(
documentFragment
.
cloneNode
(
true
));
selected
=
window
.
gl
.
CopyAsGFM
.
nodeToGFM
(
el
);
if
(
selected
.
trim
()
===
""
)
{
return
;
}
quote
=
_
.
map
(
selected
.
split
(
"
\n
"
),
function
(
val
)
{
return
(
"
>
"
+
val
).
trim
()
+
"
\n
"
;
});
// If replyField already has some content, add a newline before our quote
separator
=
replyField
.
val
().
trim
()
!==
""
&&
"
\n\n
"
||
''
;
replyField
.
val
(
function
(
a
,
current
)
{
return
current
+
separator
+
quote
.
join
(
''
)
+
"
\n
"
;
});
// Trigger autosave
replyField
.
trigger
(
'
input
'
).
trigger
(
'
change
'
);
// Trigger autosize
var
event
=
document
.
createEvent
(
'
Event
'
);
event
.
initEvent
(
'
autosize:update
'
,
true
,
false
);
replyField
.
get
(
0
).
dispatchEvent
(
event
);
// Focus the input field
return
replyField
.
focus
();
};
ShortcutsIssuable
.
prototype
.
editIssue
=
function
()
{
var
$editBtn
;
$editBtn
=
$
(
'
.issuable-edit
'
);
// Need to click the element as on issues, editing is inline
// on merge request, editing is on a different page
$editBtn
.
get
(
0
).
click
();
};
ShortcutsIssuable
.
prototype
.
openSidebarDropdown
=
function
(
name
)
{
sidebar
.
openDropdown
(
name
);
return
false
;
return
false
;
};
}
const
quote
=
_
.
map
(
selected
.
split
(
'
\n
'
),
val
=>
`
${(
`>
${
val
}
`
).
trim
()}
\n`
);
// If replyField already has some content, add a newline before our quote
const
separator
=
(
this
.
$replyField
.
val
().
trim
()
!==
''
&&
'
\n\n
'
)
||
''
;
this
.
$replyField
.
val
((
a
,
current
)
=>
`
${
current
}${
separator
}${
quote
.
join
(
''
)}
\n`
)
.
trigger
(
'
input
'
)
.
trigger
(
'
change
'
);
// Trigger autosize
const
event
=
document
.
createEvent
(
'
Event
'
);
event
.
initEvent
(
'
autosize:update
'
,
true
,
false
);
this
.
$replyField
.
get
(
0
).
dispatchEvent
(
event
);
// Focus the input field
this
.
$replyField
.
focus
();
return
false
;
}
editIssue
()
{
// Need to click the element as on issues, editing is inline
// on merge request, editing is on a different page
this
.
editBtn
.
click
();
return
false
;
}
return
ShortcutsIssuable
;
static
openSidebarDropdown
(
name
)
{
})(
ShortcutsNavigation
);
sidebar
.
openDropdown
(
name
);
}).
call
(
window
);
return
false
;
}
}
app/assets/javascripts/shortcuts_navigation.js
View file @
b76e971b
/* eslint-disable func-names, space-before-function-paren, max-len, no-var, one-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 Mousetrap */
/* global Shortcuts */
import
findAndFollowLink
from
'
./shortcuts_dashboard_navigation
'
;
import
findAndFollowLink
from
'
./shortcuts_dashboard_navigation
'
;
import
'
./shortcuts
'
;
import
Shortcuts
from
'
./shortcuts
'
;
(
function
()
{
export
default
class
ShortcutsNavigation
extends
Shortcuts
{
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
;
},
constructor
()
{
hasProp
=
{}.
hasOwnProperty
;
super
()
;
this
.
ShortcutsNavigation
=
(
function
(
superClass
)
{
Mousetrap
.
bind
(
'
g p
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-project
'
));
extend
(
ShortcutsNavigation
,
superClass
);
Mousetrap
.
bind
(
'
g e
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-project-activity
'
));
Mousetrap
.
bind
(
'
g f
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-tree
'
));
Mousetrap
.
bind
(
'
g c
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-commits
'
));
Mousetrap
.
bind
(
'
g j
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-builds
'
));
Mousetrap
.
bind
(
'
g n
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-network
'
));
Mousetrap
.
bind
(
'
g d
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-repository-charts
'
));
Mousetrap
.
bind
(
'
g i
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-issues
'
));
Mousetrap
.
bind
(
'
g b
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-issue-boards
'
));
Mousetrap
.
bind
(
'
g m
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-merge_requests
'
));
Mousetrap
.
bind
(
'
g t
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-todos
'
));
Mousetrap
.
bind
(
'
g w
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-wiki
'
));
Mousetrap
.
bind
(
'
g s
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-snippets
'
));
Mousetrap
.
bind
(
'
i
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-new-issue
'
));
function
ShortcutsNavigation
()
{
this
.
enabledHelp
.
push
(
'
.hidden-shortcut.project
'
);
ShortcutsNavigation
.
__super__
.
constructor
.
call
(
this
);
}
Mousetrap
.
bind
(
'
g p
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-project
'
));
}
Mousetrap
.
bind
(
'
g e
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-project-activity
'
));
Mousetrap
.
bind
(
'
g f
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-tree
'
));
Mousetrap
.
bind
(
'
g c
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-commits
'
));
Mousetrap
.
bind
(
'
g j
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-builds
'
));
Mousetrap
.
bind
(
'
g n
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-network
'
));
Mousetrap
.
bind
(
'
g d
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-repository-charts
'
));
Mousetrap
.
bind
(
'
g i
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-issues
'
));
Mousetrap
.
bind
(
'
g b
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-issue-boards
'
));
Mousetrap
.
bind
(
'
g m
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-merge_requests
'
));
Mousetrap
.
bind
(
'
g t
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-todos
'
));
Mousetrap
.
bind
(
'
g w
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-wiki
'
));
Mousetrap
.
bind
(
'
g s
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-snippets
'
));
Mousetrap
.
bind
(
'
i
'
,
()
=>
findAndFollowLink
(
'
.shortcuts-new-issue
'
));
this
.
enabledHelp
.
push
(
'
.hidden-shortcut.project
'
);
}
return
ShortcutsNavigation
;
})(
Shortcuts
);
}).
call
(
window
);
app/assets/javascripts/shortcuts_network.js
View file @
b76e971b
/* eslint-disable func-names, space-before-function-paren, max-len, no-var, one-var, no-restricted-syntax, vars-on-top, no-use-before-define, no-param-reassign, new-cap, no-underscore-dangle, wrap-iife, max-len */
/* global Mousetrap */
/* global Mousetrap */
/* global ShortcutsNavigation */
import
ShortcutsNavigation
from
'
./shortcuts_navigation
'
;
import
'
./shortcuts_navigation
'
;
export
default
class
ShortcutsNetwork
extends
ShortcutsNavigation
{
constructor
(
graph
)
{
super
();
(
function
()
{
Mousetrap
.
bind
([
'
left
'
,
'
h
'
],
graph
.
scrollLeft
);
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
;
},
Mousetrap
.
bind
([
'
right
'
,
'
l
'
],
graph
.
scrollRight
);
hasProp
=
{}.
hasOwnProperty
;
Mousetrap
.
bind
([
'
up
'
,
'
k
'
],
graph
.
scrollUp
);
Mousetrap
.
bind
([
'
down
'
,
'
j
'
],
graph
.
scrollDown
);
Mousetrap
.
bind
([
'
shift+up
'
,
'
shift+k
'
],
graph
.
scrollTop
);
Mousetrap
.
bind
([
'
shift+down
'
,
'
shift+j
'
],
graph
.
scrollBottom
);
this
.
ShortcutsNetwork
=
(
function
(
superClass
)
{
this
.
enabledHelp
.
push
(
'
.hidden-shortcut.network
'
);
extend
(
ShortcutsNetwork
,
superClass
);
}
}
function
ShortcutsNetwork
(
graph
)
{
this
.
graph
=
graph
;
ShortcutsNetwork
.
__super__
.
constructor
.
call
(
this
);
Mousetrap
.
bind
([
'
left
'
,
'
h
'
],
this
.
graph
.
scrollLeft
);
Mousetrap
.
bind
([
'
right
'
,
'
l
'
],
this
.
graph
.
scrollRight
);
Mousetrap
.
bind
([
'
up
'
,
'
k
'
],
this
.
graph
.
scrollUp
);
Mousetrap
.
bind
([
'
down
'
,
'
j
'
],
this
.
graph
.
scrollDown
);
Mousetrap
.
bind
([
'
shift+up
'
,
'
shift+k
'
],
this
.
graph
.
scrollTop
);
Mousetrap
.
bind
([
'
shift+down
'
,
'
shift+j
'
],
this
.
graph
.
scrollBottom
);
this
.
enabledHelp
.
push
(
'
.hidden-shortcut.network
'
);
}
return
ShortcutsNetwork
;
})(
ShortcutsNavigation
);
}).
call
(
window
);
app/assets/javascripts/shortcuts_wiki.js
View file @
b76e971b
/* eslint-disable class-methods-use-this */
/* eslint-disable class-methods-use-this */
/* global Mousetrap */
/* global Mousetrap */
/* global ShortcutsNavigation */
import
ShortcutsNavigation
from
'
./shortcuts_navigation
'
;
import
findAndFollowLink
from
'
./shortcuts_dashboard_navigation
'
;
import
findAndFollowLink
from
'
./shortcuts_dashboard_navigation
'
;
export
default
class
ShortcutsWiki
extends
ShortcutsNavigation
{
export
default
class
ShortcutsWiki
extends
ShortcutsNavigation
{
...
...
spec/javascripts/shortcuts_issuable_spec.js
View file @
b76e971b
/* global ShortcutsIssuable */
import
'
~/copy_as_gfm
'
;
import
'
~/copy_as_gfm
'
;
import
'
~/shortcuts_issuable
'
;
import
ShortcutsIssuable
from
'
~/shortcuts_issuable
'
;
describe
(
'
ShortcutsIssuable
'
,
()
=>
{
describe
(
'
ShortcutsIssuable
'
,
()
=>
{
const
fixtureName
=
'
merge_requests/diff_comment.html.raw
'
;
const
fixtureName
=
'
merge_requests/diff_comment.html.raw
'
;
...
...
spec/javascripts/shortcuts_spec.js
View file @
b76e971b
/* global Shortcuts */
import
Shortcuts
from
'
~/shortcuts
'
;
describe
(
'
Shortcuts
'
,
()
=>
{
describe
(
'
Shortcuts
'
,
()
=>
{
const
fixtureName
=
'
merge_requests/diff_comment.html.raw
'
;
const
fixtureName
=
'
merge_requests/diff_comment.html.raw
'
;
const
createEvent
=
(
type
,
target
)
=>
$
.
Event
(
type
,
{
const
createEvent
=
(
type
,
target
)
=>
$
.
Event
(
type
,
{
...
@@ -8,19 +9,17 @@ describe('Shortcuts', () => {
...
@@ -8,19 +9,17 @@ describe('Shortcuts', () => {
preloadFixtures
(
fixtureName
);
preloadFixtures
(
fixtureName
);
describe
(
'
toggleMarkdownPreview
'
,
()
=>
{
describe
(
'
toggleMarkdownPreview
'
,
()
=>
{
let
sc
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
loadFixtures
(
fixtureName
);
loadFixtures
(
fixtureName
);
spyOnEvent
(
'
.js-new-note-form .js-md-preview-button
'
,
'
focus
'
);
spyOnEvent
(
'
.js-new-note-form .js-md-preview-button
'
,
'
focus
'
);
spyOnEvent
(
'
.edit-note .js-md-preview-button
'
,
'
focus
'
);
spyOnEvent
(
'
.edit-note .js-md-preview-button
'
,
'
focus
'
);
sc
=
new
Shortcuts
();
new
Shortcuts
();
// eslint-disable-line no-new
});
});
it
(
'
focuses preview button in form
'
,
()
=>
{
it
(
'
focuses preview button in form
'
,
()
=>
{
sc
.
toggleMarkdownPreview
(
Shortcuts
.
toggleMarkdownPreview
(
createEvent
(
'
KeyboardEvent
'
,
document
.
querySelector
(
'
.js-new-note-form .js-note-text
'
),
createEvent
(
'
KeyboardEvent
'
,
document
.
querySelector
(
'
.js-new-note-form .js-note-text
'
),
));
));
...
@@ -31,7 +30,7 @@ describe('Shortcuts', () => {
...
@@ -31,7 +30,7 @@ describe('Shortcuts', () => {
document
.
querySelector
(
'
.js-note-edit
'
).
click
();
document
.
querySelector
(
'
.js-note-edit
'
).
click
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
sc
.
toggleMarkdownPreview
(
Shortcuts
.
toggleMarkdownPreview
(
createEvent
(
'
KeyboardEvent
'
,
document
.
querySelector
(
'
.edit-note .js-note-text
'
),
createEvent
(
'
KeyboardEvent
'
,
document
.
querySelector
(
'
.edit-note .js-note-text
'
),
));
));
...
...
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