Bug 600844 - Hide the site menu when the find bar appears [r=mfinkle]

This commit is contained in:
Matt Brubeck 2010-09-30 13:57:33 -07:00
Родитель e952ee6543
Коммит 196f6e9b1a
5 изменённых файлов: 46 добавлений и 5 удалений

Просмотреть файл

@ -1130,6 +1130,8 @@ var TapHighlightHelper = {
var PageActions = {
init: function init() {
document.getElementById("pageactions-container").addEventListener("click", this, false);
this.register("pageaction-reset", this.updatePagePermissions, this);
this.register("pageaction-password", this.updateForgetPassword, this);
#ifdef NS_PRINTING
@ -1139,6 +1141,14 @@ var PageActions = {
this.register("pageaction-search", BrowserSearch.updatePageSearchEngines, BrowserSearch);
},
handleEvent: function handleEvent(aEvent) {
switch (aEvent.type) {
case "click":
getIdentityHandler().hide();
break;
}
},
/**
* @param aId id of a pageaction element
* @param aCallback function that takes an element and returns true if it should be visible
@ -1207,7 +1217,7 @@ var PageActions = {
return logins.some(function(login) login.hostname == host.prePath);
},
forgetPassword: function forgetPassword() {
forgetPassword: function forgetPassword(aEvent) {
let host = Browser.selectedBrowser.currentURI;
let lm = this._loginManager;
@ -1215,9 +1225,12 @@ var PageActions = {
if (login.hostname == host.prePath)
lm.removeLogin(login);
});
this.hideItem(aEvent.target);
aEvent.stopPropagation(); // Don't hide the site menu.
},
clearPagePermissions: function clearPagePermissions() {
clearPagePermissions: function clearPagePermissions(aEvent) {
let pm = Services.perms;
let host = Browser.selectedBrowser.currentURI;
this._forEachPermissions(host, function(aType) {
@ -1227,6 +1240,9 @@ var PageActions = {
let lm = this._loginManager;
if (!lm.getLoginSavingEnabled(host.prePath))
lm.setLoginSavingEnabled(host.prePath, true);
this.hideItem(aEvent.target);
aEvent.stopPropagation(); // Don't hide the site menu.
},
savePageAsPDF: function saveAsPDF() {

Просмотреть файл

@ -1236,9 +1236,10 @@ const BrowserSearch = {
// XXX limit to the first search engine for now
let engine = items[0];
aNode.setAttribute("description", engine.title);
aNode.onclick = function() {
aNode.onclick = function(aEvent) {
BrowserSearch.addPermanentSearchEngine(engine);
PageActions.hideItem(aNode);
aEvent.stopPropagation(); // Don't hide the site menu.
};
return true;
},

Просмотреть файл

@ -344,9 +344,9 @@
<pageaction id="pageaction-share" title="&pageactions.share.page;"
onclick="SharingUI.show(getBrowser().currentURI.spec, getBrowser().contentTitle);"/>
<pageaction id="pageaction-password" title="&pageactions.password.forget;"
onclick="PageActions.forgetPassword(); PageActions.hideItem(this);"/>
onclick="PageActions.forgetPassword(event);"/>
<pageaction id="pageaction-reset" title="&pageactions.reset;"
onclick="PageActions.clearPagePermissions(); PageActions.hideItem(this);"/>
onclick="PageActions.clearPagePermissions(event);"/>
<pageaction id="pageaction-search" title="&pageactions.search.addNew;"/>
</hbox>
</vbox>

Просмотреть файл

@ -57,6 +57,7 @@ _BROWSER_FILES = \
browser_click_content.html \
browser_click_content.js \
browser_contacts.js \
browser_find.js \
browser_forms.html \
browser_forms.js \
browser_mainui.js \

Просмотреть файл

@ -0,0 +1,23 @@
// Tests for the Find In Page UI
//------------------------------------------------------------------------------
// Entry point (must be named "test")
function test() {
let menu = document.getElementById("identity-container");
let item = document.getElementById("pageaction-findinpage");
let navigator = document.getElementById("content-navigator");
// Open and close the find toolbar
getIdentityHandler().show();
ok(!menu.hidden, "Site menu is open");
ok(!navigator.isActive, "Toolbar is closed");
EventUtils.sendMouseEvent({ type: "click" }, item);
ok(menu.hidden, "Site menu is closed");
ok(navigator.isActive, "Toolbar is open");
EventUtils.synthesizeKey("VK_ESCAPE", {}, window);
ok(menu.hidden, "Site menu is closed");
ok(!navigator.isActive, "Toolbar is closed");
}