Debian Codegraph @

dojox/form/tests/test_FileUploaderForm.html

raw symbols SCIP
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
2 <html lang="en">
3 <head>
4 <title>Test dojox.form.FileUploader - Form</title>
5 <style type="text/css">
6 @import "../../../dojo/resources/dojo.css";
7 @import "../../../dijit/themes/dijit.css";
8 @import "../../../dijit/themes/tundra/form/Button.css";
9 @import "../../../dijit/themes/tundra/ProgressBar.css";
10 @import "../../../dijit/tests/css/dijitTests.css";
11 @import "../resources/FileUploader.css";
12 </style>
13 <script>
14 djConfig = {
15 isDebug: true,
16 popup:true,
17 parseOnLoad: true
18 }
19 </script>
20 <script src="../../../dojo/dojo.js"></script>
21 <script>
22 dojo.require("dojo.parser");
23 dojo.require("dojox.form.FileUploader");
24 dojo.require("dijit.form.Button");
25 dojo.require("dijit.ProgressBar");
26
27 addThumb = function(d, id){
28 console.log("THUMB:", d);
29 var fileRoot = dojo.moduleUrl("dojox.form", "tests").toString();
30 var img = '<img src='+fileRoot+"/"+escape(d.file)+
31 (d.width>d.height ?
32 ' width="50"/>' :
33 ' height="50"/>');
34 console.log("IMG:", img)
35 var str = '<div id="file_'+d.name+'" class="thumb"><div class="thumbPic">'+img+'</div>';
36 str += '<div class="thumbText">';
37 if(d.fGroup || d.hGroup){
38 str += 'Group: '+(d.fGroup || d.hGroup)+'<br/>';
39 }
40 str += 'Title: '+d.name+'<br/>';
41 if(d.author){
42 str += 'Author: '+ d.author+'<br/>';
43 }
44 if(d.date){
45 str += d.date+' ';
46 }
47 str += Math.ceil(d.size*.001)+'kb</div></div>';
48 dojo.byId(id).innerHTML += str;
49 }
50 dojo.addOnLoad(function(){
51
52 var props = {
53 isDebug:true,
54 devmode:true,
55 hoverClass:"uploadHover",
56 activeClass:"uploadPress",
57 disabledClass:"uploadDisabled",
58 uploadUrl:dojo.moduleUrl("dojox.form", "tests/UploadFile.php"),
59 fileMask:[
60 ["Jpeg File", "*.jpg;*.jpeg"],
61 ["GIF File", "*.gif"],
62 ["PNG File", "*.png"],
63 ["All Images", "*.jpg;*.jpeg;*.gif;*.png"]
64 ]
65 }
66
67 if(dojo.byId("btnF")){
68 dojo.byId("fFiles").value = "";
69 var f = new dojox.form.FileUploader(dojo.mixin({
70 progressWidgetId:"progressBar",
71 showProgress:true,
72 fileListId:"fFiles",
73 tabIndex:5,
74 selectMultipleFiles:true,
75 //uploadOnChange:true,
76 deferredUploading:false
77 },props), "btnF");
78 f.set("disabled", dojo.byId("fGroup").value=="");
79 dojo.connect(dojo.byId("fGroup"), "keyup", function(){
80 f.set("disabled", dojo.byId("fGroup").value=="");
81 });
82 dojo.connect(dijit.byId("fSubmit"), "onClick", function(){
83 f.submit(dojo.byId("formF"));
84 });
85 dojo.connect(f, "onChange", function(dataArray){
86 console.log("onChange.data:", dataArray);
87 });
88 dojo.connect(f, "onComplete", function(dataArray){
89 console.log("onComplete Data:", dataArray)
90 dojo.forEach(dataArray, function(d){
91 addThumb(d, "fThumbs");
92 });
93 });
94 }
95
96
97 if(dojo.byId("btnH")){
98 dojo.byId("hFiles").value = "";
99 var h = new dojox.form.FileUploader(dojo.mixin({
100 force:"html",
101 showProgress:true,
102 progressWidgetId:"progressBarHtml",
103 selectMultipleFiles:true,
104 //uploadOnChange:true,
105 fileListId:"hFiles",
106 tabIndex:11,
107 devMode:true
108 }, props), "btnH");
109
110 h.set("disabled", dojo.byId("hGroup").value=="");
111 dojo.connect(dojo.byId("hGroup"), "keyup", function(){
112 h.set("disabled", dojo.byId("hGroup").value=="");
113 });
114 dojo.connect(dijit.byId("hSubmit"), "onClick", function(evt){
115 h.submit(dojo.byId("formH"));
116 dojo.stopEvent(evt);
117 });
118 dojo.connect(h, "onComplete", function(dataArray){
119 console.warn("html onComplete", dataArray)
120 dojo.forEach(dataArray, function(d){
121 addThumb(d, "hThumbs");
122 });
123 });
124 dojo.connect(h, "onError", function(err){
125 console.error("html error", err)
126 });
127 }
128 if(dijit.byId("btnD")){
129 var d = new FlashHTML.widget(dojo.mixin({button:dijit.byId("btnD")}, props));
130 d.set("disabled", dojo.byId("dTitle").value=="");
131 dojo.connect(dojo.byId("dTitle"), "keyup", function(){
132 d.set("disabled", dojo.byId("dTitle").value=="");
133 });
134 dojo.connect(dijit.byId("fSubmit"), "onClick", function(evt){
135 f.submit(dojo.byId("formF"));
136 dojo.stopEvent(evt);
137 });
138 }
139
140
141 });
142
143
144 </script>
145 <style>
146 html, body{
147 font-family:sans-serif;
148 font-size:12px;
149 }
150 .uploadBtn{
151 border:1px solid #333333;
152 background:url(../../../dijit/themes/soria/images/buttonEnabled.png) #d0d0d0 repeat-x scroll 0px top;
153 font-size:14px;
154 font-family:Arial;
155 width:201px;
156 height:30px;
157 line-height:50px;
158 vertical-align:middle; /* emulates a <button> */
159 text-align:center;
160 }
161 .uploadHover{
162 background-image:url(../../../dijit/themes/soria/images/buttonHover.png);
163 cursor:pointer;
164 font-weight:bold;
165 font-style:italic;
166 font-family:serif;
167 }
168 .uploadPress{
169 background-image:url(../../../dijit/themes/soria/images/buttonActive.png);
170 }
171 .uploadDisabled{
172 background-image:none;
173 background-color:#666;
174 color:#999;
175 border:1px solid #999;
176 font-family:serif;
177 font-style:italic;
178 }
179 .progBar{
180 width:294px;
181 display:none;
182 }
183 .form{
184 width:300px;
185 border:1px solid #ccc;
186 margin:5px;
187 padding:3px;
188 position:relative;
189 }
190 .form, .thumbList{
191 float:left;
192 }
193 .thumbList{
194 width:300px;
195 border:1px solid #ccc;
196 min-height:100px;
197 margin:5px;
198 padding:3px;
199 }
200 #fFiles, #hFiles{
201 width:200px;
202 height:75px;
203 overflow-x:hidden;
204 overflow-y:auto;
205 border:1px solid #ccc;
206 }
207 .form .field{
208 width:197px;
209 }
210 .tbl{
211 width:100%;
212 }
213 .tbl td{
214 width:50%;
215 vertical-align:top;
216 }
217 .form label{
218 position:absolute;
219 width:80px;
220 text-align:right;
221 left:0px;
222 }
223 .form .field, .form .btn{
224 margin-left:85px;
225 margin-bottom:5px;
226 }
227 h3{
228 width:600px;
229 font-weight:normal;
230 font-size:14px;
231 }
232 ul{
233 font-size:12px;
234 width:600px;
235 }
236 </style>
237 </head>
238 <body class="tundra">
239 <h1>FileUploader Widget Form Test</h1>
240 <p style="font-size:14px; width:480px; border:2px solid #ff0000; padding:3px;">
241 <strong>NOTE:</strong> This test does upload,
242 but the server scripts are renamed to <em>tests/UploadFile.php.<strong>disabled</strong></em> and
243 <em>tests/cLOG.php.<strong>disabled</strong></em> to prevent security attacks on hosted servers.
244 You should rename these files (removing <em>.disabled</em>) in your local copy to conduct tests.
245 </p>
246 <h3>Both forms on this page are the same except one is for testing the Flash Uploader and one
247 is for the HTML Uploader. The following features are being tested:</h3>
248 <ul>
249 <li>Disabled: The Uploaders are disabled unless the Group field is populated.</li>
250 <li>Submit: The Submit buttons actually submit to the uploaders, and they post the data.</li>
251 <li>Post Data: Post data is tested. The field data should be in the thumbnails.</li>
252 <li>Selected List: If passing the ID of a container, the Uploaders will populate it with
253 the selected files.</li>
254 <li>Deleting Files: You can now delete pending files.</li>
255 <li>Progress Built in: showProgress:true will change the button to a progress bar on upload.</li>
256 <li>Progress Attach: Passing progressWidgetId will tell the Uploader of a progress widget.
257 If the Progress widget is initially hidden, it will change to visible and then restored after
258 upload.</li>
259 <li>A11Y: The Flash button can be accessed with the TAB key. (The HTML cannot due to browser
260 limtations)</li>
261 </ul>
262 <table class="tbl">
263 <tr>
264 <td>
265 <form id="formF" class="form">
266 <label>Group Name:</label>
267 <input class="field" tabIndex="1" type="text" value="" id="fGroup" name='fGroup' /><br/>
268 <label>Date:</label>
269 <input class="field" tabIndex="2" type="text" value="" id="fDate" name='date' /><br/>
270 <label>Author:</label>
271 <input class="field" tabIndex="3" type="text" value="" id="fAuthor" name='author' /><br/>
272 <label>Files:</label>
273 <div id="fFiles" class="field"></div>
274 <div tabIndex="5" id="btnF" class="uploadBtn btn">Flash Select Files</div>
275 <button tabIndex="6" id="fSubmit" class="btn" dojoType="dijit.form.Button" onclick="return false;">Submit</button>
276 <div indeterminate="false" id="progressBar" class="progBar" dojoType="dijit.ProgressBar"></div>
277 </form>
278 <div id="fThumbs" class="thumbList"></div>
279 </td>
280 <td>
281 <form id="formH" class="form">
282 <label>Group Name:</label>
283 <input class="field" tabIndex="7" type="text" value="" id="hGroup" name='hGroup' /><br/>
284 <label>Date:</label>
285 <input class="field" tabIndex="8" type="text" value="" id="hDate" name='date' /><br/>
286 <label>Author:</label>
287 <input class="field" tabIndex="9" type="text" value="" id="hAuthor" name='author' /><br/>
288 <label>Files:</label>
289 <div class="field" id="hFiles"></div>
290 <div tabIndex="11" id="btnH" class="uploadBtn btn">HTML Select Files</div>
291 <button tabIndex="12" class="btn" id="hSubmit" class="" onclick="return false;" dojoType="dijit.form.Button">Submit</button>
292 <div indeterminate="false" id="progressBarHtml" class="progBar" dojoType="dijit.ProgressBar"></div>
293 </form>
294 <div id="hThumbs" class="thumbList"></div>
295 </td>
296 </tr>
297 </table>
298 </body>
299 </html>