summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/shortcuts.js.coffee
diff options
context:
space:
mode:
authorRobert Schilling <rschilling@student.tugraz.at>2014-08-21 10:14:31 +0200
committerRobert Schilling <rschilling@student.tugraz.at>2014-09-01 11:49:17 +0200
commit0cbc19f9449ffc6e624c0b7e22ea837468658377 (patch)
treee48375611c09c38a14f45adecbe31309f308798b /app/assets/javascripts/shortcuts.js.coffee
parent174c00cf2c026a3bdc61d94b45195a5e5c99202f (diff)
downloadgitlab-ce-0cbc19f9449ffc6e624c0b7e22ea837468658377.tar.gz
Awesome shortcuts for GitLab
Diffstat (limited to 'app/assets/javascripts/shortcuts.js.coffee')
-rw-r--r--app/assets/javascripts/shortcuts.js.coffee25
1 files changed, 22 insertions, 3 deletions
diff --git a/app/assets/javascripts/shortcuts.js.coffee b/app/assets/javascripts/shortcuts.js.coffee
index e7e40a066ec..e9aeb1e9525 100644
--- a/app/assets/javascripts/shortcuts.js.coffee
+++ b/app/assets/javascripts/shortcuts.js.coffee
@@ -1,11 +1,30 @@
-class Shortcuts
+class @Shortcuts
constructor: ->
+ @enabledHelp = []
+ Mousetrap.reset()
+ Mousetrap.bind('?', @selectiveHelp)
+ Mousetrap.bind('s', Shortcuts.focusSearch)
+
+ selectiveHelp: (e) =>
+ Shortcuts.showHelp(e, @enabledHelp)
+
+ @showHelp: (e, location) ->
if $('#modal-shortcuts').length > 0
$('#modal-shortcuts').modal('show')
else
$.ajax(
url: '/help/shortcuts',
- dataType: "script"
+ dataType: 'script',
+ success: (e) ->
+ if location and location.length > 0
+ for l in location
+ $(l).show()
+ else
+ $('.hidden-shortcut').show()
+ $('.js-more-help-button').remove()
)
+ e.preventDefault()
-@Shortcuts = Shortcuts
+ @focusSearch: (e) ->
+ $('#search').focus()
+ e.preventDefault()