Commit 6e550af150958d0c88bf21f206c2309dc0b5c78d

Authored by Dmitriy Zaporozhets
1 parent 0f84833c

Show shotcut dialog on ?

app/assets/javascripts/main.js.coffee
... ... @@ -67,6 +67,9 @@ $ ->
67 67 $('.appear-data').fadeIn()
68 68 e.preventDefault()
69 69  
  70 + $('body').keydown (e) ->
  71 + if e.which is 191
  72 + new Shortcuts()
70 73  
71 74 # Initialize chosen selects
72 75 $('select.chosen').chosen()
... ...
app/assets/javascripts/shortcuts.js.coffee 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +class Shortcuts
  2 + constructor: ->
  3 + if $('#modal-shortcuts').length > 0
  4 + $('#modal-shortcuts').modal('show')
  5 + else
  6 + $.ajax(
  7 + url: '/help/shortcuts',
  8 + dataType: "script"
  9 + )
  10 +
  11 +@Shortcuts = Shortcuts
... ...
app/controllers/help_controller.rb
... ... @@ -12,4 +12,7 @@ class HelpController < ApplicationController
12 12 not_found!
13 13 end
14 14 end
  15 +
  16 + def shortcuts
  17 + end
15 18 end
... ...
app/views/help/_shortcuts.html.haml 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +#modal-shortcuts.modal.hide
  2 + .modal-header
  3 + %a.close{href: "#"} ×
  4 + %h3 Keyboard Shortcuts
  5 + .modal-body
  6 + %h5 Global Shortcuts
  7 + %p
  8 + %span.label.label-inverse s
  9 + –
  10 + Focus Search
  11 + %p
  12 + %span.label.label-inverse ?
  13 + –
  14 + Show this dialog
... ...
app/views/help/shortcuts.js.haml 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +:plain
  2 + $("body").append("#{escape_javascript(render('shortcuts'))}");
  3 + $("#modal-shortcuts").modal();
... ...
app/views/layouts/_head_panel.html.haml
... ... @@ -38,4 +38,3 @@
38 38 %li
39 39 = link_to current_user, class: "profile-pic", id: 'profile-pic' do
40 40 = image_tag gravatar_icon(current_user.email, 26)
41   -
... ...
config/routes.rb
... ... @@ -38,6 +38,7 @@ Gitlab::Application.routes.draw do
38 38 get 'help/system_hooks' => 'help#system_hooks'
39 39 get 'help/web_hooks' => 'help#web_hooks'
40 40 get 'help/workflow' => 'help#workflow'
  41 + get 'help/shortcuts'
41 42  
42 43 #
43 44 # Global snippets
... ...