2007-03-22 10:30:00 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
|
|
|
# -*- Mode: HTML -*-
|
2012-05-21 04:12:37 -07:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-03-26 14:59:02 -07:00
|
|
|
<!DOCTYPE bindings [
|
|
|
|
<!ENTITY % actionsDTD SYSTEM "chrome://global/locale/actions.dtd">
|
|
|
|
%actionsDTD;
|
|
|
|
]>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<bindings id="autocompleteBindings"
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:html="http://www.w3.org/1999/xhtml"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
xmlns:xbl="http://www.mozilla.org/xbl">
|
|
|
|
|
2013-07-18 21:13:35 -07:00
|
|
|
<binding id="autocomplete" role="xul:combobox"
|
2007-03-22 10:30:00 -07:00
|
|
|
extends="chrome://global/content/bindings/textbox.xml#textbox">
|
|
|
|
<resources>
|
2014-08-11 11:35:00 -07:00
|
|
|
<stylesheet src="chrome://global/content/autocomplete.css"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
|
|
|
</resources>
|
|
|
|
|
2014-02-21 12:28:43 -08:00
|
|
|
<content sizetopopup="pref">
|
2008-02-10 00:30:04 -08:00
|
|
|
<xul:hbox class="autocomplete-textbox-container" flex="1" xbl:inherits="focused">
|
2007-10-25 19:53:01 -07:00
|
|
|
<children includes="image|deck|stack|box">
|
2007-03-22 10:30:00 -07:00
|
|
|
<xul:image class="autocomplete-icon" allowevents="true"/>
|
|
|
|
</children>
|
|
|
|
|
|
|
|
<xul:hbox anonid="textbox-input-box" class="textbox-input-box" flex="1" xbl:inherits="tooltiptext=inputtooltiptext">
|
|
|
|
<children/>
|
|
|
|
<html:input anonid="input" class="autocomplete-textbox textbox-input"
|
2011-04-22 18:36:24 -07:00
|
|
|
allowevents="true"
|
2012-03-04 06:57:45 -08:00
|
|
|
xbl:inherits="tooltiptext=inputtooltiptext,value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,mozactionhint"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
</xul:hbox>
|
|
|
|
<children includes="hbox"/>
|
|
|
|
</xul:hbox>
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<xul:dropmarker anonid="historydropmarker" class="autocomplete-history-dropmarker"
|
|
|
|
allowevents="true"
|
2008-02-10 00:30:04 -08:00
|
|
|
xbl:inherits="open,enablehistory,parentfocused=focused"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<xul:popupset anonid="popupset" class="autocomplete-result-popupset"/>
|
2010-09-02 19:20:12 -07:00
|
|
|
|
|
|
|
<children includes="toolbarbutton"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
</content>
|
|
|
|
|
2013-07-18 21:13:35 -07:00
|
|
|
<implementation implements="nsIAutoCompleteInput, nsIDOMXULMenuListElement">
|
2007-03-22 10:30:00 -07:00
|
|
|
<field name="mController">null</field>
|
|
|
|
<field name="mSearchNames">null</field>
|
|
|
|
<field name="mIgnoreInput">false</field>
|
|
|
|
<field name="mEnterEvent">null</field>
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2012-02-16 11:56:06 -08:00
|
|
|
<field name="_searchBeginHandler">null</field>
|
|
|
|
<field name="_searchCompleteHandler">null</field>
|
|
|
|
<field name="_textEnteredHandler">null</field>
|
|
|
|
<field name="_textRevertedHandler">null</field>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<constructor><![CDATA[
|
2012-02-16 11:56:06 -08:00
|
|
|
this.mController = Components.classes["@mozilla.org/autocomplete/controller;1"].
|
|
|
|
getService(Components.interfaces.nsIAutoCompleteController);
|
|
|
|
|
|
|
|
this._searchBeginHandler = this.initEventHandler("searchbegin");
|
|
|
|
this._searchCompleteHandler = this.initEventHandler("searchcomplete");
|
|
|
|
this._textEnteredHandler = this.initEventHandler("textentered");
|
|
|
|
this._textRevertedHandler = this.initEventHandler("textreverted");
|
2012-01-19 03:31:29 -08:00
|
|
|
|
|
|
|
// For security reasons delay searches on pasted values.
|
|
|
|
this.inputField.controllers.insertControllerAt(0, this._pasteController);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></constructor>
|
|
|
|
|
2012-01-19 03:31:29 -08:00
|
|
|
<destructor><![CDATA[
|
|
|
|
this.inputField.controllers.removeController(this._pasteController);
|
|
|
|
]]></destructor>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<!-- =================== nsIAutoCompleteInput =================== -->
|
|
|
|
|
|
|
|
<field name="popup"><![CDATA[
|
2011-03-23 04:36:25 -07:00
|
|
|
// Wrap in a block so that the let statements don't
|
|
|
|
// create properties on 'this' (bug 635252).
|
|
|
|
{
|
|
|
|
let popup = null;
|
|
|
|
let popupId = this.getAttribute("autocompletepopup");
|
2011-02-25 11:10:25 -08:00
|
|
|
if (popupId)
|
|
|
|
popup = document.getElementById(popupId);
|
|
|
|
if (!popup) {
|
|
|
|
popup = document.createElement("panel");
|
|
|
|
popup.setAttribute("type", "autocomplete");
|
|
|
|
popup.setAttribute("noautofocus", "true");
|
2011-03-23 04:36:25 -07:00
|
|
|
|
|
|
|
let popupset = document.getAnonymousElementByAttribute(this, "anonid", "popupset");
|
2011-02-25 11:10:25 -08:00
|
|
|
popupset.appendChild(popup);
|
|
|
|
}
|
2011-03-23 04:36:25 -07:00
|
|
|
popup.mInput = this;
|
|
|
|
popup;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></field>
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<property name="controller" onget="return this.mController;" readonly="true"/>
|
|
|
|
|
|
|
|
<property name="popupOpen"
|
|
|
|
onget="return this.popup.popupOpen;"
|
|
|
|
onset="if (val) this.openPopup(); else this.closePopup();"/>
|
|
|
|
|
|
|
|
<property name="disableAutoComplete"
|
|
|
|
onset="this.setAttribute('disableautocomplete', val); return val;"
|
|
|
|
onget="return this.getAttribute('disableautocomplete') == 'true';"/>
|
|
|
|
|
|
|
|
<property name="completeDefaultIndex"
|
|
|
|
onset="this.setAttribute('completedefaultindex', val); return val;"
|
|
|
|
onget="return this.getAttribute('completedefaultindex') == 'true';"/>
|
|
|
|
|
|
|
|
<property name="completeSelectedIndex"
|
|
|
|
onset="this.setAttribute('completeselectedindex', val); return val;"
|
|
|
|
onget="return this.getAttribute('completeselectedindex') == 'true';"/>
|
|
|
|
|
|
|
|
<property name="forceComplete"
|
|
|
|
onset="this.setAttribute('forcecomplete', val); return val;"
|
|
|
|
onget="return this.getAttribute('forcecomplete') == 'true';"/>
|
|
|
|
|
|
|
|
<property name="minResultsForPopup"
|
|
|
|
onset="this.setAttribute('minresultsforpopup', val); return val;"
|
2008-07-17 06:53:04 -07:00
|
|
|
onget="var m = parseInt(this.getAttribute('minresultsforpopup')); return isNaN(m) ? 1 : m;"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<property name="showCommentColumn"
|
|
|
|
onset="this.setAttribute('showcommentcolumn', val); return val;"
|
|
|
|
onget="return this.getAttribute('showcommentcolumn') == 'true';"/>
|
|
|
|
|
2007-11-06 00:43:53 -08:00
|
|
|
<property name="showImageColumn"
|
|
|
|
onset="this.setAttribute('showimagecolumn', val); return val;"
|
|
|
|
onget="return this.getAttribute('showimagecolumn') == 'true';"/>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<property name="timeout"
|
2012-01-19 03:31:29 -08:00
|
|
|
onset="this.setAttribute('timeout', val); return val;">
|
|
|
|
<getter><![CDATA[
|
|
|
|
// For security reasons delay searches on pasted values.
|
|
|
|
if (this._valueIsPasted) {
|
|
|
|
let t = parseInt(this.getAttribute('pastetimeout'));
|
|
|
|
return isNaN(t) ? 1000 : t;
|
|
|
|
}
|
|
|
|
|
|
|
|
let t = parseInt(this.getAttribute('timeout'));
|
|
|
|
return isNaN(t) ? 50 : t;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<property name="searchParam"
|
2009-06-28 05:28:24 -07:00
|
|
|
onget="return this.getAttribute('autocompletesearchparam') || '';"
|
2007-03-22 10:30:00 -07:00
|
|
|
onset="this.setAttribute('autocompletesearchparam', val); return val;"/>
|
|
|
|
|
|
|
|
<property name="searchCount" readonly="true"
|
|
|
|
onget="this.initSearchNames(); return this.mSearchNames.length;"/>
|
|
|
|
|
2012-02-17 22:40:10 -08:00
|
|
|
<field name="PrivateBrowsingUtils" readonly="true">
|
|
|
|
let utils = {};
|
|
|
|
Components.utils.import("resource://gre/modules/PrivateBrowsingUtils.jsm", utils);
|
|
|
|
utils.PrivateBrowsingUtils
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<property name="inPrivateContext" readonly="true"
|
2012-11-26 14:20:56 -08:00
|
|
|
onget="return this.PrivateBrowsingUtils.isWindowPrivate(window);"/>
|
2012-02-17 22:40:10 -08:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<!-- This is the maximum number of drop-down rows we get when we
|
2007-03-22 10:30:00 -07:00
|
|
|
hit the drop marker beside fields that have it (like the URLbar).-->
|
2007-11-29 20:57:57 -08:00
|
|
|
<field name="maxDropMarkerRows" readonly="true">14</field>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<method name="getSearchAt">
|
|
|
|
<parameter name="aIndex"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
this.initSearchNames();
|
|
|
|
return this.mSearchNames[aIndex];
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<property name="textValue"
|
|
|
|
onget="return this.value;">
|
|
|
|
<setter><![CDATA[
|
|
|
|
// Completing a result should simulate the user typing the result,
|
|
|
|
// so fire an input event.
|
2012-01-19 03:31:27 -08:00
|
|
|
// Trim popup selected values, but never trim results coming from
|
|
|
|
// autofill.
|
|
|
|
if (this.popup.selectedIndex == -1)
|
|
|
|
this._disableTrim = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
this.value = val;
|
2012-01-19 03:31:27 -08:00
|
|
|
this._disableTrim = false;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
var evt = document.createEvent("UIEvents");
|
|
|
|
evt.initUIEvent("input", true, false, window, 0);
|
|
|
|
this.mIgnoreInput = true;
|
|
|
|
this.dispatchEvent(evt);
|
|
|
|
this.mIgnoreInput = false;
|
|
|
|
return this.value;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="selectTextRange">
|
|
|
|
<parameter name="aStartIndex"/>
|
|
|
|
<parameter name="aEndIndex"/>
|
|
|
|
<body><![CDATA[
|
2008-02-06 11:00:09 -08:00
|
|
|
this.inputField.setSelectionRange(aStartIndex, aEndIndex);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2008-02-21 15:17:33 -08:00
|
|
|
<method name="onSearchBegin">
|
|
|
|
<body><![CDATA[
|
2012-02-16 11:56:06 -08:00
|
|
|
if (this._searchBeginHandler)
|
|
|
|
this._searchBeginHandler();
|
2008-02-21 15:17:33 -08:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<method name="onSearchComplete">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.mController.matchCount == 0)
|
2008-07-17 01:33:51 -07:00
|
|
|
this.setAttribute("nomatch", "true");
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
2008-07-17 01:33:51 -07:00
|
|
|
this.removeAttribute("nomatch");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-02-16 11:56:06 -08:00
|
|
|
if (this._searchCompleteHandler)
|
|
|
|
this._searchCompleteHandler();
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onTextEntered">
|
|
|
|
<body><![CDATA[
|
2012-02-16 11:56:06 -08:00
|
|
|
let rv = false;
|
|
|
|
if (this._textEnteredHandler)
|
|
|
|
rv = this._textEnteredHandler(this.mEnterEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
this.mEnterEvent = null;
|
|
|
|
return rv;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onTextReverted">
|
|
|
|
<body><![CDATA[
|
2012-02-16 11:56:06 -08:00
|
|
|
if (this._textRevertedHandler)
|
2012-02-24 05:32:00 -08:00
|
|
|
return this._textRevertedHandler();
|
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- =================== nsIDOMXULMenuListElement =================== -->
|
|
|
|
|
|
|
|
<property name="editable" readonly="true"
|
2007-11-29 20:57:57 -08:00
|
|
|
onget="return true;" />
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<property name="crop"
|
|
|
|
onset="this.setAttribute('crop',val); return val;"
|
|
|
|
onget="return this.getAttribute('crop');"/>
|
|
|
|
|
|
|
|
<property name="open"
|
|
|
|
onget="return this.getAttribute('open') == 'true';">
|
|
|
|
<setter><![CDATA[
|
2008-02-13 02:37:36 -08:00
|
|
|
if (val)
|
|
|
|
this.showHistoryPopup();
|
|
|
|
else
|
|
|
|
this.closePopup();
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<!-- =================== PUBLIC MEMBERS =================== -->
|
|
|
|
|
2011-09-19 20:35:33 -07:00
|
|
|
<field name="valueIsTyped">false</field>
|
2012-01-19 03:31:27 -08:00
|
|
|
<field name="_disableTrim">false</field>
|
2010-03-26 14:59:02 -07:00
|
|
|
<property name="value">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (typeof this.onBeforeValueGet == "function") {
|
|
|
|
var result = this.onBeforeValueGet();
|
|
|
|
if (result)
|
|
|
|
return result.value;
|
|
|
|
}
|
|
|
|
return this.inputField.value;
|
|
|
|
]]></getter>
|
2007-03-22 10:30:00 -07:00
|
|
|
<setter><![CDATA[
|
|
|
|
this.mIgnoreInput = true;
|
2010-03-26 14:59:02 -07:00
|
|
|
|
|
|
|
if (typeof this.onBeforeValueSet == "function")
|
|
|
|
val = this.onBeforeValueSet(val);
|
|
|
|
|
2012-01-19 03:31:27 -08:00
|
|
|
if (typeof this.trimValue == "function" && !this._disableTrim)
|
2011-06-23 01:13:41 -07:00
|
|
|
val = this.trimValue(val);
|
|
|
|
|
2011-09-19 20:35:33 -07:00
|
|
|
this.valueIsTyped = false;
|
2010-03-03 23:13:27 -08:00
|
|
|
this.inputField.value = val;
|
2011-06-23 01:13:41 -07:00
|
|
|
|
2011-05-02 10:50:18 -07:00
|
|
|
if (typeof this.formatValue == "function")
|
|
|
|
this.formatValue();
|
2011-06-23 01:13:41 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
this.mIgnoreInput = false;
|
|
|
|
var event = document.createEvent('Events');
|
|
|
|
event.initEvent('ValueChange', true, true);
|
2008-02-06 11:00:09 -08:00
|
|
|
this.inputField.dispatchEvent(event);
|
2007-03-22 10:30:00 -07:00
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<property name="focused" readonly="true"
|
|
|
|
onget="return this.getAttribute('focused') == 'true';"/>
|
|
|
|
|
|
|
|
<!-- maximum number of rows to display at a time -->
|
|
|
|
<property name="maxRows"
|
|
|
|
onset="this.setAttribute('maxrows', val); return val;"
|
|
|
|
onget="return parseInt(this.getAttribute('maxrows')) || 0;"/>
|
|
|
|
|
|
|
|
<!-- option to allow scrolling through the list via the tab key, rather than
|
|
|
|
tab moving focus out of the textbox -->
|
|
|
|
<property name="tabScrolling"
|
|
|
|
onset="return this.setAttribute('tabscrolling', val); return val;"
|
|
|
|
onget="return this.getAttribute('tabscrolling') == 'true';"/>
|
|
|
|
|
|
|
|
<!-- disable key navigation handling in the popup results -->
|
|
|
|
<property name="disableKeyNavigation"
|
|
|
|
onset="this.setAttribute('disablekeynavigation', val); return val;"
|
|
|
|
onget="return this.getAttribute('disablekeynavigation') == 'true';"/>
|
|
|
|
|
2008-07-17 06:53:04 -07:00
|
|
|
<!-- option to completely ignore any blur events while
|
2007-03-22 10:30:00 -07:00
|
|
|
searches are still going on. This is useful so that nothing
|
|
|
|
gets autopicked if the window is required to lose focus for
|
|
|
|
some reason (eg in LDAP autocomplete, another window may be
|
|
|
|
brought up so that the user can enter a password to authenticate
|
|
|
|
to an LDAP server). -->
|
|
|
|
<property name="ignoreBlurWhileSearching"
|
|
|
|
onset="this.setAttribute('ignoreblurwhilesearching', val); return val;"
|
|
|
|
onget="return this.getAttribute('ignoreblurwhilesearching') == 'true';"/>
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2008-07-28 09:05:37 -07:00
|
|
|
<!-- option to highlight entries that don't have any matches -->
|
|
|
|
<property name="highlightNonMatches"
|
|
|
|
onset="this.setAttribute('highlightnonmatches', val); return val;"
|
|
|
|
onget="return this.getAttribute('highlightnonmatches') == 'true';"/>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<!-- =================== PRIVATE MEMBERS =================== -->
|
|
|
|
|
|
|
|
<!-- ::::::::::::: autocomplete controller ::::::::::::: -->
|
|
|
|
|
|
|
|
<method name="attachController">
|
|
|
|
<body><![CDATA[
|
2008-04-11 23:07:09 -07:00
|
|
|
this.mController.input = this;
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="detachController">
|
|
|
|
<body><![CDATA[
|
2008-07-17 06:53:04 -07:00
|
|
|
try {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (this.mController.input == this)
|
|
|
|
this.mController.input = null;
|
|
|
|
} catch (ex) {
|
|
|
|
// nothing really to do.
|
2008-07-17 06:53:04 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- ::::::::::::: popup opening ::::::::::::: -->
|
|
|
|
|
|
|
|
<method name="openPopup">
|
|
|
|
<body><![CDATA[
|
2007-09-30 12:00:10 -07:00
|
|
|
this.popup.openAutocompletePopup(this, this);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="closePopup">
|
|
|
|
<body><![CDATA[
|
2012-06-26 14:48:15 -07:00
|
|
|
this.popup.setAttribute("consumeoutsideclicks", "false");
|
2007-03-22 10:30:00 -07:00
|
|
|
this.popup.closePopup();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="showHistoryPopup">
|
|
|
|
<body><![CDATA[
|
2008-02-13 02:37:36 -08:00
|
|
|
// history dropmarker pushed state
|
|
|
|
function cleanup(popup) {
|
|
|
|
popup.removeEventListener("popupshowing", onShow, false);
|
|
|
|
}
|
|
|
|
function onShow(event) {
|
|
|
|
var popup = event.target, input = popup.input;
|
|
|
|
cleanup(popup);
|
|
|
|
input.setAttribute("open", "true");
|
|
|
|
function onHide() {
|
|
|
|
input.removeAttribute("open");
|
2012-06-26 14:48:15 -07:00
|
|
|
popup.setAttribute("consumeoutsideclicks", "false");
|
2008-02-13 02:37:36 -08:00
|
|
|
popup.removeEventListener("popuphiding", onHide, false);
|
|
|
|
}
|
|
|
|
popup.addEventListener("popuphiding", onHide, false);
|
|
|
|
}
|
|
|
|
this.popup.addEventListener("popupshowing", onShow, false);
|
|
|
|
setTimeout(cleanup, 1000, this.popup);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Store our "normal" maxRows on the popup, so that it can reset the
|
|
|
|
// value when the popup is hidden.
|
|
|
|
this.popup._normalMaxRows = this.maxRows;
|
|
|
|
|
|
|
|
// Increase our maxRows temporarily, since we want the dropdown to
|
|
|
|
// be bigger in this case. The popup's popupshowing/popuphiding
|
|
|
|
// handlers will take care of resetting this.
|
|
|
|
this.maxRows = this.maxDropMarkerRows;
|
|
|
|
|
|
|
|
// Ensure that we have focus.
|
|
|
|
if (!this.focused)
|
|
|
|
this.focus();
|
2012-06-26 14:48:15 -07:00
|
|
|
this.popup.setAttribute("consumeoutsideclicks", "true");
|
2007-03-22 10:30:00 -07:00
|
|
|
this.attachController();
|
|
|
|
this.mController.startSearch("");
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<method name="toggleHistoryPopup">
|
|
|
|
<body><![CDATA[
|
2013-11-27 09:28:34 -08:00
|
|
|
if (!this.popup.popupOpen)
|
2007-03-22 10:30:00 -07:00
|
|
|
this.showHistoryPopup();
|
|
|
|
else
|
|
|
|
this.closePopup();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- ::::::::::::: event dispatching ::::::::::::: -->
|
|
|
|
|
2012-02-16 11:56:06 -08:00
|
|
|
<method name="initEventHandler">
|
2007-03-22 10:30:00 -07:00
|
|
|
<parameter name="aEventType"/>
|
|
|
|
<body><![CDATA[
|
2012-02-16 11:56:06 -08:00
|
|
|
let handlerString = this.getAttribute("on" + aEventType);
|
|
|
|
if (handlerString) {
|
|
|
|
return (new Function("eventType", "param", handlerString)).bind(this, aEventType);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2012-02-16 11:56:06 -08:00
|
|
|
return null;
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- ::::::::::::: key handling ::::::::::::: -->
|
|
|
|
|
|
|
|
<method name="onKeyPress">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
2008-01-23 15:49:10 -08:00
|
|
|
if (aEvent.target.localName != "textbox")
|
2013-04-15 15:41:55 -07:00
|
|
|
return true; // Let child buttons of autocomplete take input
|
2008-01-23 15:49:10 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
//XXXpch this is so bogus...
|
2011-12-08 01:21:32 -08:00
|
|
|
if (aEvent.defaultPrevented)
|
2007-03-22 10:30:00 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
var cancel = false;
|
|
|
|
|
|
|
|
// Catch any keys that could potentially move the caret. Ctrl can be
|
2008-03-31 18:46:59 -07:00
|
|
|
// used in combination with these keys on Windows and Linux; and Alt
|
|
|
|
// can be used on OS X, so make sure the unused one isn't used.
|
|
|
|
if (!this.disableKeyNavigation &&
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
!aEvent.ctrlKey) {
|
|
|
|
#else
|
|
|
|
!aEvent.altKey) {
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
switch (aEvent.keyCode) {
|
|
|
|
case KeyEvent.DOM_VK_LEFT:
|
|
|
|
case KeyEvent.DOM_VK_RIGHT:
|
|
|
|
case KeyEvent.DOM_VK_HOME:
|
|
|
|
cancel = this.mController.handleKeyNavigation(aEvent.keyCode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle keys that are not part of a keyboard shortcut (no Ctrl or Alt)
|
|
|
|
if (!this.disableKeyNavigation && !aEvent.ctrlKey && !aEvent.altKey) {
|
|
|
|
switch (aEvent.keyCode) {
|
|
|
|
case KeyEvent.DOM_VK_TAB:
|
2013-11-27 09:28:34 -08:00
|
|
|
if (this.tabScrolling && this.popup.popupOpen)
|
2007-03-22 10:30:00 -07:00
|
|
|
cancel = this.mController.handleKeyNavigation(aEvent.shiftKey ?
|
|
|
|
KeyEvent.DOM_VK_UP :
|
|
|
|
KeyEvent.DOM_VK_DOWN);
|
2014-06-27 11:17:43 -07:00
|
|
|
else if (this.forceComplete && this.mController.matchCount >= 1)
|
|
|
|
this.mController.handleTab();
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case KeyEvent.DOM_VK_UP:
|
|
|
|
case KeyEvent.DOM_VK_DOWN:
|
|
|
|
case KeyEvent.DOM_VK_PAGE_UP:
|
|
|
|
case KeyEvent.DOM_VK_PAGE_DOWN:
|
|
|
|
cancel = this.mController.handleKeyNavigation(aEvent.keyCode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle keys we know aren't part of a shortcut, even with Alt or
|
|
|
|
// Ctrl.
|
|
|
|
switch (aEvent.keyCode) {
|
|
|
|
case KeyEvent.DOM_VK_ESCAPE:
|
|
|
|
cancel = this.mController.handleEscape();
|
|
|
|
break;
|
|
|
|
case KeyEvent.DOM_VK_RETURN:
|
2008-04-22 12:47:44 -07:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
// Prevent the default action, since it will beep on Mac
|
|
|
|
if (aEvent.metaKey)
|
|
|
|
aEvent.preventDefault();
|
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
this.mEnterEvent = aEvent;
|
2008-02-29 05:07:02 -08:00
|
|
|
cancel = this.mController.handleEnter(false);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case KeyEvent.DOM_VK_DELETE:
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
case KeyEvent.DOM_VK_BACK_SPACE:
|
|
|
|
if (aEvent.shiftKey)
|
|
|
|
#endif
|
|
|
|
cancel = this.mController.handleDelete();
|
|
|
|
break;
|
|
|
|
case KeyEvent.DOM_VK_DOWN:
|
|
|
|
case KeyEvent.DOM_VK_UP:
|
|
|
|
if (aEvent.altKey)
|
|
|
|
this.toggleHistoryPopup();
|
|
|
|
break;
|
|
|
|
#ifndef XP_MACOSX
|
|
|
|
case KeyEvent.DOM_VK_F4:
|
|
|
|
this.toggleHistoryPopup();
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cancel) {
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
aEvent.preventDefault();
|
|
|
|
}
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return true;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- ::::::::::::: miscellaneous ::::::::::::: -->
|
|
|
|
|
|
|
|
<method name="initSearchNames">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (!this.mSearchNames) {
|
|
|
|
var names = this.getAttribute("autocompletesearch");
|
|
|
|
if (!names)
|
|
|
|
this.mSearchNames = [];
|
|
|
|
else
|
|
|
|
this.mSearchNames = names.split(" ");
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<method name="_focus">
|
|
|
|
<!-- doesn't reset this.mController -->
|
2007-03-22 10:30:00 -07:00
|
|
|
<body><![CDATA[
|
|
|
|
this._dontBlur = true;
|
|
|
|
this.focus();
|
|
|
|
this._dontBlur = false;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2010-03-26 14:59:02 -07:00
|
|
|
<method name="resetActionType">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.mIgnoreInput)
|
|
|
|
return;
|
|
|
|
this.removeAttribute("actiontype");
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2012-01-19 03:31:29 -08:00
|
|
|
<field name="_valueIsPasted">false</field>
|
|
|
|
<field name="_pasteController"><![CDATA[
|
|
|
|
({
|
|
|
|
_autocomplete: this,
|
|
|
|
_kGlobalClipboard: Components.interfaces.nsIClipboard.kGlobalClipboard,
|
|
|
|
supportsCommand: function(aCommand) aCommand == "cmd_paste",
|
|
|
|
doCommand: function(aCommand) {
|
|
|
|
this._autocomplete._valueIsPasted = true;
|
|
|
|
this._autocomplete.editor.paste(this._kGlobalClipboard);
|
|
|
|
this._autocomplete._valueIsPasted = false;
|
|
|
|
},
|
|
|
|
isCommandEnabled: function(aCommand) {
|
|
|
|
return this._autocomplete.editor.isSelectionEditable &&
|
|
|
|
this._autocomplete.editor.canPaste(this._kGlobalClipboard);
|
|
|
|
},
|
|
|
|
onEvent: function() {}
|
|
|
|
})
|
|
|
|
]]></field>
|
2007-03-22 10:30:00 -07:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
2010-03-26 14:59:02 -07:00
|
|
|
<handler event="input"><![CDATA[
|
|
|
|
if (!this.mIgnoreInput && this.mController.input == this) {
|
2011-09-19 20:35:33 -07:00
|
|
|
this.valueIsTyped = true;
|
2012-01-19 03:31:29 -08:00
|
|
|
this.mController.handleText();
|
2010-03-26 14:59:02 -07:00
|
|
|
}
|
|
|
|
this.resetActionType();
|
|
|
|
]]></handler>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<handler event="keypress" phase="capturing"
|
|
|
|
action="return this.onKeyPress(event);"/>
|
|
|
|
|
|
|
|
<handler event="compositionstart" phase="capturing"
|
|
|
|
action="if (this.mController.input == this) this.mController.handleStartComposition();"/>
|
|
|
|
|
|
|
|
<handler event="compositionend" phase="capturing"
|
|
|
|
action="if (this.mController.input == this) this.mController.handleEndComposition();"/>
|
|
|
|
|
2008-02-10 00:30:04 -08:00
|
|
|
<handler event="focus" phase="capturing"
|
|
|
|
action="this.attachController();"/>
|
|
|
|
|
|
|
|
<handler event="blur" phase="capturing"
|
|
|
|
action="if (!this._dontBlur) this.detachController();"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
</handlers>
|
2007-08-21 16:55:54 -07:00
|
|
|
</binding>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<binding id="autocomplete-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-base-popup">
|
2007-03-22 10:30:00 -07:00
|
|
|
<resources>
|
2014-08-11 11:35:00 -07:00
|
|
|
<stylesheet src="chrome://global/content/autocomplete.css"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<stylesheet src="chrome://global/skin/tree.css"/>
|
|
|
|
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
|
|
|
</resources>
|
|
|
|
|
2012-06-26 14:48:15 -07:00
|
|
|
<content ignorekeys="true" level="top" consumeoutsideclicks="false">
|
2008-01-23 15:49:10 -08:00
|
|
|
<xul:tree anonid="tree" class="autocomplete-tree plain" hidecolumnpicker="true" flex="1" seltype="single">
|
2007-03-22 10:30:00 -07:00
|
|
|
<xul:treecols anonid="treecols">
|
|
|
|
<xul:treecol id="treecolAutoCompleteValue" class="autocomplete-treecol" flex="1" overflow="true"/>
|
|
|
|
</xul:treecols>
|
|
|
|
<xul:treechildren class="autocomplete-treebody"/>
|
|
|
|
</xul:tree>
|
|
|
|
</content>
|
2007-08-31 13:19:19 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<implementation>
|
|
|
|
<field name="mShowCommentColumn">false</field>
|
|
|
|
<field name="mShowImageColumn">false</field>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<property name="showCommentColumn"
|
|
|
|
onget="return this.mShowCommentColumn;">
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
if (!val && this.mShowCommentColumn) {
|
|
|
|
// reset the flex on the value column and remove the comment column
|
|
|
|
document.getElementById("treecolAutoCompleteValue").setAttribute("flex", 1);
|
|
|
|
this.removeColumn("treecolAutoCompleteComment");
|
|
|
|
} else if (val && !this.mShowCommentColumn) {
|
|
|
|
// reset the flex on the value column and add the comment column
|
|
|
|
document.getElementById("treecolAutoCompleteValue").setAttribute("flex", 2);
|
|
|
|
this.addColumn({id: "treecolAutoCompleteComment", flex: 1});
|
|
|
|
}
|
|
|
|
this.mShowCommentColumn = val;
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<property name="showImageColumn"
|
|
|
|
onget="return this.mShowImageColumn;">
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
if (!val && this.mShowImageColumn) {
|
|
|
|
// remove the image column
|
|
|
|
this.removeColumn("treecolAutoCompleteImage");
|
|
|
|
} else if (val && !this.mShowImageColumn) {
|
|
|
|
// add the image column
|
|
|
|
this.addColumn({id: "treecolAutoCompleteImage", flex: 1});
|
|
|
|
}
|
|
|
|
this.mShowImageColumn = val;
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
|
|
|
|
<method name="addColumn">
|
|
|
|
<parameter name="aAttrs"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var col = document.createElement("treecol");
|
|
|
|
col.setAttribute("class", "autocomplete-treecol");
|
|
|
|
for (var name in aAttrs)
|
|
|
|
col.setAttribute(name, aAttrs[name]);
|
|
|
|
this.treecols.appendChild(col);
|
|
|
|
return col;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="removeColumn">
|
|
|
|
<parameter name="aColId"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
return this.treecols.removeChild(document.getElementById(aColId));
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<property name="selectedIndex"
|
|
|
|
onget="return this.tree.currentIndex;">
|
2007-11-29 20:57:57 -08:00
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
2007-03-22 10:30:00 -07:00
|
|
|
this.tree.view.selection.select(val);
|
|
|
|
if (this.tree.treeBoxObject.height > 0)
|
|
|
|
this.tree.treeBoxObject.ensureRowIsVisible(val < 0 ? 0 : val);
|
|
|
|
// Fire select event on xul:tree so that accessibility API
|
|
|
|
// support layer can fire appropriate accessibility events.
|
|
|
|
var event = document.createEvent('Events');
|
|
|
|
event.initEvent("select", true, true);
|
|
|
|
this.tree.dispatchEvent(event);
|
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<method name="adjustHeight">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// detect the desired height of the tree
|
|
|
|
var bx = this.tree.treeBoxObject;
|
|
|
|
var view = this.tree.view;
|
|
|
|
if (!view)
|
|
|
|
return;
|
|
|
|
var rows = this.maxRows;
|
|
|
|
if (!view.rowCount || (rows && view.rowCount < rows))
|
|
|
|
rows = view.rowCount;
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
var height = rows * bx.rowHeight;
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
if (height == 0)
|
|
|
|
this.tree.setAttribute("collapsed", "true");
|
|
|
|
else {
|
|
|
|
if (this.tree.hasAttribute("collapsed"))
|
|
|
|
this.tree.removeAttribute("collapsed");
|
|
|
|
|
|
|
|
this.tree.setAttribute("height", height);
|
|
|
|
}
|
|
|
|
this.tree.setAttribute("hidescrollbar", view.rowCount <= rows);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-04 08:49:38 -07:00
|
|
|
<method name="openAutocompletePopup">
|
2007-12-04 13:00:12 -08:00
|
|
|
<parameter name="aInput"/>
|
|
|
|
<parameter name="aElement"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
// until we have "baseBinding", (see bug #373652) this allows
|
|
|
|
// us to override openAutocompletePopup(), but still call
|
|
|
|
// the method on the base class
|
|
|
|
this._openAutocompletePopup(aInput, aElement);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_openAutocompletePopup">
|
2007-03-22 10:30:00 -07:00
|
|
|
<parameter name="aInput"/>
|
2007-09-30 12:00:10 -07:00
|
|
|
<parameter name="aElement"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<body><![CDATA[
|
|
|
|
if (!this.mPopupOpen) {
|
|
|
|
this.mInput = aInput;
|
|
|
|
this.view = aInput.controller.QueryInterface(Components.interfaces.nsITreeView);
|
|
|
|
this.invalidate();
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
this.showCommentColumn = this.mInput.showCommentColumn;
|
2007-11-06 00:43:53 -08:00
|
|
|
this.showImageColumn = this.mInput.showImageColumn;
|
2007-08-31 13:19:19 -07:00
|
|
|
|
2007-09-30 12:00:10 -07:00
|
|
|
var rect = aElement.getBoundingClientRect();
|
2007-12-12 05:27:09 -08:00
|
|
|
var nav = aElement.ownerDocument.defaultView.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Components.interfaces.nsIWebNavigation);
|
|
|
|
var docShell = nav.QueryInterface(Components.interfaces.nsIDocShell);
|
2014-07-09 14:27:49 -07:00
|
|
|
var docViewer = docShell.contentViewer;
|
2007-12-12 05:27:09 -08:00
|
|
|
var width = (rect.right - rect.left) * docViewer.fullZoom;
|
2007-10-12 03:24:00 -07:00
|
|
|
this.setAttribute("width", width > 100 ? width : 100);
|
2007-09-30 12:00:10 -07:00
|
|
|
|
2011-04-27 01:09:23 -07:00
|
|
|
// Adjust the direction of the autocomplete popup list based on the textbox direction, bug 649840
|
|
|
|
var popupDirection = aElement.ownerDocument.defaultView.getComputedStyle(aElement).direction;
|
|
|
|
this.style.direction = popupDirection;
|
|
|
|
|
2008-03-28 12:22:50 -07:00
|
|
|
this.openPopup(aElement, "after_start", 0, 0, false, false);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="invalidate">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.adjustHeight();
|
|
|
|
this.tree.treeBoxObject.invalidate();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="selectBy">
|
|
|
|
<parameter name="aReverse"/>
|
|
|
|
<parameter name="aPage"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
try {
|
|
|
|
var amount = aPage ? 5 : 1;
|
|
|
|
this.selectedIndex = this.getNextIndex(aReverse, amount, this.selectedIndex, this.tree.view.rowCount-1);
|
|
|
|
if (this.selectedIndex == -1) {
|
|
|
|
this.input._focus();
|
|
|
|
}
|
|
|
|
} catch (ex) {
|
|
|
|
// do nothing - occasionally timer-related js errors happen here
|
|
|
|
// e.g. "this.selectedIndex has no properties", when you type fast and hit a
|
|
|
|
// navigation key before this popup has opened
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- =================== PUBLIC MEMBERS =================== -->
|
|
|
|
|
|
|
|
<field name="tree">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "tree");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<field name="treecols">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "treecols");
|
|
|
|
</field>
|
|
|
|
|
2008-07-17 06:53:04 -07:00
|
|
|
<property name="view"
|
2007-03-22 10:30:00 -07:00
|
|
|
onget="return this.mView;">
|
|
|
|
<setter><![CDATA[
|
|
|
|
// We must do this by hand because the tree binding may not be ready yet
|
|
|
|
this.mView = val;
|
|
|
|
var bx = this.tree.boxObject;
|
|
|
|
bx = bx.QueryInterface(Components.interfaces.nsITreeBoxObject);
|
|
|
|
bx.view = val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2013-07-18 21:13:35 -07:00
|
|
|
<binding id="autocomplete-base-popup" role="none"
|
|
|
|
extends="chrome://global/content/bindings/popup.xml#popup">
|
2007-11-29 20:57:57 -08:00
|
|
|
<implementation implements="nsIAutoCompletePopup">
|
|
|
|
<field name="mInput">null</field>
|
|
|
|
<field name="mPopupOpen">false</field>
|
|
|
|
|
|
|
|
<!-- =================== nsIAutoCompletePopup =================== -->
|
|
|
|
|
|
|
|
<property name="input" readonly="true"
|
|
|
|
onget="return this.mInput"/>
|
|
|
|
|
|
|
|
<property name="overrideValue" readonly="true"
|
|
|
|
onget="return null;"/>
|
|
|
|
|
|
|
|
<property name="popupOpen" readonly="true"
|
|
|
|
onget="return this.mPopupOpen;"/>
|
|
|
|
|
|
|
|
<method name="closePopup">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (this.mPopupOpen) {
|
|
|
|
this.hidePopup();
|
|
|
|
this.removeAttribute("width");
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<!-- This is the default number of rows that we give the autocomplete
|
|
|
|
popup when the textbox doesn't have a "maxrows" attribute
|
|
|
|
for us to use. -->
|
|
|
|
<field name="defaultMaxRows" readonly="true">6</field>
|
|
|
|
|
|
|
|
<!-- In some cases (e.g. when the input's dropmarker button is clicked),
|
|
|
|
the input wants to display a popup with more rows. In that case, it
|
|
|
|
should increase its maxRows property and store the "normal" maxRows
|
|
|
|
in this field. When the popup is hidden, we restore the input's
|
|
|
|
maxRows to the value stored in this field.
|
|
|
|
|
|
|
|
This field is set to -1 between uses so that we can tell when it's
|
|
|
|
been set by the input and when we need to set it in the popupshowing
|
|
|
|
handler. -->
|
|
|
|
<field name="_normalMaxRows">-1</field>
|
|
|
|
|
|
|
|
<property name="maxRows" readonly="true">
|
2007-11-29 20:57:57 -08:00
|
|
|
<getter>
|
2007-11-06 00:43:53 -08:00
|
|
|
<![CDATA[
|
2007-11-29 20:57:57 -08:00
|
|
|
return (this.mInput && this.mInput.maxRows) || this.defaultMaxRows;
|
2007-08-31 13:19:19 -07:00
|
|
|
]]>
|
2007-11-29 20:57:57 -08:00
|
|
|
</getter>
|
2007-08-31 13:19:19 -07:00
|
|
|
</property>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<method name="getNextIndex">
|
|
|
|
<parameter name="aReverse"/>
|
|
|
|
<parameter name="aAmount"/>
|
|
|
|
<parameter name="aIndex"/>
|
|
|
|
<parameter name="aMaxRow"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aMaxRow < 0)
|
|
|
|
return -1;
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
var newIdx = aIndex + (aReverse?-1:1)*aAmount;
|
|
|
|
if (aReverse && aIndex == -1 || newIdx > aMaxRow && aIndex != aMaxRow)
|
|
|
|
newIdx = aMaxRow;
|
|
|
|
else if (!aReverse && aIndex == -1 || newIdx < 0 && aIndex != 0)
|
|
|
|
newIdx = 0;
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (newIdx < 0 && aIndex == 0 || newIdx > aMaxRow && aIndex == aMaxRow)
|
|
|
|
aIndex = -1;
|
|
|
|
else
|
|
|
|
aIndex = newIdx;
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return aIndex;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onPopupClick">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
|
2008-02-29 05:07:02 -08:00
|
|
|
controller.handleEnter(true);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="popupshowing"><![CDATA[
|
|
|
|
// If normalMaxRows wasn't already set by the input, then set it here
|
|
|
|
// so that we restore the correct number when the popup is hidden.
|
|
|
|
if (this._normalMaxRows < 0)
|
|
|
|
this._normalMaxRows = this.mInput.maxRows;
|
|
|
|
|
|
|
|
this.mPopupOpen = true;
|
|
|
|
]]></handler>
|
|
|
|
|
2007-08-21 16:55:54 -07:00
|
|
|
<handler event="popuphiding"><![CDATA[
|
2008-01-23 15:49:10 -08:00
|
|
|
var isListActive = true;
|
|
|
|
if (this.selectedIndex == -1)
|
|
|
|
isListActive = false;
|
2007-08-21 16:55:54 -07:00
|
|
|
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
|
|
|
|
controller.stopSearch();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
this.mPopupOpen = false;
|
|
|
|
|
|
|
|
// Reset the maxRows property to the cached "normal" value, and reset
|
|
|
|
// _normalMaxRows so that we can detect whether it was set by the input
|
|
|
|
// when the popupshowing handler runs.
|
|
|
|
this.mInput.maxRows = this._normalMaxRows;
|
|
|
|
this._normalMaxRows = -1;
|
2008-01-23 15:49:10 -08:00
|
|
|
// If the list was being navigated and then closed, make sure
|
|
|
|
// we fire accessible focus event back to textbox
|
2008-03-06 13:43:43 -08:00
|
|
|
if (isListActive) {
|
|
|
|
this.mInput.mIgnoreFocus = true;
|
2008-01-23 15:49:10 -08:00
|
|
|
this.mInput._focus();
|
2008-03-06 13:43:43 -08:00
|
|
|
this.mInput.mIgnoreFocus = false;
|
|
|
|
}
|
2007-08-21 16:55:54 -07:00
|
|
|
]]></handler>
|
2007-03-22 10:30:00 -07:00
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<binding id="autocomplete-rich-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-base-popup">
|
|
|
|
<resources>
|
2014-08-11 11:35:00 -07:00
|
|
|
<stylesheet src="chrome://global/content/autocomplete.css"/>
|
2007-11-29 20:57:57 -08:00
|
|
|
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
|
|
|
</resources>
|
|
|
|
|
2012-06-26 14:48:15 -07:00
|
|
|
<content ignorekeys="true" level="top" consumeoutsideclicks="false">
|
2007-11-29 20:57:57 -08:00
|
|
|
<xul:richlistbox anonid="richlistbox" class="autocomplete-richlistbox" flex="1"/>
|
2008-07-17 06:53:04 -07:00
|
|
|
<xul:hbox>
|
|
|
|
<children/>
|
|
|
|
</xul:hbox>
|
2007-11-29 20:57:57 -08:00
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation implements="nsIAutoCompletePopup">
|
|
|
|
<field name="_currentIndex">0</field>
|
2012-10-25 12:27:30 -07:00
|
|
|
<field name="_rowHeight">0</field>
|
2007-11-29 20:57:57 -08:00
|
|
|
|
|
|
|
<!-- =================== nsIAutoCompletePopup =================== -->
|
|
|
|
|
|
|
|
<property name="selectedIndex"
|
|
|
|
onget="return this.richlistbox.selectedIndex;">
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
this.richlistbox.selectedIndex = val;
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-12-14 11:07:20 -08:00
|
|
|
// when clearing the selection (val == -1, so selectedItem will be
|
|
|
|
// null), we want to scroll back to the top. see bug #406194
|
|
|
|
this.richlistbox.ensureElementIsVisible(
|
|
|
|
this.richlistbox.selectedItem || this.richlistbox.firstChild);
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="openAutocompletePopup">
|
2007-12-04 13:00:12 -08:00
|
|
|
<parameter name="aInput"/>
|
|
|
|
<parameter name="aElement"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// until we have "baseBinding", (see bug #373652) this allows
|
|
|
|
// us to override openAutocompletePopup(), but still call
|
|
|
|
// the method on the base class
|
|
|
|
this._openAutocompletePopup(aInput, aElement);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_openAutocompletePopup">
|
2007-11-29 20:57:57 -08:00
|
|
|
<parameter name="aInput"/>
|
|
|
|
<parameter name="aElement"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this.mPopupOpen) {
|
|
|
|
this.mInput = aInput;
|
2009-04-19 15:51:38 -07:00
|
|
|
// clear any previous selection, see bugs 400671 and 488357
|
|
|
|
this.selectedIndex = -1;
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2009-04-19 15:51:38 -07:00
|
|
|
var width = aElement.getBoundingClientRect().width;
|
2007-11-29 20:57:57 -08:00
|
|
|
this.setAttribute("width", width > 100 ? width : 100);
|
|
|
|
// invalidate() depends on the width attribute
|
2008-03-12 22:31:14 -07:00
|
|
|
this._invalidate();
|
2007-11-29 20:57:57 -08:00
|
|
|
|
|
|
|
this.openPopup(aElement, "after_start", 0, 0, false, false);
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="invalidate">
|
2008-03-12 22:31:14 -07:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// Don't bother doing work if we're not even showing
|
|
|
|
if (!this.mPopupOpen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._invalidate();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_invalidate">
|
2007-11-29 20:57:57 -08:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2008-09-13 14:03:07 -07:00
|
|
|
if (!this.hasAttribute("height")) {
|
|
|
|
// collapsed if no matches
|
|
|
|
this.richlistbox.collapsed = (this._matchCount == 0);
|
|
|
|
|
2009-07-28 10:11:09 -07:00
|
|
|
// Dynamically update height until richlistbox.rows works (bug 401939)
|
|
|
|
// Adjust the height immediately and after the row contents update
|
|
|
|
this.adjustHeight();
|
2008-09-13 14:03:07 -07:00
|
|
|
setTimeout(function(self) self.adjustHeight(), 0, this);
|
|
|
|
}
|
2008-04-11 16:35:23 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
// make sure to collapse any existing richlistitems
|
|
|
|
// that aren't going to be used
|
|
|
|
var existingItemsCount = this.richlistbox.childNodes.length;
|
|
|
|
for (var i = this._matchCount; i < existingItemsCount; i++)
|
|
|
|
this.richlistbox.childNodes[i].collapsed = true;
|
|
|
|
|
|
|
|
this._currentIndex = 0;
|
|
|
|
this._appendCurrentResult();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<property name="maxResults" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
// this is how many richlistitems will be kept around
|
|
|
|
// (note, this getter may be overridden)
|
|
|
|
return 20;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<property name="_matchCount" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
return Math.min(this.mInput.controller.matchCount, this.maxResults);
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2008-04-02 20:49:36 -07:00
|
|
|
<method name="adjustHeight">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// Figure out how many rows to show
|
|
|
|
let rows = this.richlistbox.childNodes;
|
|
|
|
let numRows = Math.min(this._matchCount, this.maxRows, rows.length);
|
|
|
|
|
|
|
|
// Default the height to 0 if we have no rows to show
|
|
|
|
let height = 0;
|
|
|
|
if (numRows) {
|
2012-10-25 12:27:30 -07:00
|
|
|
if (!this._rowHeight) {
|
|
|
|
let firstRowRect = rows[0].getBoundingClientRect();
|
|
|
|
this._rowHeight = firstRowRect.height;
|
|
|
|
}
|
2008-04-02 20:49:36 -07:00
|
|
|
|
|
|
|
// Calculate the height to have the first row to last row shown
|
2012-10-25 12:27:30 -07:00
|
|
|
height = this._rowHeight * numRows;
|
2008-04-02 20:49:36 -07:00
|
|
|
}
|
|
|
|
|
2008-04-11 16:35:23 -07:00
|
|
|
// Only update the height if we have a non-zero height and if it
|
|
|
|
// changed (the richlistbox is collapsed if there are no results)
|
|
|
|
if (height && height != this.richlistbox.height)
|
2008-04-02 20:49:36 -07:00
|
|
|
this.richlistbox.height = height;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<method name="_appendCurrentResult">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var controller = this.mInput.controller;
|
2009-03-26 05:52:31 -07:00
|
|
|
var matchCount = this._matchCount;
|
|
|
|
var existingItemsCount = this.richlistbox.childNodes.length;
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2008-04-11 16:35:23 -07:00
|
|
|
// Process maxRows per chunk to improve performance and user experience
|
|
|
|
for (let i = 0; i < this.maxRows; i++) {
|
2009-03-26 05:52:31 -07:00
|
|
|
if (this._currentIndex >= matchCount)
|
2007-12-07 09:50:45 -08:00
|
|
|
return;
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
var item;
|
|
|
|
|
|
|
|
// trim the leading/trailing whitespace
|
2008-07-17 06:53:04 -07:00
|
|
|
var trimmedSearchString = controller.searchString.replace(/^\s+/, "").replace(/\s+$/, "");
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2008-03-12 16:39:40 -07:00
|
|
|
// Unescape the URI spec for showing as an entry in the popup
|
|
|
|
let url = Components.classes["@mozilla.org/intl/texttosuburi;1"].
|
|
|
|
getService(Components.interfaces.nsITextToSubURI).
|
|
|
|
unEscapeURIForUI("UTF-8", controller.getValueAt(this._currentIndex));
|
|
|
|
|
2011-06-23 01:13:41 -07:00
|
|
|
if (typeof this.input.trimValue == "function")
|
|
|
|
url = this.input.trimValue(url);
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
if (this._currentIndex < existingItemsCount) {
|
|
|
|
// re-use the existing item
|
|
|
|
item = this.richlistbox.childNodes[this._currentIndex];
|
2008-03-12 22:31:14 -07:00
|
|
|
|
|
|
|
// Completely re-use the existing richlistitem if it's the same
|
|
|
|
if (item.getAttribute("text") == trimmedSearchString &&
|
|
|
|
item.getAttribute("url") == url) {
|
|
|
|
item.collapsed = false;
|
|
|
|
this._currentIndex++;
|
|
|
|
continue;
|
|
|
|
}
|
2007-11-29 20:57:57 -08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// need to create a new item
|
|
|
|
item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "richlistitem");
|
|
|
|
}
|
|
|
|
|
2008-07-17 06:53:04 -07:00
|
|
|
// set these attributes before we set the class
|
2012-01-19 03:31:29 -08:00
|
|
|
// so that we can use them from the constructor
|
2007-11-29 20:57:57 -08:00
|
|
|
item.setAttribute("image", controller.getImageAt(this._currentIndex));
|
2008-03-12 16:39:40 -07:00
|
|
|
item.setAttribute("url", url);
|
2007-11-29 20:57:57 -08:00
|
|
|
item.setAttribute("title", controller.getCommentAt(this._currentIndex));
|
|
|
|
item.setAttribute("type", controller.getStyleAt(this._currentIndex));
|
|
|
|
item.setAttribute("text", trimmedSearchString);
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
if (this._currentIndex < existingItemsCount) {
|
|
|
|
// re-use the existing item
|
|
|
|
item._adjustAcItem();
|
|
|
|
item.collapsed = false;
|
|
|
|
}
|
|
|
|
else {
|
2008-07-17 06:53:04 -07:00
|
|
|
// set the class at the end so we can use the attributes
|
2007-11-29 20:57:57 -08:00
|
|
|
// in the xbl constructor
|
|
|
|
item.className = "autocomplete-richlistitem";
|
|
|
|
this.richlistbox.appendChild(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._currentIndex++;
|
|
|
|
}
|
2007-12-07 09:50:45 -08:00
|
|
|
|
|
|
|
// yield after each batch of items so that typing the url bar is responsive
|
|
|
|
setTimeout(function (self) { self._appendCurrentResult(); }, 0, this);
|
2007-11-29 20:57:57 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="selectBy">
|
|
|
|
<parameter name="aReverse"/>
|
|
|
|
<parameter name="aPage"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
try {
|
|
|
|
var amount = aPage ? 5 : 1;
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
// because we collapsed unused items, we can't use this.richlistbox.getRowCount(), we need to use the matchCount
|
|
|
|
this.selectedIndex = this.getNextIndex(aReverse, amount, this.selectedIndex, this._matchCount - 1);
|
|
|
|
if (this.selectedIndex == -1) {
|
|
|
|
this.input._focus();
|
|
|
|
}
|
|
|
|
} catch (ex) {
|
|
|
|
// do nothing - occasionally timer-related js errors happen here
|
|
|
|
// e.g. "this.selectedIndex has no properties", when you type fast and hit a
|
|
|
|
// navigation key before this popup has opened
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<field name="richlistbox">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "richlistbox");
|
|
|
|
</field>
|
|
|
|
|
2008-07-17 06:53:04 -07:00
|
|
|
<property name="view"
|
2007-11-29 20:57:57 -08:00
|
|
|
onget="return this.mInput.controller;"
|
|
|
|
onset="return val;"/>
|
|
|
|
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="autocomplete-richlistitem" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
|
|
|
<content>
|
2010-03-26 14:59:02 -07:00
|
|
|
<xul:hbox align="center" class="ac-title-box">
|
2008-01-02 21:52:37 -08:00
|
|
|
<xul:image xbl:inherits="src=image" class="ac-site-icon"/>
|
2008-03-08 01:30:43 -08:00
|
|
|
<xul:hbox anonid="title-box" class="ac-title" flex="1"
|
2010-12-10 18:32:14 -08:00
|
|
|
onunderflow="_doUnderflow('_title');"
|
|
|
|
onoverflow="_doOverflow('_title');">
|
2008-03-20 14:42:55 -07:00
|
|
|
<xul:description anonid="title" class="ac-normal-text ac-comment" xbl:inherits="selected"/>
|
2007-11-29 20:57:57 -08:00
|
|
|
</xul:hbox>
|
2008-01-02 21:52:37 -08:00
|
|
|
<xul:label anonid="title-overflow-ellipsis" xbl:inherits="selected"
|
2010-12-10 18:32:14 -08:00
|
|
|
class="ac-ellipsis-after ac-comment"/>
|
2009-10-01 07:12:29 -07:00
|
|
|
<xul:hbox anonid="extra-box" class="ac-extra" align="center" hidden="true">
|
|
|
|
<xul:image class="ac-result-type-tag"/>
|
|
|
|
<xul:label class="ac-normal-text ac-comment" xbl:inherits="selected" value=":"/>
|
|
|
|
<xul:description anonid="extra" class="ac-normal-text ac-comment" xbl:inherits="selected"/>
|
|
|
|
</xul:hbox>
|
2008-01-02 21:52:37 -08:00
|
|
|
<xul:image anonid="type-image" class="ac-type-icon"/>
|
|
|
|
</xul:hbox>
|
2008-07-17 06:53:04 -07:00
|
|
|
<xul:hbox align="center" class="ac-url-box">
|
2008-01-02 21:52:37 -08:00
|
|
|
<xul:spacer class="ac-site-icon"/>
|
2010-03-26 14:59:02 -07:00
|
|
|
<xul:image class="ac-action-icon"/>
|
2008-03-08 01:30:43 -08:00
|
|
|
<xul:hbox anonid="url-box" class="ac-url" flex="1"
|
2010-12-10 18:32:14 -08:00
|
|
|
onunderflow="_doUnderflow('_url');"
|
|
|
|
onoverflow="_doOverflow('_url');">
|
|
|
|
<xul:description anonid="url" class="ac-normal-text ac-url-text"
|
|
|
|
xbl:inherits="selected type"/>
|
|
|
|
<xul:description anonid="action" class="ac-normal-text ac-action-text"
|
|
|
|
xbl:inherits="selected type"/>
|
2007-11-29 20:57:57 -08:00
|
|
|
</xul:hbox>
|
2008-07-17 06:53:04 -07:00
|
|
|
<xul:label anonid="url-overflow-ellipsis" xbl:inherits="selected"
|
2010-12-10 18:32:14 -08:00
|
|
|
class="ac-ellipsis-after ac-url-text"/>
|
2008-01-02 21:52:37 -08:00
|
|
|
<xul:spacer class="ac-type-icon"/>
|
|
|
|
</xul:hbox>
|
2007-11-29 20:57:57 -08:00
|
|
|
</content>
|
2007-12-04 22:19:38 -08:00
|
|
|
<implementation implements="nsIDOMXULSelectControlItemElement">
|
2007-11-29 20:57:57 -08:00
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
2008-03-08 01:30:43 -08:00
|
|
|
let ellipsis = "\u2026";
|
|
|
|
try {
|
|
|
|
ellipsis = Components.classes["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(Components.interfaces.nsIPrefBranch).
|
|
|
|
getComplexValue("intl.ellipsis",
|
|
|
|
Components.interfaces.nsIPrefLocalizedString).data;
|
|
|
|
} catch (ex) {
|
|
|
|
// Do nothing.. we already have a default
|
|
|
|
}
|
|
|
|
|
2008-07-17 06:53:04 -07:00
|
|
|
this._urlOverflowEllipsis = document.getAnonymousElementByAttribute(this, "anonid", "url-overflow-ellipsis");
|
2007-11-29 20:57:57 -08:00
|
|
|
this._titleOverflowEllipsis = document.getAnonymousElementByAttribute(this, "anonid", "title-overflow-ellipsis");
|
|
|
|
|
2008-03-08 01:30:43 -08:00
|
|
|
this._urlOverflowEllipsis.value = ellipsis;
|
|
|
|
this._titleOverflowEllipsis.value = ellipsis;
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
this._typeImage = document.getAnonymousElementByAttribute(this, "anonid", "type-image");
|
|
|
|
|
2007-12-12 10:43:08 -08:00
|
|
|
this._urlBox = document.getAnonymousElementByAttribute(this, "anonid", "url-box");
|
2007-11-29 20:57:57 -08:00
|
|
|
this._url = document.getAnonymousElementByAttribute(this, "anonid", "url");
|
2010-12-10 18:32:14 -08:00
|
|
|
this._action = document.getAnonymousElementByAttribute(this, "anonid", "action");
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2007-12-12 10:43:08 -08:00
|
|
|
this._titleBox = document.getAnonymousElementByAttribute(this, "anonid", "title-box");
|
2007-11-29 20:57:57 -08:00
|
|
|
this._title = document.getAnonymousElementByAttribute(this, "anonid", "title");
|
|
|
|
|
2008-04-11 20:14:42 -07:00
|
|
|
this._extraBox = document.getAnonymousElementByAttribute(this, "anonid", "extra-box");
|
|
|
|
this._extra = document.getAnonymousElementByAttribute(this, "anonid", "extra");
|
|
|
|
|
2007-11-30 02:02:57 -08:00
|
|
|
this._adjustAcItem();
|
2007-11-29 20:57:57 -08:00
|
|
|
]]>
|
|
|
|
</constructor>
|
|
|
|
|
2007-12-04 22:19:38 -08:00
|
|
|
<property name="label" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
var title = this.getAttribute("title");
|
|
|
|
var url = this.getAttribute("url");
|
|
|
|
var panel = this.parentNode.parentNode;
|
|
|
|
|
2008-07-17 06:53:04 -07:00
|
|
|
// allow consumers that have extended popups to override
|
2007-12-04 22:19:38 -08:00
|
|
|
// the label values for the richlistitems
|
|
|
|
if (panel.createResultLabel)
|
|
|
|
return panel.createResultLabel(title, url, this.getAttribute("type"));
|
|
|
|
|
2008-07-17 06:53:04 -07:00
|
|
|
// aType (ex: "ac-result-type-<aType>") is related to the class of the image,
|
2007-12-04 22:19:38 -08:00
|
|
|
// and is not "visible" text so don't use it for the label (for accessibility).
|
|
|
|
return title + " " + url;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
2008-03-20 14:42:55 -07:00
|
|
|
<field name="_boundaryCutoff">null</field>
|
|
|
|
|
|
|
|
<property name="boundaryCutoff" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this._boundaryCutoff) {
|
|
|
|
this._boundaryCutoff =
|
|
|
|
Components.classes["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(Components.interfaces.nsIPrefBranch).
|
|
|
|
getIntPref("toolkit.autocomplete.richBoundaryCutoff");
|
|
|
|
}
|
|
|
|
return this._boundaryCutoff;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="_getBoundaryIndices">
|
2007-11-29 20:57:57 -08:00
|
|
|
<parameter name="aText"/>
|
2008-03-20 14:42:55 -07:00
|
|
|
<parameter name="aSearchTokens"/>
|
2007-11-29 20:57:57 -08:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2008-03-20 14:42:55 -07:00
|
|
|
// Short circuit for empty search ([""] == "")
|
|
|
|
if (aSearchTokens == "")
|
|
|
|
return [0, aText.length];
|
|
|
|
|
|
|
|
// Find which regions of text match the search terms
|
|
|
|
let regions = [];
|
|
|
|
for each (let search in aSearchTokens) {
|
|
|
|
let matchIndex;
|
|
|
|
let startIndex = 0;
|
|
|
|
let searchLen = search.length;
|
|
|
|
|
|
|
|
// Find all matches of the search terms, but stop early for perf
|
|
|
|
let lowerText = aText.toLowerCase().substr(0, this.boundaryCutoff);
|
|
|
|
while ((matchIndex = lowerText.indexOf(search, startIndex)) >= 0) {
|
|
|
|
// Start the next search from where this one finished
|
|
|
|
startIndex = matchIndex + searchLen;
|
|
|
|
regions.push([matchIndex, startIndex]);
|
|
|
|
}
|
|
|
|
}
|
2007-12-12 10:43:08 -08:00
|
|
|
|
2008-03-20 14:42:55 -07:00
|
|
|
// Sort the regions by start position then end position
|
|
|
|
regions = regions.sort(function(a, b) let (start = a[0] - b[0])
|
|
|
|
start == 0 ? a[1] - b[1] : start);
|
|
|
|
|
|
|
|
// Generate the boundary indices from each region
|
|
|
|
let start = 0;
|
|
|
|
let end = 0;
|
|
|
|
let boundaries = [];
|
|
|
|
let len = regions.length;
|
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
|
// We have a new boundary if the start of the next is past the end
|
|
|
|
let region = regions[i];
|
|
|
|
if (region[0] > end) {
|
|
|
|
// First index is the beginning of match
|
|
|
|
boundaries.push(start);
|
|
|
|
// Second index is the beginning of non-match
|
|
|
|
boundaries.push(end);
|
|
|
|
|
|
|
|
// Track the new region now that we've stored the previous one
|
|
|
|
start = region[0];
|
|
|
|
}
|
2007-12-12 10:43:08 -08:00
|
|
|
|
2008-03-20 14:42:55 -07:00
|
|
|
// Push back the end index for the current or new region
|
|
|
|
end = Math.max(end, region[1]);
|
2007-12-12 10:43:08 -08:00
|
|
|
}
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2008-03-20 14:42:55 -07:00
|
|
|
// Add the last region
|
|
|
|
boundaries.push(start);
|
|
|
|
boundaries.push(end);
|
|
|
|
|
|
|
|
// Put on the end boundary if necessary
|
|
|
|
if (end < aText.length)
|
|
|
|
boundaries.push(aText.length);
|
|
|
|
|
|
|
|
// Skip the first item because it's always 0
|
|
|
|
return boundaries.slice(1);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_getSearchTokens">
|
|
|
|
<parameter name="aSearch"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
let search = aSearch.toLowerCase();
|
2008-03-20 14:43:19 -07:00
|
|
|
return search.split(/\s+/);
|
2008-03-20 14:42:55 -07:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_setUpDescription">
|
|
|
|
<parameter name="aDescriptionElement"/>
|
|
|
|
<parameter name="aText"/>
|
2010-03-26 14:59:02 -07:00
|
|
|
<parameter name="aNoEmphasis"/>
|
2008-03-20 14:42:55 -07:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// Get rid of all previous text
|
|
|
|
while (aDescriptionElement.hasChildNodes())
|
|
|
|
aDescriptionElement.removeChild(aDescriptionElement.firstChild);
|
|
|
|
|
2010-03-26 14:59:02 -07:00
|
|
|
// If aNoEmphasis is specified, don't add any emphasis
|
|
|
|
if (aNoEmphasis) {
|
|
|
|
aDescriptionElement.appendChild(document.createTextNode(aText));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-03-20 14:42:55 -07:00
|
|
|
// Get the indices that separate match and non-match text
|
|
|
|
let search = this.getAttribute("text");
|
|
|
|
let tokens = this._getSearchTokens(search);
|
|
|
|
let indices = this._getBoundaryIndices(aText, tokens);
|
|
|
|
|
|
|
|
let next;
|
|
|
|
let start = 0;
|
|
|
|
let len = indices.length;
|
|
|
|
// Even indexed boundaries are matches, so skip the 0th if it's empty
|
|
|
|
for (let i = indices[0] == 0 ? 1 : 0; i < len; i++) {
|
|
|
|
next = indices[i];
|
|
|
|
let text = aText.substr(start, next - start);
|
|
|
|
start = next;
|
|
|
|
|
|
|
|
if (i % 2 == 0) {
|
|
|
|
// Emphasize the text for even indices
|
|
|
|
let span = aDescriptionElement.appendChild(
|
|
|
|
document.createElementNS("http://www.w3.org/1999/xhtml", "span"));
|
2012-07-16 20:48:00 -07:00
|
|
|
span.className = "ac-emphasize-text";
|
2008-03-20 14:42:55 -07:00
|
|
|
span.textContent = text;
|
|
|
|
} else {
|
|
|
|
// Otherwise, it's plain text
|
|
|
|
aDescriptionElement.appendChild(document.createTextNode(text));
|
|
|
|
}
|
2007-11-29 20:57:57 -08:00
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_adjustAcItem">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var url = this.getAttribute("url");
|
|
|
|
var title = this.getAttribute("title");
|
|
|
|
var type = this.getAttribute("type");
|
|
|
|
|
2010-03-26 14:59:02 -07:00
|
|
|
this.removeAttribute("actiontype");
|
|
|
|
|
2011-01-03 15:02:28 -08:00
|
|
|
// The ellipses are hidden via their visibility so that they always
|
|
|
|
// take up space and don't pop in on top of text when shown. For
|
|
|
|
// keyword searches, however, the title ellipsis should not take up
|
|
|
|
// space when hidden. Setting the hidden property accomplishes that.
|
|
|
|
this._titleOverflowEllipsis.hidden = false;
|
|
|
|
|
2010-08-25 21:01:22 -07:00
|
|
|
// If the type includes an action, set up the item appropriately.
|
|
|
|
var types = type.split(/\s+/);
|
|
|
|
var actionIndex = types.indexOf("action");
|
|
|
|
if (actionIndex >= 0) {
|
|
|
|
let [,action, param] = url.match(/^moz-action:([^,]+),(.*)$/);
|
|
|
|
this.setAttribute("actiontype", action);
|
|
|
|
url = param;
|
|
|
|
let desc = "]]>&action.switchToTab.label;<![CDATA[";
|
2010-12-10 18:32:14 -08:00
|
|
|
this._setUpDescription(this._action, desc, true);
|
2010-08-25 21:01:22 -07:00
|
|
|
|
|
|
|
// Remove the "action" substring so that the correct style, if any,
|
|
|
|
// is applied below.
|
|
|
|
types.splice(actionIndex, 1);
|
|
|
|
type = types.join(" ");
|
|
|
|
}
|
|
|
|
|
2014-08-01 08:41:32 -07:00
|
|
|
// Check if we have a search engine name
|
|
|
|
let searchEngine = "";
|
|
|
|
let searchIndex = types.indexOf("search");
|
|
|
|
if (searchIndex >= 0) {
|
|
|
|
const TITLE_SEARCH_ENGINE_SEPARATOR = " \u00B7\u2013\u00B7 ";
|
|
|
|
|
|
|
|
[title, searchEngine] = title.split(TITLE_SEARCH_ENGINE_SEPARATOR);
|
|
|
|
|
|
|
|
// Remove the "search" substring so that the correct style, if any,
|
|
|
|
// is applied below.
|
|
|
|
types.splice(searchIndex, 1);
|
|
|
|
type = types.join(" ");
|
|
|
|
}
|
|
|
|
|
2008-04-11 20:14:42 -07:00
|
|
|
// If we have a tag match, show the tags and icon
|
|
|
|
if (type == "tag") {
|
|
|
|
// Configure the extra box for tags display
|
|
|
|
this._extraBox.hidden = false;
|
2008-07-17 04:48:40 -07:00
|
|
|
this._extraBox.childNodes[0].hidden = false;
|
|
|
|
this._extraBox.childNodes[1].hidden = true;
|
2008-04-11 20:14:42 -07:00
|
|
|
this._extraBox.pack = "end";
|
2009-10-05 18:22:28 -07:00
|
|
|
this._titleBox.flex = 1;
|
2008-04-11 20:14:42 -07:00
|
|
|
|
|
|
|
// The title is separated from the tags by an endash
|
|
|
|
let tags;
|
|
|
|
[, title, tags] = title.match(/^(.+) \u2013 (.+)$/);
|
|
|
|
|
|
|
|
// Each tag is split by a comma in an undefined order, so sort it
|
|
|
|
let sortedTags = tags.split(",").sort().join(", ");
|
|
|
|
|
|
|
|
// Emphasize the matching text in the tags
|
|
|
|
this._setUpDescription(this._extra, sortedTags);
|
|
|
|
|
|
|
|
// Treat tagged matches as bookmarks for the star
|
|
|
|
type = "bookmark";
|
2008-07-17 04:48:40 -07:00
|
|
|
} else if (type == "keyword") {
|
|
|
|
// Configure the extra box for keyword display
|
|
|
|
this._extraBox.hidden = false;
|
|
|
|
this._extraBox.childNodes[0].hidden = true;
|
|
|
|
this._extraBox.childNodes[1].hidden = false;
|
|
|
|
this._extraBox.pack = "start";
|
2009-10-05 18:22:28 -07:00
|
|
|
this._titleBox.flex = 0;
|
2010-08-25 21:01:22 -07:00
|
|
|
|
2011-01-03 15:02:28 -08:00
|
|
|
// Hide the ellipsis so it doesn't take up space.
|
|
|
|
this._titleOverflowEllipsis.hidden = true;
|
|
|
|
|
2008-07-17 04:48:40 -07:00
|
|
|
// Put the parameters next to the title if we have any
|
|
|
|
let search = this.getAttribute("text");
|
2009-10-07 01:38:15 -07:00
|
|
|
let params = "";
|
|
|
|
let paramsIndex = search.indexOf(' ');
|
|
|
|
if (paramsIndex != -1)
|
|
|
|
params = search.substr(paramsIndex + 1);
|
2008-07-17 04:48:40 -07:00
|
|
|
|
|
|
|
// Emphasize the keyword parameters
|
|
|
|
this._setUpDescription(this._extra, params);
|
|
|
|
|
|
|
|
// Don't emphasize keyword searches in the title or url
|
|
|
|
this.setAttribute("text", "");
|
2008-04-11 20:14:42 -07:00
|
|
|
} else {
|
|
|
|
// Hide the title's extra box if we don't need extra stuff
|
|
|
|
this._extraBox.hidden = true;
|
2009-10-05 18:22:28 -07:00
|
|
|
this._titleBox.flex = 1;
|
2008-04-11 20:14:42 -07:00
|
|
|
}
|
|
|
|
|
2008-03-08 01:30:43 -08:00
|
|
|
// Give the image the icon style and a special one for the type
|
|
|
|
this._typeImage.className = "ac-type-icon" +
|
|
|
|
(type ? " ac-result-type-" + type : "");
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2008-04-01 23:01:08 -07:00
|
|
|
// Show the url as the title if we don't have a title
|
|
|
|
if (title == "")
|
|
|
|
title = url;
|
|
|
|
|
2008-03-20 14:42:55 -07:00
|
|
|
// Emphasize the matching search terms for the description
|
|
|
|
this._setUpDescription(this._title, title);
|
2014-08-01 08:41:32 -07:00
|
|
|
if (!searchEngine) {
|
|
|
|
this._setUpDescription(this._url, url);
|
|
|
|
} else {
|
|
|
|
// The search engine name, when present, is not emphasized.
|
|
|
|
this._setUpDescription(this._url, searchEngine, true);
|
|
|
|
}
|
2008-03-08 01:30:43 -08:00
|
|
|
|
|
|
|
// Set up overflow on a timeout because the contents of the box
|
|
|
|
// might not have a width yet even though we just changed them
|
|
|
|
setTimeout(this._setUpOverflow, 0, this._titleBox, this._titleOverflowEllipsis);
|
|
|
|
setTimeout(this._setUpOverflow, 0, this._urlBox, this._urlOverflowEllipsis);
|
2007-11-29 20:57:57 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2008-03-08 01:30:43 -08:00
|
|
|
<method name="_setUpOverflow">
|
|
|
|
<parameter name="aParentBox"/>
|
|
|
|
<parameter name="aEllipsis"/>
|
2007-11-29 20:57:57 -08:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2008-03-08 01:30:43 -08:00
|
|
|
// Hide the ellipsis incase there's just enough to not underflow
|
2010-12-10 18:32:14 -08:00
|
|
|
aEllipsis.style.visibility = "hidden";
|
2008-03-08 01:30:43 -08:00
|
|
|
|
|
|
|
// Start with the parent's width and subtract off its children
|
|
|
|
let tooltip = [];
|
|
|
|
let children = aParentBox.childNodes;
|
|
|
|
let widthDiff = aParentBox.boxObject.width;
|
|
|
|
|
|
|
|
for (let i = 0; i < children.length; i++) {
|
|
|
|
// Only consider a child if it actually takes up space
|
|
|
|
let childWidth = children[i].boxObject.width;
|
|
|
|
if (childWidth > 0) {
|
|
|
|
// Subtract a little less to account for subpixel rounding
|
|
|
|
widthDiff -= childWidth - .5;
|
|
|
|
|
|
|
|
// Add to the tooltip if it's not hidden and has text
|
|
|
|
let childText = children[i].textContent;
|
|
|
|
if (childText)
|
|
|
|
tooltip.push(childText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the children take up more space than the parent.. overflow!
|
|
|
|
if (widthDiff < 0) {
|
|
|
|
// Re-show the ellipsis now that we know it's needed
|
2010-12-10 18:32:14 -08:00
|
|
|
aEllipsis.style.visibility = "visible";
|
2008-03-08 01:30:43 -08:00
|
|
|
|
|
|
|
// Separate text components with a ndash --
|
|
|
|
aParentBox.tooltipText = tooltip.join(" \u2013 ");
|
|
|
|
}
|
|
|
|
]]>
|
2007-11-29 20:57:57 -08:00
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2008-03-08 01:30:43 -08:00
|
|
|
<method name="_doUnderflow">
|
|
|
|
<parameter name="aName"/>
|
2007-11-29 20:57:57 -08:00
|
|
|
<body>
|
|
|
|
<![CDATA[
|
2008-03-08 01:30:43 -08:00
|
|
|
// Hide the ellipsis right when we know we're underflowing instead of
|
|
|
|
// waiting for the timeout to trigger the _setUpOverflow calculations
|
|
|
|
this[aName + "Box"].tooltipText = "";
|
2010-12-10 18:32:14 -08:00
|
|
|
this[aName + "OverflowEllipsis"].style.visibility = "hidden";
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_doOverflow">
|
|
|
|
<parameter name="aName"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
this._setUpOverflow(this[aName + "Box"],
|
|
|
|
this[aName + "OverflowEllipsis"]);
|
2007-11-29 20:57:57 -08:00
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<binding id="autocomplete-tree" extends="chrome://global/content/bindings/tree.xml#tree">
|
|
|
|
<content>
|
|
|
|
<children includes="treecols"/>
|
|
|
|
<xul:treerows class="autocomplete-treerows tree-rows" xbl:inherits="hidescrollbar" flex="1">
|
|
|
|
<children/>
|
|
|
|
</xul:treerows>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
<binding id="autocomplete-richlistbox" extends="chrome://global/content/bindings/richlistbox.xml#richlistbox">
|
|
|
|
<implementation>
|
|
|
|
<field name="mLastMoveTime">Date.now()</field>
|
|
|
|
</implementation>
|
|
|
|
<handlers>
|
|
|
|
<handler event="mouseup">
|
|
|
|
<![CDATA[
|
|
|
|
// don't call onPopupClick for the scrollbar buttons, thumb, slider, etc.
|
|
|
|
var item = event.originalTarget;
|
|
|
|
|
|
|
|
while (item && item.localName != "richlistitem")
|
|
|
|
item = item.parentNode;
|
|
|
|
|
|
|
|
if (!item)
|
|
|
|
return;
|
2008-07-17 06:53:04 -07:00
|
|
|
|
2007-11-29 20:57:57 -08:00
|
|
|
this.parentNode.onPopupClick(event);
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
|
|
|
|
<handler event="mousemove">
|
|
|
|
<![CDATA[
|
|
|
|
if (Date.now() - this.mLastMoveTime > 30) {
|
|
|
|
var item = event.target;
|
|
|
|
|
|
|
|
while (item && item.localName != "richlistitem")
|
|
|
|
item = item.parentNode;
|
|
|
|
|
|
|
|
if (!item)
|
|
|
|
return;
|
|
|
|
|
|
|
|
var rc = this.getIndexOfItem(item);
|
|
|
|
if (rc != this.selectedIndex)
|
|
|
|
this.selectedIndex = rc;
|
|
|
|
|
|
|
|
this.mLastMoveTime = Date.now();
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<binding id="autocomplete-treebody">
|
|
|
|
<implementation>
|
2007-11-29 20:57:57 -08:00
|
|
|
<field name="mLastMoveTime">Date.now()</field>
|
2007-03-22 10:30:00 -07:00
|
|
|
</implementation>
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<handlers>
|
|
|
|
<handler event="mouseup" action="this.parentNode.parentNode.onPopupClick(event);"/>
|
|
|
|
|
|
|
|
<handler event="mousedown"><![CDATA[
|
2007-08-09 11:52:01 -07:00
|
|
|
var rc = this.parentNode.treeBoxObject.getRowAt(event.clientX, event.clientY);
|
|
|
|
if (rc != this.parentNode.currentIndex)
|
|
|
|
this.parentNode.view.selection.select(rc);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
<handler event="mousemove"><![CDATA[
|
2007-11-29 20:57:57 -08:00
|
|
|
if (Date.now() - this.mLastMoveTime > 30) {
|
2007-08-09 11:52:01 -07:00
|
|
|
var rc = this.parentNode.treeBoxObject.getRowAt(event.clientX, event.clientY);
|
|
|
|
if (rc != this.parentNode.currentIndex)
|
|
|
|
this.parentNode.view.selection.select(rc);
|
2007-11-29 20:57:57 -08:00
|
|
|
this.mLastMoveTime = Date.now();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="autocomplete-treerows">
|
2007-11-27 10:53:55 -08:00
|
|
|
<content>
|
2007-03-22 10:30:00 -07:00
|
|
|
<xul:hbox flex="1" class="tree-bodybox">
|
|
|
|
<children/>
|
|
|
|
</xul:hbox>
|
|
|
|
<xul:scrollbar xbl:inherits="collapsed=hidescrollbar" orient="vertical" class="tree-scrollbar"/>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="history-dropmarker" extends="chrome://global/content/bindings/general.xml#dropmarker">
|
|
|
|
<implementation>
|
|
|
|
<method name="showPopup">
|
|
|
|
<body><![CDATA[
|
|
|
|
var textbox = document.getBindingParent(this);
|
|
|
|
textbox.showHistoryPopup();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
2007-11-29 20:57:57 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<handlers>
|
|
|
|
<handler event="mousedown" button="0"><![CDATA[
|
|
|
|
this.showPopup();
|
|
|
|
]]></handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
</bindings>
|