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

35 lines
881 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)
2015-04-26 12:48:37 +05:30
@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
$(l).show() for l in location
2015-04-26 12:48:37 +05:30
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()
$(document).on 'click.more_help', '.js-more-help-button', (e) ->
$(@).remove()
$('.hidden-shortcut').show()
e.preventDefault()