summaryrefslogtreecommitdiff
path: root/src/static
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2015-03-26 16:58:13 +0000
committerJohn McLear <john@mclear.co.uk>2015-03-26 16:58:13 +0000
commit19e83d54059df5a653d7f4f7fc9cd60bf012b1fb (patch)
treeed08c53b60ae1d9dfae512fb773faea8fc43280d /src/static
parent428b547d2450b9e7fbbf50a36f8fe06a75a0625e (diff)
downloadetherpad-lite-19e83d54059df5a653d7f4f7fc9cd60bf012b1fb.zip
much better chat focus toggle behavior
Diffstat (limited to 'src/static')
-rw-r--r--src/static/js/ace2_inner.js5
-rw-r--r--src/static/js/chat.js19
2 files changed, 20 insertions, 4 deletions
diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js
index cb09432b..5442dd08 100644
--- a/src/static/js/ace2_inner.js
+++ b/src/static/js/ace2_inner.js
@@ -3636,6 +3636,7 @@ function Ace2Inner(){
var charCode = evt.charCode;
var keyCode = evt.keyCode;
var which = evt.which;
+ var altKey = evt.altKey;
// prevent ESC key
if (keyCode == 27)
@@ -3718,11 +3719,11 @@ function Ace2Inner(){
firstEditbarElement.focus();
evt.preventDefault();
}
- if ((!specialHandled) && isTypeForSpecialKey && keyCode == 67){
+ if ((!specialHandled) && altKey && keyCode == 67){
// Alt c focuses on the Chat window
+ $(this).blur();
parent.parent.chat.show();
parent.parent.chat.focus();
- $(this).blur();
evt.preventDefault();
}
if ((!specialHandled) && isTypeForSpecialKey && keyCode == 8)
diff --git a/src/static/js/chat.js b/src/static/js/chat.js
index 021a906a..7edf73ba 100644
--- a/src/static/js/chat.js
+++ b/src/static/js/chat.js
@@ -18,6 +18,7 @@ var padutils = require('./pad_utils').padutils;
var padcookie = require('./pad_cookie').padcookie;
var Tinycon = require('tinycon/tinycon');
var hooks = require('./pluginfw/hooks');
+var padeditor = require('./pad_editor').padeditor;
var chat = (function()
{
@@ -38,7 +39,11 @@ var chat = (function()
},
focus: function ()
{
- $("#chatinput").focus();
+ // I'm not sure why we need a setTimeout here but without it we don't get focus...
+ // Animation maybe?
+ setTimeout(function(){
+ $("#chatinput").focus();
+ },100);
},
stickToScreen: function(fromInitialCall) // Make chat stick to right hand side of screen
{
@@ -209,8 +214,18 @@ var chat = (function()
init: function(pad)
{
this._pad = pad;
- $("#chatinput").keypress(function(evt)
+ $("#chatinput").keyup(function(evt)
{
+ // If the event is Alt C or Escape & we're already in the chat menu
+ // Send the users focus back to the pad
+ if((evt.altKey == true && evt.which === 67) || evt.which === 27){
+ // If we're in chat already..
+ $(':focus').blur(); // required to do not try to remove!
+ padeditor.ace.focus(); // Sends focus back to pad
+ }
+ });
+
+ $("#chatinput").keypress(function(evt){
//if the user typed enter, fire the send
if(evt.which == 13 || evt.which == 10)
{