From aacdfec75879672b54835037bf47f68bb698fc4e Mon Sep 17 00:00:00 2001 From: "mgalli%geckonnection.com" Date: Fri, 30 Sep 2005 18:35:53 +0000 Subject: [PATCH] Focus controller via XUL attributes. git-svn-id: svn://10.0.0.236/trunk@181292 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/minimo/chrome/content/minimo.js | 50 ++++++++++++++++++++---- mozilla/minimo/chrome/content/minimo.xul | 35 +++++++++++------ 2 files changed, 65 insertions(+), 20 deletions(-) diff --git a/mozilla/minimo/chrome/content/minimo.js b/mozilla/minimo/chrome/content/minimo.js index 84d91b68f4a..65349be6485 100755 --- a/mozilla/minimo/chrome/content/minimo.js +++ b/mozilla/minimo/chrome/content/minimo.js @@ -47,6 +47,7 @@ var gFullScreen=false; var gRSSTag="minimo"; var gGlobalHistory = null; var gURIFixup = null; +var gShowingMenuPopup=null; function nsBrowserStatusHandler() { @@ -267,20 +268,51 @@ function MiniNavStartup() } -var gShowingMenuPopup=null; +/* + * Focus Shortcut Action. This is just a focus action dispatcher based on certain conditions + * defined in the XUL elements. Ideally would be interesting to have this as part of some new + * XUL elements that are based on existing XUL elements, or to incorporate, import, this behavior + * in the XUL declaration. + */ function eventHandlerMenu(e) { if( (e.keyCode==39 || e.keyCode==37) && (gShowingMenuPopup) ) { BrowserMenuPopupFalse(); document.getElementById("back-button").focus(); } - - if (e.keyCode == 112) { - document.getElementById("menu-button").focus(); + + + var outnavTarget=document.commandDispatcher.focusedElement.getAttribute("accessrule"); + if(outnavTarget!="" && e.keyCode==40 && !gShowingMenuPopup) { + ruleElement=findRuleById(document.getElementById(outnavTarget).getAttribute("accessnextrule")); + var tempElement=ruleElement.getAttribute("accessfocus"); + if(tempElement=="#tabContainer") { + if(ruleElement.tabContainer) { + ruleElement.mTabContainer.childNodes[0].focus(); + } + } else { + document.getElementById(tempElement).focus(); + e.preventDefault(); + } } - + + /* + * We may use onblur with content navigation tabbrowser to snav enable disable. + */ + } +function findRuleById(outnavTarget) { + var ruleElement=document.getElementById(outnavTarget); + + if(ruleElement.collapsed) { + return findRuleById(ruleElement.getAttribute("accessnextrule")); + } else { + return ruleElement; + } +} + + /** * Init stuff * @@ -551,13 +583,17 @@ function BrowserScreenRotate() function BrowserMenuPopup() { document.getElementById("menu_MainPopup").showPopup(document.getElementById("menu-button"),-1,-1,"popup","bottomleft", "topleft"); - gShowingMenuPopup=true; } function BrowserMenuPopupFalse() { document.getElementById("menu_MainPopup").hidePopup(); - gShowingMenuPopup=false; } function MenuPopupShowing() { + gShowingMenuPopup=true; document.getElementById("menu-button").focus(); } + +function MenuPopupHidden() { + gShowingMenuPopup=false; +} + diff --git a/mozilla/minimo/chrome/content/minimo.xul b/mozilla/minimo/chrome/content/minimo.xul index abe9dab9e43..9c99cb173c6 100755 --- a/mozilla/minimo/chrome/content/minimo.xul +++ b/mozilla/minimo/chrome/content/minimo.xul @@ -86,12 +86,12 @@ - + - - - - + + + + - + + @@ -116,18 +120,23 @@ - + - + + @@ -135,11 +144,11 @@ - + @@ -177,7 +186,7 @@ - +