2002-09-28 06:25:03 +00:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
2003-10-22 06:35:37 +00:00
|
|
|
# -*- Mode: HTML -*-
|
|
|
|
# ***** BEGIN LICENSE BLOCK *****
|
2005-02-01 17:07:35 +00:00
|
|
|
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
#
|
|
|
|
# The contents of this file are subject to the Mozilla 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/MPL/
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2003-10-22 06:35:37 +00:00
|
|
|
# The Original Code is mozilla.org browser.
|
2005-02-01 17:07:35 +00:00
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is
|
|
|
|
# Joe Hewitt.
|
|
|
|
# Portions created by the Initial Developer are Copyright (C) 2003
|
|
|
|
# the Initial Developer. All Rights Reserved.
|
|
|
|
#
|
2003-10-22 06:35:37 +00:00
|
|
|
# Contributor(s):
|
2005-02-01 17:07:35 +00:00
|
|
|
# Pierre Chanial (p_ch@verizon.net)
|
|
|
|
# Dean Tessman (dean_tessman@hotmail.com)
|
2006-03-18 08:09:52 +00:00
|
|
|
# Masayuki Nakano (masayuki@d-toybox.com)
|
2006-12-07 08:58:48 +00:00
|
|
|
# Pamela Greene (pamg.bugs@gmail.com)
|
2003-10-22 06:35:37 +00:00
|
|
|
#
|
2005-02-01 17:07:35 +00:00
|
|
|
# Alternatively, the contents of this file may be used under the terms of
|
|
|
|
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
# in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
# of those above. If you wish to allow use of your version of this file only
|
|
|
|
# under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
# use your version of this file under the terms of the MPL, indicate your
|
|
|
|
# decision by deleting the provisions above and replace them with the notice
|
|
|
|
# and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
# the provisions above, a recipient may use your version of this file under
|
|
|
|
# the terms of any one of the MPL, the GPL or the LGPL.
|
2003-10-22 06:35:37 +00:00
|
|
|
#
|
|
|
|
# ***** END LICENSE BLOCK *****
|
|
|
|
|
2002-09-28 06:25:03 +00: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">
|
|
|
|
|
|
|
|
<binding id="autocomplete"
|
2003-11-20 05:14:08 +00:00
|
|
|
extends="chrome://global/content/bindings/textbox.xml#textbox">
|
2002-09-28 06:25:03 +00:00
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
<content sizetopopup="pref">
|
|
|
|
<xul:hbox class="autocomplete-textbox-container" flex="1">
|
2007-10-26 02:53:01 +00:00
|
|
|
<children includes="image|deck|stack|box">
|
2002-09-28 06:25:03 +00:00
|
|
|
<xul:image class="autocomplete-icon" allowevents="true"/>
|
|
|
|
</children>
|
|
|
|
|
2004-12-01 04:48:44 +00:00
|
|
|
<xul:hbox anonid="textbox-input-box" class="textbox-input-box" flex="1" xbl:inherits="tooltiptext=inputtooltiptext">
|
2002-09-28 06:25:03 +00:00
|
|
|
<children/>
|
|
|
|
<html:input anonid="input" class="autocomplete-textbox textbox-input"
|
|
|
|
flex="1" allowevents="true"
|
|
|
|
xbl:inherits="tooltiptext=inputtooltiptext,onfocus,onblur,value,type,maxlength,disabled,size,readonly,userAction"/>
|
|
|
|
</xul:hbox>
|
2005-08-12 00:34:19 +00:00
|
|
|
<children includes="hbox"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
</xul:hbox>
|
2007-11-30 04:57:57 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<xul:dropmarker anonid="historydropmarker" class="autocomplete-history-dropmarker"
|
|
|
|
allowevents="true"
|
|
|
|
xbl:inherits="open,enablehistory"/>
|
|
|
|
|
|
|
|
<xul:popupset anonid="popupset" class="autocomplete-result-popupset"/>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation implements="nsIAccessibleProvider, nsIAutoCompleteInput, nsIDOMXULMenuListElement">
|
|
|
|
<field name="mController">null</field>
|
|
|
|
<field name="mSearchNames">null</field>
|
|
|
|
<field name="mIgnoreInput">false</field>
|
|
|
|
<field name="mEnterEvent">null</field>
|
2006-06-07 16:48:56 +00:00
|
|
|
<field name="mConsumeRollupEvent">false</field>
|
2007-11-30 04:57:57 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<field name="mInputElt">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "input");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<constructor><![CDATA[
|
|
|
|
mController = Components.classes["@mozilla.org/autocomplete/controller;1"].
|
2005-12-31 23:34:46 +00:00
|
|
|
getService(Components.interfaces.nsIAutoCompleteController);
|
2002-09-28 06:25:03 +00:00
|
|
|
]]></constructor>
|
|
|
|
|
|
|
|
<!-- =================== nsIAccessibleProvider =================== -->
|
|
|
|
|
2006-07-24 16:12:08 +00:00
|
|
|
<property name="accessibleType" readonly="true">
|
2002-09-28 06:25:03 +00:00
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
2006-09-17 18:04:13 +00:00
|
|
|
// Will be exposed as nsIAccessible::ROLE_AUTOCOMPLETE
|
|
|
|
return Components.interfaces.nsIAccessibleProvider.XULCombobox;
|
2002-09-28 06:25:03 +00:00
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<!-- =================== nsIAutoCompleteInput =================== -->
|
|
|
|
|
|
|
|
<field name="popup"><![CDATA[
|
|
|
|
var popup = null;
|
|
|
|
var popupId = this.getAttribute("autocompletepopup");
|
|
|
|
if (popupId)
|
|
|
|
popup = document.getElementById(popupId);
|
|
|
|
if (!popup) {
|
2007-07-04 15:49:38 +00:00
|
|
|
popup = document.createElement("panel");
|
2002-09-28 06:25:03 +00:00
|
|
|
popup.setAttribute("type", "autocomplete");
|
2007-08-16 01:09:58 +00:00
|
|
|
popup.setAttribute("noautofocus", "true");
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
var popupset = document.getAnonymousElementByAttribute(this, "anonid", "popupset");
|
|
|
|
popupset.appendChild(popup);
|
|
|
|
}
|
2003-08-06 08:43:56 +00:00
|
|
|
popup.mInput = this;
|
2002-09-28 06:25:03 +00:00
|
|
|
popup;
|
|
|
|
]]></field>
|
2007-11-30 04:57:57 +00:00
|
|
|
|
2002-10-11 07:50:53 +00:00
|
|
|
<property name="controller" onget="return this.mController;" readonly="true"/>
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<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';"/>
|
|
|
|
|
2005-02-18 12:40:00 +00:00
|
|
|
<property name="completeSelectedIndex"
|
|
|
|
onset="this.setAttribute('completeselectedindex', val); return val;"
|
|
|
|
onget="return this.getAttribute('completeselectedindex') == 'true';"/>
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<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;"
|
2003-07-13 02:27:25 +00:00
|
|
|
onget="return parseInt(this.getAttribute('minresultsforpopup')) || 0;"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<property name="showCommentColumn"
|
|
|
|
onset="this.setAttribute('showcommentcolumn', val); return val;"
|
|
|
|
onget="return this.getAttribute('showcommentcolumn') == 'true';"/>
|
|
|
|
|
2007-11-06 08:43:53 +00:00
|
|
|
<property name="showImageColumn"
|
|
|
|
onset="this.setAttribute('showimagecolumn', val); return val;"
|
|
|
|
onget="return this.getAttribute('showimagecolumn') == 'true';"/>
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<property name="timeout"
|
|
|
|
onset="this.setAttribute('timeout', val); return val;"
|
2003-07-13 02:27:25 +00:00
|
|
|
onget="return parseInt(this.getAttribute('timeout')) || 50;"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<property name="searchParam"
|
2002-09-29 20:06:57 +00:00
|
|
|
onget="return this.getAttribute('autocompletesearchparam');"
|
|
|
|
onset="this.setAttribute('autocompletesearchparam', val); return val;"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<property name="searchCount" readonly="true"
|
|
|
|
onget="this.initSearchNames(); return this.mSearchNames.length;"/>
|
2006-05-31 17:55:19 +00:00
|
|
|
|
|
|
|
<property name="consumeRollupEvent" readonly="true"
|
2006-06-07 16:48:56 +00:00
|
|
|
onget="return this.mConsumeRollupEvent;"/>
|
2006-05-31 17:55:19 +00:00
|
|
|
|
2007-11-30 04:57:57 +00:00
|
|
|
<!-- This is the maximum number of drop-down rows we get when we
|
2006-06-12 17:49:06 +00:00
|
|
|
hit the drop marker beside fields that have it (like the URLbar).-->
|
2007-11-30 04:57:57 +00:00
|
|
|
<field name="maxDropMarkerRows" readonly="true">14</field>
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<method name="getSearchAt">
|
|
|
|
<parameter name="aIndex"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
this.initSearchNames();
|
|
|
|
return this.mSearchNames[aIndex];
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<property name="textValue"
|
2005-08-22 18:34:21 +00:00
|
|
|
onget="return this.value;">
|
|
|
|
<setter><![CDATA[
|
|
|
|
// Completing a result should simulate the user typing the result,
|
|
|
|
// so fire an input event.
|
|
|
|
this.value = val;
|
|
|
|
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>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<method name="selectTextRange">
|
|
|
|
<parameter name="aStartIndex"/>
|
|
|
|
<parameter name="aEndIndex"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
this.mInputElt.setSelectionRange(aStartIndex, aEndIndex);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onSearchComplete">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.mController.matchCount == 0)
|
|
|
|
this.popup.setAttribute("nomatch", "true");
|
|
|
|
else
|
|
|
|
this.popup.removeAttribute("nomatch");
|
|
|
|
|
|
|
|
this.fireEvent("searchcomplete");
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onTextEntered">
|
|
|
|
<body><![CDATA[
|
2004-02-17 08:07:13 +00:00
|
|
|
var rv = this.fireEvent("textentered", this.mEnterEvent);
|
|
|
|
this.mEnterEvent = null;
|
|
|
|
return rv;
|
2002-09-28 06:25:03 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onTextReverted">
|
|
|
|
<body><![CDATA[
|
|
|
|
return this.fireEvent("textreverted");
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- =================== nsIDOMXULMenuListElement =================== -->
|
|
|
|
|
|
|
|
<property name="editable" readonly="true"
|
2007-11-30 04:57:57 +00:00
|
|
|
onget="return true;" />
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<property name="crop"
|
|
|
|
onset="this.setAttribute('crop',val); return val;"
|
|
|
|
onget="return this.getAttribute('crop');"/>
|
|
|
|
|
2005-02-11 13:17:18 +00:00
|
|
|
<property name="label" readonly="true" onget="return this.mInputElt.value;"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<property name="open"
|
|
|
|
onget="return this.getAttribute('open') == 'true';">
|
|
|
|
<setter><![CDATA[
|
|
|
|
if (val) {
|
|
|
|
this.setAttribute("open", "true");
|
2003-08-06 08:43:56 +00:00
|
|
|
this.showHistoryPopup();
|
2002-09-28 06:25:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.removeAttribute("open");
|
2003-08-06 08:43:56 +00:00
|
|
|
this.closePopup();
|
2002-09-28 06:25:03 +00:00
|
|
|
}
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<!-- =================== PUBLIC MEMBERS =================== -->
|
|
|
|
|
|
|
|
<property name="value"
|
2004-12-02 21:17:15 +00:00
|
|
|
onget="return this.mInputElt.value;">
|
|
|
|
<setter><![CDATA[
|
|
|
|
this.mIgnoreInput = true;
|
|
|
|
this.mInputElt.value = val;
|
|
|
|
this.mIgnoreInput = false;
|
|
|
|
var event = document.createEvent('Events');
|
|
|
|
event.initEvent('ValueChange', true, true);
|
|
|
|
this.mInputElt.dispatchEvent(event);
|
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<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;"
|
2003-07-13 02:27:25 +00:00
|
|
|
onget="return parseInt(this.getAttribute('maxrows')) || 0;"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<!-- 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';"/>
|
|
|
|
|
|
|
|
<!-- option to completely ignore any blur events while
|
|
|
|
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-30 04:57:57 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<!-- =================== PRIVATE MEMBERS =================== -->
|
|
|
|
|
|
|
|
<!-- ::::::::::::: autocomplete controller ::::::::::::: -->
|
|
|
|
|
|
|
|
<method name="attachController">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.mController.input != this)
|
|
|
|
this.mController.input = this;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="detachController">
|
|
|
|
<body><![CDATA[
|
2005-11-14 21:42:41 +00:00
|
|
|
try {
|
|
|
|
if (this.mController.input == this)
|
2002-09-28 06:25:03 +00:00
|
|
|
this.mController.input = null;
|
2005-11-14 21:42:41 +00:00
|
|
|
} catch (ex) {
|
|
|
|
// nothing really to do.
|
|
|
|
}
|
2002-09-28 06:25:03 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- ::::::::::::: popup opening ::::::::::::: -->
|
|
|
|
|
|
|
|
<method name="openPopup">
|
|
|
|
<body><![CDATA[
|
2007-09-30 19:00:10 +00:00
|
|
|
this.popup.openAutocompletePopup(this, this);
|
2002-09-28 06:25:03 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="closePopup">
|
|
|
|
<body><![CDATA[
|
2006-06-07 16:48:56 +00:00
|
|
|
this.mConsumeRollupEvent = false;
|
2002-09-28 06:25:03 +00:00
|
|
|
this.popup.closePopup();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="showHistoryPopup">
|
|
|
|
<body><![CDATA[
|
2006-06-16 01:50:30 +00: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.
|
2006-06-12 17:49:06 +00:00
|
|
|
this.maxRows = this.maxDropMarkerRows;
|
2006-06-16 01:50:30 +00:00
|
|
|
|
2006-06-12 17:49:06 +00:00
|
|
|
// Ensure that we have focus.
|
2006-05-29 18:34:25 +00:00
|
|
|
if (!this.focused)
|
|
|
|
this.focus();
|
2006-06-07 16:48:56 +00:00
|
|
|
this.mConsumeRollupEvent = true;
|
2002-09-28 06:25:03 +00:00
|
|
|
this.attachController();
|
|
|
|
this.mController.startSearch("");
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2007-11-30 04:57:57 +00:00
|
|
|
|
2005-06-01 02:14:46 +00:00
|
|
|
<method name="toggleHistoryPopup">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (!this.popup.mPopupOpen)
|
|
|
|
this.showHistoryPopup();
|
|
|
|
else
|
|
|
|
this.closePopup();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
2006-06-12 17:49:06 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<!-- ::::::::::::: event dispatching ::::::::::::: -->
|
|
|
|
|
|
|
|
<method name="fireEvent">
|
|
|
|
<parameter name="aEventType"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
var cancel = false;
|
|
|
|
// handle any xml attribute event handlers
|
|
|
|
var handler = this.getAttribute("on"+aEventType);
|
|
|
|
if (handler) {
|
|
|
|
var fn = new Function("eventType", "param", handler);
|
|
|
|
cancel = fn.apply(this, arguments);
|
|
|
|
}
|
2006-06-20 04:44:26 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
return cancel;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- ::::::::::::: key handling ::::::::::::: -->
|
|
|
|
|
|
|
|
<method name="onKeyPress">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
2003-10-24 06:55:04 +00:00
|
|
|
//XXXpch this is so bogus...
|
|
|
|
if (aEvent.getPreventDefault())
|
|
|
|
return false;
|
2003-10-22 08:45:54 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
var cancel = false;
|
2006-06-20 04:44:26 +00:00
|
|
|
|
|
|
|
// Catch any keys that could potentially move the caret. Ctrl can be
|
|
|
|
// used in combination with these keys, so only make sure that Alt
|
|
|
|
// isn't used.
|
|
|
|
if (!this.disableKeyNavigation && !aEvent.altKey) {
|
|
|
|
switch (aEvent.keyCode) {
|
|
|
|
case KeyEvent.DOM_VK_LEFT:
|
|
|
|
case KeyEvent.DOM_VK_RIGHT:
|
|
|
|
case KeyEvent.DOM_VK_HOME:
|
2006-12-07 12:59:02 +00:00
|
|
|
cancel = this.mController.handleKeyNavigation(aEvent.keyCode);
|
2006-06-20 04:44:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle keys that are not part of a keyboard shortcut (no Ctrl or Alt)
|
2004-12-01 18:48:25 +00:00
|
|
|
if (!this.disableKeyNavigation && !aEvent.ctrlKey && !aEvent.altKey) {
|
2002-09-28 06:25:03 +00:00
|
|
|
switch (aEvent.keyCode) {
|
|
|
|
case KeyEvent.DOM_VK_TAB:
|
2002-09-29 20:06:57 +00:00
|
|
|
if (this.tabScrolling && this.popup.mPopupOpen)
|
2006-06-20 04:44:26 +00:00
|
|
|
cancel = this.mController.handleKeyNavigation(aEvent.shiftKey ?
|
2006-12-07 12:59:02 +00:00
|
|
|
KeyEvent.DOM_VK_UP :
|
|
|
|
KeyEvent.DOM_VK_DOWN);
|
2002-09-28 06:25:03 +00:00
|
|
|
break;
|
|
|
|
case KeyEvent.DOM_VK_UP:
|
|
|
|
case KeyEvent.DOM_VK_DOWN:
|
|
|
|
case KeyEvent.DOM_VK_PAGE_UP:
|
|
|
|
case KeyEvent.DOM_VK_PAGE_DOWN:
|
2006-12-07 12:59:02 +00:00
|
|
|
cancel = this.mController.handleKeyNavigation(aEvent.keyCode);
|
2002-09-28 06:25:03 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-06-20 04:44:26 +00:00
|
|
|
|
|
|
|
// Handle keys we know aren't part of a shortcut, even with Alt or
|
|
|
|
// Ctrl.
|
2002-09-28 06:25:03 +00:00
|
|
|
switch (aEvent.keyCode) {
|
|
|
|
case KeyEvent.DOM_VK_ESCAPE:
|
|
|
|
cancel = this.mController.handleEscape();
|
|
|
|
break;
|
|
|
|
case KeyEvent.DOM_VK_RETURN:
|
|
|
|
this.mEnterEvent = aEvent;
|
|
|
|
cancel = this.mController.handleEnter();
|
|
|
|
break;
|
2006-04-05 22:57:48 +00:00
|
|
|
case KeyEvent.DOM_VK_DELETE:
|
2004-12-05 21:43:42 +00:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
case KeyEvent.DOM_VK_BACK_SPACE:
|
2006-04-05 22:57:48 +00:00
|
|
|
if (aEvent.shiftKey)
|
2004-12-05 21:43:42 +00:00
|
|
|
#endif
|
2006-01-31 21:16:11 +00:00
|
|
|
cancel = this.mController.handleDelete();
|
2004-03-18 07:07:10 +00:00
|
|
|
break;
|
2005-06-01 02:14:46 +00:00
|
|
|
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
|
2002-09-28 06:25:03 +00:00
|
|
|
}
|
2002-09-29 20:06:57 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
if (cancel) {
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
aEvent.preventDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
<method name="ifSetAttribute">
|
|
|
|
<parameter name="aAttr"/>
|
|
|
|
<parameter name="aVal"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (!this.hasAttribute(aAttr))
|
|
|
|
this.setAttribute(aAttr, aVal);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-11-30 04:57:57 +00:00
|
|
|
<method name="_focus">
|
|
|
|
<!-- doesn't reset this.mController -->
|
2005-09-17 01:12:22 +00:00
|
|
|
<body><![CDATA[
|
|
|
|
this._dontBlur = true;
|
|
|
|
this.focus();
|
|
|
|
this._dontBlur = false;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="input"
|
2005-01-30 09:31:36 +00:00
|
|
|
action="if (!this.mIgnoreInput && this.mController.input == this) this.mController.handleText(false);"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<handler event="keypress" phase="capturing"
|
|
|
|
action="return this.onKeyPress(event);"/>
|
|
|
|
|
2005-03-05 08:19:05 +00:00
|
|
|
<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();"/>
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<handler event="focus" phase="capturing"
|
|
|
|
action="this.attachController();"/>
|
|
|
|
|
|
|
|
<handler event="blur" phase="capturing"
|
2005-09-17 01:12:22 +00:00
|
|
|
action="if (!this._dontBlur) this.detachController();"/>
|
2006-06-19 19:55:33 +00:00
|
|
|
|
|
|
|
<handler event="contextmenu" phase="capturing"
|
|
|
|
action="this.closePopup();"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
</handlers>
|
2007-08-21 23:55:54 +00:00
|
|
|
</binding>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
2007-11-30 04:57:57 +00:00
|
|
|
<binding id="autocomplete-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-base-popup">
|
2002-09-28 06:25:03 +00:00
|
|
|
<resources>
|
2002-10-11 00:28:28 +00:00
|
|
|
<stylesheet src="chrome://global/skin/tree.css"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
|
|
|
</resources>
|
|
|
|
|
2007-11-30 04:57:57 +00:00
|
|
|
<content ignorekeys="true">
|
2002-09-28 06:25:03 +00:00
|
|
|
<xul:tree anonid="tree" class="autocomplete-tree plain" hidecolumnpicker="true" flex="1">
|
|
|
|
<xul:treecols anonid="treecols">
|
2007-03-02 17:58:55 +00:00
|
|
|
<xul:treecol id="treecolAutoCompleteValue" class="autocomplete-treecol" flex="1" overflow="true"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
</xul:treecols>
|
|
|
|
<xul:treechildren class="autocomplete-treebody"/>
|
|
|
|
</xul:tree>
|
|
|
|
</content>
|
2007-08-31 20:19:19 +00:00
|
|
|
|
2007-11-30 04:57:57 +00:00
|
|
|
<implementation>
|
|
|
|
<field name="mShowCommentColumn">false</field>
|
|
|
|
<field name="mShowImageColumn">false</field>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
2007-11-30 04:57:57 +00: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>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
2007-11-30 04:57:57 +00: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>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
2007-11-30 04:57:57 +00: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>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
|
|
|
<property name="selectedIndex"
|
|
|
|
onget="return this.tree.currentIndex;">
|
2007-11-30 04:57:57 +00:00
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
2004-04-17 05:53:38 +00:00
|
|
|
this.tree.view.selection.select(val);
|
2002-10-10 23:49:16 +00:00
|
|
|
if (this.tree.treeBoxObject.height > 0)
|
|
|
|
this.tree.treeBoxObject.ensureRowIsVisible(val < 0 ? 0 : val);
|
2004-12-02 21:17:15 +00:00
|
|
|
// 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);
|
2002-09-28 06:25:03 +00:00
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
2007-11-30 04:57:57 +00: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;
|
|
|
|
|
|
|
|
var height = rows * bx.rowHeight;
|
|
|
|
|
|
|
|
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>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
2007-07-04 15:49:38 +00:00
|
|
|
<method name="openAutocompletePopup">
|
2007-11-11 18:36:52 +00: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">
|
2002-09-28 06:25:03 +00:00
|
|
|
<parameter name="aInput"/>
|
2007-09-30 19:00:10 +00:00
|
|
|
<parameter name="aElement"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
<body><![CDATA[
|
|
|
|
if (!this.mPopupOpen) {
|
2002-10-11 07:54:21 +00:00
|
|
|
this.mInput = aInput;
|
|
|
|
this.view = aInput.controller.QueryInterface(Components.interfaces.nsITreeView);
|
|
|
|
this.invalidate();
|
2007-11-30 04:57:57 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
this.showCommentColumn = this.mInput.showCommentColumn;
|
2007-11-06 08:43:53 +00:00
|
|
|
this.showImageColumn = this.mInput.showImageColumn;
|
2007-08-31 20:19:19 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
document.popupNode = null;
|
2007-09-30 19:00:10 +00:00
|
|
|
|
|
|
|
var rect = aElement.getBoundingClientRect();
|
2007-10-12 10:24:00 +00:00
|
|
|
var width = rect.right - rect.left;
|
|
|
|
this.setAttribute("width", width > 100 ? width : 100);
|
2007-09-30 19:00:10 +00:00
|
|
|
this.openPopup(aElement, "after_start", 0, 0, false, false);
|
|
|
|
|
2007-07-04 15:49:38 +00:00
|
|
|
this.popupBoxObject.setConsumeRollupEvent(this.mInput.consumeRollupEvent);
|
2002-09-28 06:25:03 +00: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;
|
2005-09-17 01:12:22 +00:00
|
|
|
this.selectedIndex = this.getNextIndex(aReverse, amount, this.selectedIndex, this.tree.view.rowCount-1);
|
|
|
|
if (this.selectedIndex == -1) {
|
|
|
|
this.input._focus();
|
2005-08-06 04:14:55 +00:00
|
|
|
}
|
2002-09-28 06:25:03 +00:00
|
|
|
} 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>
|
|
|
|
|
|
|
|
<property name="view"
|
|
|
|
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-30 04:57:57 +00:00
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="autocomplete-base-popup" extends="chrome://global/content/bindings/popup.xml#popup">
|
|
|
|
<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();
|
|
|
|
document.popupNode = null;
|
|
|
|
this.removeAttribute("width");
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2006-06-12 17:49:06 +00: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>
|
|
|
|
|
2006-06-16 01:50:30 +00:00
|
|
|
<!-- 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>
|
|
|
|
|
2003-07-13 02:27:25 +00:00
|
|
|
<property name="maxRows" readonly="true">
|
2007-11-30 04:57:57 +00:00
|
|
|
<getter>
|
2007-11-06 08:43:53 +00:00
|
|
|
<![CDATA[
|
2007-11-30 04:57:57 +00:00
|
|
|
return (this.mInput && this.mInput.maxRows) || this.defaultMaxRows;
|
2007-08-31 20:19:19 +00:00
|
|
|
]]>
|
2007-11-30 04:57:57 +00:00
|
|
|
</getter>
|
2007-08-31 20:19:19 +00:00
|
|
|
</property>
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<method name="getNextIndex">
|
|
|
|
<parameter name="aReverse"/>
|
|
|
|
<parameter name="aAmount"/>
|
|
|
|
<parameter name="aIndex"/>
|
|
|
|
<parameter name="aMaxRow"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aMaxRow < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (newIdx < 0 && aIndex == 0 || newIdx > aMaxRow && aIndex == aMaxRow)
|
|
|
|
aIndex = -1;
|
|
|
|
else
|
|
|
|
aIndex = newIdx;
|
|
|
|
|
|
|
|
return aIndex;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="onPopupClick">
|
2004-02-17 08:32:42 +00:00
|
|
|
<parameter name="aEvent"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
<body><![CDATA[
|
2002-10-11 01:43:27 +00:00
|
|
|
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
|
2002-09-28 06:25:03 +00:00
|
|
|
controller.handleEnter();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
2006-06-12 17:49:06 +00:00
|
|
|
<handler event="popupshowing"><![CDATA[
|
2006-06-16 01:50:30 +00:00
|
|
|
// 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;
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
this.mPopupOpen = true;
|
2006-06-12 17:49:06 +00:00
|
|
|
]]></handler>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
2007-08-21 23:55:54 +00:00
|
|
|
<handler event="popuphiding"><![CDATA[
|
|
|
|
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
|
|
|
|
controller.stopSearch();
|
|
|
|
|
2005-12-31 23:34:46 +00:00
|
|
|
this.mPopupOpen = false;
|
2006-06-16 01:50:30 +00:00
|
|
|
|
|
|
|
// 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;
|
2007-08-21 23:55:54 +00:00
|
|
|
]]></handler>
|
2002-09-28 06:25:03 +00:00
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2007-11-30 04:57:57 +00:00
|
|
|
<binding id="autocomplete-rich-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-base-popup">
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
<content ignorekeys="true">
|
|
|
|
<xul:richlistbox anonid="richlistbox" class="autocomplete-richlistbox" flex="1"/>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation implements="nsIAutoCompletePopup">
|
|
|
|
<field name="_currentIndex">0</field>
|
|
|
|
<field name="_rowHeight">0</field>
|
|
|
|
|
|
|
|
<!-- =================== nsIAutoCompletePopup =================== -->
|
|
|
|
|
|
|
|
<property name="selectedIndex"
|
|
|
|
onget="return this.richlistbox.selectedIndex;">
|
|
|
|
<setter>
|
|
|
|
<![CDATA[
|
|
|
|
this.richlistbox.selectedIndex = val;
|
|
|
|
this.richlistbox.ensureSelectedElementIsVisible();
|
|
|
|
return val;
|
|
|
|
]]>
|
|
|
|
</setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="openAutocompletePopup">
|
|
|
|
<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">
|
|
|
|
<parameter name="aInput"/>
|
|
|
|
<parameter name="aElement"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this.mPopupOpen) {
|
|
|
|
this.mInput = aInput;
|
|
|
|
document.popupNode = null;
|
|
|
|
|
|
|
|
var rect = aElement.getBoundingClientRect();
|
|
|
|
var width = rect.right - rect.left;
|
|
|
|
this.setAttribute("width", width > 100 ? width : 100);
|
|
|
|
// invalidate() depends on the width attribute
|
|
|
|
this.invalidate();
|
|
|
|
|
|
|
|
this.openPopup(aElement, "after_start", 0, 0, false, false);
|
|
|
|
this.popupBoxObject.setConsumeRollupEvent(this.mInput.consumeRollupEvent);
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="invalidate">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// collapsed if no matches
|
|
|
|
this.richlistbox.collapsed = (this._matchCount == 0);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
var clearSelection = true;
|
|
|
|
var currentSelectedIndex = this.selectedIndex;
|
|
|
|
if (currentSelectedIndex != -1 && currentSelectedIndex < this._matchCount) {
|
|
|
|
var controller = this.mInput.controller;
|
|
|
|
var item = this.richlistbox.childNodes[currentSelectedIndex];
|
|
|
|
if (item.getAttribute("url") == controller.getValueAt(currentSelectedIndex) &&
|
|
|
|
item.getAttribute("title") == controller.getCommentAt(currentSelectedIndex)) {
|
|
|
|
clearSelection = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (currentSelectedIndex != -1 && clearSelection)
|
|
|
|
this.selectedIndex = -1;
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
<method name="_appendCurrentResult">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var controller = this.mInput.controller;
|
|
|
|
|
|
|
|
// detect the desired height of the tree
|
|
|
|
var rows = this.maxRows;
|
|
|
|
if (!this._matchCount || (rows && this._matchCount < rows))
|
|
|
|
rows = this._matchCount;
|
|
|
|
|
|
|
|
// until we have support for "rows" on richlistbox,
|
|
|
|
// determine the height dynamically. (see bug #401939)
|
|
|
|
if (!this._rowHeight && this.richlistbox.childNodes.length)
|
|
|
|
this._rowHeight = this.richlistbox.childNodes[0].boxObject.height;
|
|
|
|
|
|
|
|
var height = this._rowHeight * rows;
|
|
|
|
if (this._rowHeight && this.richlistbox.height != height)
|
|
|
|
this.richlistbox.height = height;
|
|
|
|
|
|
|
|
if (this._currentIndex < this._matchCount) {
|
|
|
|
var existingItemsCount = this.richlistbox.childNodes.length;
|
|
|
|
var item;
|
|
|
|
|
|
|
|
// trim the leading/trailing whitespace
|
|
|
|
var trimmedSearchString = controller.searchString.replace(/^\s+/, "").replace(/\s+$/, "");
|
|
|
|
|
|
|
|
if (this._currentIndex < existingItemsCount) {
|
|
|
|
// re-use the existing item
|
|
|
|
item = this.richlistbox.childNodes[this._currentIndex];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// need to create a new item
|
|
|
|
item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "richlistitem");
|
|
|
|
}
|
|
|
|
|
|
|
|
// set these attributes before we set the class
|
|
|
|
// so that we can use them from the contructor
|
|
|
|
item.setAttribute("image", controller.getImageAt(this._currentIndex));
|
|
|
|
item.setAttribute("url", controller.getValueAt(this._currentIndex));
|
|
|
|
item.setAttribute("title", controller.getCommentAt(this._currentIndex));
|
|
|
|
item.setAttribute("type", controller.getStyleAt(this._currentIndex));
|
|
|
|
item.setAttribute("text", trimmedSearchString);
|
|
|
|
|
|
|
|
var width = this.getAttribute("width");
|
|
|
|
|
|
|
|
if (this._currentIndex < existingItemsCount) {
|
|
|
|
// re-use the existing item
|
|
|
|
item._adjustAcItem();
|
|
|
|
item.collapsed = false;
|
|
|
|
|
|
|
|
var current_width = item.getAttribute("current_width");
|
|
|
|
|
|
|
|
if (width && current_width != width) {
|
|
|
|
item.setAttribute("current_width", width);
|
|
|
|
item._adjustWidth();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// created a new item
|
|
|
|
if (width)
|
|
|
|
item.setAttribute("current_width", width);
|
|
|
|
|
|
|
|
// set the class at the end so we can use the attributes
|
|
|
|
// in the xbl constructor
|
|
|
|
item.className = "autocomplete-richlistitem";
|
|
|
|
this.richlistbox.appendChild(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._currentIndex++;
|
|
|
|
|
|
|
|
// yield after creating each item so that the UI is responsive
|
|
|
|
// note, when browser.urlbar.maxRichResults is small, this setTimeout()
|
|
|
|
// is not needed, and we could call this._appendCurrentResult() directly.
|
|
|
|
// but the bigger browser.urlbar.maxRichResults gets, this is necessary
|
|
|
|
// so that typing the url bar is responsive
|
|
|
|
setTimeout(function (self) { self._appendCurrentResult(); }, 0, this);
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="selectBy">
|
|
|
|
<parameter name="aReverse"/>
|
|
|
|
<parameter name="aPage"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
try {
|
|
|
|
var amount = aPage ? 5 : 1;
|
|
|
|
|
|
|
|
// 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>
|
|
|
|
|
|
|
|
<property name="view"
|
|
|
|
onget="return this.mInput.controller;"
|
|
|
|
onset="return val;"/>
|
|
|
|
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="autocomplete-richlistitem" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
|
|
|
|
<content>
|
|
|
|
<xul:vbox>
|
|
|
|
<xul:hbox align="center">
|
|
|
|
<xul:image xbl:inherits="src=image" class="ac-site-icon"/>
|
|
|
|
<xul:scrollbox anonid="title-scrollbox" class="ac-title">
|
|
|
|
# note, we rely on the newlines here so that we have
|
|
|
|
# a textNode before and after the span. see _setUpDescription()
|
|
|
|
# for more details
|
|
|
|
<xul:description anonid="title" class="ac-normal-text ac-comment" xbl:inherits="selected">
|
|
|
|
<xul:label class="ac-emphasize-text"/>
|
|
|
|
</xul:description>
|
|
|
|
</xul:scrollbox>
|
|
|
|
<xul:label anonid="title-overflow-ellipsis" xbl:inherits="selected"
|
|
|
|
class="ac-ellipsis-after ac-comment"/>
|
|
|
|
<xul:image anonid="type-image" class="ac-type-icon"/>
|
|
|
|
</xul:hbox>
|
|
|
|
<xul:hbox align="center">
|
|
|
|
<xul:spacer class="ac-site-icon"/>
|
|
|
|
<xul:scrollbox anonid="url-scrollbox" class="ac-url">
|
|
|
|
# note, we rely on the newlines here so that we have
|
|
|
|
# a textNode before and after the span. see _setUpDescription()
|
|
|
|
# for more details
|
|
|
|
<xul:description anonid="url" class="ac-normal-text ac-url-text" xbl:inherits="selected">
|
|
|
|
<xul:label class="ac-emphasize-text"/>
|
|
|
|
</xul:description>
|
|
|
|
</xul:scrollbox>
|
|
|
|
<xul:label anonid="url-overflow-ellipsis" xbl:inherits="selected"
|
|
|
|
class="ac-ellipsis-after ac-url-text"/>
|
|
|
|
<xul:spacer class="ac-type-icon"/>
|
|
|
|
</xul:hbox>
|
|
|
|
</xul:vbox>
|
|
|
|
</content>
|
|
|
|
<implementation>
|
|
|
|
<constructor>
|
|
|
|
<![CDATA[
|
|
|
|
this._urlOverflowEllipsis = document.getAnonymousElementByAttribute(this, "anonid", "url-overflow-ellipsis");
|
|
|
|
this._titleOverflowEllipsis = document.getAnonymousElementByAttribute(this, "anonid", "title-overflow-ellipsis");
|
|
|
|
|
|
|
|
this._typeImage = document.getAnonymousElementByAttribute(this, "anonid", "type-image");
|
|
|
|
|
|
|
|
this._urlScrollbox = document.getAnonymousElementByAttribute(this, "anonid", "url-scrollbox");
|
|
|
|
this._url = document.getAnonymousElementByAttribute(this, "anonid", "url");
|
|
|
|
|
|
|
|
this._titleScrollbox = document.getAnonymousElementByAttribute(this, "anonid", "title-scrollbox");
|
|
|
|
this._title = document.getAnonymousElementByAttribute(this, "anonid", "title");
|
|
|
|
|
|
|
|
// XXX hack
|
|
|
|
// for the first richlistitem, when we call _adjustWidth()
|
|
|
|
// from the xbl constructor, these elements don't have widths
|
|
|
|
// but we rely on those widths to properly set the widths
|
2007-11-30 05:56:58 +00:00
|
|
|
// of the scrollboxes. if we don't have the widths
|
|
|
|
// try again on a timeout.
|
|
|
|
if (!this._urlOverflowEllipsis.boxObject.width ||
|
|
|
|
!this._titleOverflowEllipsis.boxObject.width)
|
|
|
|
setTimeout(function(self) { self._adjustWidth(); }, 0, this);
|
|
|
|
else
|
|
|
|
this._adjustWidth();
|
2007-11-30 04:57:57 +00:00
|
|
|
]]>
|
|
|
|
</constructor>
|
|
|
|
|
|
|
|
<field name="_ellipsis">null</field>
|
|
|
|
|
|
|
|
<property name="ellipsis" readonly="true">
|
|
|
|
<getter>
|
|
|
|
<![CDATA[
|
|
|
|
if (!this._ellipsis) {
|
|
|
|
try {
|
|
|
|
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefBranch);
|
|
|
|
this._ellipsis = pref.getComplexValue("intl.ellipsis",
|
|
|
|
Components.interfaces.nsIPrefLocalizedString).data;
|
|
|
|
} catch (ex) {
|
|
|
|
this._ellipsis = "\u2026";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return this._ellipsis;
|
|
|
|
]]>
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="_setUpDescription">
|
|
|
|
<parameter name="aDescriptionElement"/>
|
|
|
|
<parameter name="aText"/>
|
|
|
|
<parameter name="aScrollBoxObject"/>
|
|
|
|
<parameter name="aEllipsis"/>
|
|
|
|
<parameter name="aMatchIndex"/>
|
|
|
|
<parameter name="aMatchLength"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
if (aMatchIndex == -1) {
|
|
|
|
aDescriptionElement.childNodes[0].textContent = aText;
|
|
|
|
aDescriptionElement.childNodes[1].value = "";
|
|
|
|
aDescriptionElement.childNodes[2].textContent = "";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aDescriptionElement.childNodes[0].textContent =
|
|
|
|
aText.substring(0, aMatchIndex);
|
|
|
|
|
|
|
|
aDescriptionElement.childNodes[1].value =
|
|
|
|
aText.substring(aMatchIndex, aMatchIndex + aMatchLength);
|
|
|
|
|
|
|
|
aDescriptionElement.childNodes[2].textContent =
|
|
|
|
aText.substring(aMatchIndex + aMatchLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
// need to set up the ellipsis on a time out,
|
|
|
|
// because the width of the description element may still be 0
|
|
|
|
// even though the aText length is non-zero
|
|
|
|
setTimeout(function(self) { self._setUpEllipsis(aScrollBoxObject, aDescriptionElement, aEllipsis); }, 0, this);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_adjustAcItem">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var text = this.getAttribute("text");
|
|
|
|
var url = this.getAttribute("url");
|
|
|
|
var title = this.getAttribute("title");
|
|
|
|
var type = this.getAttribute("type");
|
|
|
|
|
|
|
|
var url_sbo = this._urlScrollbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
|
|
|
|
var title_sbo = this._titleScrollbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
|
|
|
|
|
|
|
|
this._typeImage.className = type ? ("ac-result-type-" + type) : "";
|
|
|
|
|
|
|
|
// if we aren't matching any text
|
|
|
|
// (the user has clicked on the history drop down
|
|
|
|
// or this result is a "tag" match, don't bold any matching text
|
|
|
|
if (text == "" || type == "tag") {
|
|
|
|
this._setUpDescription(this._url, url, url_sbo, this._urlOverflowEllipsis, -1, -1);
|
|
|
|
this._setUpDescription(this._title, title, title_sbo, this._titleOverflowEllipsis, -1, -1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// emphasize the matching text, first try title, and then try url
|
|
|
|
var needle = text.toLowerCase();
|
|
|
|
var hay = title.toLowerCase();
|
|
|
|
var index = hay.indexOf(needle);
|
|
|
|
|
|
|
|
this._setUpDescription(this._title, title, title_sbo, this._titleOverflowEllipsis, index, text.length);
|
|
|
|
|
|
|
|
// if we didn't find it in the url, check the title
|
|
|
|
if (index == -1) {
|
|
|
|
hay = url.toLowerCase();
|
|
|
|
index = hay.indexOf(needle);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
index = -1;
|
|
|
|
|
|
|
|
this._setUpDescription(this._url, url, url_sbo, this._urlOverflowEllipsis, index, text.length);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_adjustWidth">
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// XXX hack
|
|
|
|
// see bug #399644 comment #39 for some details
|
|
|
|
// add 16px for the site image, 8 for the margin right of the site icon,
|
|
|
|
// 16px for the type image, and 24px for scroll bar
|
|
|
|
var pixelsUsedForNonText = 16 + 8 + 16 + 24;
|
|
|
|
|
|
|
|
var current_url_width = this.getAttribute("current_width") -
|
|
|
|
pixelsUsedForNonText -
|
|
|
|
this._urlOverflowEllipsis.boxObject.width;
|
|
|
|
|
|
|
|
var current_title_width = this.getAttribute("current_width") -
|
|
|
|
pixelsUsedForNonText -
|
|
|
|
this._titleOverflowEllipsis.boxObject.width;
|
|
|
|
|
|
|
|
this._urlScrollbox.minWidth = current_url_width;
|
|
|
|
this._urlScrollbox.maxWidth = current_url_width;
|
|
|
|
|
|
|
|
this._titleScrollbox.minWidth = current_title_width;
|
|
|
|
this._titleScrollbox.maxWidth = current_title_width;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_setUpEllipsis">
|
|
|
|
<parameter name="aScrollBoxObject"/>
|
|
|
|
<parameter name="aDescriptionElement"/>
|
|
|
|
<parameter name="aEllipsis"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
// determine if we need to show the ellipsis
|
|
|
|
if ((aScrollBoxObject.x + aScrollBoxObject.width) >= (aDescriptionElement.boxObject.x + aDescriptionElement.boxObject.width))
|
|
|
|
aEllipsis.value = "";
|
|
|
|
else
|
|
|
|
aEllipsis.value = this.ellipsis;
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
2003-11-20 05:14:08 +00:00
|
|
|
<binding id="autocomplete-tree" extends="chrome://global/content/bindings/tree.xml#tree">
|
2002-09-28 06:25:03 +00:00
|
|
|
<content>
|
|
|
|
<children includes="treecols"/>
|
|
|
|
<xul:treerows class="autocomplete-treerows tree-rows" xbl:inherits="hidescrollbar" flex="1">
|
|
|
|
<children/>
|
|
|
|
</xul:treerows>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
2007-11-30 04:57:57 +00: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;
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<binding id="autocomplete-treebody">
|
|
|
|
<implementation>
|
2007-11-30 04:57:57 +00:00
|
|
|
<field name="mLastMoveTime">Date.now()</field>
|
2002-09-28 06:25:03 +00:00
|
|
|
</implementation>
|
2007-11-30 04:57:57 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<handlers>
|
2004-02-17 08:32:42 +00:00
|
|
|
<handler event="mouseup" action="this.parentNode.parentNode.onPopupClick(event);"/>
|
2002-09-28 06:25:03 +00:00
|
|
|
|
2005-09-19 17:29:40 +00:00
|
|
|
<handler event="mousedown"><![CDATA[
|
2007-08-09 18:52:01 +00:00
|
|
|
var rc = this.parentNode.treeBoxObject.getRowAt(event.clientX, event.clientY);
|
|
|
|
if (rc != this.parentNode.currentIndex)
|
|
|
|
this.parentNode.view.selection.select(rc);
|
2005-09-19 17:29:40 +00:00
|
|
|
]]></handler>
|
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<handler event="mousemove"><![CDATA[
|
2007-11-30 04:57:57 +00:00
|
|
|
if (Date.now() - this.mLastMoveTime > 30) {
|
2007-08-09 18:52:01 +00:00
|
|
|
var rc = this.parentNode.treeBoxObject.getRowAt(event.clientX, event.clientY);
|
|
|
|
if (rc != this.parentNode.currentIndex)
|
|
|
|
this.parentNode.view.selection.select(rc);
|
2007-11-30 04:57:57 +00:00
|
|
|
this.mLastMoveTime = Date.now();
|
2002-09-28 06:25:03 +00:00
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="autocomplete-treerows">
|
2007-11-27 18:53:55 +00:00
|
|
|
<content>
|
2002-09-28 06:25:03 +00:00
|
|
|
<xul:hbox flex="1" class="tree-bodybox">
|
|
|
|
<children/>
|
|
|
|
</xul:hbox>
|
|
|
|
<xul:scrollbar xbl:inherits="collapsed=hidescrollbar" orient="vertical" class="tree-scrollbar"/>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
2006-08-28 15:56:47 +00:00
|
|
|
<binding id="history-dropmarker" extends="chrome://global/content/bindings/general.xml#dropmarker">
|
|
|
|
<implementation>
|
2002-09-28 06:25:03 +00:00
|
|
|
<method name="showPopup">
|
|
|
|
<body><![CDATA[
|
|
|
|
var textbox = document.getBindingParent(this);
|
2005-12-31 23:34:46 +00:00
|
|
|
textbox.showHistoryPopup();
|
2002-09-28 06:25:03 +00:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
2007-11-30 04:57:57 +00:00
|
|
|
|
2002-09-28 06:25:03 +00:00
|
|
|
<handlers>
|
2005-12-09 16:49:34 +00:00
|
|
|
<handler event="mousedown" button="0"><![CDATA[
|
2002-09-28 06:25:03 +00:00
|
|
|
this.showPopup();
|
|
|
|
]]></handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
</bindings>
|
|
|
|
|