| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <title>Test dojox.form.UploaderHTML5</title> |
| 5 | <link href="../../../dijit/themes/dijit.css" rel="stylesheet" /> |
| 6 | <link href="../../../dijit/themes/claro/Common.css" rel="stylesheet" /> |
| 7 | <link href="../../../dijit/themes/claro/form/Common.css" rel="stylesheet" /> |
| 8 | <link href="../../../dijit/themes/claro/Dialog.css" rel="stylesheet" /> |
| 9 | <link href="../../../dijit/themes/claro/form/Button.css" rel="stylesheet" /> |
| 10 | <link href="../../../dijit/themes/claro/layout/TabContainer.css" rel="stylesheet" /> |
| 11 | <link href="../../../dijit/themes/claro/Dialog.css" rel="stylesheet" /> |
| 12 | |
| 13 | <link href="../resources/UploaderFileList.css" rel="stylesheet" /> |
| 14 | <style> |
| 15 | @import "../../../dijit/tests/css/dijitTests.css"; |
| 16 | html, body{ |
| 17 | font-family:sans-serif; |
| 18 | } |
| 19 | .browseButton{ |
| 20 | width:300px; |
| 21 | height:20px; |
| 22 | font-weight:bold; |
| 23 | margin:10px 0 2px 0; |
| 24 | } |
| 25 | .dijitTabPane{ |
| 26 | padding:20px; |
| 27 | } |
| 28 | form{ |
| 29 | width:315px; |
| 30 | margin-right:10px; |
| 31 | } |
| 32 | fieldset{ |
| 33 | text-align:right; |
| 34 | } |
| 35 | input[type=text]{ |
| 36 | width:140px; |
| 37 | } |
| 38 | .dijitButton{ |
| 39 | margin-top:15px; |
| 40 | } |
| 41 | .dojoxUploaderFileList{ |
| 42 | text-align:left; |
| 43 | margin-top:10px; |
| 44 | } |
| 45 | .pageTable{ |
| 46 | width:100%; |
| 47 | } |
| 48 | .pageTable td{ |
| 49 | vertical-align:top; |
| 50 | } |
| 51 | #colForm{ |
| 52 | width:330px; |
| 53 | } |
| 54 | #colImages{ |
| 55 | padding-top:7px; |
| 56 | } |
| 57 | .thumb{ |
| 58 | border:1px solid #ccc; |
| 59 | padding:5px; |
| 60 | width:123px; |
| 61 | background:#eee; |
| 62 | float:left; |
| 63 | margin:0 5px 5px 0; |
| 64 | } |
| 65 | .thumbbk{ |
| 66 | background:#fff; |
| 67 | display:block; |
| 68 | } |
| 69 | .thumb img{ |
| 70 | border:1px solid #ccc; |
| 71 | width:120px; |
| 72 | } |
| 73 | .form, .html5, .iframe, .flash{ |
| 74 | display:none; |
| 75 | } |
| 76 | .Form .form, .HTML5 .html5, .IFrame .iframe, .Flash .flash{ |
| 77 | display:block; |
| 78 | } |
| 79 | #dialog p{ |
| 80 | width:310px; |
| 81 | } |
| 82 | .claro .attachButton{ |
| 83 | width:350px; |
| 84 | height:60px; |
| 85 | border:0; |
| 86 | } |
| 87 | .claro .attachButton .dijitButton .dijitButtonNode{ |
| 88 | background-color:#ffffff; |
| 89 | background-image:url(images/attach.png); |
| 90 | background-position:left top; |
| 91 | background-repeat:no-repeat; |
| 92 | height:56px; |
| 93 | border:0; |
| 94 | -moz-box-shadow:0 0 0; |
| 95 | -webkit-box-shadow:0 0 0; |
| 96 | } |
| 97 | .claro .attachButton .dijitButtonHover .dijitButtonNode{ |
| 98 | background-position:0px -60px; |
| 99 | } |
| 100 | code{ |
| 101 | font-family:monospace; |
| 102 | white-space:nowrap; |
| 103 | } |
| 104 | </style> |
| 105 | <script> |
| 106 | djConfig = { |
| 107 | parseOnLoad:true, |
| 108 | isDebug:true |
| 109 | } |
| 110 | </script> |
| 111 | <script src="../../../dojo/dojo.js"></script> |
| 112 | <script> |
| 113 | dojo.require("dojo.parser"); |
| 114 | dojo.require("dojox.form.Uploader"); |
| 115 | dojo.require("dojox.form.uploader.FileList"); |
| 116 | dojo.require("dijit.form.Button"); |
| 117 | |
| 118 | // Dynamically determining which plugin to use, based off of the location search. |
| 119 | var plug = "Form"; // Default |
| 120 | switch(document.location.search){ |
| 121 | case "?html5": |
| 122 | dojo.require("dojox.form.uploader.plugins.HTML5"); |
| 123 | plug = "HTML5"; |
| 124 | break; |
| 125 | case "?iframe": |
| 126 | dojo.require("dojox.form.uploader.plugins.IFrame"); |
| 127 | plug = "IFrame"; |
| 128 | break; |
| 129 | case "?flash": |
| 130 | dojo.require("dojox.form.uploader.plugins.Flash"); |
| 131 | plug = "Flash"; |
| 132 | break; |
| 133 | } |
| 134 | |
| 135 | var title = "Test dojox.form.Uploader + " + plug; |
| 136 | document.title = title; |
| 137 | var handleUpload = function(upl, node){ |
| 138 | if(plug == "Form"){ |
| 139 | dojo.connect(upl, "onChange", function(){ |
| 140 | node.appendChild(dojo.create('div', {innerHTML:"This Uploader does not work in Form mode."})); |
| 141 | //alert("This Uploader does not work in Form mode.") |
| 142 | }); |
| 143 | } |
| 144 | dojo.connect(upl, "onComplete", function(dataArray){ |
| 145 | dojo.forEach(dataArray, function(file){ |
| 146 | console.log("display:", file) |
| 147 | |
| 148 | var div = dojo.create('div', {className:'thumb'}); |
| 149 | var span = dojo.create('span', {className:'thumbbk'}, div); |
| 150 | var img = dojo.create('img', {src:file.file}, span); |
| 151 | node.appendChild(div); |
| 152 | }); |
| 153 | }); |
| 154 | } |
| 155 | dojo.addOnLoad(function(){ |
| 156 | dojo.addClass(dojo.body(), plug); |
| 157 | dojo.query('h1')[0].innerHTML = title; |
| 158 | dojo.connect(dijit.byId("remBtn"), "onClick", dijit.byId("uploader"), "reset"); |
| 159 | handleUpload(dijit.byId("uploader"), dojo.byId('colImages')); |
| 160 | }); |
| 161 | </script> |
| 162 | </head> |
| 163 | <body class="claro"> |
| 164 | <div role="main"> |
| 165 | <h1>Test dojox.form.Uploader Flash</h1> |
| 166 | <p style="font-size:14px; border:2px solid #ff0000; padding:3px;"> |
| 167 | <strong>NOTE:</strong> This test does upload, |
| 168 | but the server scripts are renamed to <code>tests/UploadFile.php.<strong>disabled</strong></code> and |
| 169 | <code>tests/cLOG.php.<strong>disabled</strong></code> to prevent security attacks on hosted servers. |
| 170 | You should rename these files (removing <code>.disabled</code>) in your local copy to conduct tests. |
| 171 | </p> |
| 172 | <p class="form"> |
| 173 | The Uploader with no plugins is in "Form" mode. This mode <strong>will not do an Ajax upload</strong>. |
| 174 | Only form POSTs will work and they will navigate to the UploadFile.php page. |
| 175 | </p> |
| 176 | <p class="html5"> |
| 177 | The HTML5 Uploder plugin does not support IE. HTML5 is more of a base class for IFrame or |
| 178 | Flash, or used in cases where IE is not a requirement. This test case is for development purposes. |
| 179 | </p> |
| 180 | <p class="iframe"> |
| 181 | The IFrame plugin will use the IFrame to upload in IE. All other browsers will use the HTML5 plugin |
| 182 | unless force="iframe" is used. |
| 183 | When using this plugin, be sure your form use the attribute: <code>enctype="multipart/form-data"</code> |
| 184 | </p> |
| 185 | <p class="flash"> |
| 186 | The Flash plugin will use a SWF to upload in non-HTML5 browsers. All other browsers will use the HTML5 plugin, |
| 187 | unless <code>force="flash"</code> is used, then Flash will be used in all browsers. <code>force="flash"</code> |
| 188 | is provided because Flash has some features that HTML5 does not yet have. But it is still not |
| 189 | recommended because of the many problems that Firefox and Webkit have with the Flash plugin. |
| 190 | </p> |
| 191 | <p> |
| 192 | <a href="test_UploaderAll.html">Form</a> |
| 193 | <a href="test_UploaderAll.html?html5">HTML5</a> |
| 194 | <a href="test_UploaderAll.html?iframe">IFrame</a> |
| 195 | <a href="test_UploaderAll.html?flash">Flash</a> |
| 196 | </p> |
| 197 | <table class="pageTable" role="presentation"> |
| 198 | <tr> |
| 199 | <td id="colForm"> |
| 200 | <form method="post" action="UploadFile.php" id="myForm" enctype="multipart/form-data" > |
| 201 | <fieldset> |
| 202 | <legend>Form Post Test</legend> |
| 203 | <input class="browseButton" name="uploadedfile" multiple="true" type="file" dojoType="dojox.form.Uploader" label="Select Some Files" id="uploader"> |
| 204 | <input type="text" name="album" value="Summer Vacation" aria-label="album" /> |
| 205 | <input type="text" name="year" value="2011" aria-label="year" /> |
| 206 | <input type="button" id="remBtn" label="Clear" dojoType="dijit.form.Button" /> |
| 207 | <input type="submit" label="Submit" dojoType="dijit.form.Button" /> |
| 208 | <div id="files" dojoType="dojox.form.uploader.FileList" uploaderId="uploader"></div> |
| 209 | </fieldset> |
| 210 | </form> |
| 211 | </td> |
| 212 | <td id="colImages"> |
| 213 | </td> |
| 214 | </tr> |
| 215 | </table> |
| 216 | |
| 217 | </body> |
| 218 | </html> |