From c903cb3925be5be7c08ac5ba558d2f873cdf1116 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 6 May 2015 00:32:36 +0100 Subject: [PATCH 1/2] fix alt c and escape --- src/static/js/ace2_inner.js | 5 +++-- src/static/js/chat.js | 13 ++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index d3cc4fd3..da249c92 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -3640,6 +3640,7 @@ function Ace2Inner(){ }else{ var lineHeight = myselection.focusNode.offsetHeight; // line height of blank lines } + var heightOfChatIcon = parent.parent.$('#chaticon').height(); // height of the chat icon button lineHeight = (lineHeight *2) + heightOfChatIcon; var viewport = getViewPortTopBottom(); @@ -3704,11 +3705,11 @@ function Ace2Inner(){ firstEditbarElement.focus(); evt.preventDefault(); } - if ((!specialHandled) && altKey && keyCode == 67){ + if ((!specialHandled) && altKey && keyCode == 67 && type === "keydown"){ // Alt c focuses on the Chat window $(this).blur(); parent.parent.chat.show(); - parent.parent.chat.focus(); + parent.parent.$("#chatinput").focus(); evt.preventDefault(); } if ((!specialHandled) && evt.ctrlKey && shiftKey && keyCode == 50 && type === "keydown"){ diff --git a/src/static/js/chat.js b/src/static/js/chat.js index 42cd50f4..fa087eec 100644 --- a/src/static/js/chat.js +++ b/src/static/js/chat.js @@ -39,8 +39,6 @@ var chat = (function() }, focus: function () { - // 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); @@ -214,23 +212,24 @@ var chat = (function() init: function(pad) { this._pad = pad; - $("#chatinput").keyup(function(evt) - { + $("#chatinput").on("keydown", 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 + evt.preventDefault(); + return false; } }); - $('body:not(#chatinput)').on("keydown", function(evt){ + $('body:not(#chatinput)').on("keypress", function(evt){ if (evt.altKey && evt.which == 67){ // Alt c focuses on the Chat window $(this).blur(); - parent.parent.chat.show(); - parent.parent.chat.focus(); + chat.show(); + $("#chatinput").focus(); evt.preventDefault(); } }); From 361807e5785b8ef999b6aa90a54f322d14cfcd64 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 6 May 2015 00:36:42 +0100 Subject: [PATCH 2/2] console msg should go to window --- src/static/js/collab_client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index e5c0ec8b..ad493528 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -279,7 +279,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if (newRev != (oldRev + 1)) { - parent.parent.console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (oldRev + 1)); + window.console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (oldRev + 1)); // setChannelState("DISCONNECTED", "badmessage_newchanges"); return; } @@ -289,7 +289,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if (newRev != (rev + 1)) { - parent.parent.console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (rev + 1)); + window.console.warn("bad message revision on NEW_CHANGES: " + newRev + " not " + (rev + 1)); // setChannelState("DISCONNECTED", "badmessage_newchanges"); return; } @@ -303,7 +303,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) { if (newRev != (msgQueue[msgQueue.length - 1].newRev + 1)) { - parent.parent.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (msgQueue[msgQueue.length - 1][0] + 1)); + window.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (msgQueue[msgQueue.length - 1][0] + 1)); // setChannelState("DISCONNECTED", "badmessage_acceptcommit"); return; } @@ -313,7 +313,7 @@ function getCollabClient(ace2editor, serverVars, initialUserInfo, options, _pad) if (newRev != (rev + 1)) { - parent.parent.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (rev + 1)); + window.console.warn("bad message revision on ACCEPT_COMMIT: " + newRev + " not " + (rev + 1)); // setChannelState("DISCONNECTED", "badmessage_acceptcommit"); return; }