Commit 91de6e25 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Toggle help modal

parent 7f153077
...@@ -2,21 +2,25 @@ class @Shortcuts ...@@ -2,21 +2,25 @@ class @Shortcuts
constructor: -> constructor: ->
@enabledHelp = [] @enabledHelp = []
Mousetrap.reset() Mousetrap.reset()
Mousetrap.bind('?', @selectiveHelp) Mousetrap.bind('?', @onToggleHelp)
Mousetrap.bind('s', Shortcuts.focusSearch) Mousetrap.bind('s', Shortcuts.focusSearch)
Mousetrap.bind(['ctrl+shift+p', 'command+shift+p'], @toggleMarkdownPreview) Mousetrap.bind(['ctrl+shift+p', 'command+shift+p'], @toggleMarkdownPreview)
Mousetrap.bind('t', -> Turbolinks.visit(findFileURL)) if findFileURL? Mousetrap.bind('t', -> Turbolinks.visit(findFileURL)) if findFileURL?
selectiveHelp: (e) => onToggleHelp: (e) =>
Shortcuts.showHelp(e, @enabledHelp) e.preventDefault()
@toggleHelp(@enabledHelp)
toggleMarkdownPreview: (e) => toggleMarkdownPreview: (e) =>
$(document).triggerHandler('markdown-preview:toggle', [e]) $(document).triggerHandler('markdown-preview:toggle', [e])
@showHelp: (e, location) -> toggleHelp: (location) ->
if $('#modal-shortcuts').length > 0 $modal = $('#modal-shortcuts')
$('#modal-shortcuts').modal('show')
else if $modal.length
$modal.modal('toggle')
return
url = '/help/shortcuts' url = '/help/shortcuts'
url = gon.relative_url_root + url if gon.relative_url_root? url = gon.relative_url_root + url if gon.relative_url_root?
$.ajax( $.ajax(
...@@ -29,7 +33,6 @@ class @Shortcuts ...@@ -29,7 +33,6 @@ class @Shortcuts
$('.hidden-shortcut').show() $('.hidden-shortcut').show()
$('.js-more-help-button').remove() $('.js-more-help-button').remove()
) )
e.preventDefault()
@focusSearch: (e) -> @focusSearch: (e) ->
$('#search').focus() $('#search').focus()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment