From 64323d7f434d040f2daa3cedcc83ea1e7e5946f5 Mon Sep 17 00:00:00 2001 From: "allan%beaufour.dk" Date: Thu, 23 Mar 2006 09:10:42 +0000 Subject: [PATCH] [XForms] Moved upload to xforms-xhtml. Bug 328150, r=me+doronr, patch by surkov@dc.baikal.ru --- .../xforms/resources/content/xforms-xhtml.xml | 98 ++++++++++++++ .../xforms/resources/content/xforms.css | 12 +- .../xforms/resources/content/xforms.xml | 122 +++--------------- 3 files changed, 124 insertions(+), 108 deletions(-) diff --git a/extensions/xforms/resources/content/xforms-xhtml.xml b/extensions/xforms/resources/content/xforms-xhtml.xml index 0cb4b23604c..005d013fcec 100644 --- a/extensions/xforms/resources/content/xforms-xhtml.xml +++ b/extensions/xforms/resources/content/xforms-xhtml.xml @@ -319,4 +319,102 @@ + + + + + + + + &xforms.upload.browsetext; + + + &xforms.upload.cleartext; + + + + + + + + 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'), + }; + + + + + + + switch (event.originalTarget.getAttribute("anonid")) { + case "browse_button": + this.uploadElement.pickFile(); + break; + case "clear_button": + this.uploadElement.clearFile(); + break; + } + + + + switch (event.originalTarget.getAttribute("anonid")) { + case "browse_button": + case "clear_button": + this.dispatchDOMUIEvent('DOMActivate'); + break; + } + + + + + + + + + + + + &xforms.upload.browsetext; + + + &xforms.upload.cleartext; + + + + + + + + return { + set value(val){}, + set readonly(val){}, + focus: function(){} + }; + + + + diff --git a/extensions/xforms/resources/content/xforms.css b/extensions/xforms/resources/content/xforms.css index dd35e9300f4..6c3046c9be6 100755 --- a/extensions/xforms/resources/content/xforms.css +++ b/extensions/xforms/resources/content/xforms.css @@ -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 */ diff --git a/extensions/xforms/resources/content/xforms.xml b/extensions/xforms/resources/content/xforms.xml index 02ebaf3ba22..15730920424 100644 --- a/extensions/xforms/resources/content/xforms.xml +++ b/extensions/xforms/resources/content/xforms.xml @@ -313,129 +313,47 @@ - - - - - &xforms.upload.browsetext; - &xforms.upload.cleartext; - - + - 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(); + + + + + this.control.focus(); return true; - - this._uploadElem = null; - this._textControl = null; - this._browseButton = null; - this._clearButton = null; - - - null - - + - if (!this._uploadElem) { - this._uploadElem = + if (!this._uploadElement) { + this._uploadElement = this.QueryInterface(Components.interfaces.nsIXFormsUploadElement); } - return this._uploadElem; - - - - null - - - - if (!this._textControl) { - this._textControl = - document.getAnonymousElementByAttribute(this, "anonid", - "upload_text_control"); - } - return this._textControl; - - - - null - - - - if (!this._browseButton) { - this._browseButton = - document.getAnonymousElementByAttribute(this, "anonid", - "upload_browse_button"); - } - return this._browseButton; - - - - null - - - - if (!this._clearButton) { - this._clearButton = - document.getAnonymousElementByAttribute(this, "anonid", - "upload_clear_button"); - } - return this._clearButton; + return this._uploadElement; + null - this.textControl.value = aString; + this.control.value = aString; - - - - - - - &xforms.upload.browsetext; - &xforms.upload.cleartext; - - -