2150 |
mathias |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
|
|
2 |
"http://www.w3.org/TR/html4/strict.dtd">
|
|
|
3 |
<html>
|
|
|
4 |
<head>
|
|
|
5 |
<title>dojox.widget.FileInput | The Dojo Toolkit</title>
|
|
|
6 |
<style type="text/css">
|
|
|
7 |
@import "../../../dojo/resources/dojo.css";
|
|
|
8 |
@import "../../../dijit/themes/dijit.css";
|
|
|
9 |
@import "../../../dijit/tests/css/dijitTests.css";
|
|
|
10 |
@import "../FileInput/FileInput.css";
|
|
|
11 |
</style>
|
|
|
12 |
|
|
|
13 |
<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug:true, parseOnLoad: true"></script>
|
|
|
14 |
<script type="text/javascript" src="../FileInput.js"></script>
|
|
|
15 |
<script type="text/javascript" src="../FileInputAuto.js"></script>
|
|
|
16 |
<script type="text/javascript">
|
|
|
17 |
// dojo.require("dojox.widget.FileInput");
|
|
|
18 |
dojo.require("dojo.parser"); // scan page for widgets and instantiate them
|
|
|
19 |
|
|
|
20 |
var sampleCallback = function(data,ioArgs,widget){
|
|
|
21 |
// this function is fired for every programatic FileUploadAuto
|
|
|
22 |
// when the upload is complete. It uses dojo.io.iframe, which
|
|
|
23 |
// expects the results to come wrapped in TEXTAREA tags.
|
|
|
24 |
// this is IMPORTANT. to utilize FileUploadAuto (or Blind)
|
|
|
25 |
// you have to pass your respose data in a TEXTAREA tag.
|
|
|
26 |
// in our sample file (if you have php5 installed and have
|
|
|
27 |
// file uploads enabled) it _should_ return some text in the
|
|
|
28 |
// form of valid JSON data, like:
|
|
|
29 |
// { status: "success", details: { size: "1024" } }
|
|
|
30 |
// you can do whatever.
|
|
|
31 |
//
|
|
|
32 |
// the ioArgs is the standard ioArgs ref found in all dojo.xhr* methods.
|
|
|
33 |
//
|
|
|
34 |
// widget is a reference to the calling widget. you can manipulate the widget
|
|
|
35 |
// from within this callback function
|
|
|
36 |
if(data){
|
|
|
37 |
var d = dojo.fromJson(data);
|
|
|
38 |
if(d.status && d.status == "success"){
|
|
|
39 |
widget.overlay.innerHTML = "success!";
|
|
|
40 |
}else{
|
|
|
41 |
widget.overlay.innerHTML = "error? ";
|
|
|
42 |
console.log(data,ioArgs);
|
|
|
43 |
}
|
|
|
44 |
}else{
|
|
|
45 |
// debug assist
|
|
|
46 |
console.log(arguments);
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
var i = 0;
|
|
|
51 |
function addNewUpload(){
|
|
|
52 |
var node = document.createElement('input');
|
|
|
53 |
dojo.byId('dynamic').appendChild(node);
|
|
|
54 |
var widget = new dojox.widget.FileInputAuto({
|
|
|
55 |
id: "dynamic"+(++i),
|
|
|
56 |
url: "../FileInput/ReceiveFile.php",
|
|
|
57 |
//url:"http://archive.dojotoolkit.org/nightly/checkout/dojox/widget/FileInput/ReceiveFile.php",
|
|
|
58 |
name: "dynamic"+i,
|
|
|
59 |
onComplete: sampleCallback
|
|
|
60 |
},node);
|
|
|
61 |
widget.startup();
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
</script>
|
|
|
65 |
</head>
|
|
|
66 |
<body>
|
|
|
67 |
|
|
|
68 |
<h1 class="testTitle">dojox FileInput widget:</h1>
|
|
|
69 |
<p>This is a prototype of a dojo input type="file" with a FormWidget mixin, to be styled to match tundra and soria themes</p>
|
|
|
70 |
<p>The API is up for discussion, nor is it known to drop into forms and "just work" yet</p>
|
|
|
71 |
<p>FileInputAuto API is up for discussion, as well, though by use of the url="" attrib, you can basically
|
|
|
72 |
do all your file-processing server side, and just use the filename sent that remains in the form input</p>
|
|
|
73 |
<p>There are two parts. dojo.require("dojox.widget.FileInput") for just the base class, or dojo.require("dojox.widget.FileInputAuto");
|
|
|
74 |
to provide the Auto Uploading widget (on blur), and the Blind Auto Upload widget.</p>
|
|
|
75 |
<p>Both themes are defined in the FileInput.css file, as well as basic styling needed to run</p>
|
|
|
76 |
|
|
|
77 |
<h3>A standard file input:</h3>
|
|
|
78 |
<input type="file" id="normal" name="inputFile" />
|
|
|
79 |
|
|
|
80 |
<h3>The default dojox.widget.FileInput:</h3>
|
|
|
81 |
<p>
|
|
|
82 |
<input dojoType="dojox.widget.FileInput" id="default" name="inputFile" />
|
|
|
83 |
</p>
|
|
|
84 |
|
|
|
85 |
<h3>default dojox.widget.FileInput, tundra:</h3>
|
|
|
86 |
<p class="tundra">
|
|
|
87 |
<input dojoType="dojox.widget.FileInput" id="default2" name="inputFile" />
|
|
|
88 |
</p>
|
|
|
89 |
|
|
|
90 |
<h3>dojox.widget.FileInputAuto, soria theme:</h3>
|
|
|
91 |
<p class="soria">
|
|
|
92 |
<input dojoType="dojox.widget.FileInputAuto" id="defaultAuto" name="inputFileAuto" url="../FileInput/ReceiveFile.php" />
|
|
|
93 |
</p>
|
|
|
94 |
|
|
|
95 |
<h3>another one, tundra theme (with callback)</h3>
|
|
|
96 |
<p class="tundra">
|
|
|
97 |
<input dojoType="dojox.widget.FileInputAuto" id="defaultAuto2" name="inputFileAuto2" url="../FileInput/ReceiveFile.php" onComplete="sampleCallback"/>
|
|
|
98 |
</p>
|
|
|
99 |
|
|
|
100 |
<h3>a blind auto upload widget, tundra:</h3>
|
|
|
101 |
<p class="tundra">
|
|
|
102 |
<input dojoType="dojox.widget.FileInputBlind" id="blind1" name="blind1" url="../FileInput/ReceiveFile.php" />
|
|
|
103 |
</p>
|
|
|
104 |
|
|
|
105 |
<h3>dojox.widget.FileInputBlind - soria</h3>
|
|
|
106 |
<p class="soria">
|
|
|
107 |
<input dojoType="dojox.widget.FileInputBlind" id="blind2" name="blind2" url="../FileInput/ReceiveFile.php" />
|
|
|
108 |
</p>
|
|
|
109 |
|
|
|
110 |
<h3>dynamic, tundra, dojox.widget.FileInputAuto:</h3>
|
|
|
111 |
<button onclick="addNewUpload()">add new file upload</button>
|
|
|
112 |
<br><br>
|
|
|
113 |
<div id="dynamic" class="tundra"></div>
|
|
|
114 |
|
|
|
115 |
</body>
|
|
|
116 |
</html>
|