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,47 +312,61 @@ 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 we're in the editbar already.. if($(':focus').parents(".toolbar").length === 1){
// Close any dropdowns we have open.. // If we're in the editbar already..
padeditbar.toggleDropDown("none"); // Close any dropdowns we have open..
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 // 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 $('#padmain').focus(); // Focus back onto the pad
// The above focus doesn't always work in FF, you have to hit enter afterwards }else{
evt.preventDefault(); // Shift focus away from any drop downs
$(':focus').blur(); // required to do not try to remove!
padeditor.ace.focus(); // Sends focus back to pad
// The above focus doesn't always work in FF, you have to hit enter afterwards
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
if(evt.keyCode !== 39 && evt.keyCode !== 37) return;
// On arrow keys go to next/previous button item in editbar // Get all the focusable items in the editbar
if(evt.keyCode !== 39 && evt.keyCode !== 37) return; var focusItems = $('#editbar').find('button, select');
// Get all the focusable items in the editbar // On left arrow move to next button in editbar
var focusItems = $('#editbar').find('button, select'); if(evt.keyCode === 37){
// If a dropdown is visible or we're in an input don't move to the next button
if($('.popup').is(":visible") || evt.target.localName === "input") return;
// On left arrow move to next button in editbar editbarPosition--;
if(evt.keyCode === 37){ // Allow focus to shift back to end of row and start of row
// If a dropdown is visible or we're in an input don't move to the next button if(editbarPosition === -1) editbarPosition = focusItems.length -1;
if($('.popup').is(":visible") || evt.target.localName === "input") return; $(focusItems[editbarPosition]).focus()
}
editbarPosition--; // On right arrow move to next button in editbar
// Allow focus to shift back to end of row and start of row if(evt.keyCode === 39){
if(editbarPosition === -1) editbarPosition = focusItems.length -1; // If a dropdown is visible or we're in an input don't move to the next button
$(focusItems[editbarPosition]).focus() if($('.popup').is(":visible") || evt.target.localName === "input") return;
}
// On right arrow move to next button in editbar editbarPosition++;
if(evt.keyCode === 39){ // Allow focus to shift back to end of row and start of row
// If a dropdown is visible or we're in an input don't move to the next button if(editbarPosition >= focusItems.length) editbarPosition = 0;
if($('.popup').is(":visible") || evt.target.localName === "input") return; $(focusItems[editbarPosition]).focus();
}
editbarPosition++;
// Allow focus to shift back to end of row and start of row
if(editbarPosition >= focusItems.length) editbarPosition = 0;
$(focusItems[editbarPosition]).focus();
} }
} }