fix for accessibility bug #94802

r=ssu, sr=bienvenu, a=asa
space bar should toggle a filter's enabled state.

also, some clean up for my similar fix for #95212
(space bar should toggle the subscribed state)
This commit is contained in:
sspitzer%netscape.com 2002-03-15 00:07:04 +00:00
parent a43acc68fa
commit 9053c2ce83
4 changed files with 64 additions and 59 deletions

View File

@ -508,47 +508,33 @@ function CleanUpSearchView()
}
}
function SubscribeTreeOrSearchOutlinerHasFocus()
function onSearchOutlinerKeyPress(event)
{
var currentNode = top.document.commandDispatcher.focusedElement;
while (currentNode) {
if (currentNode === gSubscribeTree ||
currentNode === gSearchOutliner)
return true;
currentNode = currentNode.parentNode;
}
return false;
}
function SubscribeSpaceHit()
{
// if the subscribe tree / search outliner
// doesn't have focus, return.
// the space should be processed as it might be
// for the quick search text field, or for a button.
if (!SubscribeTreeOrSearchOutlinerHasFocus())
// for now, only do something on space key
if (event.keyCode != 0)
return;
var i;
var outlinerSelection = gSearchView.selection;
for (var i=0;i<outlinerSelection.getRangeCount();i++) {
var start = new Object;
var end = new Object;
outlinerSelection.getRangeAt(i,start,end);
for (var k=start.value;k<=end.value;k++)
ReverseStateFromRow(k);
if (InSearchMode()) {
var outlinerSelection = gSearchView.selection;
for (i=0;i<outlinerSelection.getRangeCount();i++) {
var start = new Object;
var end = new Object;
outlinerSelection.getRangeAt(i,start,end);
for (var k=start.value;k<=end.value;k++)
ReverseStateFromRow(k);
// force a repaint
InvalidateSearchOutliner();
}
}
else {
var groupList = gSubscribeTree.selectedItems;
for (i=0;i<groupList.length;i++)
ReverseStateFromNode(groupList[i]);
// force a repaint
InvalidateSearchOutliner();
}
}
function onSubscribeTreeKeyPress(event)
{
// for now, only do something on space key
if (event.keyCode != 0)
return;
var groupList = gSubscribeTree.selectedItems;
for (var i=0;i<groupList.length;i++)
ReverseStateFromNode(groupList[i]);
}

View File

@ -46,10 +46,6 @@ Rights Reserved.
<script type="application/x-javascript" src="chrome://messenger/content/subscribe.js"/>
<script type="application/x-javascript" src="chrome://messenger/content/widgetglue.js"/>
<keyset id="subscribeKeys">
<key id="space" key=" " oncommand="SubscribeSpaceHit()"/>
</keyset>
<grid flex="1" style="width: 40em; height: 25em;">
<columns>
<column flex="1"/>
@ -101,6 +97,7 @@ Rights Reserved.
id="subscribetree"
datasources="rdf:null"
seltype="multiple"
onkeypress="onSubscribeTreeKeyPress(event);"
onclick="SubscribeOnClick(event);">
<template>
<rule>
@ -134,7 +131,9 @@ Rights Reserved.
</tree>
</hbox>
<hbox id="searchview">
<outliner id="searchOutliner" flex="1" onclick="SearchOnClick(event);">
<outliner id="searchOutliner" flex="1"
onkeypress="onSearchOutlinerKeyPress(event);"
onclick="SearchOnClick(event);">
<outlinercols>
<outlinercol id="nameCol" label="..." flex="5" width="0" persist="hidden width" ignoreincolumnpicker="true" />
<splitter class="tree-splitter" />

View File

@ -30,6 +30,7 @@ const nsMsgFilterMotion = Components.interfaces.nsMsgFilterMotion;
var gFilterBundle;
var gPromptService;
var gFilterListMsgWindow = null;
var gFilterTree;
function onLoad()
{
@ -44,6 +45,7 @@ function onLoad()
gFilterListMsgWindow.SetDOMWindow(window);
gFilterBundle = document.getElementById("bundle_filter");
gFilterTree = document.getElementById("filterTree");
editButton = document.getElementById("editButton");
deleteButton = document.getElementById("deleteButton");
@ -68,7 +70,7 @@ function onLoad()
if (firstItem) {
selectServer(firstItem);
}
if (("arguments" in window) && window.arguments[0] && ("prefillValue" in window.arguments[0]))
onNewFilter(window.arguments[0].prefillValue);
}
@ -101,14 +103,13 @@ function setServer(uri)
var msgFolder = resource.QueryInterface(Components.interfaces.nsIMsgFolder);
//Calling getFilterList will detect any errors in rules.dat, backup the file, and alert the user
//we need to do this because tree.setAttribute will cause rdf to call getFilterList and there is
//we need to do this because gFilterTree.setAttribute will cause rdf to call getFilterList and there is
//no way to pass msgWindow in that case.
if (msgFolder)
msgFolder.getFilterList(gFilterListMsgWindow);
var tree = document.getElementById("filterTree");
tree.setAttribute("ref", uri);
gFilterTree.setAttribute("ref", uri);
updateButtons();
}
@ -118,15 +119,19 @@ function onToggleEnabled(event)
while (item && item.localName != "treeitem") {
item = item.parentNode;
}
toggleFilter(item.id);
}
var filterResource = rdf.GetUnicodeResource(item.id);
function toggleFilter(aFilterURI)
{
var filterResource = rdf.GetUnicodeResource(aFilterURI);
var filter = filterResource.GetDelegate("filter",
Components.interfaces.nsIMsgFilter);
filter.enabled = !filter.enabled;
refreshFilterList();
}
// sets up the menulist and the tree
// sets up the menulist and the gFilterTree
function selectServer(uri)
{
// update the server menu
@ -138,7 +143,7 @@ function selectServer(uri)
function currentFilter()
{
var selection = document.getElementById("filterTree").selectedItems;
var selection = gFilterTree.selectedItems;
if (!selection || selection.length <=0)
return null;
@ -228,26 +233,27 @@ function moveCurrentFilter(motion)
refreshFilterList();
}
function refreshFilterList() {
var tree = document.getElementById("filterTree");
if (!tree) return;
function refreshFilterList()
{
if (!gFilterTree)
return;
var selection;
var selectedItems = tree.selectedItems;
var selectedItems = gFilterTree.selectedItems;
if (selectedItems && selectedItems.length >0)
selection = tree.selectedItems[0].id;
selection = gFilterTree.selectedItems[0].id;
tree.clearSelection();
tree.setAttribute("ref", tree.getAttribute("ref"));
gFilterTree.clearSelection();
gFilterTree.setAttribute("ref", gFilterTree.getAttribute("ref"));
if (selection) {
var newItem = document.getElementById(selection);
// sometimes the selected element is gone.
if (newItem) {
tree.selectItem(newItem);
tree.ensureElementIsVisible(newItem);
gFilterTree.selectItem(newItem);
gFilterTree.ensureElementIsVisible(newItem);
}
}
}
@ -347,10 +353,23 @@ function getServerThatCanHaveFilters()
function onFilterDoubleClick(event)
{
// we only care about button 0 (left click) events
if (event.button != 0) return;
if (event.button != 0)
return;
var t = event.originalTarget;
if (t.parentNode.parentNode.localName == "treeitem")
onEditFilter();
}
function onFilterTreeKeyPress(event)
{
// for now, only do something on space key
if (event.keyCode != 0)
return;
var selectedFilters = gFilterTree.selectedItems;
for (var i=0;i<selectedFilters.length;i++)
toggleFilter(selectedFilters[i].getAttribute("id"));
}

View File

@ -81,6 +81,7 @@ Contributor(s): H
<vbox>
<tree id="filterTree" flex="1"
onselect="onFilterSelect(event);"
onkeypress="onFilterTreeKeyPress(event);"
ondblclick="onFilterDoubleClick(event);"
datasources="rdf:msgfilters rdf:msgaccountmanager"
containment="http://home.netscape.com/NC-rdf#child">