| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dojo/_base/kernel", |
| 4 |
"dojo/_base/fx", |
| 5 |
"dojo/dom-attr", |
| 6 |
"dojo/dom-class", |
| 7 |
"dojo/text!./resources/FileInput.html", |
| 8 |
"dijit/form/_FormWidget", |
| 9 |
"dijit/_Templated" |
| 10 |
], |
| 11 |
function(declare, kernel, fx, domAttr, domClass, template, FormWidget, Templated){ |
| 12 |
kernel.experimental("dojox.form.FileInput"); |
| 13 |
|
| 14 |
return declare("dojox.form.FileInput", FormWidget, |
| 15 |
{ |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
label: "Browse ...", |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
cancelText: "Cancel", |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
name: "uploadFile", |
| 35 |
|
| 36 |
templateString: template, |
| 37 |
|
| 38 |
startup: function(){ |
| 39 |
|
| 40 |
|
| 41 |
this._listener = this.connect(this.fileInput,"onchange","_matchValue"); |
| 42 |
this._keyListener = this.connect(this.fileInput,"onkeyup","_matchValue"); |
| 43 |
}, |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
postCreate: function(){}, |
| 48 |
|
| 49 |
_matchValue: function(){ |
| 50 |
|
| 51 |
|
| 52 |
this.inputNode.value = this.fileInput.value; |
| 53 |
if(this.inputNode.value){ |
| 54 |
this.cancelNode.style.visibility = "visible"; |
| 55 |
fx.fadeIn({ node: this.cancelNode, duration:275 }).play(); |
| 56 |
} |
| 57 |
}, |
| 58 |
|
| 59 |
setLabel: function( label, cssClass){ |
| 60 |
|
| 61 |
|
| 62 |
this.titleNode.innerHTML = label; |
| 63 |
}, |
| 64 |
|
| 65 |
reset: function( e){ |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
this.disconnect(this._listener); |
| 70 |
this.disconnect(this._keyListener); |
| 71 |
if(this.fileInput){ |
| 72 |
this.domNode.removeChild(this.fileInput); |
| 73 |
} |
| 74 |
fx.fadeOut({ node: this.cancelNode, duration:275 }).play(); |
| 75 |
|
| 76 |
|
| 77 |
this.fileInput = document.createElement('input'); |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
this.fileInput.setAttribute("type","file"); |
| 82 |
this.fileInput.setAttribute("id", this.id); |
| 83 |
this.fileInput.setAttribute("name", this.name); |
| 84 |
domClass.add(this.fileInput,"dijitFileInputReal"); |
| 85 |
this.domNode.appendChild(this.fileInput); |
| 86 |
|
| 87 |
this._keyListener = this.connect(this.fileInput, "onkeyup", "_matchValue"); |
| 88 |
this._listener = this.connect(this.fileInput, "onchange", "_matchValue"); |
| 89 |
this.inputNode.value = ""; |
| 90 |
} |
| 91 |
|
| 92 |
}); |
| 93 |
|
| 94 |
}); |