diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-04-18 22:20:15 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-04-18 22:20:15 +0300 |
commit | 4d1878253e228db55485dae9e4ad66aebe009040 (patch) | |
tree | e8d028a92bf61b9f13cab29c4e3cc3800e635954 /app/assets/javascripts/shortcuts_issuable.coffee | |
parent | 8e6fa2555ec37f010ac93b43816d8bcdb3ee835c (diff) |
Typo: Issueable -> Issuable
Diffstat (limited to 'app/assets/javascripts/shortcuts_issuable.coffee')
-rw-r--r-- | app/assets/javascripts/shortcuts_issuable.coffee | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/assets/javascripts/shortcuts_issuable.coffee b/app/assets/javascripts/shortcuts_issuable.coffee new file mode 100644 index 00000000000..6b534f29218 --- /dev/null +++ b/app/assets/javascripts/shortcuts_issuable.coffee @@ -0,0 +1,48 @@ +#= require jquery +#= require mousetrap + +#= require shortcuts_navigation + +class @ShortcutsIssuable extends ShortcutsNavigation + constructor: (isMergeRequest) -> + super() + Mousetrap.bind('a', -> + $('.js-assignee').select2('open') + return false + ) + Mousetrap.bind('m', -> + $('.js-milestone').select2('open') + return false + ) + Mousetrap.bind('r', => + @replyWithSelectedText() + return false + ) + + if isMergeRequest + @enabledHelp.push('.hidden-shortcut.merge_requests') + else + @enabledHelp.push('.hidden-shortcut.issues') + + replyWithSelectedText: -> + if window.getSelection + selected = window.getSelection().toString() + replyField = $('.js-main-target-form #note_note') + + return if selected.trim() == "" + + # Put a '>' character before each non-empty line in the selection + quote = _.map selected.split("\n"), (val) -> + "> #{val}\n" if val.trim() != '' + + # If replyField already has some content, add a newline before our quote + separator = replyField.val().trim() != "" and "\n" or '' + + replyField.val (_, current) -> + current + separator + quote.join('') + "\n" + + # Trigger autosave for the added text + replyField.trigger('input') + + # Focus the input field + replyField.focus() |