root / trunk / web / dojo / dojox / form / FileInput.js
History | View | Annotate | Download (2.23 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.form.FileInput"]){ |
9 |
dojo._hasResource["dojox.form.FileInput"]=true; |
10 |
dojo.provide("dojox.form.FileInput");
|
11 |
dojo.experimental("dojox.form.FileInput");
|
12 |
dojo.require("dijit.form._FormWidget");
|
13 |
dojo.require("dijit._Templated");
|
14 |
dojo.declare("dojox.form.FileInput",dijit.form._FormWidget,{label:"Browse ...",cancelText:"Cancel",name:"uploadFile",templateString:dojo.cache("dojox.form","resources/FileInput.html","<div class=\"dijitFileInput\">\n\t<input id=\"${id}\" class=\"dijitFileInputReal\" type=\"file\" dojoAttachPoint=\"fileInput\" name=\"${name}\" />\n\t<div class=\"dijitFakeInput\">\n\t\t<input class=\"dijitFileInputVisible\" type=\"text\" dojoAttachPoint=\"focusNode, inputNode\" />\n\t\t<div class=\"dijitInline dijitFileInputText\" dojoAttachPoint=\"titleNode\">${label}</div>\n\t\t<div class=\"dijitInline dijitFileInputButton\" dojoAttachPoint=\"cancelNode\" \n\t\t\tdojoAttachEvent=\"onclick:reset\">${cancelText}</div>\n\t</div>\n</div>\n"),startup:function(){ |
15 |
this._listener=this.connect(this.fileInput,"onchange","_matchValue"); |
16 |
this._keyListener=this.connect(this.fileInput,"onkeyup","_matchValue"); |
17 |
},postCreate:function(){ |
18 |
},_matchValue:function(){ |
19 |
this.inputNode.value=this.fileInput.value; |
20 |
if(this.inputNode.value){ |
21 |
this.cancelNode.style.visibility="visible"; |
22 |
dojo.fadeIn({node:this.cancelNode,duration:275}).play(); |
23 |
} |
24 |
},setLabel:function(_1,_2){ |
25 |
this.titleNode.innerHTML=_1;
|
26 |
},reset:function(e){ |
27 |
this.disconnect(this._listener); |
28 |
this.disconnect(this._keyListener); |
29 |
if(this.fileInput){ |
30 |
this.domNode.removeChild(this.fileInput); |
31 |
} |
32 |
dojo.fadeOut({node:this.cancelNode,duration:275}).play(); |
33 |
this.fileInput=document.createElement("input"); |
34 |
this.fileInput.setAttribute("type","file"); |
35 |
this.fileInput.setAttribute("id",this.id); |
36 |
this.fileInput.setAttribute("name",this.name); |
37 |
dojo.addClass(this.fileInput,"dijitFileInputReal"); |
38 |
this.domNode.appendChild(this.fileInput); |
39 |
this._keyListener=this.connect(this.fileInput,"onkeyup","_matchValue"); |
40 |
this._listener=this.connect(this.fileInput,"onchange","_matchValue"); |
41 |
this.inputNode.value=""; |
42 |
}}); |
43 |
} |