summaryrefslogtreecommitdiff
path: root/src/static/js
diff options
context:
space:
mode:
authorJohn McLear <john@mclear.co.uk>2015-03-25 15:19:52 +0000
committerJohn McLear <john@mclear.co.uk>2015-03-25 15:19:52 +0000
commit0c902ced7399ad1aacde688b34096c8851a6d699 (patch)
treef02efddc58a3ca430cc6ab012341b01502d52af5 /src/static/js
parentc6cac53ddada4eb89bb4b74dc4a7be9131b30d1d (diff)
downloadetherpad-lite-0c902ced7399ad1aacde688b34096c8851a6d699.zip
better logic for handling lr arrows
Diffstat (limited to 'src/static/js')
-rw-r--r--src/static/js/pad_editbar.js25
1 files changed, 9 insertions, 16 deletions
diff --git a/src/static/js/pad_editbar.js b/src/static/js/pad_editbar.js
index b2d5ada5..14e33fe1 100644
--- a/src/static/js/pad_editbar.js
+++ b/src/static/js/pad_editbar.js
@@ -304,34 +304,27 @@ var padeditbar = (function()
}
};
+ var editbarPosition = 0;
+
function editbarKeyEvent(evt){
// On arrow keys go to next/previous button item in editbar
if(evt.keyCode !== 39 && evt.keyCode !== 37) return;
- // Get our current Focus (Which editbar icon we're currently on)
- var currentFocus = $(':focus');
+ // Get all the focusable items in the editbar
+ var focusItems = $('#editbar').find('button, select');
// On left arrow move to next button in editbar
if(evt.keyCode === 37){
- var nextFocus = $(currentFocus).parent().parent().prev();
- // No button in this focus so move on
- if(nextFocus.find("button").length === 0){
- $(nextFocus).prev().find("button").focus();
- }else{
- $(currentFocus).parent().parent().prev().find("button").focus();
- }
+ editbarPosition--;
+ $(focusItems[editbarPosition]).focus();
}
// On right arrow move to next button in editbar
if(evt.keyCode === 39){
- var nextFocus = $(currentFocus).parent().parent().next();
- // No button in this focus so move on
- if(nextFocus.find("button").length === 0){
- $(nextFocus).next().find("button").focus();
- }else{
- $(currentFocus).parent().parent().next().find("button").focus();
- }
+ editbarPosition++;
+ $(focusItems[editbarPosition]).focus();
}
+
}
function aceAttributeCommand(cmd, ace) {