pedemont%us.ibm.com 0df967901f Bug 275453 - Finish <upload> implementation. r=allan, r=aaronr. Not part of default build.
git-svn-id: svn://10.0.0.236/trunk@182788 18797224-902f-48f8-a5cc-f745e15eee43
2005-10-23 04:24:23 +00:00

559 lines
18 KiB
XML

<?xml version="1.0"?>
<!-- ***** BEGIN LICENSE BLOCK *****
- 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.
-
- The Original Code is Mozilla XForms support.
-
- The Initial Developer of the Original Code is
- Novell, Inc.
- Portions created by the Initial Developer are Copyright (C) 2005
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
- Allan Beaufour <abeaufour@novell.com>
- Olli Pettay <Olli.Pettay@helsinki.fi>
-
- 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.
-
- ***** END LICENSE BLOCK ***** -->
<!DOCTYPE bindings [
<!ENTITY % xformsDTD SYSTEM "chrome://xforms/locale/xforms.dtd">
%xformsDTD;
]>
<bindings id="xformsBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xforms="http://www.w3.org/2002/xforms"
xmlns:lazy="http://www.mozilla.org/projects/xforms/2005/lazy">
<binding id="xforms-lazy-instance">
<content><xforms:instance lazy:lazy="true"/><children/></content>
</binding>
<!-- BASE -->
<binding id="xformswidget-base">
<content><children/></content>
<implementation implements="nsIXFormsUIWidget">
<constructor>
this.delegate.widgetAttached();
</constructor>
<destructor>
this._delegate = null;
</destructor>
<field name="_delegate">null</field>
<property name="XFORMS_NS" readonly="true">
<getter>
return "http://www.w3.org/2002/xforms";
</getter>
</property>
<property name="delegate" readonly="true">
<getter>
if (!this._delegate)
this._delegate = this.QueryInterface(Components.interfaces.nsIXFormsDelegate);
return this._delegate;
</getter>
</property>
<property name="stringValue" readonly="true">
<getter>
var value = this.delegate.value;
return value != null ? value : "";
</getter>
</property>
<method name="refresh">
<body>
return true;
</body>
</method>
<method name="disable">
<parameter name="aDisable"/>
<body>
return true;
</body>
</method>
<method name="focus">
<body>
return false;
</body>
</method>
<method name="dispatchDOMUIEvent">
<parameter name="aType"/>
<body>
var ev = document.createEvent("UIEvents");
ev.initUIEvent(aType, true, true, window, 1);
this.dispatchEvent(ev);
return true;
</body>
</method>
</implementation>
</binding>
<!-- OUTPUT: <DEFAULT> -->
<binding id="xformswidget-output"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<children includes="label"/>
<html:span anonid="content"></html:span>
<children/>
</content>
<implementation implements="nsIXFormsUIWidget">
<method name="refresh">
<body>
document.getAnonymousElementByAttribute(this, "anonid", "content").textContent =
this.stringValue;
return true;
</body>
</method>
</implementation>
</binding>
<!-- LABEL: <DEFAULT> -->
<binding id="xformswidget-label"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<html:span anonid="content"></html:span>
<html:span anonid="anoncontent">
<children/>
</html:span>
</content>
<implementation implements="nsIXFormsUIWidget">
<method name="refresh">
<body>
var anoncontent =
document.getAnonymousElementByAttribute(this, "anonid", "anoncontent");
if (this.delegate.hasBoundNode || this.delegate.value != null) {
anoncontent.setAttribute("style", "display:none;");
} else {
anoncontent.removeAttribute("style");
}
document.getAnonymousElementByAttribute(this, "anonid", "content").textContent =
this.stringValue;
return true;
</body>
</method>
</implementation>
</binding>
<!-- INPUT: <DEFAULT> -->
<binding id="xformswidget-input"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<children includes="label"/>
<html:input anonid="control"
onblur="this.parentNode.delegate.value = this.value; this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')"
onclick="this.parentNode._change();"
onkeyup="this.parentNode._change();"
onkeypress="if (event.keyCode == event.DOM_VK_RETURN) this.parentNode.dispatchDOMUIEvent('DOMActivate');"
xbl:inherits="accesskey"/>
<children/>
</content>
<implementation implements="nsIXFormsUIWidget">
<field name="_inputField">null</field>
<property name="inputField" readonly="true">
<getter>
if (!this._inputField) {
this._inputField =
document.getAnonymousElementByAttribute(this, "anonid", "control");
}
return this._inputField;
</getter>
</property>
<method name="_change">
<body>
if (this.getAttribute("incremental") == "true") {
this.delegate.value = this.inputField.value;
}
return true;
</body>
</method>
<method name="refresh">
<body>
this.inputField.value = this.stringValue;
if (this.delegate.isReadonly) {
this.inputField.setAttribute("readonly", "readonly");
} else {
this.inputField.removeAttribute("readonly");
}
return true;
</body>
</method>
<method name="focus">
<body>
this.inputField.focus();
return true;
</body>
</method>
</implementation>
</binding>
<!-- INPUT: BOOLEAN -->
<binding id="xformswidget-input-boolean"
extends="chrome://xforms/content/xforms.xml#xformswidget-input">
<implementation>
<method name="refresh">
<body>
this.inputField.setAttribute("type","checkbox");
var value = this.stringValue;
if (value == "true" || value == "1") {
this.inputField.setAttribute("checked", "checked");
} else {
this.inputField.removeAttribute("checked");
}
this.inputField.value = value;
if (this.delegate.isReadonly) {
this.inputField.setAttribute("readonly", "readonly");
} else {
this.inputField.removeAttribute("readonly");
}
<!-- Ignore Enter keypress on checkbox -->
this.inputField.removeAttribute("onkeypress");
return true;
</body>
</method>
<method name="_change">
<body>
if (this.getAttribute("incremental") != "false") {
if (this.inputField.checked) {
this.delegate.value = "true";
} else {
this.delegate.value = "false";
}
}
</body>
</method>
</implementation>
</binding>
<!-- SECRET: <DEFAULT> -->
<binding id="xformswidget-secret"
extends="chrome://xforms/content/xforms.xml#xformswidget-input">
<implementation>
<method name="refresh">
<body>
this.inputField.setAttribute("type","password");
this.inputField.value = this.stringValue;
this.inputField.readonly = this.delegate.isReadonly;
return true;
</body>
</method>
</implementation>
</binding>
<!-- TEXTAREA: <DEFAULT> -->
<binding id="xformswidget-textarea"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<children includes="label"/>
<html:textarea anonid="control"
onblur="this.parentNode.delegate.value = this.value; this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')"
onkeyup="this.parentNode._change();"
xbl:inherits="accesskey"/>
<children/>
</content>
<implementation implements="nsIXFormsUIWidget">
<field name="_controlField">null</field>
<property name="controlField" readonly="true">
<getter>
if (!this._controlField) {
this._controlField =
document.getAnonymousElementByAttribute(this, "anonid", "control");
}
return this._controlField;
</getter>
</property>
<method name="refresh">
<body>
this.controlField.readonly = this.delegate.isReadonly;
// If the value has not changed, no need to update the
// value of the control, because that makes the textarea widget
// to scroll up.
if (this.controlField.value != this.stringValue) {
this.controlField.value = this.stringValue;
}
return true;
</body>
</method>
<method name="_change">
<body>
if (this.getAttribute("incremental") == "true") {
this.delegate.value = this.controlField.value;
}
return true;
</body>
</method>
<method name="focus">
<body>
this.controlField.focus();
return true;
</body>
</method>
</implementation>
</binding>
<!-- TRIGGER: <DEFAULT> -->
<binding id="xformswidget-trigger"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<html:button anonid="thebutton" xbl:inherits="accesskey"
onblur="this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')">
<children/>
</html:button>
</content>
<implementation implements="nsIXFormsUIWidget">
<method name="disable">
<parameter name="aDisable"/>
<body>
var control =
document.getAnonymousElementByAttribute(this, "anonid", "thebutton");
if (aDisable) {
control.setAttribute("disabled", "disabled");
} else {
control.removeAttribute("disabled");
}
</body>
</method>
<method name="focus">
<body>
document.getAnonymousElementByAttribute(this, "anonid", "thebutton").focus();
return true;
</body>
</method>
</implementation>
</binding>
<!-- TRIGGER: MINIMAL -->
<binding id="xformswidget-trigger-minimal"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<html:span tabindex="0" anonid="thespan" xbl:inherits="accesskey"
onclick="if (!this._disabled) this.parentNode.dispatchDOMUIEvent('DOMActivate');"
onblur="this.parentNode.dispatchDOMUIEvent('DOMFocusOut')"
onfocus="this.parentNode.dispatchDOMUIEvent('DOMFocusIn')">
<children/>
</html:span>
</content>
<implementation implements="nsIXFormsUIWidget">
<field name="_disabled">false</field>
<method name="disable">
<parameter name="aDisable"/>
<body>
this._disabled = aDisable;
</body>
</method>
<method name="focus">
<body>
document.getAnonymousElementByAttribute(this, "anonid", "thespan").focus();
return true;
</body>
</method>
</implementation>
</binding>
<!-- CASE: <DEFAULT> -->
<binding id="xformswidget-case">
<content>
<html:div anonid="container" class="-moz-xforms-case-container">
<children/>
</html:div>
</content>
<implementation implements="nsIXFormsCaseUIElement">
<constructor>
this.QueryInterface(Components.interfaces.nsIXFormsCaseElement).widgetAttached();
</constructor>
<field name="_container">null</field>
<property name="container" readonly="true">
<getter>
if (!this._container) {
this._container =
document.getAnonymousElementByAttribute(this, "anonid", "container");
}
return this._container;
</getter>
</property>
<method name="caseSelected">
<parameter name="aEnable"/>
<body>
if (aEnable) {
this.container.style.display = "inherit";
} else {
this.container.style.display = "none"
}
return true;
</body>
</method>
</implementation>
</binding>
<!-- UPLOAD: <DEFAULT> -->
<binding id="xformswidget-upload"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<children includes="label"/>
<html:input anonid="upload_text_control"
readonly="true"
xbl:inherits="accesskey"/>
<html:button anonid="upload_browse_button"
type="button"
onclick="this.parentNode.uploadElem.pickFile();"
onkeypress="if (event.keyCode == event.DOM_VK_RETURN) this.parentNode.dispatchDOMActivate();"
xbl:inherits="accesskey"> &xforms.upload.browsetext; </html:button>
<html:button anonid="upload_clear_button"
type="button"
onclick="this.parentNode.uploadElem.clearFile();"
onkeypress="if (event.keyCode == event.DOM_VK_RETURN) this.parentNode.dispatchDOMActivate();"
xbl:inherits="accesskey"> &xforms.upload.cleartext; </html:button>
<children/>
</content>
<implementation implements="nsIXFormsUIWidget, nsIXFormsUploadUIElement">
<destructor>
this._uploadElem = null;
this._textControl = null;
this._browseButton = null;
this._clearButton = null;
</destructor>
<field name="_uploadElem">null</field>
<property name="uploadElem" readonly="true">
<getter>
if (!this._uploadElem) {
this._uploadElem =
this.QueryInterface(Components.interfaces.nsIXFormsUploadElement);
}
return this._uploadElem;
</getter>
</property>
<field name="_textControl">null</field>
<property name="textControl" readonly="true">
<getter>
if (!this._textControl) {
this._textControl =
document.getAnonymousElementByAttribute(this, "anonid",
"upload_text_control");
}
return this._textControl;
</getter>
</property>
<field name="_browseButton">null</field>
<property name="browseButton" readonly="true">
<getter>
if (!this._browseButton) {
this._browseButton =
document.getAnonymousElementByAttribute(this, "anonid",
"upload_browse_button");
}
return this._browseButton;
</getter>
</property>
<field name="_clearButton">null</field>
<property name="clearButton" readonly="true">
<getter>
if (!this._clearButton) {
this._clearButton =
document.getAnonymousElementByAttribute(this, "anonid",
"upload_clear_button");
}
return this._clearButton;
</getter>
</property>
<method name="setFieldText">
<parameter name="aString"/>
<body>
this.textControl.value = aString;
</body>
</method>
</implementation>
</binding>
<!-- UPLOAD: DISABLED -->
<binding id="xformswidget-upload-disabled"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<children includes="label"/>
<html:input readonly="true"
xbl:inherits="accesskey"/>
<html:button type="button"
disabled="true"
xbl:inherits="accesskey"> &xforms.upload.browsetext; </html:button>
<html:button type="button"
disabled="true"
xbl:inherits="accesskey"> &xforms.upload.cleartext; </html:button>
<children/>
</content>
</binding>
</bindings>