BigW Consortium Gitlab

shortcuts_find_file.js.coffee 837 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#= require shortcuts_navigation

class @ShortcutsFindFile extends ShortcutsNavigation
  constructor: (@projectFindFile) ->
    super()
    _oldStopCallback = Mousetrap.stopCallback
    # override to fire shortcuts action when focus in textbox
    Mousetrap.stopCallback = (event, element, combo) =>
      if element == @projectFindFile.inputElement[0] and (combo == 'up' or combo == 'down' or combo == 'esc' or combo == 'enter')
        # when press up/down key in textbox, cusor prevent to move to home/end
        event.preventDefault()
        return false

      return _oldStopCallback(event, element, combo)

    Mousetrap.bind('up', @projectFindFile.selectRowUp)
    Mousetrap.bind('down', @projectFindFile.selectRowDown)
    Mousetrap.bind('esc', @projectFindFile.goToTree)
    Mousetrap.bind('enter', @projectFindFile.goToBlob)