From 6edfbc5614cb2f91613aebad9f91de5c3ccb5d4c Mon Sep 17 00:00:00 2001 From: "dougt%meer.net" Date: Tue, 10 Jan 2006 06:49:17 +0000 Subject: [PATCH] XUL Cleanup, feedback incorporation, and shakeout git-svn-id: svn://10.0.0.236/trunk@187234 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/minimo/chrome/content/minimo.js | 247 ++------- mozilla/minimo/chrome/content/minimo.xul | 489 ++++++++++-------- .../content/preferences/pane-general.xul | 36 -- .../content/preferences/preferences.xul | 2 - .../chrome/content/toolbars/toolbar-find.xul | 27 +- mozilla/minimo/chrome/jar.mn | 1 + mozilla/minimo/chrome/locale/en-US/minimo.dtd | 16 +- mozilla/minimo/chrome/skin/go-color.png | Bin 0 -> 747 bytes mozilla/minimo/chrome/skin/minimo.css | 6 + 9 files changed, 343 insertions(+), 481 deletions(-) create mode 100755 mozilla/minimo/chrome/skin/go-color.png diff --git a/mozilla/minimo/chrome/content/minimo.js b/mozilla/minimo/chrome/content/minimo.js index b291aa50482..04709c5bcad 100755 --- a/mozilla/minimo/chrome/content/minimo.js +++ b/mozilla/minimo/chrome/content/minimo.js @@ -53,7 +53,8 @@ var gFullScreen=false; var gRSSTag="minimo"; var gGlobalHistory = null; var gURIFixup = null; -var gShowingMenuPopup=null; +var gShowingMenuPopup=false; +var gShowingNavMenuPopup=false; var gFocusedElementHREFContextMenu=null; var gDeckMode=0; // 0 = site, 1 = sb, 2= rss. Used for the URLBAR selector, DeckMode impl. var gDeckMenuChecked=null; // to keep the state of the checked URLBAR selector mode. @@ -62,8 +63,6 @@ var gPref = null; // so far snav toggles on / off via direct // See bugzilla.mozilla.org/show_bug.cgi?id=311287#c1 var gPrefAdded=false; // shall be used to flush the pref. -var gSNAV=-1; - function nsBrowserStatusHandler() { } @@ -85,14 +84,12 @@ nsBrowserStatusHandler.prototype = init : function() { this.urlBar = document.getElementById("urlbar"); - this.stopreloadButton = document.getElementById("reload-stop-button"); this.progressBGPosition = 0; /* To be removed, fix in onProgressChange ... */ }, destroy : function() { this.urlBar = null; - this.stopreloadButton = null; this.progressBGPosition = null; /* To be removed, fix in onProgressChange ... */ }, @@ -111,9 +108,6 @@ nsBrowserStatusHandler.prototype = if(aRequest && aWebProgress.DOMWindow == content) { this.startDocumentLoad(aRequest); } - this.stopreloadButton.className = "stop-button"; - this.stopreloadButton.setAttribute("command","cmd_BrowserStop"); - return; } @@ -124,9 +118,6 @@ nsBrowserStatusHandler.prototype = /* To be fixed. We dont want to directly access sytle from here */ document.styleSheets[1].cssRules[0].style.backgroundPosition="1000px 100%"; - this.stopreloadButton.className = "reload-button"; - this.stopreloadButton.setAttribute("command","cmd_BrowserReload"); - return; } return; @@ -333,25 +324,8 @@ nsBrowserStatusHandler.prototype = document.__defineSetter__("title",function(x){}); // Stays with the titled defined by the XUL element. - /* - * We add event handler to catch the right and left keys on the main_MenuPopup - */ - document.addEventListener("keypress",eventHandlerMenu,true); - /* - * Sync UI zoom level - */ - - syncUIZoom(); - - - /* - * Add event clicks to Minimo toolbars and also to the mStrip BOX in the tabbrowser - */ - gBrowser.mStrip.addEventListener("click",BrowserWithoutSNAV,false); - document.getElementById("mini-toolbars").addEventListener("click",BrowserWithoutSNAV,false); - - gBrowser.addEventListener("DOMLinkAdded", BrowserLinkAdded, false); + gBrowser.addEventListener("DOMLinkAdded", BrowserLinkAdded, false); } @@ -439,19 +413,6 @@ function BrowserUpdateFeeds() { * For now, this updates via DOM the top menu. Context menu should be here as well. */ function BrowserUpdateBackForwardState() { - - if(gBrowser.webNavigation.canGoBack) { - document.getElementById("back-button").setAttribute("disabled","false"); - } else { - document.getElementById("back-button").setAttribute("disabled","true"); - } - - if(gBrowser.webNavigation.canGoForward) { - document.getElementById("forward-button").setAttribute("disabled","false"); - } else { - document.getElementById("forward-button").setAttribute("disabled","true"); - } - } @@ -473,103 +434,6 @@ function findChildShell(aDocument, aDocShell, aSoughtURI) { } -function BrowserWithoutSNAV(e) { - if(gSNAV==1||gSNAV==-1) { - gSNAV=0; - document.addEventListener("keypress",eventHandlerMenu,true); - gPref.setBoolPref("snav.enabled", false); - } -} - -function BrowserWithSNAV(e) { - if(gSNAV==0||gSNAV==-1) { - gSNAV=1; - document.removeEventListener("keypress",eventHandlerMenu,true); - gPref.setBoolPref("snav.enabled", true); - } -} - -function enableMenuAccess() { - - if(document.commandDispatcher&&document.commandDispatcher.focusedElement) { - if (document.commandDispatcher.focusedElement.getAttribute("id")=="menu-button") { - BrowserWithSNAV(); - gBrowser.focus(); - gBrowser.contentWindow.focus(); - return; - } - } - - // In case focus is somewhere else.. - - document.getElementById("menu-button").focus(); - BrowserWithoutSNAV(); -} - - -/* - * 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==e.DOM_VK_LEFT || e.keyCode==e.DOM_VK_RIGHT) && (gShowingMenuPopup) ) { - BrowserMenuPopupFalse(); - document.getElementById("menu-button").focus(); // forcing state back to the menu. - } - - if(document.commandDispatcher&&document.commandDispatcher.focusedElement) { - - var outnavTarget=document.commandDispatcher.focusedElement.getAttribute("accessrule"); - - if(outnavTarget && (e.keyCode==e.DOM_VK_DOWN||e.keyCode==e.DOM_VK_UP) && !gShowingMenuPopup) { - - e.preventBubble(); - if(e.keyCode==e.DOM_VK_DOWN) { - - ruleElement=findRuleById(document.getElementById(outnavTarget).getAttribute("accessnextrule"),"accessnextrule"); - } - if(e.keyCode==e.DOM_VK_UP) { - - ruleElement=findRuleById(document.getElementById(outnavTarget).getAttribute("accessprevrule"),"accessprevrule"); - } - var tempElement=ruleElement.getAttribute("accessfocus"); - if(tempElement.indexOf("#")>-1) { - - if(tempElement=="#tabContainer") { - if(gBrowser.tabContainer) { - gBrowser.selectedTab.focus(); - - if(gBrowser.mStrip.collapsed) { - gBrowser.contentWindow.focus(); - } - } - } - if(tempElement=="#tabContent") { - gBrowser.focus(); - gBrowser.contentWindow.focus(); - } - } else { - document.getElementById(tempElement).focus(); - } - } - } -} - -function findRuleById(outnavTarget,ruleattribute) { - var ruleElement=document.getElementById(outnavTarget); - - if(document.getElementById(ruleElement.getAttribute("target")).collapsed) { - return findRuleById(ruleElement.getAttribute(ruleattribute), ruleattribute); - } else { - return ruleElement; - } -} - - - /** * Init stuff * @@ -587,11 +451,6 @@ function browserInit(refTab) */ var refBrowser=gBrowser.getBrowserForTab(refTab); - /* New Browser OnFocus SNAV Toggle */ - - refBrowser.addEventListener("focus", BrowserWithSNAV , true); - - try { refBrowser.markupDocumentViewer.textZoom = .90; } catch (e) { @@ -767,38 +626,6 @@ function BrowserResetZoomMinus() { } -/* Reset the UI text size */ -function BrowserUIResetZoomPlus() { - var currentUILevel=gPref.getIntPref("browser.display.zoomui"); - currentUILevel+=3; - gPref.setIntPref("browser.display.zoomui", currentUILevel); - syncUIZoom(); - - /* - * YES I know. - * I do this because somehow the grid does not expand - * when the style CSS syncUIzoom kicks in - */ - document.getElementById("uizoomminusitem").focus(); - document.getElementById("uizoomplusitem").focus(); -} - -function BrowserUIResetZoomMinus() { - var currentUILevel=gPref.getIntPref("browser.display.zoomui"); - currentUILevel-=3; - gPref.setIntPref("browser.display.zoomui", currentUILevel); - syncUIZoom(); - - /* - * YES I know. - * I do this because somehow the grid does not expand - * when the style CSS syncUIzoom kicks in - */ - document.getElementById("uizoomplusitem").focus(); - document.getElementById("uizoomminusitem").focus(); -} - - /* We want to intercept before it shows, to evaluate when the selected content area is a phone number, @@ -991,7 +818,6 @@ function DoBrowserFindNext() { function DoPanelPreferences() { window.openDialog("chrome://minimo/content/preferences/preferences.xul","preferences","modal,centerscreeen,chrome,resizable=no"); // BrowserReload(); - syncUIZoom(); } /* @@ -1002,6 +828,30 @@ function DoTestSendCall(toCall) { phoneInterface.makeCall(toCall,""); } +function DoSSRToggle() +{ + try { + var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(nsCI.nsIPrefBranch); + pref.setBoolPref("ssr.enabled", !pref.getBoolPref("ssr.enabled")); + + gBrowser.webNavigation.reload(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE); + } + catch(ex) { alert(ex); } + +} + +function DoSNavToggle() +{ + try { + var pref = Components.classes["@mozilla.org/preferences-service;1"].getService(nsCI.nsIPrefBranch); + pref.setBoolPref("snav.enabled", !pref.getBoolPref("snav.enabled")); + + content.focus(); + } + catch(ex) { alert(ex); } + +} + function DoFullScreen() { gFullScreen = !gFullScreen; @@ -1161,52 +1011,35 @@ function URLBarClickHandler(aEvent, aElt) aElt.select(); } -var gRotationDirection = true; - -function BrowserScreenRotate() -{ - try { - var deviceSupport = Components.classes["@mozilla.org/device/support;1"].getService(nsCI.nsIDeviceSupport); - - deviceSupport.rotateScreen(gRotationDirection); - gRotationDirection != gRotationDirection; - } - catch (ex) - { - alert(ex); - } -} - /* * Main Menu */ +function BrowserNavMenuPopup() { + if (!gShowingNavMenuPopup){ + document.getElementById("menu_NavPopup").showPopup(document.getElementById("nav-menu-button"),-1,-1,"popup","bottomright", "topright"); + } + else { + document.getElementById("menu_NavPopup").hidePopup(); + } + + gShowingNavMenuPopup != gShowingNavMenuPopup; +} + function BrowserMenuPopup() { if(!gShowingMenuPopup) { document.getElementById("menu_MainPopup").showPopup(document.getElementById("menu-button"),-1,-1,"popup","bottomleft", "topleft"); } else { document.getElementById("menu_MainPopup").hidePopup(); } + + gShowingMenuPopup != gShowingMenuPopup; } function BrowserMenuPopupFalse() { document.getElementById("menu_MainPopup").hidePopup(); } -function BrowserMenuPopupContextualMenu() { - document.getElementById("contentAreaContextMenu").hidePopup(); - DoFullScreen(); - BrowserMenuPopup(); -} - -function MenuPopupShowing() { - gShowingMenuPopup=true; - document.getElementById("menu-button").focus(); -} - -function MenuPopupHidden() { - gShowingMenuPopup=false; -} /* The URLBAR Deck mode selector */ diff --git a/mozilla/minimo/chrome/content/minimo.xul b/mozilla/minimo/chrome/content/minimo.xul index f556f55f2d9..998aa659c52 100755 --- a/mozilla/minimo/chrome/content/minimo.xul +++ b/mozilla/minimo/chrome/content/minimo.xul @@ -1,42 +1,41 @@ +***** END LICENSE BLOCK ***** --> @@ -48,131 +47,42 @@ -%minimoDTD; - -%brandDTD; -]> + + %minimoDTD; + + %brandDTD; + ]> - + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" + orient="vertical" + contenttitlesetting="false" + title="Minimo" + titlemodifier="Minimo" + titlemenuseparator=" - " + onload="MiniNavStartup()" + onunload="MiniNavShutdown()" + windowtype="navigator:browser"> +