final accessibility for Timeslider hopefully

pull/2566/head
John McLear 2015-04-03 12:29:47 +01:00
parent 139edceb66
commit f79e2c7de2
2 changed files with 54 additions and 35 deletions

View File

@ -290,6 +290,11 @@ function loadBroadcastSliderJS(fireWhenAllScriptsAreLoaded)
$(document).keyup(function(e) $(document).keyup(function(e)
{ {
// If focus is on editbar, don't do anything
var target = $(':focus');
if($(target).parents(".toolbar").length === 1){
return;
}
var code = -1; var code = -1;
if (!e) var e = window.event; if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode; if (e.keyCode) code = e.keyCode;

View File

@ -312,21 +312,34 @@ var padeditbar = (function()
// If the event is Alt F9 or Escape & we're already in the editbar menu // If the event is Alt F9 or Escape & we're already in the editbar menu
// Send the users focus back to the pad // Send the users focus back to the pad
if((evt.keyCode === 120 && evt.altKey) || evt.keyCode === 27){ if((evt.keyCode === 120 && evt.altKey) || evt.keyCode === 27){
if($(':focus').parents(".toolbar").length === 1){
// If we're in the editbar already.. // If we're in the editbar already..
// Close any dropdowns we have open.. // Close any dropdowns we have open..
padeditbar.toggleDropDown("none"); padeditbar.toggleDropDown("none");
// Check we're on a pad and not on the timeslider // Check we're on a pad and not on the timeslider
// Or some other window I haven't thought about! // Or some other window I haven't thought about!
if(typeof pad === 'undefined') return false; if(typeof pad === 'undefined'){
// Timeslider probably..
// Shift focus away from any drop downs
$(':focus').blur(); // required to do not try to remove!
$('#padmain').focus(); // Focus back onto the pad
}else{
// Shift focus away from any drop downs // Shift focus away from any drop downs
$(':focus').blur(); // required to do not try to remove! $(':focus').blur(); // required to do not try to remove!
padeditor.ace.focus(); // Sends focus back to pad padeditor.ace.focus(); // Sends focus back to pad
// The above focus doesn't always work in FF, you have to hit enter afterwards // The above focus doesn't always work in FF, you have to hit enter afterwards
evt.preventDefault(); evt.preventDefault();
} }
}else{
// Focus on the editbar :)
var firstEditbarElement = parent.parent.$('#editbar').children("ul").first().children().first().children().first().children().first();
$(this).blur();
firstEditbarElement.focus();
evt.preventDefault();
}
}
// Are we in the toolbar??
if($(':focus').parents(".toolbar").length === 1){
// On arrow keys go to next/previous button item in editbar // On arrow keys go to next/previous button item in editbar
if(evt.keyCode !== 39 && evt.keyCode !== 37) return; if(evt.keyCode !== 39 && evt.keyCode !== 37) return;
@ -354,6 +367,7 @@ var padeditbar = (function()
if(editbarPosition >= focusItems.length) editbarPosition = 0; if(editbarPosition >= focusItems.length) editbarPosition = 0;
$(focusItems[editbarPosition]).focus(); $(focusItems[editbarPosition]).focus();
} }
}
} }