debian-mirror-gitlab/app/assets/javascripts/shortcuts.js.coffee

31 lines
767 B
CoffeeScript
Raw Normal View History

2015-04-26 12:48:37 +05:30
class @Shortcuts
2014-09-02 18:07:02 +05:30
constructor: ->
2015-04-26 12:48:37 +05:30
@enabledHelp = []
Mousetrap.reset()
Mousetrap.bind('?', @selectiveHelp)
Mousetrap.bind('s', Shortcuts.focusSearch)
selectiveHelp: (e) =>
Shortcuts.showHelp(e, @enabledHelp)
@showHelp: (e, location) ->
2014-09-02 18:07:02 +05:30
if $('#modal-shortcuts').length > 0
$('#modal-shortcuts').modal('show')
else
$.ajax(
url: '/help/shortcuts',
2015-04-26 12:48:37 +05:30
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()
2014-09-02 18:07:02 +05:30
)
2015-04-26 12:48:37 +05:30
e.preventDefault()
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
@focusSearch: (e) ->
$('#search').focus()
e.preventDefault()