[XForms] Moved upload to xforms-xhtml. Bug 328150, r=me+doronr, patch by surkov@dc.baikal.ru

This commit is contained in:
allan%beaufour.dk 2006-03-23 09:10:42 +00:00
Родитель 1a26d72755
Коммит 64323d7f43
3 изменённых файлов: 124 добавлений и 108 удалений

Просмотреть файл

@ -319,4 +319,102 @@
</handlers>
</binding>
<!-- UPLOAD: <DEFAULT> -->
<binding id="xformswidget-upload"
extends="chrome://xforms/content/xforms.xml#xformswidget-upload-base">
<content>
<children includes="label"/>
<html:input anonid="text_control" class="xf-value" readonly="readonly"/>
<html:button anonid="browse_button" xbl:inherits="accesskey">
&xforms.upload.browsetext;
</html:button>
<html:button anonid="clear_button">
&xforms.upload.cleartext;
</html:button>
<children/>
</content>
<implementation implements="nsIXFormsUIWidget, nsIXFormsUploadUIElement">
<method name="getControlElement">
<body>
return {
set value(val) {
this._textControl.value = val;
},
set readonly(val) {
if (val) {
this._browseButton.setAttribute('disabled', 'disabled');
this._clearButton.setAttribute('disabled', 'disabled');
} else {
this._browseButton.removeAttribute('disabled');
this._clearButton.removeAttribute('disabled');
}
},
focus: function() {
this._browseButton.focus();
},
_browseButton: this.ownerDocument.
getAnonymousElementByAttribute(this, 'anonid', 'browse_button'),
_clearButton: this.ownerDocument.
getAnonymousElementByAttribute(this, 'anonid', 'clear_button'),
_textControl: this.ownerDocument.
getAnonymousElementByAttribute(this, 'anonid', 'text_control'),
};
</body>
</method>
</implementation>
<handlers>
<handler event="click">
switch (event.originalTarget.getAttribute("anonid")) {
case "browse_button":
this.uploadElement.pickFile();
break;
case "clear_button":
this.uploadElement.clearFile();
break;
}
</handler>
<handler event="keypress" keycode="VK_RETURN">
switch (event.originalTarget.getAttribute("anonid")) {
case "browse_button":
case "clear_button":
this.dispatchDOMUIEvent('DOMActivate');
break;
}
</handler>
</handlers>
</binding>
<!-- UPLOAD: DISABLED -->
<binding id="xformswidget-upload-disabled"
extends="chrome://xforms/content/xforms.xml#xformswidget-upload-base">
<content>
<children includes="label"/>
<html:input readonly="readonly" class="xf-value" xbl:inherits="accesskey"/>
<html:button disabled="disabled" xbl:inherits="accesskey">
&xforms.upload.browsetext;
</html:button>
<html:button disabled="disabled" xbl:inherits="accesskey">
&xforms.upload.cleartext;
</html:button>
<children/>
</content>
<implementation>
<method name="getControlElement">
<body>
return {
set value(val){},
set readonly(val){},
focus: function(){}
};
</body>
</method>
</implementation>
</binding>
</bindings>

Просмотреть файл

@ -482,14 +482,14 @@ select html|div.select-choice-content {
}
/* upload widgets */
upload {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-upload-disabled');
html|*:root upload {
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-upload-disabled');
}
upload[mozType|type="http://www.w3.org/2001/XMLSchema#anyURI"],
upload[mozType|type="http://www.w3.org/2001/XMLSchema#base64Binary"],
upload[mozType|type="http://www.w3.org/2001/XMLSchema#hexBinary"] {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-upload');
html|*:root upload[mozType|type="http://www.w3.org/2001/XMLSchema#anyURI"],
html|*:root upload[mozType|type="http://www.w3.org/2001/XMLSchema#base64Binary"],
html|*:root upload[mozType|type="http://www.w3.org/2001/XMLSchema#hexBinary"] {
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-upload');
}
/* default MIP styling */

Просмотреть файл

@ -313,129 +313,47 @@
<!-- UPLOAD: <DEFAULT>
XXX: The widget doesn't support interface based on getElementControl()
method (see a bug https://bugzilla.mozilla.org/show_bug.cgi?id=323845).
The upload widget assumes successors bindings implement getElementControl()
method what returns the object:
{
set value(); // set "string" value
set readonly(); // set readonly state
focus(); // set focus
}
-->
<binding id="xformswidget-upload"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<children includes="label"/>
<html:input anonid="upload_text_control"
class="xf-value"
readonly="readonly"/>
<html:button anonid="upload_browse_button"
type="button"
onclick="this.parentNode.uploadElem.pickFile();"
onkeypress="if (event.keyCode == event.DOM_VK_RETURN) this.parentNode.dispatchDOMUIEvent('DOMActivate');"
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.dispatchDOMUIEvent('DOMActivate');"
> &xforms.upload.cleartext; </html:button>
<children/>
</content>
<binding id="xformswidget-upload-base" extends="#xformswidget-base">
<implementation implements="nsIXFormsUIWidget, nsIXFormsUploadUIElement">
<method name="refresh">
<body>
if (this.accessors.isReadonly()) {
this.browseButton.setAttribute("disabled", "disabled");
this.clearButton.setAttribute("disabled", "disabled");
} else {
this.browseButton.removeAttribute("disabled");
this.clearButton.removeAttribute("disabled");
}
this.control.readonly = this.accessors.isReadonly();
</body>
</method>
<method name="focus">
<body>
this.control.focus();
return true;
</body>
</method>
<destructor>
this._uploadElem = null;
this._textControl = null;
this._browseButton = null;
this._clearButton = null;
</destructor>
<field name="_uploadElem">null</field>
<property name="uploadElem" readonly="true">
<property name="uploadElement" readonly="true">
<getter>
if (!this._uploadElem) {
this._uploadElem =
if (!this._uploadElement) {
this._uploadElement =
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;
return this._uploadElement;
</getter>
</property>
<field name="_uploadElement">null</field>
<method name="setFieldText">
<parameter name="aString"/>
<body>
this.textControl.value = aString;
this.control.value = aString;
</body>
</method>
</implementation>
</binding>
<!-- UPLOAD: DISABLED
XXX: The widget doesn't support interface based on getElementControl()
method (see a bug https://bugzilla.mozilla.org/show_bug.cgi?id=323845).
-->
<binding id="xformswidget-upload-disabled"
extends="chrome://xforms/content/xforms.xml#xformswidget-base">
<content>
<children includes="label"/>
<html:input readonly="readonly"
class="xf-value"
xbl:inherits="accesskey"/>
<html:button type="button"
disabled="disabled"
xbl:inherits="accesskey"> &xforms.upload.browsetext; </html:button>
<html:button type="button"
disabled="disabled"
xbl:inherits="accesskey"> &xforms.upload.cleartext; </html:button>
<children/>
</content>
</binding>
</bindings>