From 5761e998de575f6eac6d332c4def443a5aae977a Mon Sep 17 00:00:00 2001 From: John McLear Date: Wed, 25 Mar 2015 11:03:45 +0000 Subject: [PATCH] first semi working alt f9 functionality --- src/node/utils/toolbar.js | 2 +- src/static/css/pad.css | 13 ++++++++----- src/static/js/ace2_inner.js | 14 ++++++++++++++ src/static/js/pad_editbar.js | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/node/utils/toolbar.js b/src/node/utils/toolbar.js index a5d30f960..65c2c1d54 100644 --- a/src/node/utils/toolbar.js +++ b/src/node/utils/toolbar.js @@ -99,7 +99,7 @@ _.extend(Button.prototype, { }; return tag("li", liAttributes, tag("a", { "class": this.grouping, "data-l10n-id": this.attributes.localizationId }, - tag("span", { "class": " "+ this.attributes.class }) + tag("button", { "class": " "+ this.attributes.class }) ) ); } diff --git a/src/static/css/pad.css b/src/static/css/pad.css index c9ebff4a5..7a91c0b5f 100644 --- a/src/static/css/pad.css +++ b/src/static/css/pad.css @@ -70,10 +70,6 @@ a img { .toolbar ul li { float: left; margin-left: 2px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; height:32px; } .toolbar ul li.separator { @@ -197,6 +193,7 @@ li[data-key=showusers] > a #online_count { #editbar{ display:none; } + #editorcontainer { position: absolute; top: 37px; /* + 1px border */ @@ -742,13 +739,19 @@ table#otheruserstable { height: 16px; display: inline-block; vertical-align: middle; - + border: none; + padding: 0; + background: none; font-family: "fontawesome-etherpad"; font-size: 15px; font-style: normal; font-weight: normal; color: #666; } + +.buttonicon:focus{ + border: 1px solid #fff; +} .buttonicon-bold:before { content: "\e81c"; } diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index be54b0c07..8e4dab5ca 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -3707,6 +3707,19 @@ function Ace2Inner(){ evt:evt }); specialHandled = (specialHandledInHook&&specialHandledInHook.length>0)?specialHandledInHook[0]:specialHandled; + if ((!specialHandled) && isTypeForSpecialKey && keyCode == 120){ + // Alt F9 focuses on the File Menu and/or editbar. + // 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"); + 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) { // "delete" key; in mozilla, if we're at the beginning of a line, normalize now, @@ -4951,6 +4964,7 @@ function Ace2Inner(){ // a fix: in IE, clicking on a control like a button outside the // iframe can "blur" the editor, causing it to stop getting // events, though typing still affects it(!). + top.console.log("blur handled"); setSelection(null); } } diff --git a/src/static/js/pad_editbar.js b/src/static/js/pad_editbar.js index 7d0539af9..b2d5ada53 100644 --- a/src/static/js/pad_editbar.js +++ b/src/static/js/pad_editbar.js @@ -155,6 +155,10 @@ var padeditbar = (function() }); }); + $('#editbar').on("keyup", function(evt){ + editbarKeyEvent(evt); + }); + $('#editbar').show(); this.redrawHeight(); @@ -300,6 +304,36 @@ var padeditbar = (function() } }; + 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'); + + // 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(); + } + } + + // 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(); + } + } + } + function aceAttributeCommand(cmd, ace) { ace.ace_toggleAttributeOnSelection(cmd); }