fixes to Blocked Popups dialog:

- no confirmation after unblocking a site
- if there are no more sites in the list after unblocking, dialog closes
- if there are more sites, ensure one's selected
- added accesskeys to the two buttons
- now a dialog, so there's no minimize or maximize buttons
This commit is contained in:
dean_tessman%hotmail.com 2003-04-29 08:31:46 +00:00
parent f8a6f10bf1
commit 226b51d7f5
4 changed files with 43 additions and 32 deletions

View File

@ -2653,7 +2653,7 @@ function displayPageReportFirstTime()
function displayPageReport()
{
window.openDialog("chrome://browser/content/pageReport.xul", "_blank",
"dialog=no,modal");
"dialog,modal,resizable");
}
function nsBrowserContentListener(toplevelWindow, contentWindow)

View File

@ -17,12 +17,12 @@
# Rights Reserved.
#
# Contributor(s):
# David Hyatt (hyatt@apple.com)
# David Hyatt (hyatt@apple.com)
# Dean Tessman (dean_tessman@hotmail.com)
var gSiteBox;
var gUnblockButton;
var gPageReport;
var gUPMsg;
var permissionmanager =
Components.classes["@mozilla.org/permissionmanager;1"]
@ -34,9 +34,15 @@ function onLoad()
gSiteBox = document.getElementById("siteBox");
gUnblockButton = document.getElementById("unblockButton");
gPageReport = opener.gBrowser.pageReport;
gUPMsg = document.getElementById("unblockedPopupMsg");
buildSiteBox();
// select the first item using a delay, otherwise the listitems
// don't paint as selected.
setTimeout(selectFirstItem, 0);
}
function selectFirstItem()
{
gSiteBox.selectedIndex = 0;
}
@ -51,12 +57,8 @@ function buildSiteBox()
}
}
if (found) continue;
var listitem = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
"listitem");
listitem.setAttribute("label", gPageReport[i]);
gSiteBox.appendChild(listitem);
if (!found)
gSiteBox.appendItem(gPageReport[i]);
}
}
@ -71,13 +73,22 @@ function whitelistSite()
if (!selectedItem)
return;
var selectedIndex = gSiteBox.getIndexOfItem(selectedItem);
var uri = Components.classes['@mozilla.org/network/standard-url;1'].createInstance(Components.interfaces.nsIURI);
uri.spec = selectedItem.label;
permissionmanager.add(uri, nsIPermissionManager.POPUP_TYPE, nsIPermissionManager.ALLOW_ACTION);
gSiteBox.removeChild(selectedItem);
// XXXlocalize
alert(uri.host + gUPMsg.value);
document.documentElement.getButton("accept").focus();
}
if (gSiteBox.getRowCount() == 0) {
// close if there are no other sites to whitelist
window.close();
return;
}
// make sure a site is selected
if (selectedIndex > gSiteBox.getRowCount() - 1)
selectedIndex -= 1;
gSiteBox.selectedIndex = selectedIndex;
document.documentElement.getButton("accept").focus()
}

View File

@ -19,7 +19,8 @@
# Rights Reserved.
#
# Contributor(s):
# David Hyatt (hyatt@apple.com)
# David Hyatt (hyatt@apple.com)
# Dean Tessman (dean_tessman@hotmail.com)
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
@ -41,18 +42,16 @@
<script type="application/x-javascript" src="chrome://browser/content/pageReport.js"/>
<description value="&unblockedPopupMsg.label;" collapsed="true" id="unblockedPopupMsg"/>
<vbox flex="1">
<description>
&intro.label;
</description>
<listbox style="height:10em" id="siteBox" onselect="siteSelected();" flex="1"/>
<separator class="thin"/>
<hbox>
<button label="&unblock.label;" id="unblockButton" oncommand="whitelistSite();" disabled="true"/>
<spacer flex="1"/>
<button dlgtype="accept" label="&done.label;" default="true" oncommand="window.close();"/>
</hbox>
</vbox>
</dialog>
<description>
&intro.label;
</description>
<listbox style="height:10em" id="siteBox" onselect="siteSelected();" flex="1"/>
<separator class="thin"/>
<hbox>
<button label="&unblock.label;" id="unblockButton" oncommand="whitelistSite();"
disabled="true" accesskey="&unblock.accesskey;"/>
<spacer flex="1"/>
<button dlgtype="accept" label="&done.label;" default="true"
oncommand="window.close();" accesskey="&done.accesskey;"/>
</hbox>
</dialog>

View File

@ -4,6 +4,7 @@
unrequested popup windows:">
<!ENTITY done.label "Done">
<!ENTITY unblock.label "Unblock Site">
<!ENTITY done.accesskey "D">
<!ENTITY unblockedPopupMsg.label " will now be able to open unrequested popup windows.">
<!ENTITY unblock.label "Unblock Site">
<!ENTITY unblock.accesskey "U">