Welcome to mirror list, hosted at ThFree Co, Russian Federation.

shortcuts.js.coffee « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e9aeb1e9525ccd00e733b625178e5b2fcb8fa84a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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',
        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()

  @focusSearch: (e) ->
    $('#search').focus()
    e.preventDefault()