gitlab-org--gitlab-foss/app/assets/javascripts/shortcuts.js.coffee

31 lines
767 B
CoffeeScript
Raw Normal View History

2014-08-21 04:14:31 -04:00
class @Shortcuts
2013-06-30 15:10:52 -04:00
constructor: ->
2014-08-21 04:14:31 -04:00
@enabledHelp = []
Mousetrap.reset()
Mousetrap.bind('?', @selectiveHelp)
Mousetrap.bind('s', Shortcuts.focusSearch)
selectiveHelp: (e) =>
Shortcuts.showHelp(e, @enabledHelp)
@showHelp: (e, location) ->
2013-06-30 15:10:52 -04:00
if $('#modal-shortcuts').length > 0
$('#modal-shortcuts').modal('show')
else
$.ajax(
url: '/help/shortcuts',
2014-08-21 04:14:31 -04:00
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()
2013-06-30 15:10:52 -04:00
)
2014-08-21 04:14:31 -04:00
e.preventDefault()
2013-06-30 15:10:52 -04:00
2014-08-21 04:14:31 -04:00
@focusSearch: (e) ->
$('#search').focus()
e.preventDefault()