gecko-dev/xpfe/components/prefwindow/resources/content/pref-smart_browsing.xul
eddyk%netscape.com c34374706a Bug 70625: complex locked pref FE disabling
r=blake, sr=ben
2001-04-12 02:42:08 +00:00

257 lines
9.0 KiB
XML

<?xml version="1.0"?>
<!--
The contents of this file are subject to the Netscape Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/NPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is Mozilla Communicator client code, released
March 31, 1998.
The Initial Developer of the Original Code is Netscape
Communications Corporation. Portions created by Netscape are
Copyright (C) 1998-1999 Netscape Communications Corporation. All
Rights Reserved.
Contributor(s):
Blake Ross <blakeross@telocity.com>
-->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/dialogOverlay.css" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/prefpanels.css" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
%brandDTD;
<!ENTITY % prefSmartBrowsingDTD SYSTEM "chrome://communicator/locale/pref/pref-smart_browsing.dtd" >
%prefSmartBrowsingDTD;
]>
<window xmlns:html="http://www.w3.org/1999/xhtml"
class="color-dialog"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
orient="vertical"
onload="parent.initPanel('chrome://communicator/content/pref/pref-smart_browsing.xul');">
<stringbundle id="bundle_region"
src="chrome://global-region/locale/region.properties"/>
<script type="application/x-javascript">
<![CDATA[
var _elementIDs = ["browserRelatedDisabledForDomains", "addDomain",
"browserGoBrowsingEnabled", "browserAutoCompleteEnabled"];
function Startup()
{
// populate tree
var domainPrefField = document.getElementById( "browserRelatedDisabledForDomains" );
var domains = domainPrefField.getAttribute("value").split(",");
if( domains[0] != "" )
{
for( var i = 0; i < domains.length; i++ )
createCell( domains[i] );
}
// select the first item
selectFirstCell();
// enable buttons
doButtonEnabling();
}
function selectFirstCell()
{
var domainKids = document.getElementById( "disabledKids" );
if( domainKids.childNodes.length >= 1 ) {
var domainTree = document.getElementById( "disabledDomains" );
domainTree.selectItem( domainKids.firstChild );
}
}
function addDomain()
{
var domainField = document.getElementById( "addDomain" );
if( domainField.value != "" ) {
var domainTree = document.getElementById( "disabledDomains" );
domainTree.selectItem( createCell( domainField.value ) );
rebuildPrefValue();
domainField.value = "";
doButtonEnabling();
}
}
function removeDomain()
{
var domainTree = document.getElementById( "disabledDomains" );
var treeKids = document.getElementById( "disabledKids" );
var selectedItems = domainTree.selectedItems;
if( selectedItems.length >= 1 )
{
for( var i = 0; i < selectedItems.length; i++ )
{
treeKids.removeChild( selectedItems[i] );
}
}
selectFirstCell();
rebuildPrefValue();
}
function rebuildPrefValue()
{
var treeKids = document.getElementById( "disabledKids" );
var string = "";
if( treeKids.hasChildNodes() )
{
for( var i = 0; i < treeKids.childNodes.length; i++ )
{
var domain = treeKids.childNodes[i].firstChild.firstChild.getAttribute("label");
string += ( domain + "," );
}
}
var domainPrefField = document.getElementById( "browserRelatedDisabledForDomains" );
domainPrefField.setAttribute("value",string);
}
function createCell( aLabel )
{
var treeKids = document.getElementById( "disabledKids" );
var item = document.createElement( "treeitem" );
var row = document.createElement( "treerow" );
var cell = document.createElement( "treecell" );
cell.setAttribute( "label", aLabel );
row.appendChild( cell );
item.appendChild( row );
treeKids.appendChild( item );
return item;
}
function treeHandleEvent( aEvent )
{
if( aEvent.keyCode == 46 )
removeDomain();
}
function doButtonEnabling()
{
var addDomain = document.getElementById("addDomain");
var addDomainButton = document.getElementById("addDomainButton");
var prefstring = document.getElementById("browserRelatedDisabledForDomains").getAttribute("value");
if( addDomain.value == "" || prefstring.indexOf( addDomain.value + "," ) != -1 )
addDomainButton.disabled = true;
else
addDomainButton.removeAttribute("disabled");
if (parent.hPrefWindow.getPrefIsLocked(addDomainButton.getAttribute("prefstring")))
addDomainButton.disabled = true;
if (parent.hPrefWindow.getPrefIsLocked(addDomain.getAttribute("prefstring")))
addDomain.disabled = true;
}
function moreInfo()
{
var browserURL = null;
var regionBundle = document.getElementById("bundle_region");
var smartBrowsingURL = regionBundle.getString("smartBrowsingURL");
if (smartBrowsingURL) {
try {
var prefs = Components.classes["@mozilla.org/preferences;1"];
if (prefs) {
prefs = prefs.getService();
if (prefs)
prefs = prefs.QueryInterface(Components.interfaces.nsIPref);
}
if (prefs) {
var url = prefs.CopyCharPref("browser.chromeURL");
if (url)
browserURL = url;
}
} catch(e) {
}
if (browserURL == null)
browserURL = "chrome://navigator/content/navigator.xul";
window.openDialog( browserURL, "_blank", "chrome,all,dialog=no", smartBrowsingURL );
}
}
]]>
</script>
<box class="box-smallheader" title="&lHeader;"/>
<titledbox orient="vertical">
<label value="&whatsRelated.label;"/>
<html id="doNotAcceptText">&doNotDecp.label;</html>
<grid flex="1">
<columns>
<column flex="1"/>
<column/>
</columns>
<rows>
<row>
<tree class="inset" id="disabledDomains" multiple="true" onkeyup="treeHandleEvent(event)" style="height: 65px;" flex="1">
<treecolgroup>
<treecol flex="1"/>
</treecolgroup>
<treechildren id="disabledKids" flex="1"/>
</tree>
<box autostretch="never" valign="top">
<button class="dialog" id="removeDomain" label="&removeDomain.label;" accesskey="&removeDomain.accesskey;"
oncommand="removeDomain();" pref="true" preftype="bool"
prefstring="pref.browser.smartbrowsing.disable_button.remove" prefattribute="disabled"/>
</box>
</row>
<row>
<box autostretch="never">
<text class="label" id="domainText" value="&domain.label;" accesskey="&domain.accesskey;" for="addDomain"/>
<textbox id="addDomain" flex="1" oninput="doButtonEnabling();"
prefstring="pref.browser.smartbrowsing.disable_textbox.add" prefattribute="disabled"/>
</box>
<button disabled="true" class="dialog" id="addDomainButton" label="&addDomain.label;" accesskey="&addDomain.accesskey;"
oncommand="addDomain();" pref="true" preftype="bool"
prefstring="pref.browser.smartbrowsing.disable_button.add" prefattribute="disabled"/>
</row>
</rows>
</grid>
<data id="browserRelatedDisabledForDomains" pref="true" preftype="string"
prefstring="browser.related.disabledForDomains" prefattribute="value" wsm_attributes="value"/>
</titledbox>
<titledbox orient="vertical">
<label value="&internetKeywordsHeader.label;"/>
<html>&internetKeywordsDescription.label;</html>
<box autostretch="never">
<checkbox id="browserGoBrowsingEnabled" label="&keywordsEnabled.label;" accesskey="&keywordsEnabled.accesskey;"
pref="true" preftype="bool" prefstring="keyword.enabled"
prefattribute="checked"/>
<spring flex="1"/>
<button class="dialog" label="&moreInformation.label;" accesskey="&moreInformation.accesskey;" oncommand="moreInfo();"
id="moreInformationButton" pref="true" preftype="bool"
prefstring="pref.browser.smartbrowsing.disable_button.more_info" prefattribute="disabled"/>
</box>
</titledbox>
<titledbox orient="vertical">
<label value="&autoCompleteHeader.label;"/>
<html>&autoCompleteDescription.label;</html>
<box autostretch="never">
<checkbox id="browserAutoCompleteEnabled" label="&autoCompleteEnabled.label;" accesskey="&autoCompleteEnabled.accesskey;"
pref="true" preftype="bool" prefstring="browser.urlbar.autocomplete.enabled"
prefattribute="checked"/>
<spring flex="1"/>
</box>
</titledbox>
</window>