2007-03-22 10:30:00 -07:00
|
|
|
<?xml version="1.0"?>
|
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
|
|
|
|
|
|
|
<!DOCTYPE bindings [
|
|
|
|
<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd" >
|
|
|
|
%textcontextDTD;
|
|
|
|
]>
|
|
|
|
|
|
|
|
<bindings id="textboxBindings"
|
|
|
|
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="textbox" extends="xul:box" role="xul:textbox">
|
2007-03-22 10:30:00 -07:00
|
|
|
<resources>
|
2009-03-12 07:16:33 -07:00
|
|
|
<stylesheet src="chrome://global/content/textbox.css"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<stylesheet src="chrome://global/skin/textbox.css"/>
|
|
|
|
</resources>
|
|
|
|
|
|
|
|
<content>
|
|
|
|
<children/>
|
|
|
|
<xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context,spellcheck">
|
2011-04-22 18:36:24 -07:00
|
|
|
<html:input class="textbox-input" anonid="input"
|
2012-03-04 06:57:45 -08:00
|
|
|
xbl:inherits="value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,noinitialfocus,mozactionhint,spellcheck"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
|
|
|
|
2013-07-18 21:13:35 -07:00
|
|
|
<implementation implements="nsIDOMXULTextBoxElement, nsIDOMXULLabeledControlElement">
|
2008-02-06 11:00:09 -08:00
|
|
|
<!-- nsIDOMXULLabeledControlElement -->
|
|
|
|
<field name="crop">""</field>
|
|
|
|
<field name="image">""</field>
|
|
|
|
<field name="command">""</field>
|
|
|
|
<field name="accessKey">""</field>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<field name="mInputField">null</field>
|
|
|
|
<field name="mIgnoreClick">false</field>
|
|
|
|
<field name="mIgnoreFocus">false</field>
|
2012-10-07 19:33:45 -07:00
|
|
|
<field name="mEditor">null</field>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<property name="inputField" readonly="true">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (!this.mInputField)
|
|
|
|
this.mInputField = document.getAnonymousElementByAttribute(this, "anonid", "input");
|
|
|
|
return this.mInputField;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
|
2010-03-03 23:13:27 -08:00
|
|
|
<property name="value" onset="this.inputField.value = val; return val;"
|
|
|
|
onget="return this.inputField.value;"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<property name="defaultValue" onset="this.inputField.defaultValue = val; return val;"
|
|
|
|
onget="return this.inputField.defaultValue;"/>
|
2008-02-06 11:00:09 -08:00
|
|
|
<property name="label" onset="this.setAttribute('label', val); return val;"
|
|
|
|
onget="return this.getAttribute('label') ||
|
|
|
|
(this.labelElement ? this.labelElement.value :
|
2010-03-03 23:13:27 -08:00
|
|
|
this.placeholder);"/>
|
|
|
|
<property name="placeholder" onset="this.inputField.placeholder = val; return val;"
|
|
|
|
onget="return this.inputField.placeholder;"/>
|
|
|
|
<property name="emptyText" onset="this.placeholder = val; return val;"
|
|
|
|
onget="return this.placeholder;"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<property name="type" onset="if (val) this.setAttribute('type', val);
|
|
|
|
else this.removeAttribute('type'); return val;"
|
|
|
|
onget="return this.getAttribute('type');"/>
|
|
|
|
<property name="maxLength" onset="this.inputField.maxLength = val; return val;"
|
|
|
|
onget="return this.inputField.maxLength;"/>
|
|
|
|
<property name="disabled" onset="this.inputField.disabled = val;
|
|
|
|
if (val) this.setAttribute('disabled', 'true');
|
|
|
|
else this.removeAttribute('disabled'); return val;"
|
|
|
|
onget="return this.inputField.disabled;"/>
|
|
|
|
<property name="tabIndex" onget="return parseInt(this.getAttribute('tabindex'));"
|
|
|
|
onset="this.inputField.tabIndex = val;
|
|
|
|
if (val) this.setAttribute('tabindex', val);
|
|
|
|
else this.removeAttribute('tabindex'); return val;"/>
|
|
|
|
<property name="size" onset="this.inputField.size = val; return val;"
|
|
|
|
onget="return this.inputField.size;"/>
|
|
|
|
<property name="readOnly" onset="this.inputField.readOnly = val;
|
|
|
|
if (val) this.setAttribute('readonly', 'true');
|
|
|
|
else this.removeAttribute('readonly'); return val;"
|
|
|
|
onget="return this.inputField.readOnly;"/>
|
|
|
|
<property name="clickSelectsAll"
|
|
|
|
onget="return this.getAttribute('clickSelectsAll') == 'true';"
|
|
|
|
onset="if (val) this.setAttribute('clickSelectsAll', 'true');
|
|
|
|
else this.removeAttribute('clickSelectsAll'); return val;" />
|
|
|
|
|
2012-10-07 15:18:42 -07:00
|
|
|
<property name="editor" readonly="true">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (!this.mEditor) {
|
|
|
|
const nsIDOMNSEditableElement = Components.interfaces.nsIDOMNSEditableElement;
|
|
|
|
this.mEditor = this.inputField.QueryInterface(nsIDOMNSEditableElement).editor;
|
|
|
|
}
|
|
|
|
return this.mEditor;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<method name="reset">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.value = this.defaultValue;
|
|
|
|
try {
|
|
|
|
this.editor.transactionManager.clear();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
catch(e) {}
|
|
|
|
return false;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="select">
|
|
|
|
<body>
|
|
|
|
this.inputField.select();
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<property name="controllers" readonly="true" onget="return this.inputField.controllers"/>
|
2008-02-10 22:16:23 -08:00
|
|
|
<property name="textLength" readonly="true"
|
2010-03-03 23:13:27 -08:00
|
|
|
onget="return this.inputField.textLength;"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<property name="selectionStart" onset="this.inputField.selectionStart = val; return val;"
|
|
|
|
onget="return this.inputField.selectionStart;"/>
|
|
|
|
<property name="selectionEnd" onset="this.inputField.selectionEnd = val; return val;"
|
|
|
|
onget="return this.inputField.selectionEnd;"/>
|
|
|
|
|
|
|
|
<method name="setSelectionRange">
|
|
|
|
<parameter name="aSelectionStart"/>
|
|
|
|
<parameter name="aSelectionEnd"/>
|
|
|
|
<body>
|
|
|
|
this.inputField.setSelectionRange( aSelectionStart, aSelectionEnd );
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
2007-09-17 18:08:33 -07:00
|
|
|
<method name="_setNewlineHandling">
|
|
|
|
<body><![CDATA[
|
|
|
|
var str = this.getAttribute("newlines");
|
2010-06-04 11:58:02 -07:00
|
|
|
if (str && this.editor) {
|
2007-09-17 18:08:33 -07:00
|
|
|
const nsIPlaintextEditor = Components.interfaces.nsIPlaintextEditor;
|
|
|
|
for (var x in nsIPlaintextEditor) {
|
|
|
|
if (/^eNewlines/.test(x)) {
|
|
|
|
if (str == RegExp.rightContext.toLowerCase()) {
|
|
|
|
this.editor.QueryInterface(nsIPlaintextEditor)
|
|
|
|
.newlineHandling = nsIPlaintextEditor[x];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2012-09-15 16:46:13 -07:00
|
|
|
<method name="_maybeSelectAll">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (!this.mIgnoreClick && this.clickSelectsAll &&
|
|
|
|
document.activeElement == this.inputField &&
|
|
|
|
this.inputField.selectionStart == this.inputField.selectionEnd)
|
|
|
|
this.editor.selectAll();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<constructor><![CDATA[
|
|
|
|
var str = this.boxObject.getProperty("value");
|
|
|
|
if (str) {
|
|
|
|
this.inputField.value = str;
|
|
|
|
this.boxObject.removeProperty("value");
|
|
|
|
}
|
2008-02-06 11:00:09 -08:00
|
|
|
|
2009-01-12 11:55:37 -08:00
|
|
|
this._setNewlineHandling();
|
2010-03-03 23:13:27 -08:00
|
|
|
|
|
|
|
if (this.hasAttribute("emptytext"))
|
2010-03-06 14:15:12 -08:00
|
|
|
this.placeholder = this.getAttribute("emptytext");
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></constructor>
|
|
|
|
|
|
|
|
<destructor>
|
|
|
|
<![CDATA[
|
|
|
|
if (this.inputField.value)
|
|
|
|
this.boxObject.setProperty('value', this.inputField.value);
|
|
|
|
this.mInputField = null;
|
|
|
|
]]>
|
|
|
|
</destructor>
|
|
|
|
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="focus" phase="capturing">
|
|
|
|
<![CDATA[
|
2009-01-12 11:55:37 -08:00
|
|
|
if (this.hasAttribute("focused"))
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-01-12 11:55:37 -08:00
|
|
|
switch (event.originalTarget) {
|
|
|
|
case this:
|
|
|
|
// Forward focus to actual HTML input
|
|
|
|
this.inputField.focus();
|
|
|
|
break;
|
|
|
|
case this.inputField:
|
|
|
|
if (this.mIgnoreFocus) {
|
|
|
|
this.mIgnoreFocus = false;
|
|
|
|
} else if (this.clickSelectsAll) {
|
|
|
|
try {
|
|
|
|
const nsIEditorIMESupport =
|
|
|
|
Components.interfaces.nsIEditorIMESupport;
|
|
|
|
let imeEditor = this.editor.QueryInterface(nsIEditorIMESupport);
|
|
|
|
if (!imeEditor || !imeEditor.composing)
|
|
|
|
this.editor.selectAll();
|
|
|
|
} catch (e) {}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
// Allow other children (e.g. URL bar buttons) to get focus
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-01-12 11:55:37 -08:00
|
|
|
this.setAttribute("focused", "true");
|
2007-03-22 10:30:00 -07:00
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
|
|
|
|
<handler event="blur" phase="capturing">
|
|
|
|
<![CDATA[
|
2012-09-21 16:03:23 -07:00
|
|
|
this.removeAttribute("focused");
|
2009-06-22 12:53:58 -07:00
|
|
|
|
|
|
|
// don't trigger clickSelectsAll when switching application windows
|
|
|
|
if (window == window.top &&
|
|
|
|
window.constructor == ChromeWindow &&
|
|
|
|
document.activeElement == this.inputField)
|
|
|
|
this.mIgnoreFocus = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
|
|
|
|
<handler event="mousedown">
|
|
|
|
<![CDATA[
|
|
|
|
this.mIgnoreClick = this.hasAttribute("focused");
|
|
|
|
|
|
|
|
if (!this.mIgnoreClick) {
|
|
|
|
this.mIgnoreFocus = true;
|
|
|
|
this.inputField.setSelectionRange(0, 0);
|
2008-09-28 11:58:48 -07:00
|
|
|
if (event.originalTarget == this ||
|
|
|
|
event.originalTarget == this.inputField.parentNode)
|
|
|
|
this.inputField.focus();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
|
2012-09-15 16:46:13 -07:00
|
|
|
<handler event="click" action="this._maybeSelectAll();"/>
|
|
|
|
|
2010-07-05 21:27:52 -07:00
|
|
|
#ifndef XP_WIN
|
2012-09-15 16:46:13 -07:00
|
|
|
<handler event="contextmenu">
|
|
|
|
if (!event.button) // context menu opened via keyboard shortcut
|
|
|
|
return;
|
|
|
|
this._maybeSelectAll();
|
|
|
|
// see bug 576135 comment 4
|
|
|
|
let box = this.inputField.parentNode;
|
|
|
|
let menu = document.getAnonymousElementByAttribute(box, "anonid", "input-box-contextmenu");
|
|
|
|
box._doPopupItemEnabling(menu);
|
2007-03-22 10:30:00 -07:00
|
|
|
</handler>
|
2012-09-15 16:46:13 -07:00
|
|
|
#endif
|
2007-03-22 10:30:00 -07:00
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="timed-textbox" extends="chrome://global/content/bindings/textbox.xml#textbox">
|
|
|
|
<implementation>
|
2008-08-30 17:44:12 -07:00
|
|
|
<constructor><![CDATA[
|
|
|
|
try {
|
|
|
|
var consoleService = Components.classes["@mozilla.org/consoleservice;1"]
|
|
|
|
.getService(Components.interfaces.nsIConsoleService);
|
|
|
|
var scriptError = Components.classes["@mozilla.org/scripterror;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIScriptError);
|
|
|
|
scriptError.init("Timed textboxes are deprecated. Consider using type=\"search\" instead.",
|
|
|
|
this.ownerDocument.location.href, null, null,
|
|
|
|
null, scriptError.warningFlag, "XUL Widgets");
|
|
|
|
consoleService.logMessage(scriptError);
|
|
|
|
} catch (e) {}
|
|
|
|
]]></constructor>
|
2007-03-22 10:30:00 -07:00
|
|
|
<field name="_timer">null</field>
|
|
|
|
<property name="timeout"
|
|
|
|
onset="this.setAttribute('timeout', val); return val;"
|
|
|
|
onget="return parseInt(this.getAttribute('timeout')) || 0;"/>
|
2008-02-09 21:10:01 -08:00
|
|
|
<property name="value"
|
2010-03-03 23:13:27 -08:00
|
|
|
onget="return this.inputField.value;">
|
2008-02-09 21:10:01 -08:00
|
|
|
<setter><![CDATA[
|
2010-03-03 23:13:27 -08:00
|
|
|
this.inputField.value = val;
|
2008-02-09 21:10:01 -08:00
|
|
|
if (this._timer)
|
|
|
|
clearTimeout(this._timer);
|
|
|
|
return val;
|
|
|
|
]]></setter>
|
2007-03-22 10:30:00 -07:00
|
|
|
</property>
|
|
|
|
<method name="_fireCommand">
|
|
|
|
<parameter name="me"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
me._timer = null;
|
|
|
|
me.doCommand();
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
<handlers>
|
|
|
|
<handler event="input">
|
|
|
|
<![CDATA[
|
|
|
|
if (this._timer)
|
|
|
|
clearTimeout(this._timer);
|
|
|
|
this._timer = this.timeout && setTimeout(this._fireCommand, this.timeout, this);
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_RETURN">
|
|
|
|
<![CDATA[
|
|
|
|
if (this._timer)
|
|
|
|
clearTimeout(this._timer);
|
|
|
|
this._fireCommand(this);
|
|
|
|
event.preventDefault();
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2008-08-05 10:42:30 -07:00
|
|
|
<binding id="search-textbox" extends="chrome://global/content/bindings/textbox.xml#textbox">
|
|
|
|
<content>
|
|
|
|
<children/>
|
|
|
|
<xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context,spellcheck" align="center">
|
2011-04-22 18:36:24 -07:00
|
|
|
<html:input class="textbox-input" anonid="input" mozactionhint="search"
|
2012-03-04 06:57:45 -08:00
|
|
|
xbl:inherits="value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,mozactionhint,spellcheck"/>
|
2008-08-05 10:42:30 -07:00
|
|
|
<xul:deck class="textbox-search-icons" anonid="search-icons">
|
|
|
|
<xul:image class="textbox-search-icon"
|
|
|
|
onclick="document.getBindingParent(this)._iconClick();"
|
2009-07-29 11:33:53 -07:00
|
|
|
xbl:inherits="src=image,searchbutton,disabled"/>
|
2008-08-05 10:42:30 -07:00
|
|
|
<xul:image class="textbox-search-clear"
|
|
|
|
onclick="document.getBindingParent(this)._clearSearch();"
|
2009-07-29 11:33:53 -07:00
|
|
|
xbl:inherits="disabled"/>
|
2008-08-05 10:42:30 -07:00
|
|
|
</xul:deck>
|
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
|
|
|
<implementation>
|
|
|
|
<field name="_timer">null</field>
|
|
|
|
<field name="_searchIcons">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "search-icons");
|
|
|
|
</field>
|
|
|
|
<property name="timeout"
|
|
|
|
onset="this.setAttribute('timeout', val); return val;"
|
|
|
|
onget="return parseInt(this.getAttribute('timeout')) || 500;"/>
|
|
|
|
<property name="searchButton"
|
2009-02-02 01:38:53 -08:00
|
|
|
onget="return this.getAttribute('searchbutton') == 'true';">
|
|
|
|
<setter><![CDATA[
|
|
|
|
if (val) {
|
|
|
|
this.setAttribute("searchbutton", "true");
|
|
|
|
this.removeAttribute("aria-autocomplete");
|
|
|
|
} else {
|
|
|
|
this.removeAttribute("searchbutton");
|
|
|
|
this.setAttribute("aria-autocomplete", "list");
|
|
|
|
}
|
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
2008-08-05 10:42:30 -07:00
|
|
|
<property name="value"
|
2010-03-03 23:13:27 -08:00
|
|
|
onget="return this.inputField.value;">
|
2008-08-05 10:42:30 -07:00
|
|
|
<setter><![CDATA[
|
2010-03-03 23:13:27 -08:00
|
|
|
this.inputField.value = val;
|
|
|
|
|
|
|
|
if (val)
|
2008-08-05 10:42:30 -07:00
|
|
|
this._searchIcons.selectedIndex = this.searchButton ? 0 : 1;
|
2010-03-03 23:13:27 -08:00
|
|
|
else
|
2008-08-05 10:42:30 -07:00
|
|
|
this._searchIcons.selectedIndex = 0;
|
2010-03-03 23:13:27 -08:00
|
|
|
|
2008-08-05 10:42:30 -07:00
|
|
|
if (this._timer)
|
|
|
|
clearTimeout(this._timer);
|
2010-03-03 23:13:27 -08:00
|
|
|
|
2008-08-05 10:42:30 -07:00
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
2009-02-02 01:38:53 -08:00
|
|
|
<constructor><![CDATA[
|
|
|
|
if (this.searchButton)
|
|
|
|
this.removeAttribute("aria-autocomplete");
|
|
|
|
else
|
|
|
|
this.setAttribute("aria-autocomplete", "list");
|
|
|
|
]]></constructor>
|
2008-08-05 10:42:30 -07:00
|
|
|
<method name="_fireCommand">
|
|
|
|
<parameter name="me"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (me._timer)
|
|
|
|
clearTimeout(me._timer);
|
|
|
|
me._timer = null;
|
|
|
|
me.doCommand();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_iconClick">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.searchButton)
|
|
|
|
this._enterSearch();
|
|
|
|
else
|
|
|
|
this.focus();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_enterSearch">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.disabled)
|
|
|
|
return;
|
|
|
|
if (this.searchButton && this.value && !this.readOnly)
|
|
|
|
this._searchIcons.selectedIndex = 1;
|
|
|
|
this._fireCommand(this);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
<method name="_clearSearch">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (!this.disabled && !this.readOnly && this.value) {
|
|
|
|
this.value = "";
|
|
|
|
this._fireCommand(this);
|
|
|
|
this._searchIcons.selectedIndex = 0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
<handlers>
|
|
|
|
<handler event="input">
|
|
|
|
<![CDATA[
|
|
|
|
if (this.searchButton) {
|
|
|
|
this._searchIcons.selectedIndex = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this._timer)
|
|
|
|
clearTimeout(this._timer);
|
|
|
|
this._timer = this.timeout && setTimeout(this._fireCommand, this.timeout, this);
|
|
|
|
this._searchIcons.selectedIndex = this.value ? 1 : 0;
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_ESCAPE">
|
|
|
|
<![CDATA[
|
|
|
|
if (this._clearSearch()) {
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
<handler event="keypress" keycode="VK_RETURN">
|
|
|
|
<![CDATA[
|
|
|
|
this._enterSearch();
|
|
|
|
event.preventDefault();
|
|
|
|
event.stopPropagation();
|
|
|
|
]]>
|
|
|
|
</handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<binding id="textarea" extends="chrome://global/content/bindings/textbox.xml#textbox">
|
|
|
|
<content>
|
|
|
|
<xul:hbox class="textbox-input-box" flex="1" xbl:inherits="context,spellcheck">
|
2011-04-22 18:36:24 -07:00
|
|
|
<html:textarea class="textbox-textarea" anonid="input"
|
2012-03-04 06:57:45 -08:00
|
|
|
xbl:inherits="xbl:text=value,disabled,tabindex,rows,cols,readonly,wrap,placeholder,mozactionhint,spellcheck"><children/></html:textarea>
|
2007-03-22 10:30:00 -07:00
|
|
|
</xul:hbox>
|
|
|
|
</content>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="input-box">
|
|
|
|
<content context="_child">
|
|
|
|
<children/>
|
|
|
|
<xul:menupopup anonid="input-box-contextmenu"
|
2009-01-14 08:56:33 -08:00
|
|
|
class="textbox-contextmenu"
|
2013-05-06 11:15:51 -07:00
|
|
|
onpopupshowing="var input =
|
|
|
|
this.parentNode.getElementsByAttribute('anonid', 'input')[0];
|
|
|
|
if (document.commandDispatcher.focusedElement != input)
|
|
|
|
input.focus();
|
2007-03-22 10:30:00 -07:00
|
|
|
this.parentNode._doPopupItemEnabling(this);"
|
|
|
|
oncommand="var cmd = event.originalTarget.getAttribute('cmd'); if(cmd) { this.parentNode.doCommand(cmd); event.stopPropagation(); }">
|
|
|
|
<xul:menuitem label="&undoCmd.label;" accesskey="&undoCmd.accesskey;" cmd="cmd_undo"/>
|
|
|
|
<xul:menuseparator/>
|
|
|
|
<xul:menuitem label="&cutCmd.label;" accesskey="&cutCmd.accesskey;" cmd="cmd_cut"/>
|
|
|
|
<xul:menuitem label="©Cmd.label;" accesskey="©Cmd.accesskey;" cmd="cmd_copy"/>
|
|
|
|
<xul:menuitem label="&pasteCmd.label;" accesskey="&pasteCmd.accesskey;" cmd="cmd_paste"/>
|
|
|
|
<xul:menuitem label="&deleteCmd.label;" accesskey="&deleteCmd.accesskey;" cmd="cmd_delete"/>
|
|
|
|
<xul:menuseparator/>
|
|
|
|
<xul:menuitem label="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" cmd="cmd_selectAll"/>
|
|
|
|
</xul:menupopup>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation>
|
|
|
|
<method name="_doPopupItemEnabling">
|
|
|
|
<parameter name="popupNode"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var children = popupNode.childNodes;
|
|
|
|
for (var i = 0; i < children.length; i++) {
|
|
|
|
var command = children[i].getAttribute("cmd");
|
|
|
|
if (command) {
|
|
|
|
var controller = document.commandDispatcher.getControllerForCommand(command);
|
|
|
|
var enabled = controller.isCommandEnabled(command);
|
|
|
|
if (enabled)
|
|
|
|
children[i].removeAttribute("disabled");
|
|
|
|
else
|
|
|
|
children[i].setAttribute("disabled", "true");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_setMenuItemVisibility">
|
|
|
|
<parameter name="anonid"/>
|
|
|
|
<parameter name="visible"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", anonid).
|
|
|
|
hidden = ! visible;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="doCommand">
|
|
|
|
<parameter name="command"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var controller = document.commandDispatcher.getControllerForCommand(command);
|
|
|
|
controller.doCommand(command);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="input-box-spell" extends="chrome://global/content/bindings/textbox.xml#input-box">
|
|
|
|
<content context="_child">
|
|
|
|
<children/>
|
|
|
|
<xul:menupopup anonid="input-box-contextmenu"
|
2009-01-14 08:56:33 -08:00
|
|
|
class="textbox-contextmenu"
|
2013-05-06 11:15:51 -07:00
|
|
|
onpopupshowing="var input =
|
|
|
|
this.parentNode.getElementsByAttribute('anonid', 'input')[0];
|
|
|
|
if (document.commandDispatcher.focusedElement != input)
|
|
|
|
input.focus();
|
2007-03-22 10:30:00 -07:00
|
|
|
this.parentNode._doPopupItemEnablingSpell(this);"
|
|
|
|
onpopuphiding="this.parentNode._doPopupItemDisabling(this);"
|
|
|
|
oncommand="var cmd = event.originalTarget.getAttribute('cmd'); if(cmd) { this.parentNode.doCommand(cmd); event.stopPropagation(); }">
|
|
|
|
<xul:menuitem label="&spellNoSuggestions.label;" anonid="spell-no-suggestions" disabled="true"/>
|
|
|
|
<xul:menuitem label="&spellAddToDictionary.label;" accesskey="&spellAddToDictionary.accesskey;" anonid="spell-add-to-dictionary"
|
|
|
|
oncommand="this.parentNode.parentNode.spellCheckerUI.addToDictionary();"/>
|
2011-12-29 13:06:56 -08:00
|
|
|
<xul:menuitem label="&spellUndoAddToDictionary.label;" accesskey="&spellUndoAddToDictionary.accesskey;" anonid="spell-undo-add-to-dictionary"
|
|
|
|
oncommand="this.parentNode.parentNode.spellCheckerUI.undoAddToDictionary();"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<xul:menuseparator anonid="spell-suggestions-separator"/>
|
|
|
|
<xul:menuitem label="&undoCmd.label;" accesskey="&undoCmd.accesskey;" cmd="cmd_undo"/>
|
|
|
|
<xul:menuseparator/>
|
|
|
|
<xul:menuitem label="&cutCmd.label;" accesskey="&cutCmd.accesskey;" cmd="cmd_cut"/>
|
|
|
|
<xul:menuitem label="©Cmd.label;" accesskey="©Cmd.accesskey;" cmd="cmd_copy"/>
|
|
|
|
<xul:menuitem label="&pasteCmd.label;" accesskey="&pasteCmd.accesskey;" cmd="cmd_paste"/>
|
|
|
|
<xul:menuitem label="&deleteCmd.label;" accesskey="&deleteCmd.accesskey;" cmd="cmd_delete"/>
|
|
|
|
<xul:menuseparator/>
|
|
|
|
<xul:menuitem label="&selectAllCmd.label;" accesskey="&selectAllCmd.accesskey;" cmd="cmd_selectAll"/>
|
|
|
|
<xul:menuseparator anonid="spell-check-separator"/>
|
2011-04-24 09:15:53 -07:00
|
|
|
<xul:menuitem label="&spellCheckToggle.label;" type="checkbox" accesskey="&spellCheckToggle.accesskey;" anonid="spell-check-enabled"
|
2014-10-03 07:52:37 -07:00
|
|
|
oncommand="this.parentNode.parentNode.spellCheckerUI.toggleEnabled();"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<xul:menu label="&spellDictionaries.label;" accesskey="&spellDictionaries.accesskey;" anonid="spell-dictionaries">
|
|
|
|
<xul:menupopup anonid="spell-dictionaries-menu"
|
|
|
|
onpopupshowing="event.stopPropagation();"
|
|
|
|
onpopuphiding="event.stopPropagation();"/>
|
|
|
|
</xul:menu>
|
|
|
|
</xul:menupopup>
|
|
|
|
</content>
|
|
|
|
|
|
|
|
<implementation>
|
|
|
|
<field name="_spellCheckInitialized">false</field>
|
|
|
|
<field name="_enabledCheckbox">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "spell-check-enabled");
|
|
|
|
</field>
|
|
|
|
<field name="_suggestionsSeparator">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "spell-no-suggestions");
|
|
|
|
</field>
|
|
|
|
<field name="_dictionariesMenu">
|
|
|
|
document.getAnonymousElementByAttribute(this, "anonid", "spell-dictionaries-menu");
|
|
|
|
</field>
|
|
|
|
|
|
|
|
<property name="spellCheckerUI" readonly="true">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (!this._spellCheckInitialized) {
|
|
|
|
this._spellCheckInitialized = true;
|
|
|
|
|
|
|
|
const CI = Components.interfaces;
|
2007-09-02 09:40:33 -07:00
|
|
|
if (!(document instanceof CI.nsIDOMXULDocument))
|
2007-03-22 10:30:00 -07:00
|
|
|
return null;
|
|
|
|
|
|
|
|
var textbox = document.getBindingParent(this);
|
2007-09-02 09:40:33 -07:00
|
|
|
if (!textbox || !(textbox instanceof CI.nsIDOMXULTextBoxElement))
|
2007-03-22 10:30:00 -07:00
|
|
|
return null;
|
|
|
|
|
|
|
|
try {
|
2009-10-28 04:15:22 -07:00
|
|
|
Components.utils.import("resource://gre/modules/InlineSpellChecker.jsm", this);
|
|
|
|
this.InlineSpellCheckerUI = new this.InlineSpellChecker(textbox.editor);
|
2007-03-22 10:30:00 -07:00
|
|
|
} catch(ex) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.InlineSpellCheckerUI;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="_doPopupItemEnablingSpell">
|
|
|
|
<parameter name="popupNode"/>
|
|
|
|
<body>
|
|
|
|
<![CDATA[
|
|
|
|
var spellui = this.spellCheckerUI;
|
|
|
|
if (!spellui || !spellui.canSpellCheck) {
|
|
|
|
this._setMenuItemVisibility("spell-no-suggestions", false);
|
|
|
|
this._setMenuItemVisibility("spell-check-enabled", false);
|
|
|
|
this._setMenuItemVisibility("spell-check-separator", false);
|
|
|
|
this._setMenuItemVisibility("spell-add-to-dictionary", false);
|
2011-12-29 13:06:56 -08:00
|
|
|
this._setMenuItemVisibility("spell-undo-add-to-dictionary", false);
|
2007-03-22 10:30:00 -07:00
|
|
|
this._setMenuItemVisibility("spell-suggestions-separator", false);
|
|
|
|
this._setMenuItemVisibility("spell-dictionaries", false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
spellui.initFromEvent(document.popupRangeParent,
|
|
|
|
document.popupRangeOffset);
|
|
|
|
|
|
|
|
var enabled = spellui.enabled;
|
2012-01-31 14:53:21 -08:00
|
|
|
var showUndo = spellui.canSpellCheck && spellui.canUndo();
|
2007-03-22 10:30:00 -07:00
|
|
|
this._enabledCheckbox.setAttribute("checked", enabled);
|
|
|
|
|
|
|
|
var overMisspelling = spellui.overMisspelling;
|
|
|
|
this._setMenuItemVisibility("spell-add-to-dictionary", overMisspelling);
|
2012-01-31 14:53:21 -08:00
|
|
|
this._setMenuItemVisibility("spell-undo-add-to-dictionary", showUndo);
|
|
|
|
this._setMenuItemVisibility("spell-suggestions-separator", overMisspelling || showUndo);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// suggestion list
|
|
|
|
var numsug = spellui.addSuggestionsToMenu(popupNode, this._suggestionsSeparator, 5);
|
|
|
|
this._setMenuItemVisibility("spell-no-suggestions", overMisspelling && numsug == 0);
|
|
|
|
|
|
|
|
// dictionary list
|
|
|
|
var numdicts = spellui.addDictionaryListToMenu(this._dictionariesMenu, null);
|
|
|
|
this._setMenuItemVisibility("spell-dictionaries", enabled && numdicts > 1);
|
|
|
|
|
|
|
|
this._doPopupItemEnabling(popupNode);
|
|
|
|
]]>
|
|
|
|
</body>
|
|
|
|
</method>
|
|
|
|
<method name="_doPopupItemDisabling">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.spellCheckerUI) {
|
|
|
|
this.spellCheckerUI.clearSuggestionsFromMenu();
|
|
|
|
this.spellCheckerUI.clearDictionaryListFromMenu();
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
</bindings>
|