From bc760e9494ab66f8ff72d14ec08614c286ebc5d3 Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 25 Mar 2015 15:38:19 +0000 Subject: [PATCH] logic to send focus back to pad on Alt F9 when focus on editbar --- src/static/js/ace2_inner.js | 5 +---- src/static/js/pad_editbar.js | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index 8e4dab5ca..4c8c5204e 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -3712,12 +3712,9 @@ function Ace2Inner(){ // Note that while most editors use Alt F10 this is not desirable // As ubuntu cannot use Alt F10.... evt.preventDefault(); - // Focus on the editbar. - top.console.log("focusing on first child in menu"); + // Focus on the editbar. -- TODO: Move Focus back to previous state (we know it so we can use it) var firstEditbarElement = parent.parent.$('#editbar').children("ul").first().children().first().children().first().children().first(); firstEditbarElement.focus(); - top.console.log(firstEditbarElement); - top.console.log(parent.parent.$(':focus')); $(this).blur(); } if ((!specialHandled) && isTypeForSpecialKey && keyCode == 8) diff --git a/src/static/js/pad_editbar.js b/src/static/js/pad_editbar.js index 14e33fe14..92e671c4d 100644 --- a/src/static/js/pad_editbar.js +++ b/src/static/js/pad_editbar.js @@ -155,7 +155,7 @@ var padeditbar = (function() }); }); - $('#editbar').on("keyup", function(evt){ + $('#editbar').on("keydown", function(evt){ editbarKeyEvent(evt); }); @@ -307,6 +307,13 @@ var padeditbar = (function() var editbarPosition = 0; function editbarKeyEvent(evt){ + // If the event is Alt F9 (we're already in the editbar menu + // Send the users focus back to the pad + if(evt.keyCode === 120){ + // If we're in the editbar already.. + padeditor.ace.focus(); // Sends focus back + } + // On arrow keys go to next/previous button item in editbar if(evt.keyCode !== 39 && evt.keyCode !== 37) return; @@ -338,6 +345,20 @@ var padeditbar = (function() toolbar.registerDropdownCommand("import_export"); toolbar.registerDropdownCommand("embed"); + toolbar.registerCommand("import_export", function () { + setTimeout(function(){ + $('#importfileinput').focus(); + },100); + toolbar.toggleDropDown("import_export"); + }); + + toolbar.registerCommand("showusers", function () { + setTimeout(function(){ + $('#myusernameedit').focus(); // TODO: Not working + },100); + toolbar.toggleDropDown("users"); + }); + toolbar.registerCommand("embed", function () { toolbar.setEmbedLinks(); $('#linkinput').focus().select();