home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Minami 80
/
MINAMI80.iso
/
Extra
/
DivXInstaller.exe
/
$PLUGINSDIR
/
GoogleToolbarFirefox.msi
/
xpi
/
chrome
/
google-toolbar.jar
/
content
/
autocomplete-menulist.xml
< prev
next >
Wrap
Extensible Markup Language
|
2006-05-15
|
9KB
|
243 lines
<?xml version="1.0"?>
<bindings id="AutocompleteMenulistBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="autocomplete-menulist" extends="chrome://global/content/bindings/menulist.xml#menulist-editable">
<content sizetopopup="pref">
<!-- Autocomplete is off until we need it. Make sure showcommentcolumn
is false at startup to work around autocomplete bug. -->
<xul:textbox class="gtb-search-box" type="autocomplete" autocompletesearch="google-search-suggest" flex="1" anonid="textbox"
autocompletepopup="gtbPopupAutoComplete"
completeselectedindex="true"
tabscrolling="true"
showcommentcolumn="false"
xbl:inherits="disableautocomplete,src,width,minwidth"/>
<xul:dropmarker class="menulist-dropmarker" type="menu"/>
<children includes="menupopup"/>
</content>
<implementation>
<field name="alreadySearched">false</field>
<field name="mTextBox">null</field>
<property name="textBox">
<getter><![CDATA[
if(!this.mTextBox) {
this.mTextBox = document.getAnonymousElementByAttribute(this, "anonid", "textbox");
}
return this.mTextBox;
]]></getter>
</property>
<property name="value" onget="return this.inputField.value;">
<setter><![CDATA[
// Override editable menulist's value setter to refer to the textBox
// instead of inputField. This prevents the autocomplete pop-up
// from showing when the menulist value is re-set
this.textBox.value = val;
this.setAttribute('value', val);
this.setAttribute('label', val);
this._selectInputFieldValueInList();
return val;
]]></setter>
</property>
<property name="inputField" readonly="true">
<getter><![CDATA[
if(!this.mInputField) {
this.mInputField = this.textBox.mInputElt;
}
return this.mInputField;
]]></getter>
</property>
<property name="selectedItem">
<getter>
<![CDATA[
// Need to override selectedItem() in editable menulist to access
// the inputField via the textbox only--otherwise the textBox
// autocomplete pop-up will show after selection from the menulist
// drop-down
// Make sure internally-selected item
// is in sync with inputField.value
this._selectInputFieldValueInList();
return this.selectedInternal;
]]>
</getter>
<setter>
<![CDATA[
// This doesn't touch textBox.value or "value" and "label" attributes
this.setSelectionInternal(val);
if (!this.selectedInternal) {
this.inputField.value = "";
this.removeAttribute('value');
this.removeAttribute('label');
return val;
}
// Editable menulist uses "label" as its "value"
var label = val.getAttribute('label');
this.textBox.value = label;
this.setAttribute('value', label);
this.setAttribute('label', label);
//need to re-set the focus to the text-box so that
//it will populate the pop-up with the correct suggestions.
this.textBox.focus();
return val;
]]>
</setter>
</property>
</implementation>
</binding>
<binding id="gtb-search-box" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete">
<resources>
<stylesheet src="chrome://google-toolbar/skin/google-toolbar.css"/>
</resources>
<implementation>
<!-- These variables keep track of whether attachController()
and detachController() may have been called before the
constructor. -->
<field name="mPendingAttach">false</field>
<field name="mPendingDetach">false</field>
<constructor><![CDATA[
// If attachController() or detachController() were called
// before the constructor, call them now that the base class
// constructor has set mController correctly.
if (this.mPendingAttach) {
this.attachController();
}
if (this.mPendingDetach) {
this.detachController();
}
]]></constructor>
<method name="onTextEntered">
<body><![CDATA[
this.parentNode.alreadySearched = false;
setTimeout("GTB_GoogleToolbar.doSuggestSearch()", 100);
//need to re-set the focus to the text-box so that
//it will populate the pop-up with the correct suggestions.
this.focus();
]]></body>
</method>
<!-- There is a weird bug where attachController can be
called before the constructor. This causes problems
because mController will be null. In this case, set
a variable to tell the contstructor to attach the
controller when it is called. -->
<method name="attachController">
<body><![CDATA[
if (!this.mController) {
// Defer attaching to the constructor.
this.mPendingAttach = true;
this.mPendingDetach = false;
return;
}
if (this.mController.input != this) {
this.mController.input = this;
}
]]></body>
</method>
<!-- There is a weird bug where detachController can be
called before the constructor. This causes problems
because mController will be null. In this case, set
a variable to tell the contstructor to attach the
controller when it is called. -->
<method name="detachController">
<body><![CDATA[
if (!this.mController) {
// Defer detatching to the constructor.
this.mPendingDetach = true;
this.mPendingAttach = false;
return;
}
if (this.mController.input == this) {
this.mController.input = null;
}
]]></body>
</method>
<!-- Override the openPopup menu so we can control
showCommentColumn. -->
<method name="openPopup">
<body><![CDATA[
var searchBox = this.parentNode;
GTB_Assert(searchBox && "gtbGoogleSearchBox" == searchBox.id,
'unable to find search box');
var x = searchBox.boxObject.screenX;
var y = searchBox.boxObject.screenY + searchBox.boxObject.height;
var w = searchBox.boxObject.width;
this.popup.showCommentColumn = true;
this.popup.openPopup(this, x, y, w);
return true;
]]></body>
</method>
<!-- Firefox's autocomplete code is broken. It sets the ID of the
comment column such that if there are two autocomplete boxes, the
IDs collide. To prevent the ID collision, we remove the comment
column when we're not using it. -->
<method name="closePopup">
<body><![CDATA[
this.popup.closePopup();
this.popup.showCommentColumn = false;
]]></body>
</method>
</implementation>
</binding>
<!-- Overload showCommentColumn to apply the styles we want. -->
<binding id="gtb-search-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-result-popup">
<implementation>
<property name="showCommentColumn"
onget="return this.mShowCommentColumn;">
<setter><![CDATA[
// add or remove the comment column
if (!val && this.mShowCommentColumn) {
this.removeColumn("treecolAutoCompleteComment");
} else if (val && !this.mShowCommentColumn) {
var col = this.addColumn({
id: "treecolAutoCompleteComment",
flex: 0,
width: '150px',
style: 'text-align: right',
});
}
this.mShowCommentColumn = val;
return val;
]]></setter>
</property>
<method name="removeColumn">
<parameter name="aColId"/>
<body><![CDATA[
// Override original code that uses doc.getElementById which
// may collide.
var i, node;
for (i = 0, node = null; node = this.treecols.childNodes[i]; ++i) {
if (node.id == aColId) {
this.treecols.removeChild(node);
return true;
}
}
return false;
]]></body>
</method>
</implementation>
</binding>
</bindings>