Skip to content

Commit

Permalink
Fix bug 347563 - implement xforms:upload for XUL. r=aaronr+smaug
Browse files Browse the repository at this point in the history
  • Loading branch information
surkov.alexander%gmail.com committed Mar 8, 2007
1 parent c121625 commit b607ef5
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 14 deletions.
15 changes: 1 addition & 14 deletions extensions/xforms/resources/content/xforms-xhtml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@

<!-- UPLOAD: DISABLED -->
<binding id="xformswidget-upload-disabled"
extends="chrome://xforms/content/xforms.xml#xformswidget-upload-base">
extends="chrome://xforms/content/xforms.xml#xformswidget-upload-disabled-base">
<content>
<children includes="label"/>
<html:input readonly="readonly" class="xf-value"/>
Expand All @@ -583,19 +583,6 @@
</html:button>
<children/>
</content>

<implementation>
<method name="getControlElement">
<body>
return {
get value(){ return ""; },
set value(val){},
set readonly(val){},
focus: function(){}
};
</body>
</method>
</implementation>
</binding>


Expand Down
91 changes: 91 additions & 0 deletions extensions/xforms/resources/content/xforms-xul.xml
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,97 @@
</binding>


<!-- UPLOAD: <DEFAULT> -->
<binding id="xformswidget-upload"
extends="chrome://xforms/content/xforms.xml#xformswidget-upload-base">
<content>
<children includes="label"/>
<xul:textbox anonid="text_control"
class="xf-value"
readonly="readonly"
tabindex="-1"/>
<xul:button anonid="browse_button"
xbl:inherits="tabindex"
label="&xforms.upload.browsetext;"/>
<xul:button anonid="clear_button"
xbl:inherits="tabindex"
label="&xforms.upload.cleartext;"/>
<children/>
</content>

<implementation implements="nsIXFormsUIWidget, nsIXFormsUploadUIElement">
<method name="getControlElement">
<body>
return {
get value() {
return this._textControl.value;
},
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="command">
switch (event.originalTarget.getAttribute("anonid")) {
case "browse_button":
this.uploadElement.pickFile();
this.dispatchDOMUIEvent('DOMActivate');
break;
case "clear_button":
this.uploadElement.clearFile();
this.dispatchDOMUIEvent('DOMActivate');
break;
}
</handler>
</handlers>
</binding>


<!-- UPLOAD: DISABLED -->
<binding id="xformswidget-upload-disabled"
extends="chrome://xforms/content/xforms.xml#xformswidget-upload-disabled-base">
<content>
<children includes="label"/>
<xul:textbox anonid="text_control"
class="xf-value"
readonly="readonly"
tabindex="-1"/>
<xul:button anonid="browse_button"
xbl:inherits="tabindex"
label="&xforms.upload.browsetext;"
disabled="true"/>
<xul:button anonid="clear_button"
xbl:inherits="tabindex"
label="&xforms.upload.cleartext;"
disabled="true"/>
<children/>
</content>
</binding>


<!-- REPEAT -->
<binding id="xformswidget-repeat"
extends="chrome://xforms/content/xforms.xml#xformswidget-repeat-base">
Expand Down
11 changes: 11 additions & 0 deletions extensions/xforms/resources/content/xforms.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ xul|*:root secret:not(:disabled),
xul|*:root textarea:not(:disabled),
xul|*:root trigger:not(:disabled),
xul|*:root submit:not(:disabled),
xul|*:root upload:not(:disabled),
xul|*:root repeat:not(:disabled),
xul|*:root repeatitem,
xul|*:root contextcontainer,
Expand Down Expand Up @@ -750,13 +751,23 @@ html|*:root upload {
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-upload-disabled');
}

xul|*:root upload {
-moz-binding: url('chrome://xforms/content/xforms-xul.xml#xformswidget-upload-disabled');
}

html|*:root upload[mozType|typelist~="http://www.w3.org/2001/XMLSchema#anyURI"],
html|*:root upload[mozType|typelist~="http://www.w3.org/2001/XMLSchema#base64Binary"],
html|*:root upload[mozType|typelist~="http://www.w3.org/2001/XMLSchema#hexBinary"] {
-moz-binding: url('chrome://xforms/content/xforms-xhtml.xml#xformswidget-upload');
display: inline;
}

xul|*:root upload[mozType|typelist~="http://www.w3.org/2001/XMLSchema#anyURI"],
xul|*:root upload[mozType|typelist~="http://www.w3.org/2001/XMLSchema#base64Binary"],
xul|*:root upload[mozType|typelist~="http://www.w3.org/2001/XMLSchema#hexBinary"] {
-moz-binding: url('chrome://xforms/content/xforms-xul.xml#xformswidget-upload');
}

/* repeat widgets */
*|*[xf|repeat-bind] {
-moz-binding: url('chrome://xforms/content/xforms.xml#xformswidget-attr-repeat');
Expand Down
18 changes: 18 additions & 0 deletions extensions/xforms/resources/content/xforms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,24 @@
</binding>


<!-- UPLOAD: DISABLED -->
<binding id="xformswidget-upload-disabled-base"
extends="#xformswidget-upload-base">
<implementation>
<method name="getControlElement">
<body>
return {
get value(){ return ""; },
set value(val){},
set readonly(val){},
focus: function(){}
};
</body>
</method>
</implementation>
</binding>


<!-- REPEAT -->
<binding id="xformswidget-repeat-base" extends="#xformswidget-accessors">

Expand Down

0 comments on commit b607ef5

Please sign in to comment.