From 6d6d593ffb6a3a114f58664e5df10db9a574d077 Mon Sep 17 00:00:00 2001 From: "hewitt%netscape.com" Date: Sun, 29 Sep 2002 20:06:57 +0000 Subject: [PATCH] 171581 - toolbar search/find in page for phoenix --- browser/base/content/browser.css | 4 + browser/base/content/browser.js | 91 +++++++++++++- browser/base/content/browser.xul | 20 +++- browser/base/content/search.xml | 146 +++++++++++++++++++++++ browser/base/jar.mn | 2 + browser/base/skin/browser.css | 7 ++ browser/base/skin/search-bar.png | Bin 0 -> 457 bytes toolkit/content/widgets/autocomplete.xml | 8 +- 8 files changed, 271 insertions(+), 7 deletions(-) create mode 100644 browser/base/content/search.xml create mode 100644 browser/base/skin/search-bar.png diff --git a/browser/base/content/browser.css b/browser/base/content/browser.css index 0028df6b6204..ee4892b5247a 100644 --- a/browser/base/content/browser.css +++ b/browser/base/content/browser.css @@ -18,3 +18,7 @@ window[chromehidden~="toolbar"] #navigator-throbber { window[chromehidden~="toolbar"] #navigator-throbber[busy="true"] { list-style-image: url("chrome://communicator/skin/brand/throbber16-anim.gif") !important; } + +#search-bar { + -moz-binding: url("chrome://browser/content/search.xml#searchbar"); +} diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 9200ed5003d2..fbbdc994473f 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -81,7 +81,8 @@ var gPrintSettings = null; var gChromeState = null; // chrome state before we went into print preview var gOldCloseHandler = null; // close handler before we went into print preview var gInPrintPreviewMode = false; -var gWebProgress = null; +var gWebProgress = null; +var gFormHistory = null; /** * We can avoid adding multiple load event listeners and save some time by adding @@ -1164,6 +1165,94 @@ function PageProxyDragGesture(aEvent) return false; } +function SearchBarPopupShowing(aEvent) +{ + var popup = aEvent.target; + if (popup.firstChild.localName == "menuitem") + popup.removeChild(popup.firstChild); + + var searchBar = document.getElementById("search-bar"); + var searchMode = searchBar.getAttribute("searchmode"); + var findItem = document.getElementById("miSearchModeFind"); + findItem.setAttribute("checked", searchMode == "findinpage"); + + var searchBar = document.getElementById("search-bar"); + if (!searchBar.enginesReady) + searchBar.updateEngines(); + + if (searchBar.currentSearchId) { + var menuitem = document.createElement("menuitem"); + menuitem.setAttribute("label", searchBar.currentSearchName); + + if (searchBar.currentSearchIcon) { + menuitem.setAttribute("class", "menuitem-iconic"); + menuitem.setAttribute("image", searchBar.currentSearchIcon); + } else { + menuitem.setAttribute("type", "checkbox"); + menuitem.setAttribute("checked", searchMode == "web"); + } + + popup.insertBefore(menuitem, popup.firstChild); + } + +} + +function SearchBarPopupCommand(aEvent) +{ + var searchBar = document.getElementById("search-bar"); + + if (aEvent.target.id == "miSearchModeFind") { + searchBar.setAttribute("autocompletesearchparam", "__PhoenixFindInPage"); + searchBar.setAttribute("searchmode", "findinpage"); + } else { + searchBar.setAttribute("autocompletesearchparam", "q"); + searchBar.setAttribute("searchmode", "web"); + } + + searchBar.detachController(); + searchBar.focus(); +} + +function handleSearchBarCommand(aEvent) +{ + var searchBar = document.getElementById("search-bar"); + + // Save the current value in the form history + if (!gFormHistory) + gFormHistory = Components.classes["@mozilla.org/satchel/form-history;1"] + .getService(Components.interfaces.nsIFormHistory); + gFormHistory.addEntry(searchBar.getAttribute("autocompletesearchparam"), searchBar.value); + + if (searchBar.getAttribute("searchmode") == "web") { + gURLBar.value = searchBar.searchValue; + BrowserLoadURL(aEvent); + } else { + quickFindInPage(searchBar.value); + } +} + +function quickFindInPage(aValue) +{ + var focusedWindow = document.commandDispatcher.focusedWindow; + if (!focusedWindow || focusedWindow == window) + focusedWindow = window._content; + + var findInst = getBrowser().webBrowserFind; + var findInFrames = findInst.QueryInterface(Components.interfaces.nsIWebBrowserFindInFrames); + findInFrames.rootSearchFrame = _content; + findInFrames.currentSearchFrame = focusedWindow; + + var findService = Components.classes["@mozilla.org/find/find_service;1"] + .getService(Components.interfaces.nsIFindService); + findInst.searchString = aValue; + findInst.matchCase = findService.matchCase; + findInst.wrapFind = true; + findInst.entireWord = findService.entireWord; + findInst.findBackwards = false; + + findInst.findNext(); +} + function updateToolbarStates(toolbarMenuElt) { if (!gHaveUpdatedToolbarState) { diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 785446ac65f4..e0a176300bb7 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -227,7 +227,14 @@ Contributor(s): - + + + + + + @@ -755,7 +762,16 @@ Contributor(s): - + + + diff --git a/browser/base/content/search.xml b/browser/base/content/search.xml new file mode 100644 index 000000000000..979019360fb8 --- /dev/null +++ b/browser/base/content/search.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + var svc = Components.classes["@mozilla.org/preferences-service;1"] + .getService(Components.interfaces.nsIPrefService); + svc.getBranch(null); + + + + + false + + "" + + "" + + "" + + "" + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/browser/base/jar.mn b/browser/base/jar.mn index 5d9c24fc396b..a13b7de1b680 100644 --- a/browser/base/jar.mn +++ b/browser/base/jar.mn @@ -12,6 +12,7 @@ browser.jar: content/browser/viewSourceOverlay.xul (content/viewSourceOverlay.xul) content/browser/openLocation.xul (content/openLocation.xul) content/browser/openLocation.js (content/openLocation.js) + content/browser/search.xml (content/search.xml) classic.jar: skin/classic/browser/browser.css (skin/browser.css) @@ -46,6 +47,7 @@ classic.jar: skin/classic/browser/lock-mixed.gif (skin/lock-mixed.gif) skin/classic/browser/lock-secure.gif (skin/lock-secure.gif) skin/classic/browser/loading.gif (skin/loading.gif) + skin/classic/browser/search-bar.png (skin/search-bar.png) en-US.jar: locale/en-US/browser/contents.rdf (locale/contents.rdf) diff --git a/browser/base/skin/browser.css b/browser/base/skin/browser.css index 8295dc134bf4..8d02ce9d4fb2 100644 --- a/browser/base/skin/browser.css +++ b/browser/base/skin/browser.css @@ -613,6 +613,13 @@ toolbar[iconsize="small"] #history-button[disabled="true"] { -moz-image-region: rect(0px 64px 16px 48px); } +/* ::::: search-bar ::::: */ + +#search-proxy-button { + margin: 2px; + list-style-image: url("chrome://browser/skin/search-bar.png"); +} + /* ::::: autocomplete ::::: */ .autocomplete-treebody:-moz-tree-cell-text(treecolAutoCompleteComment) { diff --git a/browser/base/skin/search-bar.png b/browser/base/skin/search-bar.png new file mode 100644 index 0000000000000000000000000000000000000000..2652304d6e7e050f2b83b2334656a7c380c1a3d7 GIT binary patch literal 457 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`)Ym%P6qN7l0AZa z85pWm85kOx85n;42huMX7)lKo7+xhXFj!4zU=YurzH;Uj1_s6uPZ!6KiaAL?{{OdU z<`HI?bc2PFsiSp*p27#lBzJ{>oJX!VRv2zlabPeMC}`vsuxEW_@9;;yD|><{1B-wi zvr5Acfso653iH}hP8caXW7lNjP>5mUVE$ON;?Y+J9WGIBrbp)kKFTPhfhArrd{kEW z$9CjjhTd!@(*!Gl%}gu;!e;%<2lW;HaUGfCu%dur9J;WDa0(XkcXMUAo;$?&%W`U|cYGy85}Sb4q9e0IlPeKmY&$ literal 0 HcmV?d00001 diff --git a/toolkit/content/widgets/autocomplete.xml b/toolkit/content/widgets/autocomplete.xml index 1d8bd619bfec..8971b5e9711a 100644 --- a/toolkit/content/widgets/autocomplete.xml +++ b/toolkit/content/widgets/autocomplete.xml @@ -111,8 +111,8 @@ onget="var t = parseInt(this.getAttribute('timeout')); return t ? t : 50;"/> + onget="return this.getAttribute('autocompletesearchparam');" + onset="this.setAttribute('autocompletesearchparam', val); return val;"/> @@ -297,7 +297,7 @@ if (!this.disableKeyNavigation) { switch (aEvent.keyCode) { case KeyEvent.DOM_VK_TAB: - if (this.tabScrolling && this.mPopupOpen) + if (this.tabScrolling && this.popup.mPopupOpen) cancel = this.mController.handleKeyNavigation(aEvent.shiftKey ? IController.KEY_UP : IController.KEY_DOWN); break; case KeyEvent.DOM_VK_UP: @@ -330,7 +330,7 @@ cancel = this.mController.handleEnter(); break; } - + if (cancel) { aEvent.stopPropagation(); aEvent.preventDefault();