From 66734193b00d94f02beeb99064fc169624c85d31 Mon Sep 17 00:00:00 2001 From: ix Date: Wed, 7 Jan 2015 19:58:43 +0100 Subject: [PATCH] pressing ctrl/meta + m toggles the question box --- app/assets/javascripts/application.js.erb.coffee | 2 +- app/assets/javascripts/questionbox/all.coffee | 8 ++++++-- app/views/layouts/_header.html.haml | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/application.js.erb.coffee b/app/assets/javascripts/application.js.erb.coffee index 8a479028..5842510d 100644 --- a/app/assets/javascripts/application.js.erb.coffee +++ b/app/assets/javascripts/application.js.erb.coffee @@ -30,4 +30,4 @@ _ready = -> sweetAlertInitialize() $(document).ready _ready -$(document).on 'page:load', _ready \ No newline at end of file +$(document).on 'page:load', _ready diff --git a/app/assets/javascripts/questionbox/all.coffee b/app/assets/javascripts/questionbox/all.coffee index 9178123b..c3bb88a7 100644 --- a/app/assets/javascripts/questionbox/all.coffee +++ b/app/assets/javascripts/questionbox/all.coffee @@ -22,8 +22,12 @@ $(document).on "click", "button[name=qb-all-ask]", -> btn.button "reset" $("textarea[name=qb-all-question]").removeAttr "readonly" +# hotkey for accessing this quickly +$(document).on "keydown", (evt) -> + if evt.keyCode == 77 and (evt.ctrlKey or evt.metaKey) + $('button[name=toggle-all-ask]').trigger 'click' # see GitHub issue #2 ($ document).on "keydown", "textarea[name=qb-all-question]", (evt) -> - if evt.keyCode == 13 and evt.ctrlKey - ($ "button[name=qb-all-ask]").trigger 'click' \ No newline at end of file + if evt.keyCode == 13 and (evt.ctrlKey or evt.metaKey) + ($ "button[name=qb-all-ask]").trigger 'click' diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 58c371a9..a3835231 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -25,7 +25,7 @@ = render "layouts/notifications" %ul.nav.navbar-nav.navbar-right %li - .btn.btn-primary.navbar-btn.btn-sm.hidden-xs{"data-target" => "#modal-ask-followers", "data-toggle" => "modal", :type => "button"} + .btn.btn-primary.navbar-btn.btn-sm.hidden-xs{name: "toggle-all-ask", "data-target" => "#modal-ask-followers", "data-toggle" => "modal", :type => "button"} %i.fa.fa-pencil-square-o %li.dropdown %a.dropdown-toggle{href: "#", "data-toggle" => "dropdown"}