diff options
-rw-r--r-- | app/assets/javascripts/main.js.coffee | 3 | ||||
-rw-r--r-- | app/assets/javascripts/shortcuts.js.coffee | 11 | ||||
-rw-r--r-- | app/controllers/help_controller.rb | 3 | ||||
-rw-r--r-- | app/views/help/_shortcuts.html.haml | 14 | ||||
-rw-r--r-- | app/views/help/shortcuts.js.haml | 3 | ||||
-rw-r--r-- | app/views/layouts/_head_panel.html.haml | 1 | ||||
-rw-r--r-- | config/routes.rb | 1 |
7 files changed, 35 insertions, 1 deletions
diff --git a/app/assets/javascripts/main.js.coffee b/app/assets/javascripts/main.js.coffee index b96ef65af93..cb9678d4839 100644 --- a/app/assets/javascripts/main.js.coffee +++ b/app/assets/javascripts/main.js.coffee @@ -67,6 +67,9 @@ $ -> $('.appear-data').fadeIn() e.preventDefault() + $('body').keydown (e) -> + if e.which is 191 + new Shortcuts() # Initialize chosen selects $('select.chosen').chosen() diff --git a/app/assets/javascripts/shortcuts.js.coffee b/app/assets/javascripts/shortcuts.js.coffee new file mode 100644 index 00000000000..e7e40a066ec --- /dev/null +++ b/app/assets/javascripts/shortcuts.js.coffee @@ -0,0 +1,11 @@ +class Shortcuts + constructor: -> + if $('#modal-shortcuts').length > 0 + $('#modal-shortcuts').modal('show') + else + $.ajax( + url: '/help/shortcuts', + dataType: "script" + ) + +@Shortcuts = Shortcuts diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 2958367e0f8..051cbdfaf05 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -12,4 +12,7 @@ class HelpController < ApplicationController not_found! end end + + def shortcuts + end end diff --git a/app/views/help/_shortcuts.html.haml b/app/views/help/_shortcuts.html.haml new file mode 100644 index 00000000000..7cbe5fc45ff --- /dev/null +++ b/app/views/help/_shortcuts.html.haml @@ -0,0 +1,14 @@ +#modal-shortcuts.modal.hide + .modal-header + %a.close{href: "#"} × + %h3 Keyboard Shortcuts + .modal-body + %h5 Global Shortcuts + %p + %span.label.label-inverse s + – + Focus Search + %p + %span.label.label-inverse ? + – + Show this dialog diff --git a/app/views/help/shortcuts.js.haml b/app/views/help/shortcuts.js.haml new file mode 100644 index 00000000000..99ed042ea3b --- /dev/null +++ b/app/views/help/shortcuts.js.haml @@ -0,0 +1,3 @@ +:plain + $("body").append("#{escape_javascript(render('shortcuts'))}"); + $("#modal-shortcuts").modal(); diff --git a/app/views/layouts/_head_panel.html.haml b/app/views/layouts/_head_panel.html.haml index e59528897d1..2fbac5fff37 100644 --- a/app/views/layouts/_head_panel.html.haml +++ b/app/views/layouts/_head_panel.html.haml @@ -38,4 +38,3 @@ %li = link_to current_user, class: "profile-pic", id: 'profile-pic' do = image_tag gravatar_icon(current_user.email, 26) - diff --git a/config/routes.rb b/config/routes.rb index 0e6454f00e7..4e0c010840f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -38,6 +38,7 @@ Gitlab::Application.routes.draw do get 'help/system_hooks' => 'help#system_hooks' get 'help/web_hooks' => 'help#web_hooks' get 'help/workflow' => 'help#workflow' + get 'help/shortcuts' # # Global snippets |