├── .gitignore ├── README.md └── mysite ├── main ├── __init__.py ├── forms.py ├── models.py ├── static │ └── main │ │ ├── css │ │ ├── basic.css │ │ ├── dropzone.css │ │ └── stylus │ │ │ ├── basic.styl │ │ │ └── dropzone.styl │ │ ├── images │ │ ├── spritemap.png │ │ └── spritemap@2x.png │ │ └── js │ │ ├── dropzone-amd-module.js │ │ ├── dropzone-amd-module.min.js │ │ ├── dropzone.js │ │ └── dropzone.min.js ├── templates │ └── main │ │ └── index.html ├── tests.py ├── urls.py └── views.py ├── manage.py └── mysite ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | *.pot 3 | *.pyc 4 | local_settings.py 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | dropzonejs-django-file-upload 2 | ============================= 3 | 4 | Introduction 5 | ------------ 6 | This is a small example on how to build file upload form using DropzoneJS and the backend will be handled by Django. 7 | 8 | Here, you'll find a minimal Django project with a minimal app. You can run the example standalone by cloning the repository. 9 | 10 | For more information about how this project has been created you can visit [my blog](http://amatellanes.wordpress.com/2013/11/05/dropzonejs-django-how-to-build-a-file-upload-form/ "DropzoneJs + Django: How to build a file upload form"). 11 | 12 | Installation 13 | ------------ 14 | * ```python manage.py syncdb``` 15 | * ```python manage.py runserver``` 16 | * Go to http://127.0.0.1:8000/ and upload some files. 17 | 18 | Requirements 19 | ------------ 20 | * Django 1.5 (https://www.djangoproject.com/) 21 | * Python 2.x (http://www.python.org/) 22 | * Dropzone 2.0 (http://www.dropzonejs.com/) -------------------------------------------------------------------------------- /mysite/main/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amatellanes/dropzonejs-django-file-upload/abd8ceae931ee14e89d748d595c8e402d78cb9f6/mysite/main/__init__.py -------------------------------------------------------------------------------- /mysite/main/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | 3 | from models import UploadFile 4 | 5 | 6 | class UploadFileForm(forms.ModelForm): 7 | 8 | class Meta: 9 | model = UploadFile -------------------------------------------------------------------------------- /mysite/main/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | class UploadFile(models.Model): 4 | file = models.FileField(upload_to='files/%Y/%m/%d') 5 | -------------------------------------------------------------------------------- /mysite/main/static/main/css/basic.css: -------------------------------------------------------------------------------- 1 | /* The MIT License */ 2 | .dropzone, 3 | .dropzone *, 4 | .dropzone-previews, 5 | .dropzone-previews * { 6 | -webkit-box-sizing: border-box; 7 | -moz-box-sizing: border-box; 8 | box-sizing: border-box; 9 | } 10 | .dropzone { 11 | position: relative; 12 | border: 1px solid rgba(0,0,0,0.08); 13 | background: rgba(0,0,0,0.02); 14 | padding: 1em; 15 | } 16 | .dropzone.dz-clickable { 17 | cursor: pointer; 18 | } 19 | .dropzone.dz-clickable .dz-message, 20 | .dropzone.dz-clickable .dz-message span { 21 | cursor: pointer; 22 | } 23 | .dropzone.dz-clickable * { 24 | cursor: default; 25 | } 26 | .dropzone .dz-message { 27 | opacity: 1; 28 | -ms-filter: none; 29 | filter: none; 30 | } 31 | .dropzone.dz-drag-hover { 32 | border-color: rgba(0,0,0,0.15); 33 | background: rgba(0,0,0,0.04); 34 | } 35 | .dropzone.dz-started .dz-message { 36 | display: none; 37 | } 38 | .dropzone .dz-preview, 39 | .dropzone-previews .dz-preview { 40 | background: rgba(255,255,255,0.8); 41 | position: relative; 42 | display: inline-block; 43 | margin: 17px; 44 | vertical-align: top; 45 | border: 1px solid #acacac; 46 | padding: 6px 6px 6px 6px; 47 | } 48 | .dropzone .dz-preview.dz-file-preview [data-dz-thumbnail], 49 | .dropzone-previews .dz-preview.dz-file-preview [data-dz-thumbnail] { 50 | display: none; 51 | } 52 | .dropzone .dz-preview .dz-details, 53 | .dropzone-previews .dz-preview .dz-details { 54 | width: 100px; 55 | height: 100px; 56 | position: relative; 57 | background: #ebebeb; 58 | padding: 5px; 59 | margin-bottom: 22px; 60 | } 61 | .dropzone .dz-preview .dz-details .dz-filename, 62 | .dropzone-previews .dz-preview .dz-details .dz-filename { 63 | overflow: hidden; 64 | height: 100%; 65 | } 66 | .dropzone .dz-preview .dz-details img, 67 | .dropzone-previews .dz-preview .dz-details img { 68 | position: absolute; 69 | top: 0; 70 | left: 0; 71 | width: 100px; 72 | height: 100px; 73 | } 74 | .dropzone .dz-preview .dz-details .dz-size, 75 | .dropzone-previews .dz-preview .dz-details .dz-size { 76 | position: absolute; 77 | bottom: -28px; 78 | left: 3px; 79 | height: 28px; 80 | line-height: 28px; 81 | } 82 | .dropzone .dz-preview.dz-error .dz-error-mark, 83 | .dropzone-previews .dz-preview.dz-error .dz-error-mark { 84 | display: block; 85 | } 86 | .dropzone .dz-preview.dz-success .dz-success-mark, 87 | .dropzone-previews .dz-preview.dz-success .dz-success-mark { 88 | display: block; 89 | } 90 | .dropzone .dz-preview:hover .dz-details img, 91 | .dropzone-previews .dz-preview:hover .dz-details img { 92 | display: none; 93 | } 94 | .dropzone .dz-preview .dz-success-mark, 95 | .dropzone-previews .dz-preview .dz-success-mark, 96 | .dropzone .dz-preview .dz-error-mark, 97 | .dropzone-previews .dz-preview .dz-error-mark { 98 | display: none; 99 | position: absolute; 100 | width: 40px; 101 | height: 40px; 102 | font-size: 30px; 103 | text-align: center; 104 | right: -10px; 105 | top: -10px; 106 | } 107 | .dropzone .dz-preview .dz-success-mark, 108 | .dropzone-previews .dz-preview .dz-success-mark { 109 | color: #8cc657; 110 | } 111 | .dropzone .dz-preview .dz-error-mark, 112 | .dropzone-previews .dz-preview .dz-error-mark { 113 | color: #ee162d; 114 | } 115 | .dropzone .dz-preview .dz-progress, 116 | .dropzone-previews .dz-preview .dz-progress { 117 | position: absolute; 118 | top: 100px; 119 | left: 6px; 120 | right: 6px; 121 | height: 6px; 122 | background: #d7d7d7; 123 | display: none; 124 | } 125 | .dropzone .dz-preview .dz-progress .dz-upload, 126 | .dropzone-previews .dz-preview .dz-progress .dz-upload { 127 | position: absolute; 128 | top: 0; 129 | bottom: 0; 130 | left: 0; 131 | width: 0%; 132 | background-color: #8cc657; 133 | } 134 | .dropzone .dz-preview.dz-processing .dz-progress, 135 | .dropzone-previews .dz-preview.dz-processing .dz-progress { 136 | display: block; 137 | } 138 | .dropzone .dz-preview .dz-error-message, 139 | .dropzone-previews .dz-preview .dz-error-message { 140 | display: none; 141 | position: absolute; 142 | top: -5px; 143 | left: -20px; 144 | background: rgba(245,245,245,0.8); 145 | padding: 8px 10px; 146 | color: #800; 147 | min-width: 140px; 148 | max-width: 500px; 149 | z-index: 500; 150 | } 151 | .dropzone .dz-preview:hover.dz-error .dz-error-message, 152 | .dropzone-previews .dz-preview:hover.dz-error .dz-error-message { 153 | display: block; 154 | } 155 | -------------------------------------------------------------------------------- /mysite/main/static/main/css/dropzone.css: -------------------------------------------------------------------------------- 1 | /* The MIT License */ 2 | .dropzone, 3 | .dropzone *, 4 | .dropzone-previews, 5 | .dropzone-previews * { 6 | -webkit-box-sizing: border-box; 7 | -moz-box-sizing: border-box; 8 | box-sizing: border-box; 9 | } 10 | .dropzone { 11 | position: relative; 12 | border: 1px solid rgba(0,0,0,0.08); 13 | background: rgba(0,0,0,0.02); 14 | padding: 1em; 15 | } 16 | .dropzone.dz-clickable { 17 | cursor: pointer; 18 | } 19 | .dropzone.dz-clickable .dz-message, 20 | .dropzone.dz-clickable .dz-message span { 21 | cursor: pointer; 22 | } 23 | .dropzone.dz-clickable * { 24 | cursor: default; 25 | } 26 | .dropzone .dz-message { 27 | opacity: 1; 28 | -ms-filter: none; 29 | filter: none; 30 | } 31 | .dropzone.dz-drag-hover { 32 | border-color: rgba(0,0,0,0.15); 33 | background: rgba(0,0,0,0.04); 34 | } 35 | .dropzone.dz-started .dz-message { 36 | display: none; 37 | } 38 | .dropzone .dz-preview, 39 | .dropzone-previews .dz-preview { 40 | background: rgba(255,255,255,0.8); 41 | position: relative; 42 | display: inline-block; 43 | margin: 17px; 44 | vertical-align: top; 45 | border: 1px solid #acacac; 46 | padding: 6px 6px 6px 6px; 47 | } 48 | .dropzone .dz-preview.dz-file-preview [data-dz-thumbnail], 49 | .dropzone-previews .dz-preview.dz-file-preview [data-dz-thumbnail] { 50 | display: none; 51 | } 52 | .dropzone .dz-preview .dz-details, 53 | .dropzone-previews .dz-preview .dz-details { 54 | width: 100px; 55 | height: 100px; 56 | position: relative; 57 | background: #ebebeb; 58 | padding: 5px; 59 | margin-bottom: 22px; 60 | } 61 | .dropzone .dz-preview .dz-details .dz-filename, 62 | .dropzone-previews .dz-preview .dz-details .dz-filename { 63 | overflow: hidden; 64 | height: 100%; 65 | } 66 | .dropzone .dz-preview .dz-details img, 67 | .dropzone-previews .dz-preview .dz-details img { 68 | position: absolute; 69 | top: 0; 70 | left: 0; 71 | width: 100px; 72 | height: 100px; 73 | } 74 | .dropzone .dz-preview .dz-details .dz-size, 75 | .dropzone-previews .dz-preview .dz-details .dz-size { 76 | position: absolute; 77 | bottom: -28px; 78 | left: 3px; 79 | height: 28px; 80 | line-height: 28px; 81 | } 82 | .dropzone .dz-preview.dz-error .dz-error-mark, 83 | .dropzone-previews .dz-preview.dz-error .dz-error-mark { 84 | display: block; 85 | } 86 | .dropzone .dz-preview.dz-success .dz-success-mark, 87 | .dropzone-previews .dz-preview.dz-success .dz-success-mark { 88 | display: block; 89 | } 90 | .dropzone .dz-preview:hover .dz-details img, 91 | .dropzone-previews .dz-preview:hover .dz-details img { 92 | display: none; 93 | } 94 | .dropzone .dz-preview .dz-success-mark, 95 | .dropzone-previews .dz-preview .dz-success-mark, 96 | .dropzone .dz-preview .dz-error-mark, 97 | .dropzone-previews .dz-preview .dz-error-mark { 98 | display: none; 99 | position: absolute; 100 | width: 40px; 101 | height: 40px; 102 | font-size: 30px; 103 | text-align: center; 104 | right: -10px; 105 | top: -10px; 106 | } 107 | .dropzone .dz-preview .dz-success-mark, 108 | .dropzone-previews .dz-preview .dz-success-mark { 109 | color: #8cc657; 110 | } 111 | .dropzone .dz-preview .dz-error-mark, 112 | .dropzone-previews .dz-preview .dz-error-mark { 113 | color: #ee162d; 114 | } 115 | .dropzone .dz-preview .dz-progress, 116 | .dropzone-previews .dz-preview .dz-progress { 117 | position: absolute; 118 | top: 100px; 119 | left: 6px; 120 | right: 6px; 121 | height: 6px; 122 | background: #d7d7d7; 123 | display: none; 124 | } 125 | .dropzone .dz-preview .dz-progress .dz-upload, 126 | .dropzone-previews .dz-preview .dz-progress .dz-upload { 127 | position: absolute; 128 | top: 0; 129 | bottom: 0; 130 | left: 0; 131 | width: 0%; 132 | background-color: #8cc657; 133 | } 134 | .dropzone .dz-preview.dz-processing .dz-progress, 135 | .dropzone-previews .dz-preview.dz-processing .dz-progress { 136 | display: block; 137 | } 138 | .dropzone .dz-preview .dz-error-message, 139 | .dropzone-previews .dz-preview .dz-error-message { 140 | display: none; 141 | position: absolute; 142 | top: -5px; 143 | left: -20px; 144 | background: rgba(245,245,245,0.8); 145 | padding: 8px 10px; 146 | color: #800; 147 | min-width: 140px; 148 | max-width: 500px; 149 | z-index: 500; 150 | } 151 | .dropzone .dz-preview:hover.dz-error .dz-error-message, 152 | .dropzone-previews .dz-preview:hover.dz-error .dz-error-message { 153 | display: block; 154 | } 155 | .dropzone { 156 | border: 1px solid rgba(0,0,0,0.03); 157 | min-height: 360px; 158 | -webkit-border-radius: 3px; 159 | border-radius: 3px; 160 | background: rgba(0,0,0,0.03); 161 | padding: 23px; 162 | } 163 | .dropzone .dz-default.dz-message { 164 | opacity: 1; 165 | -ms-filter: none; 166 | filter: none; 167 | -webkit-transition: opacity 0.3s ease-in-out; 168 | -moz-transition: opacity 0.3s ease-in-out; 169 | -o-transition: opacity 0.3s ease-in-out; 170 | -ms-transition: opacity 0.3s ease-in-out; 171 | transition: opacity 0.3s ease-in-out; 172 | background-image: url("../images/spritemap.png"); 173 | background-repeat: no-repeat; 174 | background-position: 0 0; 175 | position: absolute; 176 | width: 428px; 177 | height: 123px; 178 | margin-left: -214px; 179 | margin-top: -61.5px; 180 | top: 50%; 181 | left: 50%; 182 | } 183 | @media all and (-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx) { 184 | .dropzone .dz-default.dz-message { 185 | background-image: url("../images/spritemap@2x.png"); 186 | -webkit-background-size: 428px 406px; 187 | -moz-background-size: 428px 406px; 188 | background-size: 428px 406px; 189 | } 190 | } 191 | .dropzone .dz-default.dz-message span { 192 | display: none; 193 | } 194 | .dropzone.dz-square .dz-default.dz-message { 195 | background-position: 0 -123px; 196 | width: 268px; 197 | margin-left: -134px; 198 | height: 174px; 199 | margin-top: -87px; 200 | } 201 | .dropzone.dz-drag-hover .dz-message { 202 | opacity: 0.15; 203 | -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=15)"; 204 | filter: alpha(opacity=15); 205 | } 206 | .dropzone.dz-started .dz-message { 207 | display: block; 208 | opacity: 0; 209 | -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; 210 | filter: alpha(opacity=0); 211 | } 212 | .dropzone .dz-preview, 213 | .dropzone-previews .dz-preview { 214 | -webkit-box-shadow: 1px 1px 4px rgba(0,0,0,0.16); 215 | box-shadow: 1px 1px 4px rgba(0,0,0,0.16); 216 | font-size: 14px; 217 | } 218 | .dropzone .dz-preview.dz-image-preview:hover .dz-details img, 219 | .dropzone-previews .dz-preview.dz-image-preview:hover .dz-details img { 220 | display: block; 221 | opacity: 0.1; 222 | -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=10)"; 223 | filter: alpha(opacity=10); 224 | } 225 | .dropzone .dz-preview.dz-success .dz-success-mark, 226 | .dropzone-previews .dz-preview.dz-success .dz-success-mark { 227 | opacity: 1; 228 | -ms-filter: none; 229 | filter: none; 230 | } 231 | .dropzone .dz-preview.dz-error .dz-error-mark, 232 | .dropzone-previews .dz-preview.dz-error .dz-error-mark { 233 | opacity: 1; 234 | -ms-filter: none; 235 | filter: none; 236 | } 237 | .dropzone .dz-preview.dz-error .dz-progress .dz-upload, 238 | .dropzone-previews .dz-preview.dz-error .dz-progress .dz-upload { 239 | background: #ee1e2d; 240 | } 241 | .dropzone .dz-preview .dz-error-mark, 242 | .dropzone-previews .dz-preview .dz-error-mark, 243 | .dropzone .dz-preview .dz-success-mark, 244 | .dropzone-previews .dz-preview .dz-success-mark { 245 | display: block; 246 | opacity: 0; 247 | -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; 248 | filter: alpha(opacity=0); 249 | -webkit-transition: opacity 0.4s ease-in-out; 250 | -moz-transition: opacity 0.4s ease-in-out; 251 | -o-transition: opacity 0.4s ease-in-out; 252 | -ms-transition: opacity 0.4s ease-in-out; 253 | transition: opacity 0.4s ease-in-out; 254 | background-image: url("../images/spritemap.png"); 255 | background-repeat: no-repeat; 256 | } 257 | @media all and (-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx) { 258 | .dropzone .dz-preview .dz-error-mark, 259 | .dropzone-previews .dz-preview .dz-error-mark, 260 | .dropzone .dz-preview .dz-success-mark, 261 | .dropzone-previews .dz-preview .dz-success-mark { 262 | background-image: url("../images/spritemap@2x.png"); 263 | -webkit-background-size: 428px 406px; 264 | -moz-background-size: 428px 406px; 265 | background-size: 428px 406px; 266 | } 267 | } 268 | .dropzone .dz-preview .dz-error-mark span, 269 | .dropzone-previews .dz-preview .dz-error-mark span, 270 | .dropzone .dz-preview .dz-success-mark span, 271 | .dropzone-previews .dz-preview .dz-success-mark span { 272 | display: none; 273 | } 274 | .dropzone .dz-preview .dz-error-mark, 275 | .dropzone-previews .dz-preview .dz-error-mark { 276 | background-position: -268px -123px; 277 | } 278 | .dropzone .dz-preview .dz-success-mark, 279 | .dropzone-previews .dz-preview .dz-success-mark { 280 | background-position: -268px -163px; 281 | } 282 | .dropzone .dz-preview .dz-progress .dz-upload, 283 | .dropzone-previews .dz-preview .dz-progress .dz-upload { 284 | -webkit-animation: loading 0.4s linear infinite; 285 | -moz-animation: loading 0.4s linear infinite; 286 | -o-animation: loading 0.4s linear infinite; 287 | -ms-animation: loading 0.4s linear infinite; 288 | animation: loading 0.4s linear infinite; 289 | -webkit-transition: width 0.3s ease-in-out; 290 | -moz-transition: width 0.3s ease-in-out; 291 | -o-transition: width 0.3s ease-in-out; 292 | -ms-transition: width 0.3s ease-in-out; 293 | transition: width 0.3s ease-in-out; 294 | -webkit-border-radius: 2px; 295 | border-radius: 2px; 296 | position: absolute; 297 | top: 0; 298 | left: 0; 299 | width: 0%; 300 | height: 100%; 301 | background-image: url("../images/spritemap.png"); 302 | background-repeat: repeat-x; 303 | background-position: 0px -400px; 304 | } 305 | @media all and (-webkit-min-device-pixel-ratio:1.5),(min--moz-device-pixel-ratio:1.5),(-o-min-device-pixel-ratio:1.5/1),(min-device-pixel-ratio:1.5),(min-resolution:138dpi),(min-resolution:1.5dppx) { 306 | .dropzone .dz-preview .dz-progress .dz-upload, 307 | .dropzone-previews .dz-preview .dz-progress .dz-upload { 308 | background-image: url("../images/spritemap@2x.png"); 309 | -webkit-background-size: 428px 406px; 310 | -moz-background-size: 428px 406px; 311 | background-size: 428px 406px; 312 | } 313 | } 314 | .dropzone .dz-preview.dz-success .dz-progress, 315 | .dropzone-previews .dz-preview.dz-success .dz-progress { 316 | display: block; 317 | opacity: 0; 318 | -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; 319 | filter: alpha(opacity=0); 320 | -webkit-transition: opacity 0.4s ease-in-out; 321 | -moz-transition: opacity 0.4s ease-in-out; 322 | -o-transition: opacity 0.4s ease-in-out; 323 | -ms-transition: opacity 0.4s ease-in-out; 324 | transition: opacity 0.4s ease-in-out; 325 | } 326 | .dropzone .dz-preview .dz-error-message, 327 | .dropzone-previews .dz-preview .dz-error-message { 328 | display: block; 329 | opacity: 0; 330 | -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; 331 | filter: alpha(opacity=0); 332 | -webkit-transition: opacity 0.3s ease-in-out; 333 | -moz-transition: opacity 0.3s ease-in-out; 334 | -o-transition: opacity 0.3s ease-in-out; 335 | -ms-transition: opacity 0.3s ease-in-out; 336 | transition: opacity 0.3s ease-in-out; 337 | } 338 | .dropzone .dz-preview:hover.dz-error .dz-error-message, 339 | .dropzone-previews .dz-preview:hover.dz-error .dz-error-message { 340 | opacity: 1; 341 | -ms-filter: none; 342 | filter: none; 343 | } 344 | .dropzone a.dz-remove, 345 | .dropzone-previews a.dz-remove { 346 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fafafa), color-stop(1, #eee)); 347 | background-image: -webkit-linear-gradient(top, #fafafa 0, #eee 100%); 348 | background-image: -moz-linear-gradient(top, #fafafa 0, #eee 100%); 349 | background-image: -o-linear-gradient(top, #fafafa 0, #eee 100%); 350 | background-image: -ms-linear-gradient(top, #fafafa 0, #eee 100%); 351 | background-image: linear-gradient(top, #fafafa 0, #eee 100%); 352 | -webkit-border-radius: 2px; 353 | border-radius: 2px; 354 | border: 1px solid #eee; 355 | text-decoration: none; 356 | display: block; 357 | padding: 4px 5px; 358 | text-align: center; 359 | color: #aaa; 360 | margin-top: 26px; 361 | } 362 | .dropzone a.dz-remove:hover, 363 | .dropzone-previews a.dz-remove:hover { 364 | color: #666; 365 | } 366 | @-moz-keyframes loading { 367 | 0% { 368 | background-position: 0 -400px; 369 | } 370 | 371 | 100% { 372 | background-position: -7px -400px; 373 | } 374 | } 375 | @-webkit-keyframes loading { 376 | 0% { 377 | background-position: 0 -400px; 378 | } 379 | 380 | 100% { 381 | background-position: -7px -400px; 382 | } 383 | } 384 | @-o-keyframes loading { 385 | 0% { 386 | background-position: 0 -400px; 387 | } 388 | 389 | 100% { 390 | background-position: -7px -400px; 391 | } 392 | } 393 | @-ms-keyframes loading { 394 | 0% { 395 | background-position: 0 -400px; 396 | } 397 | 398 | 100% { 399 | background-position: -7px -400px; 400 | } 401 | } 402 | @keyframes loading { 403 | 0% { 404 | background-position: 0 -400px; 405 | } 406 | 407 | 100% { 408 | background-position: -7px -400px; 409 | } 410 | } 411 | -------------------------------------------------------------------------------- /mysite/main/static/main/css/stylus/basic.styl: -------------------------------------------------------------------------------- 1 | /* The MIT License */ 2 | // Copyright (c) 2012 Matias Meno 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | // of the Software, and to permit persons to whom the Software is furnished to do 8 | // so, subject to the following conditions: 9 | 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | // SOFTWARE. 20 | 21 | @import "nib" 22 | 23 | .dropzone 24 | .dropzone * 25 | .dropzone-previews 26 | .dropzone-previews * 27 | box-sizing border-box 28 | 29 | 30 | .dropzone 31 | position relative 32 | border 1px solid rgba(0, 0, 0, 0.08) 33 | background rgba(0, 0, 0, 0.02) 34 | padding 1em 35 | 36 | &.dz-clickable 37 | cursor pointer 38 | .dz-message 39 | .dz-message span 40 | cursor pointer 41 | * 42 | cursor default 43 | 44 | .dz-message 45 | opacity 1 46 | 47 | &.dz-drag-hover 48 | border-color rgba(0, 0, 0, 0.15) 49 | background rgba(0, 0, 0, 0.04) 50 | 51 | &.dz-started 52 | .dz-message 53 | display none 54 | 55 | .dropzone 56 | .dropzone-previews 57 | .dz-preview 58 | background rgba(255, 255, 255, 0.8) 59 | position relative 60 | display inline-block 61 | margin 17px 62 | 63 | vertical-align top 64 | 65 | border 1px solid #acacac 66 | 67 | padding 6px 6px 6px 6px 68 | 69 | &.dz-file-preview 70 | [data-dz-thumbnail] 71 | display none 72 | 73 | .dz-details 74 | width 100px 75 | height @width 76 | position relative 77 | background #ebebeb 78 | padding 5px 79 | margin-bottom 22px 80 | 81 | .dz-filename 82 | overflow hidden 83 | height 100% 84 | 85 | 86 | img 87 | absolute top left 88 | width @width 89 | height @width 90 | 91 | .dz-size 92 | absolute bottom -28px left 3px 93 | height 28px 94 | line-height @height 95 | 96 | 97 | &.dz-error 98 | .dz-error-mark 99 | display block 100 | &.dz-success 101 | .dz-success-mark 102 | display block 103 | 104 | 105 | &:hover 106 | .dz-details 107 | img 108 | display none 109 | 110 | 111 | .dz-success-mark 112 | .dz-error-mark 113 | display none 114 | position absolute 115 | 116 | width 40px 117 | height 40px 118 | 119 | font-size 30px 120 | text-align center 121 | right -10px 122 | top -10px 123 | 124 | .dz-success-mark 125 | color #8CC657 126 | .dz-error-mark 127 | color #EE162D 128 | 129 | 130 | .dz-progress 131 | position absolute 132 | top 100px 133 | left 6px 134 | right 6px 135 | height 6px 136 | background #d7d7d7 137 | display none 138 | 139 | .dz-upload 140 | position absolute 141 | top 0 142 | bottom 0 143 | left 0 144 | width 0% 145 | background-color #8CC657 146 | 147 | 148 | &.dz-processing 149 | .dz-progress 150 | display block 151 | 152 | 153 | .dz-error-message 154 | display none 155 | absolute top -5px left -20px 156 | background rgba(245, 245, 245, 0.8) 157 | padding 8px 10px 158 | color #800 159 | min-width 140px 160 | max-width 500px 161 | z-index 500 162 | &:hover.dz-error 163 | .dz-error-message 164 | display block 165 | -------------------------------------------------------------------------------- /mysite/main/static/main/css/stylus/dropzone.styl: -------------------------------------------------------------------------------- 1 | /* The MIT License */ 2 | // Copyright (c) 2012 Matias Meno 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | // this software and associated documentation files (the "Software"), to deal in 5 | // the Software without restriction, including without limitation the rights to 6 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | // of the Software, and to permit persons to whom the Software is furnished to do 8 | // so, subject to the following conditions: 9 | 10 | // The above copyright notice and this permission notice shall be included in all 11 | // copies or substantial portions of the Software. 12 | 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | // SOFTWARE. 20 | 21 | @import "nib" 22 | @import "basic" 23 | 24 | @keyframes loading 25 | from 26 | background-position: 0 -400px 27 | to 28 | background-position: -7px -400px 29 | 30 | .dropzone 31 | border 1px solid rgba(0, 0, 0, 0.03) 32 | min-height 360px 33 | border-radius 3px 34 | background rgba(0, 0, 0, 0.03) 35 | 36 | padding 23px 37 | 38 | .dz-default.dz-message 39 | opacity 1 40 | transition opacity 0.3s ease-in-out 41 | 42 | image "../images/spritemap.png" 428px 406px 43 | background-repeat no-repeat 44 | background-position 0 0 45 | 46 | position absolute 47 | width 428px 48 | height 123px 49 | margin-left -(@width / 2) 50 | margin-top -(@height / 2) 51 | top 50% 52 | left 50% 53 | span 54 | display none 55 | 56 | &.dz-square 57 | .dz-default.dz-message 58 | background-position 0 -123px 59 | width 268px 60 | margin-left -(@width / 2) 61 | height 174px 62 | margin-top -(@height / 2) 63 | 64 | &.dz-drag-hover 65 | .dz-message 66 | opacity 0.15 67 | 68 | &.dz-started 69 | .dz-message 70 | display block 71 | opacity 0 // Rather fade out nicely 72 | 73 | 74 | .dropzone 75 | .dropzone-previews 76 | 77 | .dz-preview 78 | box-shadow 1px 1px 4px rgba(0, 0, 0, 0.16) 79 | font-size 14px 80 | 81 | 82 | .dz-details 83 | 84 | // Not implemented yet. This is the CSS definition of the file 85 | // content as text. 86 | // .content 87 | // font-size 3px 88 | // white-space pre 89 | // position absolute 90 | // top 5px 91 | // left 12px 92 | // right 19px 93 | // bottom 5px 94 | // overflow hidden 95 | // line-height 100% 96 | // cursor default 97 | // word-wrap break-word 98 | 99 | &.dz-image-preview 100 | &:hover 101 | .dz-details 102 | img 103 | display block 104 | opacity 0.1 105 | 106 | &.dz-success 107 | .dz-success-mark 108 | opacity 1 109 | &.dz-error 110 | .dz-error-mark 111 | opacity 1 112 | .dz-progress .dz-upload 113 | background #EE1E2D 114 | 115 | .dz-error-mark 116 | .dz-success-mark 117 | display block 118 | opacity 0 // Fade in / out 119 | transition opacity 0.4s ease-in-out 120 | image "../images/spritemap.png" 428px 406px 121 | background-repeat no-repeat 122 | 123 | span 124 | display none 125 | .dz-error-mark 126 | background-position -268px -123px 127 | .dz-success-mark 128 | background-position -268px -163px 129 | 130 | 131 | 132 | .dz-progress 133 | .dz-upload 134 | animation loading 0.4s linear infinite 135 | transition width 0.3s ease-in-out 136 | border-radius 2px 137 | position absolute 138 | top 0 139 | left 0 140 | width 0% 141 | height 100% 142 | 143 | image "../images/spritemap.png" 428px 406px 144 | background-repeat repeat-x 145 | background-position 0px -400px 146 | 147 | 148 | &.dz-success 149 | .dz-progress 150 | display block 151 | opacity 0 152 | transition opacity 0.4s ease-in-out 153 | 154 | 155 | // Disabled for now until I find a better way to cope with long filenames 156 | // .filename 157 | // span 158 | // overflow ellipsis 159 | 160 | .dz-error-message 161 | display block 162 | opacity 0 // Rather fade in / out 163 | transition opacity 0.3s ease-in-out 164 | 165 | &:hover.dz-error 166 | .dz-error-message 167 | opacity 1 168 | 169 | a.dz-remove 170 | background-image linear-gradient(top, #fafafa, #eee) 171 | border-radius 2px 172 | border 1px solid #eee 173 | text-decoration none 174 | display block 175 | padding 4px 5px 176 | text-align center 177 | color #aaa 178 | margin-top 26px 179 | &:hover 180 | color #666 181 | 182 | -------------------------------------------------------------------------------- /mysite/main/static/main/images/spritemap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amatellanes/dropzonejs-django-file-upload/abd8ceae931ee14e89d748d595c8e402d78cb9f6/mysite/main/static/main/images/spritemap.png -------------------------------------------------------------------------------- /mysite/main/static/main/images/spritemap@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amatellanes/dropzonejs-django-file-upload/abd8ceae931ee14e89d748d595c8e402d78cb9f6/mysite/main/static/main/images/spritemap@2x.png -------------------------------------------------------------------------------- /mysite/main/static/main/js/dropzone-amd-module.js: -------------------------------------------------------------------------------- 1 | // Uses AMD or browser globals to create a jQuery plugin. 2 | (function (factory) { 3 | if (typeof define === 'function' && define.amd) { 4 | // AMD. Register as an anonymous module. 5 | define(['jquery'], factory); 6 | } else { 7 | // Browser globals 8 | factory(jQuery); 9 | } 10 | } (function (jQuery) { 11 | var module = { exports: { } }; // Fake component 12 | 13 | 14 | /** 15 | * Expose `Emitter`. 16 | */ 17 | 18 | module.exports = Emitter; 19 | 20 | /** 21 | * Initialize a new `Emitter`. 22 | * 23 | * @api public 24 | */ 25 | 26 | function Emitter(obj) { 27 | if (obj) return mixin(obj); 28 | }; 29 | 30 | /** 31 | * Mixin the emitter properties. 32 | * 33 | * @param {Object} obj 34 | * @return {Object} 35 | * @api private 36 | */ 37 | 38 | function mixin(obj) { 39 | for (var key in Emitter.prototype) { 40 | obj[key] = Emitter.prototype[key]; 41 | } 42 | return obj; 43 | } 44 | 45 | /** 46 | * Listen on the given `event` with `fn`. 47 | * 48 | * @param {String} event 49 | * @param {Function} fn 50 | * @return {Emitter} 51 | * @api public 52 | */ 53 | 54 | Emitter.prototype.on = function(event, fn){ 55 | this._callbacks = this._callbacks || {}; 56 | (this._callbacks[event] = this._callbacks[event] || []) 57 | .push(fn); 58 | return this; 59 | }; 60 | 61 | /** 62 | * Adds an `event` listener that will be invoked a single 63 | * time then automatically removed. 64 | * 65 | * @param {String} event 66 | * @param {Function} fn 67 | * @return {Emitter} 68 | * @api public 69 | */ 70 | 71 | Emitter.prototype.once = function(event, fn){ 72 | var self = this; 73 | this._callbacks = this._callbacks || {}; 74 | 75 | function on() { 76 | self.off(event, on); 77 | fn.apply(this, arguments); 78 | } 79 | 80 | fn._off = on; 81 | this.on(event, on); 82 | return this; 83 | }; 84 | 85 | /** 86 | * Remove the given callback for `event` or all 87 | * registered callbacks. 88 | * 89 | * @param {String} event 90 | * @param {Function} fn 91 | * @return {Emitter} 92 | * @api public 93 | */ 94 | 95 | Emitter.prototype.off = 96 | Emitter.prototype.removeListener = 97 | Emitter.prototype.removeAllListeners = function(event, fn){ 98 | this._callbacks = this._callbacks || {}; 99 | var callbacks = this._callbacks[event]; 100 | if (!callbacks) return this; 101 | 102 | // remove all handlers 103 | if (1 == arguments.length) { 104 | delete this._callbacks[event]; 105 | return this; 106 | } 107 | 108 | // remove specific handler 109 | var i = callbacks.indexOf(fn._off || fn); 110 | if (~i) callbacks.splice(i, 1); 111 | return this; 112 | }; 113 | 114 | /** 115 | * Emit `event` with the given args. 116 | * 117 | * @param {String} event 118 | * @param {Mixed} ... 119 | * @return {Emitter} 120 | */ 121 | 122 | Emitter.prototype.emit = function(event){ 123 | this._callbacks = this._callbacks || {}; 124 | var args = [].slice.call(arguments, 1) 125 | , callbacks = this._callbacks[event]; 126 | 127 | if (callbacks) { 128 | callbacks = callbacks.slice(0); 129 | for (var i = 0, len = callbacks.length; i < len; ++i) { 130 | callbacks[i].apply(this, args); 131 | } 132 | } 133 | 134 | return this; 135 | }; 136 | 137 | /** 138 | * Return array of callbacks for `event`. 139 | * 140 | * @param {String} event 141 | * @return {Array} 142 | * @api public 143 | */ 144 | 145 | Emitter.prototype.listeners = function(event){ 146 | this._callbacks = this._callbacks || {}; 147 | return this._callbacks[event] || []; 148 | }; 149 | 150 | /** 151 | * Check if this emitter has `event` handlers. 152 | * 153 | * @param {String} event 154 | * @return {Boolean} 155 | * @api public 156 | */ 157 | 158 | Emitter.prototype.hasListeners = function(event){ 159 | return !! this.listeners(event).length; 160 | }; 161 | 162 | /* 163 | # 164 | # More info at [www.dropzonejs.com](http://www.dropzonejs.com) 165 | # 166 | # Copyright (c) 2012, Matias Meno 167 | # 168 | # Permission is hereby granted, free of charge, to any person obtaining a copy 169 | # of this software and associated documentation files (the "Software"), to deal 170 | # in the Software without restriction, including without limitation the rights 171 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 172 | # copies of the Software, and to permit persons to whom the Software is 173 | # furnished to do so, subject to the following conditions: 174 | # 175 | # The above copyright notice and this permission notice shall be included in 176 | # all copies or substantial portions of the Software. 177 | # 178 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 179 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 180 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 181 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 182 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 183 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 184 | # THE SOFTWARE. 185 | # 186 | */ 187 | 188 | 189 | (function() { 190 | var Dropzone, Em, camelize, contentLoaded, noop, without, 191 | __hasProp = {}.hasOwnProperty, 192 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, 193 | __slice = [].slice; 194 | 195 | Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter"); 196 | 197 | noop = function() {}; 198 | 199 | Dropzone = (function(_super) { 200 | var extend; 201 | 202 | __extends(Dropzone, _super); 203 | 204 | /* 205 | This is a list of all available events you can register on a dropzone object. 206 | 207 | You can register an event handler like this: 208 | 209 | dropzone.on("dragEnter", function() { }); 210 | */ 211 | 212 | 213 | Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded"]; 214 | 215 | Dropzone.prototype.defaultOptions = { 216 | url: null, 217 | method: "post", 218 | withCredentials: false, 219 | parallelUploads: 2, 220 | uploadMultiple: false, 221 | maxFilesize: 256, 222 | paramName: "file", 223 | createImageThumbnails: true, 224 | maxThumbnailFilesize: 10, 225 | thumbnailWidth: 100, 226 | thumbnailHeight: 100, 227 | maxFiles: null, 228 | params: {}, 229 | clickable: true, 230 | ignoreHiddenFiles: true, 231 | acceptedFiles: null, 232 | acceptedMimeTypes: null, 233 | autoProcessQueue: true, 234 | addRemoveLinks: false, 235 | previewsContainer: null, 236 | dictDefaultMessage: "Drop files here to upload", 237 | dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.", 238 | dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.", 239 | dictFileTooBig: "File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.", 240 | dictInvalidFileType: "You can't upload files of this type.", 241 | dictResponseError: "Server responded with {{statusCode}} code.", 242 | dictCancelUpload: "Cancel upload", 243 | dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?", 244 | dictRemoveFile: "Remove file", 245 | dictRemoveFileConfirmation: null, 246 | dictMaxFilesExceeded: "You can only upload {{maxFiles}} files.", 247 | accept: function(file, done) { 248 | return done(); 249 | }, 250 | init: function() { 251 | return noop; 252 | }, 253 | forceFallback: false, 254 | fallback: function() { 255 | var child, messageElement, span, _i, _len, _ref; 256 | this.element.className = "" + this.element.className + " dz-browser-not-supported"; 257 | _ref = this.element.getElementsByTagName("div"); 258 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 259 | child = _ref[_i]; 260 | if (/(^| )dz-message($| )/.test(child.className)) { 261 | messageElement = child; 262 | child.className = "dz-message"; 263 | continue; 264 | } 265 | } 266 | if (!messageElement) { 267 | messageElement = Dropzone.createElement("
"); 268 | this.element.appendChild(messageElement); 269 | } 270 | span = messageElement.getElementsByTagName("span")[0]; 271 | if (span) { 272 | span.textContent = this.options.dictFallbackMessage; 273 | } 274 | return this.element.appendChild(this.getFallbackForm()); 275 | }, 276 | resize: function(file) { 277 | var info, srcRatio, trgRatio; 278 | info = { 279 | srcX: 0, 280 | srcY: 0, 281 | srcWidth: file.width, 282 | srcHeight: file.height 283 | }; 284 | srcRatio = file.width / file.height; 285 | trgRatio = this.options.thumbnailWidth / this.options.thumbnailHeight; 286 | if (file.height < this.options.thumbnailHeight || file.width < this.options.thumbnailWidth) { 287 | info.trgHeight = info.srcHeight; 288 | info.trgWidth = info.srcWidth; 289 | } else { 290 | if (srcRatio > trgRatio) { 291 | info.srcHeight = file.height; 292 | info.srcWidth = info.srcHeight * trgRatio; 293 | } else { 294 | info.srcWidth = file.width; 295 | info.srcHeight = info.srcWidth / trgRatio; 296 | } 297 | } 298 | info.srcX = (file.width - info.srcWidth) / 2; 299 | info.srcY = (file.height - info.srcHeight) / 2; 300 | return info; 301 | }, 302 | /* 303 | Those functions register themselves to the events on init and handle all 304 | the user interface specific stuff. Overwriting them won't break the upload 305 | but can break the way it's displayed. 306 | You can overwrite them if you don't like the default behavior. If you just 307 | want to add an additional event handler, register it on the dropzone object 308 | and don't overwrite those options. 309 | */ 310 | 311 | drop: function(e) { 312 | return this.element.classList.remove("dz-drag-hover"); 313 | }, 314 | dragstart: noop, 315 | dragend: function(e) { 316 | return this.element.classList.remove("dz-drag-hover"); 317 | }, 318 | dragenter: function(e) { 319 | return this.element.classList.add("dz-drag-hover"); 320 | }, 321 | dragover: function(e) { 322 | return this.element.classList.add("dz-drag-hover"); 323 | }, 324 | dragleave: function(e) { 325 | return this.element.classList.remove("dz-drag-hover"); 326 | }, 327 | selectedfiles: function(files) { 328 | if (this.element === this.previewsContainer) { 329 | return this.element.classList.add("dz-started"); 330 | } 331 | }, 332 | reset: function() { 333 | return this.element.classList.remove("dz-started"); 334 | }, 335 | addedfile: function(file) { 336 | var _this = this; 337 | file.previewElement = Dropzone.createElement(this.options.previewTemplate); 338 | file.previewTemplate = file.previewElement; 339 | this.previewsContainer.appendChild(file.previewElement); 340 | file.previewElement.querySelector("[data-dz-name]").textContent = file.name; 341 | file.previewElement.querySelector("[data-dz-size]").innerHTML = this.filesize(file.size); 342 | if (this.options.addRemoveLinks) { 343 | file._removeLink = Dropzone.createElement("" + this.options.dictRemoveFile + ""); 344 | file._removeLink.addEventListener("click", function(e) { 345 | e.preventDefault(); 346 | e.stopPropagation(); 347 | if (file.status === Dropzone.UPLOADING) { 348 | return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() { 349 | return _this.removeFile(file); 350 | }); 351 | } else { 352 | if (_this.options.dictRemoveFileConfirmation) { 353 | return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() { 354 | return _this.removeFile(file); 355 | }); 356 | } else { 357 | return _this.removeFile(file); 358 | } 359 | } 360 | }); 361 | file.previewElement.appendChild(file._removeLink); 362 | } 363 | return this._updateMaxFilesReachedClass(); 364 | }, 365 | removedfile: function(file) { 366 | var _ref; 367 | if ((_ref = file.previewElement) != null) { 368 | _ref.parentNode.removeChild(file.previewElement); 369 | } 370 | return this._updateMaxFilesReachedClass(); 371 | }, 372 | thumbnail: function(file, dataUrl) { 373 | var thumbnailElement; 374 | file.previewElement.classList.remove("dz-file-preview"); 375 | file.previewElement.classList.add("dz-image-preview"); 376 | thumbnailElement = file.previewElement.querySelector("[data-dz-thumbnail]"); 377 | thumbnailElement.alt = file.name; 378 | return thumbnailElement.src = dataUrl; 379 | }, 380 | error: function(file, message) { 381 | file.previewElement.classList.add("dz-error"); 382 | return file.previewElement.querySelector("[data-dz-errormessage]").textContent = message; 383 | }, 384 | errormultiple: noop, 385 | processing: function(file) { 386 | file.previewElement.classList.add("dz-processing"); 387 | if (file._removeLink) { 388 | return file._removeLink.textContent = this.options.dictCancelUpload; 389 | } 390 | }, 391 | processingmultiple: noop, 392 | uploadprogress: function(file, progress, bytesSent) { 393 | return file.previewElement.querySelector("[data-dz-uploadprogress]").style.width = "" + progress + "%"; 394 | }, 395 | totaluploadprogress: noop, 396 | sending: noop, 397 | sendingmultiple: noop, 398 | success: function(file) { 399 | return file.previewElement.classList.add("dz-success"); 400 | }, 401 | successmultiple: noop, 402 | canceled: function(file) { 403 | return this.emit("error", file, "Upload canceled."); 404 | }, 405 | canceledmultiple: noop, 406 | complete: function(file) { 407 | if (file._removeLink) { 408 | return file._removeLink.textContent = this.options.dictRemoveFile; 409 | } 410 | }, 411 | completemultiple: noop, 412 | maxfilesexceeded: noop, 413 | previewTemplate: "
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
" 414 | }; 415 | 416 | extend = function() { 417 | var key, object, objects, target, val, _i, _len; 418 | target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : []; 419 | for (_i = 0, _len = objects.length; _i < _len; _i++) { 420 | object = objects[_i]; 421 | for (key in object) { 422 | val = object[key]; 423 | target[key] = val; 424 | } 425 | } 426 | return target; 427 | }; 428 | 429 | function Dropzone(element, options) { 430 | var elementOptions, fallback, _ref; 431 | this.element = element; 432 | this.version = Dropzone.version; 433 | this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, ""); 434 | this.clickableElements = []; 435 | this.listeners = []; 436 | this.files = []; 437 | if (typeof this.element === "string") { 438 | this.element = document.querySelector(this.element); 439 | } 440 | if (!(this.element && (this.element.nodeType != null))) { 441 | throw new Error("Invalid dropzone element."); 442 | } 443 | if (this.element.dropzone) { 444 | throw new Error("Dropzone already attached."); 445 | } 446 | Dropzone.instances.push(this); 447 | element.dropzone = this; 448 | elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {}; 449 | this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {}); 450 | if (this.options.forceFallback || !Dropzone.isBrowserSupported()) { 451 | return this.options.fallback.call(this); 452 | } 453 | if (this.options.url == null) { 454 | this.options.url = this.element.getAttribute("action"); 455 | } 456 | if (!this.options.url) { 457 | throw new Error("No URL provided."); 458 | } 459 | if (this.options.acceptedFiles && this.options.acceptedMimeTypes) { 460 | throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated."); 461 | } 462 | if (this.options.acceptedMimeTypes) { 463 | this.options.acceptedFiles = this.options.acceptedMimeTypes; 464 | delete this.options.acceptedMimeTypes; 465 | } 466 | this.options.method = this.options.method.toUpperCase(); 467 | if ((fallback = this.getExistingFallback()) && fallback.parentNode) { 468 | fallback.parentNode.removeChild(fallback); 469 | } 470 | if (this.options.previewsContainer) { 471 | this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer"); 472 | } else { 473 | this.previewsContainer = this.element; 474 | } 475 | if (this.options.clickable) { 476 | if (this.options.clickable === true) { 477 | this.clickableElements = [this.element]; 478 | } else { 479 | this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable"); 480 | } 481 | } 482 | this.init(); 483 | } 484 | 485 | Dropzone.prototype.getAcceptedFiles = function() { 486 | var file, _i, _len, _ref, _results; 487 | _ref = this.files; 488 | _results = []; 489 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 490 | file = _ref[_i]; 491 | if (file.accepted) { 492 | _results.push(file); 493 | } 494 | } 495 | return _results; 496 | }; 497 | 498 | Dropzone.prototype.getRejectedFiles = function() { 499 | var file, _i, _len, _ref, _results; 500 | _ref = this.files; 501 | _results = []; 502 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 503 | file = _ref[_i]; 504 | if (!file.accepted) { 505 | _results.push(file); 506 | } 507 | } 508 | return _results; 509 | }; 510 | 511 | Dropzone.prototype.getQueuedFiles = function() { 512 | var file, _i, _len, _ref, _results; 513 | _ref = this.files; 514 | _results = []; 515 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 516 | file = _ref[_i]; 517 | if (file.status === Dropzone.QUEUED) { 518 | _results.push(file); 519 | } 520 | } 521 | return _results; 522 | }; 523 | 524 | Dropzone.prototype.getUploadingFiles = function() { 525 | var file, _i, _len, _ref, _results; 526 | _ref = this.files; 527 | _results = []; 528 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 529 | file = _ref[_i]; 530 | if (file.status === Dropzone.UPLOADING) { 531 | _results.push(file); 532 | } 533 | } 534 | return _results; 535 | }; 536 | 537 | Dropzone.prototype.init = function() { 538 | var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1, 539 | _this = this; 540 | if (this.element.tagName === "form") { 541 | this.element.setAttribute("enctype", "multipart/form-data"); 542 | } 543 | if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) { 544 | this.element.appendChild(Dropzone.createElement("
" + this.options.dictDefaultMessage + "
")); 545 | } 546 | if (this.clickableElements.length) { 547 | setupHiddenFileInput = function() { 548 | if (_this.hiddenFileInput) { 549 | document.body.removeChild(_this.hiddenFileInput); 550 | } 551 | _this.hiddenFileInput = document.createElement("input"); 552 | _this.hiddenFileInput.setAttribute("type", "file"); 553 | _this.hiddenFileInput.setAttribute("multiple", "multiple"); 554 | if (_this.options.acceptedFiles != null) { 555 | _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles); 556 | } 557 | _this.hiddenFileInput.style.visibility = "hidden"; 558 | _this.hiddenFileInput.style.position = "absolute"; 559 | _this.hiddenFileInput.style.top = "0"; 560 | _this.hiddenFileInput.style.left = "0"; 561 | _this.hiddenFileInput.style.height = "0"; 562 | _this.hiddenFileInput.style.width = "0"; 563 | document.body.appendChild(_this.hiddenFileInput); 564 | return _this.hiddenFileInput.addEventListener("change", function() { 565 | var files; 566 | files = _this.hiddenFileInput.files; 567 | if (files.length) { 568 | _this.emit("selectedfiles", files); 569 | _this.handleFiles(files); 570 | } 571 | return setupHiddenFileInput(); 572 | }); 573 | }; 574 | setupHiddenFileInput(); 575 | } 576 | this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL; 577 | _ref1 = this.events; 578 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) { 579 | eventName = _ref1[_i]; 580 | this.on(eventName, this.options[eventName]); 581 | } 582 | this.on("uploadprogress", function() { 583 | return _this.updateTotalUploadProgress(); 584 | }); 585 | this.on("removedfile", function() { 586 | return _this.updateTotalUploadProgress(); 587 | }); 588 | this.on("canceled", function(file) { 589 | return _this.emit("complete", file); 590 | }); 591 | noPropagation = function(e) { 592 | e.stopPropagation(); 593 | if (e.preventDefault) { 594 | return e.preventDefault(); 595 | } else { 596 | return e.returnValue = false; 597 | } 598 | }; 599 | this.listeners = [ 600 | { 601 | element: this.element, 602 | events: { 603 | "dragstart": function(e) { 604 | return _this.emit("dragstart", e); 605 | }, 606 | "dragenter": function(e) { 607 | noPropagation(e); 608 | return _this.emit("dragenter", e); 609 | }, 610 | "dragover": function(e) { 611 | noPropagation(e); 612 | return _this.emit("dragover", e); 613 | }, 614 | "dragleave": function(e) { 615 | return _this.emit("dragleave", e); 616 | }, 617 | "drop": function(e) { 618 | noPropagation(e); 619 | return _this.drop(e); 620 | }, 621 | "dragend": function(e) { 622 | return _this.emit("dragend", e); 623 | } 624 | } 625 | } 626 | ]; 627 | this.clickableElements.forEach(function(clickableElement) { 628 | return _this.listeners.push({ 629 | element: clickableElement, 630 | events: { 631 | "click": function(evt) { 632 | if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) { 633 | return _this.hiddenFileInput.click(); 634 | } 635 | } 636 | } 637 | }); 638 | }); 639 | this.enable(); 640 | return this.options.init.call(this); 641 | }; 642 | 643 | Dropzone.prototype.destroy = function() { 644 | var _ref; 645 | this.disable(); 646 | this.removeAllFiles(true); 647 | if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) { 648 | this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput); 649 | this.hiddenFileInput = null; 650 | } 651 | return delete this.element.dropzone; 652 | }; 653 | 654 | Dropzone.prototype.updateTotalUploadProgress = function() { 655 | var acceptedFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref; 656 | totalBytesSent = 0; 657 | totalBytes = 0; 658 | acceptedFiles = this.getAcceptedFiles(); 659 | if (acceptedFiles.length) { 660 | _ref = this.getAcceptedFiles(); 661 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 662 | file = _ref[_i]; 663 | totalBytesSent += file.upload.bytesSent; 664 | totalBytes += file.upload.total; 665 | } 666 | totalUploadProgress = 100 * totalBytesSent / totalBytes; 667 | } else { 668 | totalUploadProgress = 100; 669 | } 670 | return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent); 671 | }; 672 | 673 | Dropzone.prototype.getFallbackForm = function() { 674 | var existingFallback, fields, fieldsString, form; 675 | if (existingFallback = this.getExistingFallback()) { 676 | return existingFallback; 677 | } 678 | fieldsString = "
"; 679 | if (this.options.dictFallbackText) { 680 | fieldsString += "

" + this.options.dictFallbackText + "

"; 681 | } 682 | fieldsString += "
"; 683 | fields = Dropzone.createElement(fieldsString); 684 | if (this.element.tagName !== "FORM") { 685 | form = Dropzone.createElement("
"); 686 | form.appendChild(fields); 687 | } else { 688 | this.element.setAttribute("enctype", "multipart/form-data"); 689 | this.element.setAttribute("method", this.options.method); 690 | } 691 | return form != null ? form : fields; 692 | }; 693 | 694 | Dropzone.prototype.getExistingFallback = function() { 695 | var fallback, getFallback, tagName, _i, _len, _ref; 696 | getFallback = function(elements) { 697 | var el, _i, _len; 698 | for (_i = 0, _len = elements.length; _i < _len; _i++) { 699 | el = elements[_i]; 700 | if (/(^| )fallback($| )/.test(el.className)) { 701 | return el; 702 | } 703 | } 704 | }; 705 | _ref = ["div", "form"]; 706 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 707 | tagName = _ref[_i]; 708 | if (fallback = getFallback(this.element.getElementsByTagName(tagName))) { 709 | return fallback; 710 | } 711 | } 712 | }; 713 | 714 | Dropzone.prototype.setupEventListeners = function() { 715 | var elementListeners, event, listener, _i, _len, _ref, _results; 716 | _ref = this.listeners; 717 | _results = []; 718 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 719 | elementListeners = _ref[_i]; 720 | _results.push((function() { 721 | var _ref1, _results1; 722 | _ref1 = elementListeners.events; 723 | _results1 = []; 724 | for (event in _ref1) { 725 | listener = _ref1[event]; 726 | _results1.push(elementListeners.element.addEventListener(event, listener, false)); 727 | } 728 | return _results1; 729 | })()); 730 | } 731 | return _results; 732 | }; 733 | 734 | Dropzone.prototype.removeEventListeners = function() { 735 | var elementListeners, event, listener, _i, _len, _ref, _results; 736 | _ref = this.listeners; 737 | _results = []; 738 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 739 | elementListeners = _ref[_i]; 740 | _results.push((function() { 741 | var _ref1, _results1; 742 | _ref1 = elementListeners.events; 743 | _results1 = []; 744 | for (event in _ref1) { 745 | listener = _ref1[event]; 746 | _results1.push(elementListeners.element.removeEventListener(event, listener, false)); 747 | } 748 | return _results1; 749 | })()); 750 | } 751 | return _results; 752 | }; 753 | 754 | Dropzone.prototype.disable = function() { 755 | var file, _i, _len, _ref, _results; 756 | this.clickableElements.forEach(function(element) { 757 | return element.classList.remove("dz-clickable"); 758 | }); 759 | this.removeEventListeners(); 760 | _ref = this.files; 761 | _results = []; 762 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 763 | file = _ref[_i]; 764 | _results.push(this.cancelUpload(file)); 765 | } 766 | return _results; 767 | }; 768 | 769 | Dropzone.prototype.enable = function() { 770 | this.clickableElements.forEach(function(element) { 771 | return element.classList.add("dz-clickable"); 772 | }); 773 | return this.setupEventListeners(); 774 | }; 775 | 776 | Dropzone.prototype.filesize = function(size) { 777 | var string; 778 | if (size >= 100000000000) { 779 | size = size / 100000000000; 780 | string = "TB"; 781 | } else if (size >= 100000000) { 782 | size = size / 100000000; 783 | string = "GB"; 784 | } else if (size >= 100000) { 785 | size = size / 100000; 786 | string = "MB"; 787 | } else if (size >= 100) { 788 | size = size / 100; 789 | string = "KB"; 790 | } else { 791 | size = size * 10; 792 | string = "b"; 793 | } 794 | return "" + (Math.round(size) / 10) + " " + string; 795 | }; 796 | 797 | Dropzone.prototype._updateMaxFilesReachedClass = function() { 798 | if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) { 799 | return this.element.classList.add("dz-max-files-reached"); 800 | } else { 801 | return this.element.classList.remove("dz-max-files-reached"); 802 | } 803 | }; 804 | 805 | Dropzone.prototype.drop = function(e) { 806 | var files, items; 807 | if (!e.dataTransfer) { 808 | return; 809 | } 810 | this.emit("drop", e); 811 | files = e.dataTransfer.files; 812 | this.emit("selectedfiles", files); 813 | if (files.length) { 814 | items = e.dataTransfer.items; 815 | if (items && items.length && ((items[0].webkitGetAsEntry != null) || (items[0].getAsEntry != null))) { 816 | this.handleItems(items); 817 | } else { 818 | this.handleFiles(files); 819 | } 820 | } 821 | }; 822 | 823 | Dropzone.prototype.handleFiles = function(files) { 824 | var file, _i, _len, _results; 825 | _results = []; 826 | for (_i = 0, _len = files.length; _i < _len; _i++) { 827 | file = files[_i]; 828 | _results.push(this.addFile(file)); 829 | } 830 | return _results; 831 | }; 832 | 833 | Dropzone.prototype.handleItems = function(items) { 834 | var entry, item, _i, _len; 835 | for (_i = 0, _len = items.length; _i < _len; _i++) { 836 | item = items[_i]; 837 | if (item.webkitGetAsEntry != null) { 838 | entry = item.webkitGetAsEntry(); 839 | if (entry.isFile) { 840 | this.addFile(item.getAsFile()); 841 | } else if (entry.isDirectory) { 842 | this.addDirectory(entry, entry.name); 843 | } 844 | } else { 845 | this.addFile(item.getAsFile()); 846 | } 847 | } 848 | }; 849 | 850 | Dropzone.prototype.accept = function(file, done) { 851 | if (file.size > this.options.maxFilesize * 1024 * 1024) { 852 | return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize)); 853 | } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) { 854 | return done(this.options.dictInvalidFileType); 855 | } else if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) { 856 | done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles)); 857 | return this.emit("maxfilesexceeded", file); 858 | } else { 859 | return this.options.accept.call(this, file, done); 860 | } 861 | }; 862 | 863 | Dropzone.prototype.addFile = function(file) { 864 | var _this = this; 865 | file.upload = { 866 | progress: 0, 867 | total: file.size, 868 | bytesSent: 0 869 | }; 870 | this.files.push(file); 871 | file.status = Dropzone.ADDED; 872 | this.emit("addedfile", file); 873 | if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) { 874 | this.createThumbnail(file); 875 | } 876 | return this.accept(file, function(error) { 877 | if (error) { 878 | file.accepted = false; 879 | return _this._errorProcessing([file], error); 880 | } else { 881 | return _this.enqueueFile(file); 882 | } 883 | }); 884 | }; 885 | 886 | Dropzone.prototype.enqueueFiles = function(files) { 887 | var file, _i, _len; 888 | for (_i = 0, _len = files.length; _i < _len; _i++) { 889 | file = files[_i]; 890 | this.enqueueFile(file); 891 | } 892 | return null; 893 | }; 894 | 895 | Dropzone.prototype.enqueueFile = function(file) { 896 | var _this = this; 897 | file.accepted = true; 898 | if (file.status === Dropzone.ADDED) { 899 | file.status = Dropzone.QUEUED; 900 | if (this.options.autoProcessQueue) { 901 | return setTimeout((function() { 902 | return _this.processQueue(); 903 | }), 1); 904 | } 905 | } else { 906 | throw new Error("This file can't be queued because it has already been processed or was rejected."); 907 | } 908 | }; 909 | 910 | Dropzone.prototype.addDirectory = function(entry, path) { 911 | var dirReader, entriesReader, 912 | _this = this; 913 | dirReader = entry.createReader(); 914 | entriesReader = function(entries) { 915 | var _i, _len; 916 | for (_i = 0, _len = entries.length; _i < _len; _i++) { 917 | entry = entries[_i]; 918 | if (entry.isFile) { 919 | entry.file(function(file) { 920 | if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') { 921 | return; 922 | } 923 | file.fullPath = "" + path + "/" + file.name; 924 | return _this.addFile(file); 925 | }); 926 | } else if (entry.isDirectory) { 927 | _this.addDirectory(entry, "" + path + "/" + entry.name); 928 | } 929 | } 930 | }; 931 | return dirReader.readEntries(entriesReader, function(error) { 932 | return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0; 933 | }); 934 | }; 935 | 936 | Dropzone.prototype.removeFile = function(file) { 937 | if (file.status === Dropzone.UPLOADING) { 938 | this.cancelUpload(file); 939 | } 940 | this.files = without(this.files, file); 941 | this.emit("removedfile", file); 942 | if (this.files.length === 0) { 943 | return this.emit("reset"); 944 | } 945 | }; 946 | 947 | Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) { 948 | var file, _i, _len, _ref; 949 | if (cancelIfNecessary == null) { 950 | cancelIfNecessary = false; 951 | } 952 | _ref = this.files.slice(); 953 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 954 | file = _ref[_i]; 955 | if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) { 956 | this.removeFile(file); 957 | } 958 | } 959 | return null; 960 | }; 961 | 962 | Dropzone.prototype.createThumbnail = function(file) { 963 | var fileReader, 964 | _this = this; 965 | fileReader = new FileReader; 966 | fileReader.onload = function() { 967 | var img; 968 | img = new Image; 969 | img.onload = function() { 970 | var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3; 971 | file.width = img.width; 972 | file.height = img.height; 973 | resizeInfo = _this.options.resize.call(_this, file); 974 | if (resizeInfo.trgWidth == null) { 975 | resizeInfo.trgWidth = _this.options.thumbnailWidth; 976 | } 977 | if (resizeInfo.trgHeight == null) { 978 | resizeInfo.trgHeight = _this.options.thumbnailHeight; 979 | } 980 | canvas = document.createElement("canvas"); 981 | ctx = canvas.getContext("2d"); 982 | canvas.width = resizeInfo.trgWidth; 983 | canvas.height = resizeInfo.trgHeight; 984 | ctx.drawImage(img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight); 985 | thumbnail = canvas.toDataURL("image/png"); 986 | return _this.emit("thumbnail", file, thumbnail); 987 | }; 988 | return img.src = fileReader.result; 989 | }; 990 | return fileReader.readAsDataURL(file); 991 | }; 992 | 993 | Dropzone.prototype.processQueue = function() { 994 | var i, parallelUploads, processingLength, queuedFiles; 995 | parallelUploads = this.options.parallelUploads; 996 | processingLength = this.getUploadingFiles().length; 997 | i = processingLength; 998 | if (processingLength >= parallelUploads) { 999 | return; 1000 | } 1001 | queuedFiles = this.getQueuedFiles(); 1002 | if (!(queuedFiles.length > 0)) { 1003 | return; 1004 | } 1005 | if (this.options.uploadMultiple) { 1006 | return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength)); 1007 | } else { 1008 | while (i < parallelUploads) { 1009 | if (!queuedFiles.length) { 1010 | return; 1011 | } 1012 | this.processFile(queuedFiles.shift()); 1013 | i++; 1014 | } 1015 | } 1016 | }; 1017 | 1018 | Dropzone.prototype.processFile = function(file) { 1019 | return this.processFiles([file]); 1020 | }; 1021 | 1022 | Dropzone.prototype.processFiles = function(files) { 1023 | var file, _i, _len; 1024 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1025 | file = files[_i]; 1026 | file.processing = true; 1027 | file.status = Dropzone.UPLOADING; 1028 | this.emit("processing", file); 1029 | } 1030 | if (this.options.uploadMultiple) { 1031 | this.emit("processingmultiple", files); 1032 | } 1033 | return this.uploadFiles(files); 1034 | }; 1035 | 1036 | Dropzone.prototype._getFilesWithXhr = function(xhr) { 1037 | var file, files; 1038 | return files = (function() { 1039 | var _i, _len, _ref, _results; 1040 | _ref = this.files; 1041 | _results = []; 1042 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 1043 | file = _ref[_i]; 1044 | if (file.xhr === xhr) { 1045 | _results.push(file); 1046 | } 1047 | } 1048 | return _results; 1049 | }).call(this); 1050 | }; 1051 | 1052 | Dropzone.prototype.cancelUpload = function(file) { 1053 | var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref; 1054 | if (file.status === Dropzone.UPLOADING) { 1055 | groupedFiles = this._getFilesWithXhr(file.xhr); 1056 | for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) { 1057 | groupedFile = groupedFiles[_i]; 1058 | groupedFile.status = Dropzone.CANCELED; 1059 | } 1060 | file.xhr.abort(); 1061 | for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) { 1062 | groupedFile = groupedFiles[_j]; 1063 | this.emit("canceled", groupedFile); 1064 | } 1065 | if (this.options.uploadMultiple) { 1066 | this.emit("canceledmultiple", groupedFiles); 1067 | } 1068 | } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) { 1069 | file.status = Dropzone.CANCELED; 1070 | this.emit("canceled", file); 1071 | if (this.options.uploadMultiple) { 1072 | this.emit("canceledmultiple", [file]); 1073 | } 1074 | } 1075 | if (this.options.autoProcessQueue) { 1076 | return this.processQueue(); 1077 | } 1078 | }; 1079 | 1080 | Dropzone.prototype.uploadFile = function(file) { 1081 | return this.uploadFiles([file]); 1082 | }; 1083 | 1084 | Dropzone.prototype.uploadFiles = function(files) { 1085 | var file, formData, handleError, headerName, headerValue, headers, input, inputName, inputType, key, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, 1086 | _this = this; 1087 | xhr = new XMLHttpRequest(); 1088 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1089 | file = files[_i]; 1090 | file.xhr = xhr; 1091 | } 1092 | xhr.open(this.options.method, this.options.url, true); 1093 | xhr.withCredentials = !!this.options.withCredentials; 1094 | response = null; 1095 | handleError = function() { 1096 | var _j, _len1, _results; 1097 | _results = []; 1098 | for (_j = 0, _len1 = files.length; _j < _len1; _j++) { 1099 | file = files[_j]; 1100 | _results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr)); 1101 | } 1102 | return _results; 1103 | }; 1104 | updateProgress = function(e) { 1105 | var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results; 1106 | if (e != null) { 1107 | progress = 100 * e.loaded / e.total; 1108 | for (_j = 0, _len1 = files.length; _j < _len1; _j++) { 1109 | file = files[_j]; 1110 | file.upload = { 1111 | progress: progress, 1112 | total: e.total, 1113 | bytesSent: e.loaded 1114 | }; 1115 | } 1116 | } else { 1117 | allFilesFinished = true; 1118 | progress = 100; 1119 | for (_k = 0, _len2 = files.length; _k < _len2; _k++) { 1120 | file = files[_k]; 1121 | if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) { 1122 | allFilesFinished = false; 1123 | } 1124 | file.upload.progress = progress; 1125 | file.upload.bytesSent = file.upload.total; 1126 | } 1127 | if (allFilesFinished) { 1128 | return; 1129 | } 1130 | } 1131 | _results = []; 1132 | for (_l = 0, _len3 = files.length; _l < _len3; _l++) { 1133 | file = files[_l]; 1134 | _results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent)); 1135 | } 1136 | return _results; 1137 | }; 1138 | xhr.onload = function(e) { 1139 | var _ref; 1140 | if (files[0].status === Dropzone.CANCELED) { 1141 | return; 1142 | } 1143 | if (xhr.readyState !== 4) { 1144 | return; 1145 | } 1146 | response = xhr.responseText; 1147 | if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) { 1148 | try { 1149 | response = JSON.parse(response); 1150 | } catch (_error) { 1151 | e = _error; 1152 | response = "Invalid JSON response from server."; 1153 | } 1154 | } 1155 | updateProgress(); 1156 | if (!((200 <= (_ref = xhr.status) && _ref < 300))) { 1157 | return handleError(); 1158 | } else { 1159 | return _this._finished(files, response, e); 1160 | } 1161 | }; 1162 | xhr.onerror = function() { 1163 | if (files[0].status === Dropzone.CANCELED) { 1164 | return; 1165 | } 1166 | return handleError(); 1167 | }; 1168 | progressObj = (_ref = xhr.upload) != null ? _ref : xhr; 1169 | progressObj.onprogress = updateProgress; 1170 | headers = { 1171 | "Accept": "application/json", 1172 | "Cache-Control": "no-cache", 1173 | "X-Requested-With": "XMLHttpRequest" 1174 | }; 1175 | if (this.options.headers) { 1176 | extend(headers, this.options.headers); 1177 | } 1178 | for (headerName in headers) { 1179 | headerValue = headers[headerName]; 1180 | xhr.setRequestHeader(headerName, headerValue); 1181 | } 1182 | formData = new FormData(); 1183 | if (this.options.params) { 1184 | _ref1 = this.options.params; 1185 | for (key in _ref1) { 1186 | value = _ref1[key]; 1187 | formData.append(key, value); 1188 | } 1189 | } 1190 | for (_j = 0, _len1 = files.length; _j < _len1; _j++) { 1191 | file = files[_j]; 1192 | this.emit("sending", file, xhr, formData); 1193 | } 1194 | if (this.options.uploadMultiple) { 1195 | this.emit("sendingmultiple", files, xhr, formData); 1196 | } 1197 | if (this.element.tagName === "FORM") { 1198 | _ref2 = this.element.querySelectorAll("input, textarea, select, button"); 1199 | for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { 1200 | input = _ref2[_k]; 1201 | inputName = input.getAttribute("name"); 1202 | inputType = input.getAttribute("type"); 1203 | if (!inputType || ((_ref3 = inputType.toLowerCase()) !== "checkbox" && _ref3 !== "radio") || input.checked) { 1204 | formData.append(inputName, input.value); 1205 | } 1206 | } 1207 | } 1208 | for (_l = 0, _len3 = files.length; _l < _len3; _l++) { 1209 | file = files[_l]; 1210 | formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name); 1211 | } 1212 | return xhr.send(formData); 1213 | }; 1214 | 1215 | Dropzone.prototype._finished = function(files, responseText, e) { 1216 | var file, _i, _len; 1217 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1218 | file = files[_i]; 1219 | file.status = Dropzone.SUCCESS; 1220 | this.emit("success", file, responseText, e); 1221 | this.emit("complete", file); 1222 | } 1223 | if (this.options.uploadMultiple) { 1224 | this.emit("successmultiple", files, responseText, e); 1225 | this.emit("completemultiple", files); 1226 | } 1227 | if (this.options.autoProcessQueue) { 1228 | return this.processQueue(); 1229 | } 1230 | }; 1231 | 1232 | Dropzone.prototype._errorProcessing = function(files, message, xhr) { 1233 | var file, _i, _len; 1234 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1235 | file = files[_i]; 1236 | file.status = Dropzone.ERROR; 1237 | this.emit("error", file, message, xhr); 1238 | this.emit("complete", file); 1239 | } 1240 | if (this.options.uploadMultiple) { 1241 | this.emit("errormultiple", files, message, xhr); 1242 | this.emit("completemultiple", files); 1243 | } 1244 | if (this.options.autoProcessQueue) { 1245 | return this.processQueue(); 1246 | } 1247 | }; 1248 | 1249 | return Dropzone; 1250 | 1251 | })(Em); 1252 | 1253 | Dropzone.version = "3.7.1"; 1254 | 1255 | Dropzone.options = {}; 1256 | 1257 | Dropzone.optionsForElement = function(element) { 1258 | if (element.id) { 1259 | return Dropzone.options[camelize(element.id)]; 1260 | } else { 1261 | return void 0; 1262 | } 1263 | }; 1264 | 1265 | Dropzone.instances = []; 1266 | 1267 | Dropzone.forElement = function(element) { 1268 | if (typeof element === "string") { 1269 | element = document.querySelector(element); 1270 | } 1271 | if ((element != null ? element.dropzone : void 0) == null) { 1272 | throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone."); 1273 | } 1274 | return element.dropzone; 1275 | }; 1276 | 1277 | Dropzone.autoDiscover = true; 1278 | 1279 | Dropzone.discover = function() { 1280 | var checkElements, dropzone, dropzones, _i, _len, _results; 1281 | if (document.querySelectorAll) { 1282 | dropzones = document.querySelectorAll(".dropzone"); 1283 | } else { 1284 | dropzones = []; 1285 | checkElements = function(elements) { 1286 | var el, _i, _len, _results; 1287 | _results = []; 1288 | for (_i = 0, _len = elements.length; _i < _len; _i++) { 1289 | el = elements[_i]; 1290 | if (/(^| )dropzone($| )/.test(el.className)) { 1291 | _results.push(dropzones.push(el)); 1292 | } else { 1293 | _results.push(void 0); 1294 | } 1295 | } 1296 | return _results; 1297 | }; 1298 | checkElements(document.getElementsByTagName("div")); 1299 | checkElements(document.getElementsByTagName("form")); 1300 | } 1301 | _results = []; 1302 | for (_i = 0, _len = dropzones.length; _i < _len; _i++) { 1303 | dropzone = dropzones[_i]; 1304 | if (Dropzone.optionsForElement(dropzone) !== false) { 1305 | _results.push(new Dropzone(dropzone)); 1306 | } else { 1307 | _results.push(void 0); 1308 | } 1309 | } 1310 | return _results; 1311 | }; 1312 | 1313 | Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i]; 1314 | 1315 | Dropzone.isBrowserSupported = function() { 1316 | var capableBrowser, regex, _i, _len, _ref; 1317 | capableBrowser = true; 1318 | if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) { 1319 | if (!("classList" in document.createElement("a"))) { 1320 | capableBrowser = false; 1321 | } else { 1322 | _ref = Dropzone.blacklistedBrowsers; 1323 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 1324 | regex = _ref[_i]; 1325 | if (regex.test(navigator.userAgent)) { 1326 | capableBrowser = false; 1327 | continue; 1328 | } 1329 | } 1330 | } 1331 | } else { 1332 | capableBrowser = false; 1333 | } 1334 | return capableBrowser; 1335 | }; 1336 | 1337 | without = function(list, rejectedItem) { 1338 | var item, _i, _len, _results; 1339 | _results = []; 1340 | for (_i = 0, _len = list.length; _i < _len; _i++) { 1341 | item = list[_i]; 1342 | if (item !== rejectedItem) { 1343 | _results.push(item); 1344 | } 1345 | } 1346 | return _results; 1347 | }; 1348 | 1349 | camelize = function(str) { 1350 | return str.replace(/[\-_](\w)/g, function(match) { 1351 | return match[1].toUpperCase(); 1352 | }); 1353 | }; 1354 | 1355 | Dropzone.createElement = function(string) { 1356 | var div; 1357 | div = document.createElement("div"); 1358 | div.innerHTML = string; 1359 | return div.childNodes[0]; 1360 | }; 1361 | 1362 | Dropzone.elementInside = function(element, container) { 1363 | if (element === container) { 1364 | return true; 1365 | } 1366 | while (element = element.parentNode) { 1367 | if (element === container) { 1368 | return true; 1369 | } 1370 | } 1371 | return false; 1372 | }; 1373 | 1374 | Dropzone.getElement = function(el, name) { 1375 | var element; 1376 | if (typeof el === "string") { 1377 | element = document.querySelector(el); 1378 | } else if (el.nodeType != null) { 1379 | element = el; 1380 | } 1381 | if (element == null) { 1382 | throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element."); 1383 | } 1384 | return element; 1385 | }; 1386 | 1387 | Dropzone.getElements = function(els, name) { 1388 | var e, el, elements, _i, _j, _len, _len1, _ref; 1389 | if (els instanceof Array) { 1390 | elements = []; 1391 | try { 1392 | for (_i = 0, _len = els.length; _i < _len; _i++) { 1393 | el = els[_i]; 1394 | elements.push(this.getElement(el, name)); 1395 | } 1396 | } catch (_error) { 1397 | e = _error; 1398 | elements = null; 1399 | } 1400 | } else if (typeof els === "string") { 1401 | elements = []; 1402 | _ref = document.querySelectorAll(els); 1403 | for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { 1404 | el = _ref[_j]; 1405 | elements.push(el); 1406 | } 1407 | } else if (els.nodeType != null) { 1408 | elements = [els]; 1409 | } 1410 | if (!((elements != null) && elements.length)) { 1411 | throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those."); 1412 | } 1413 | return elements; 1414 | }; 1415 | 1416 | Dropzone.confirm = function(question, accepted, rejected) { 1417 | if (window.confirm(question)) { 1418 | return accepted(); 1419 | } else if (rejected != null) { 1420 | return rejected(); 1421 | } 1422 | }; 1423 | 1424 | Dropzone.isValidFile = function(file, acceptedFiles) { 1425 | var baseMimeType, mimeType, validType, _i, _len; 1426 | if (!acceptedFiles) { 1427 | return true; 1428 | } 1429 | acceptedFiles = acceptedFiles.split(","); 1430 | mimeType = file.type; 1431 | baseMimeType = mimeType.replace(/\/.*$/, ""); 1432 | for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) { 1433 | validType = acceptedFiles[_i]; 1434 | validType = validType.trim(); 1435 | if (validType.charAt(0) === ".") { 1436 | if (file.name.indexOf(validType, file.name.length - validType.length) !== -1) { 1437 | return true; 1438 | } 1439 | } else if (/\/\*$/.test(validType)) { 1440 | if (baseMimeType === validType.replace(/\/.*$/, "")) { 1441 | return true; 1442 | } 1443 | } else { 1444 | if (mimeType === validType) { 1445 | return true; 1446 | } 1447 | } 1448 | } 1449 | return false; 1450 | }; 1451 | 1452 | if (typeof jQuery !== "undefined" && jQuery !== null) { 1453 | jQuery.fn.dropzone = function(options) { 1454 | return this.each(function() { 1455 | return new Dropzone(this, options); 1456 | }); 1457 | }; 1458 | } 1459 | 1460 | if (typeof module !== "undefined" && module !== null) { 1461 | module.exports = Dropzone; 1462 | } else { 1463 | window.Dropzone = Dropzone; 1464 | } 1465 | 1466 | Dropzone.ADDED = "added"; 1467 | 1468 | Dropzone.QUEUED = "queued"; 1469 | 1470 | Dropzone.ACCEPTED = Dropzone.QUEUED; 1471 | 1472 | Dropzone.UPLOADING = "uploading"; 1473 | 1474 | Dropzone.PROCESSING = Dropzone.UPLOADING; 1475 | 1476 | Dropzone.CANCELED = "canceled"; 1477 | 1478 | Dropzone.ERROR = "error"; 1479 | 1480 | Dropzone.SUCCESS = "success"; 1481 | 1482 | /* 1483 | # contentloaded.js 1484 | # 1485 | # Author: Diego Perini (diego.perini at gmail.com) 1486 | # Summary: cross-browser wrapper for DOMContentLoaded 1487 | # Updated: 20101020 1488 | # License: MIT 1489 | # Version: 1.2 1490 | # 1491 | # URL: 1492 | # http://javascript.nwbox.com/ContentLoaded/ 1493 | # http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE 1494 | */ 1495 | 1496 | 1497 | contentLoaded = function(win, fn) { 1498 | var add, doc, done, init, poll, pre, rem, root, top; 1499 | done = false; 1500 | top = true; 1501 | doc = win.document; 1502 | root = doc.documentElement; 1503 | add = (doc.addEventListener ? "addEventListener" : "attachEvent"); 1504 | rem = (doc.addEventListener ? "removeEventListener" : "detachEvent"); 1505 | pre = (doc.addEventListener ? "" : "on"); 1506 | init = function(e) { 1507 | if (e.type === "readystatechange" && doc.readyState !== "complete") { 1508 | return; 1509 | } 1510 | (e.type === "load" ? win : doc)[rem](pre + e.type, init, false); 1511 | if (!done && (done = true)) { 1512 | return fn.call(win, e.type || e); 1513 | } 1514 | }; 1515 | poll = function() { 1516 | var e; 1517 | try { 1518 | root.doScroll("left"); 1519 | } catch (_error) { 1520 | e = _error; 1521 | setTimeout(poll, 50); 1522 | return; 1523 | } 1524 | return init("poll"); 1525 | }; 1526 | if (doc.readyState !== "complete") { 1527 | if (doc.createEventObject && root.doScroll) { 1528 | try { 1529 | top = !win.frameElement; 1530 | } catch (_error) {} 1531 | if (top) { 1532 | poll(); 1533 | } 1534 | } 1535 | doc[add](pre + "DOMContentLoaded", init, false); 1536 | doc[add](pre + "readystatechange", init, false); 1537 | return win[add](pre + "load", init, false); 1538 | } 1539 | }; 1540 | 1541 | Dropzone._autoDiscoverFunction = function() { 1542 | if (Dropzone.autoDiscover) { 1543 | return Dropzone.discover(); 1544 | } 1545 | }; 1546 | 1547 | contentLoaded(window, Dropzone._autoDiscoverFunction); 1548 | 1549 | }).call(this); 1550 | 1551 | return module.exports; 1552 | })); -------------------------------------------------------------------------------- /mysite/main/static/main/js/dropzone-amd-module.min.js: -------------------------------------------------------------------------------- 1 | !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a(jQuery)}(function(a){function b(a){return a?c(a):void 0}function c(a){for(var c in b.prototype)a[c]=b.prototype[c];return a}var d={exports:{}};return d.exports=b,b.prototype.on=function(a,b){return this._callbacks=this._callbacks||{},(this._callbacks[a]=this._callbacks[a]||[]).push(b),this},b.prototype.once=function(a,b){function c(){d.off(a,c),b.apply(this,arguments)}var d=this;return this._callbacks=this._callbacks||{},b._off=c,this.on(a,c),this},b.prototype.off=b.prototype.removeListener=b.prototype.removeAllListeners=function(a,b){this._callbacks=this._callbacks||{};var c=this._callbacks[a];if(!c)return this;if(1==arguments.length)return delete this._callbacks[a],this;var d=c.indexOf(b._off||b);return~d&&c.splice(d,1),this},b.prototype.emit=function(a){this._callbacks=this._callbacks||{};var b=[].slice.call(arguments,1),c=this._callbacks[a];if(c){c=c.slice(0);for(var d=0,e=c.length;e>d;++d)c[d].apply(this,b)}return this},b.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},b.prototype.hasListeners=function(a){return!!this.listeners(a).length},function(){var c,e,f,g,h,i,j={}.hasOwnProperty,k=function(a,b){function c(){this.constructor=a}for(var d in b)j.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},l=[].slice;e="undefined"!=typeof b&&null!==b?b:require("emitter"),h=function(){},c=function(a){function b(a,d){var e,f,g;if(this.element=a,this.version=b.version,this.defaultOptions.previewTemplate=this.defaultOptions.previewTemplate.replace(/\n*/g,""),this.clickableElements=[],this.listeners=[],this.files=[],"string"==typeof this.element&&(this.element=document.querySelector(this.element)),!this.element||null==this.element.nodeType)throw new Error("Invalid dropzone element.");if(this.element.dropzone)throw new Error("Dropzone already attached.");if(b.instances.push(this),a.dropzone=this,e=null!=(g=b.optionsForElement(this.element))?g:{},this.options=c({},this.defaultOptions,e,null!=d?d:{}),this.options.forceFallback||!b.isBrowserSupported())return this.options.fallback.call(this);if(null==this.options.url&&(this.options.url=this.element.getAttribute("action")),!this.options.url)throw new Error("No URL provided.");if(this.options.acceptedFiles&&this.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");this.options.acceptedMimeTypes&&(this.options.acceptedFiles=this.options.acceptedMimeTypes,delete this.options.acceptedMimeTypes),this.options.method=this.options.method.toUpperCase(),(f=this.getExistingFallback())&&f.parentNode&&f.parentNode.removeChild(f),this.previewsContainer=this.options.previewsContainer?b.getElement(this.options.previewsContainer,"previewsContainer"):this.element,this.options.clickable&&(this.clickableElements=this.options.clickable===!0?[this.element]:b.getElements(this.options.clickable,"clickable")),this.init()}var c;return k(b,a),b.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","selectedfiles","addedfile","removedfile","thumbnail","error","errormultiple","processing","processingmultiple","uploadprogress","totaluploadprogress","sending","sendingmultiple","success","successmultiple","canceled","canceledmultiple","complete","completemultiple","reset","maxfilesexceeded"],b.prototype.defaultOptions={url:null,method:"post",withCredentials:!1,parallelUploads:2,uploadMultiple:!1,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:100,thumbnailHeight:100,maxFiles:null,params:{},clickable:!0,ignoreHiddenFiles:!0,acceptedFiles:null,acceptedMimeTypes:null,autoProcessQueue:!0,addRemoveLinks:!1,previewsContainer:null,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",dictFileTooBig:"File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.",dictInvalidFileType:"You can't upload files of this type.",dictResponseError:"Server responded with {{statusCode}} code.",dictCancelUpload:"Cancel upload",dictCancelUploadConfirmation:"Are you sure you want to cancel this upload?",dictRemoveFile:"Remove file",dictRemoveFileConfirmation:null,dictMaxFilesExceeded:"You can only upload {{maxFiles}} files.",accept:function(a,b){return b()},init:function(){return h},forceFallback:!1,fallback:function(){var a,c,d,e,f,g;for(this.element.className=""+this.element.className+" dz-browser-not-supported",g=this.element.getElementsByTagName("div"),e=0,f=g.length;f>e;e++)a=g[e],/(^| )dz-message($| )/.test(a.className)&&(c=a,a.className="dz-message");return c||(c=b.createElement('
'),this.element.appendChild(c)),d=c.getElementsByTagName("span")[0],d&&(d.textContent=this.options.dictFallbackMessage),this.element.appendChild(this.getFallbackForm())},resize:function(a){var b,c,d;return b={srcX:0,srcY:0,srcWidth:a.width,srcHeight:a.height},c=a.width/a.height,d=this.options.thumbnailWidth/this.options.thumbnailHeight,a.heightd?(b.srcHeight=a.height,b.srcWidth=b.srcHeight*d):(b.srcWidth=a.width,b.srcHeight=b.srcWidth/d),b.srcX=(a.width-b.srcWidth)/2,b.srcY=(a.height-b.srcHeight)/2,b},drop:function(){return this.element.classList.remove("dz-drag-hover")},dragstart:h,dragend:function(){return this.element.classList.remove("dz-drag-hover")},dragenter:function(){return this.element.classList.add("dz-drag-hover")},dragover:function(){return this.element.classList.add("dz-drag-hover")},dragleave:function(){return this.element.classList.remove("dz-drag-hover")},selectedfiles:function(){return this.element===this.previewsContainer?this.element.classList.add("dz-started"):void 0},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(a){var c=this;return a.previewElement=b.createElement(this.options.previewTemplate),a.previewTemplate=a.previewElement,this.previewsContainer.appendChild(a.previewElement),a.previewElement.querySelector("[data-dz-name]").textContent=a.name,a.previewElement.querySelector("[data-dz-size]").innerHTML=this.filesize(a.size),this.options.addRemoveLinks&&(a._removeLink=b.createElement(''+this.options.dictRemoveFile+""),a._removeLink.addEventListener("click",function(d){return d.preventDefault(),d.stopPropagation(),a.status===b.UPLOADING?b.confirm(c.options.dictCancelUploadConfirmation,function(){return c.removeFile(a)}):c.options.dictRemoveFileConfirmation?b.confirm(c.options.dictRemoveFileConfirmation,function(){return c.removeFile(a)}):c.removeFile(a)}),a.previewElement.appendChild(a._removeLink)),this._updateMaxFilesReachedClass()},removedfile:function(a){var b;return null!=(b=a.previewElement)&&b.parentNode.removeChild(a.previewElement),this._updateMaxFilesReachedClass()},thumbnail:function(a,b){var c;return a.previewElement.classList.remove("dz-file-preview"),a.previewElement.classList.add("dz-image-preview"),c=a.previewElement.querySelector("[data-dz-thumbnail]"),c.alt=a.name,c.src=b},error:function(a,b){return a.previewElement.classList.add("dz-error"),a.previewElement.querySelector("[data-dz-errormessage]").textContent=b},errormultiple:h,processing:function(a){return a.previewElement.classList.add("dz-processing"),a._removeLink?a._removeLink.textContent=this.options.dictCancelUpload:void 0},processingmultiple:h,uploadprogress:function(a,b){return a.previewElement.querySelector("[data-dz-uploadprogress]").style.width=""+b+"%"},totaluploadprogress:h,sending:h,sendingmultiple:h,success:function(a){return a.previewElement.classList.add("dz-success")},successmultiple:h,canceled:function(a){return this.emit("error",a,"Upload canceled.")},canceledmultiple:h,complete:function(a){return a._removeLink?a._removeLink.textContent=this.options.dictRemoveFile:void 0},completemultiple:h,maxfilesexceeded:h,previewTemplate:'
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
'},c=function(){var a,b,c,d,e,f,g;for(d=arguments[0],c=2<=arguments.length?l.call(arguments,1):[],f=0,g=c.length;g>f;f++){b=c[f];for(a in b)e=b[a],d[a]=e}return d},b.prototype.getAcceptedFiles=function(){var a,b,c,d,e;for(d=this.files,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.accepted&&e.push(a);return e},b.prototype.getRejectedFiles=function(){var a,b,c,d,e;for(d=this.files,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.accepted||e.push(a);return e},b.prototype.getQueuedFiles=function(){var a,c,d,e,f;for(e=this.files,f=[],c=0,d=e.length;d>c;c++)a=e[c],a.status===b.QUEUED&&f.push(a);return f},b.prototype.getUploadingFiles=function(){var a,c,d,e,f;for(e=this.files,f=[],c=0,d=e.length;d>c;c++)a=e[c],a.status===b.UPLOADING&&f.push(a);return f},b.prototype.init=function(){var a,c,d,e,f,g,h,i=this;for("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")&&this.element.appendChild(b.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length&&(d=function(){return i.hiddenFileInput&&document.body.removeChild(i.hiddenFileInput),i.hiddenFileInput=document.createElement("input"),i.hiddenFileInput.setAttribute("type","file"),i.hiddenFileInput.setAttribute("multiple","multiple"),null!=i.options.acceptedFiles&&i.hiddenFileInput.setAttribute("accept",i.options.acceptedFiles),i.hiddenFileInput.style.visibility="hidden",i.hiddenFileInput.style.position="absolute",i.hiddenFileInput.style.top="0",i.hiddenFileInput.style.left="0",i.hiddenFileInput.style.height="0",i.hiddenFileInput.style.width="0",document.body.appendChild(i.hiddenFileInput),i.hiddenFileInput.addEventListener("change",function(){var a;return a=i.hiddenFileInput.files,a.length&&(i.emit("selectedfiles",a),i.handleFiles(a)),d()})},d()),this.URL=null!=(g=window.URL)?g:window.webkitURL,h=this.events,e=0,f=h.length;f>e;e++)a=h[e],this.on(a,this.options[a]);return this.on("uploadprogress",function(){return i.updateTotalUploadProgress()}),this.on("removedfile",function(){return i.updateTotalUploadProgress()}),this.on("canceled",function(a){return i.emit("complete",a)}),c=function(a){return a.stopPropagation(),a.preventDefault?a.preventDefault():a.returnValue=!1},this.listeners=[{element:this.element,events:{dragstart:function(a){return i.emit("dragstart",a)},dragenter:function(a){return c(a),i.emit("dragenter",a)},dragover:function(a){return c(a),i.emit("dragover",a)},dragleave:function(a){return i.emit("dragleave",a)},drop:function(a){return c(a),i.drop(a)},dragend:function(a){return i.emit("dragend",a)}}}],this.clickableElements.forEach(function(a){return i.listeners.push({element:a,events:{click:function(c){return a!==i.element||c.target===i.element||b.elementInside(c.target,i.element.querySelector(".dz-message"))?i.hiddenFileInput.click():void 0}}})}),this.enable(),this.options.init.call(this)},b.prototype.destroy=function(){var a;return this.disable(),this.removeAllFiles(!0),(null!=(a=this.hiddenFileInput)?a.parentNode:void 0)&&(this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput),this.hiddenFileInput=null),delete this.element.dropzone},b.prototype.updateTotalUploadProgress=function(){var a,b,c,d,e,f,g,h;if(d=0,c=0,a=this.getAcceptedFiles(),a.length){for(h=this.getAcceptedFiles(),f=0,g=h.length;g>f;f++)b=h[f],d+=b.upload.bytesSent,c+=b.upload.total;e=100*d/c}else e=100;return this.emit("totaluploadprogress",e,c,d)},b.prototype.getFallbackForm=function(){var a,c,d,e;return(a=this.getExistingFallback())?a:(d='
',this.options.dictFallbackText&&(d+="

"+this.options.dictFallbackText+"

"),d+='
',c=b.createElement(d),"FORM"!==this.element.tagName?(e=b.createElement('
'),e.appendChild(c)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=e?e:c)},b.prototype.getExistingFallback=function(){var a,b,c,d,e,f;for(b=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)if(b=a[c],/(^| )fallback($| )/.test(b.className))return b},f=["div","form"],d=0,e=f.length;e>d;d++)if(c=f[d],a=b(this.element.getElementsByTagName(c)))return a},b.prototype.setupEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.addEventListener(b,c,!1));return e}());return g},b.prototype.removeEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.removeEventListener(b,c,!1));return e}());return g},b.prototype.disable=function(){var a,b,c,d,e;for(this.clickableElements.forEach(function(a){return a.classList.remove("dz-clickable")}),this.removeEventListeners(),d=this.files,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this.cancelUpload(a));return e},b.prototype.enable=function(){return this.clickableElements.forEach(function(a){return a.classList.add("dz-clickable")}),this.setupEventListeners()},b.prototype.filesize=function(a){var b;return a>=1e11?(a/=1e11,b="TB"):a>=1e8?(a/=1e8,b="GB"):a>=1e5?(a/=1e5,b="MB"):a>=100?(a/=100,b="KB"):(a=10*a,b="b"),""+Math.round(a)/10+" "+b},b.prototype._updateMaxFilesReachedClass=function(){return this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?this.element.classList.add("dz-max-files-reached"):this.element.classList.remove("dz-max-files-reached")},b.prototype.drop=function(a){var b,c;a.dataTransfer&&(this.emit("drop",a),b=a.dataTransfer.files,this.emit("selectedfiles",b),b.length&&(c=a.dataTransfer.items,c&&c.length&&(null!=c[0].webkitGetAsEntry||null!=c[0].getAsEntry)?this.handleItems(c):this.handleFiles(b)))},b.prototype.handleFiles=function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(this.addFile(b));return e},b.prototype.handleItems=function(a){var b,c,d,e;for(d=0,e=a.length;e>d;d++)c=a[d],null!=c.webkitGetAsEntry?(b=c.webkitGetAsEntry(),b.isFile?this.addFile(c.getAsFile()):b.isDirectory&&this.addDirectory(b,b.name)):this.addFile(c.getAsFile())},b.prototype.accept=function(a,c){return a.size>1024*1024*this.options.maxFilesize?c(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(a.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):b.isValidFile(a,this.options.acceptedFiles)?this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(c(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",a)):this.options.accept.call(this,a,c):c(this.options.dictInvalidFileType)},b.prototype.addFile=function(a){var c=this;return a.upload={progress:0,total:a.size,bytesSent:0},this.files.push(a),a.status=b.ADDED,this.emit("addedfile",a),this.options.createImageThumbnails&&a.type.match(/image.*/)&&a.size<=1024*1024*this.options.maxThumbnailFilesize&&this.createThumbnail(a),this.accept(a,function(b){return b?(a.accepted=!1,c._errorProcessing([a],b)):c.enqueueFile(a)})},b.prototype.enqueueFiles=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)b=a[c],this.enqueueFile(b);return null},b.prototype.enqueueFile=function(a){var c=this;if(a.accepted=!0,a.status!==b.ADDED)throw new Error("This file can't be queued because it has already been processed or was rejected.");return a.status=b.QUEUED,this.options.autoProcessQueue?setTimeout(function(){return c.processQueue()},1):void 0},b.prototype.addDirectory=function(a,b){var c,d,e=this;return c=a.createReader(),d=function(c){var d,f;for(d=0,f=c.length;f>d;d++)a=c[d],a.isFile?a.file(function(a){return e.options.ignoreHiddenFiles&&"."===a.name.substring(0,1)?void 0:(a.fullPath=""+b+"/"+a.name,e.addFile(a))}):a.isDirectory&&e.addDirectory(a,""+b+"/"+a.name)},c.readEntries(d,function(a){return"undefined"!=typeof console&&null!==console?"function"==typeof console.log?console.log(a):void 0:void 0})},b.prototype.removeFile=function(a){return a.status===b.UPLOADING&&this.cancelUpload(a),this.files=i(this.files,a),this.emit("removedfile",a),0===this.files.length?this.emit("reset"):void 0},b.prototype.removeAllFiles=function(a){var c,d,e,f;for(null==a&&(a=!1),f=this.files.slice(),d=0,e=f.length;e>d;d++)c=f[d],(c.status!==b.UPLOADING||a)&&this.removeFile(c);return null},b.prototype.createThumbnail=function(a){var b,c=this;return b=new FileReader,b.onload=function(){var d;return d=new Image,d.onload=function(){var b,e,f,g,h,i,j,k;return a.width=d.width,a.height=d.height,f=c.options.resize.call(c,a),null==f.trgWidth&&(f.trgWidth=c.options.thumbnailWidth),null==f.trgHeight&&(f.trgHeight=c.options.thumbnailHeight),b=document.createElement("canvas"),e=b.getContext("2d"),b.width=f.trgWidth,b.height=f.trgHeight,e.drawImage(d,null!=(h=f.srcX)?h:0,null!=(i=f.srcY)?i:0,f.srcWidth,f.srcHeight,null!=(j=f.trgX)?j:0,null!=(k=f.trgY)?k:0,f.trgWidth,f.trgHeight),g=b.toDataURL("image/png"),c.emit("thumbnail",a,g)},d.src=b.result},b.readAsDataURL(a)},b.prototype.processQueue=function(){var a,b,c,d;if(b=this.options.parallelUploads,c=this.getUploadingFiles().length,a=c,!(c>=b)&&(d=this.getQueuedFiles(),d.length>0)){if(this.options.uploadMultiple)return this.processFiles(d.slice(0,b-c));for(;b>a;){if(!d.length)return;this.processFile(d.shift()),a++}}},b.prototype.processFile=function(a){return this.processFiles([a])},b.prototype.processFiles=function(a){var c,d,e;for(d=0,e=a.length;e>d;d++)c=a[d],c.processing=!0,c.status=b.UPLOADING,this.emit("processing",c);return this.options.uploadMultiple&&this.emit("processingmultiple",a),this.uploadFiles(a)},b.prototype._getFilesWithXhr=function(a){var b,c;return c=function(){var c,d,e,f;for(e=this.files,f=[],c=0,d=e.length;d>c;c++)b=e[c],b.xhr===a&&f.push(b);return f}.call(this)},b.prototype.cancelUpload=function(a){var c,d,e,f,g,h,i;if(a.status===b.UPLOADING){for(d=this._getFilesWithXhr(a.xhr),e=0,g=d.length;g>e;e++)c=d[e],c.status=b.CANCELED;for(a.xhr.abort(),f=0,h=d.length;h>f;f++)c=d[f],this.emit("canceled",c);this.options.uploadMultiple&&this.emit("canceledmultiple",d)}else((i=a.status)===b.ADDED||i===b.QUEUED)&&(a.status=b.CANCELED,this.emit("canceled",a),this.options.uploadMultiple&&this.emit("canceledmultiple",[a]));return this.options.autoProcessQueue?this.processQueue():void 0},b.prototype.uploadFile=function(a){return this.uploadFiles([a])},b.prototype.uploadFiles=function(a){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E=this;for(r=new XMLHttpRequest,s=0,w=a.length;w>s;s++)d=a[s],d.xhr=r;r.open(this.options.method,this.options.url,!0),r.withCredentials=!!this.options.withCredentials,o=null,f=function(){var b,c,e;for(e=[],b=0,c=a.length;c>b;b++)d=a[b],e.push(E._errorProcessing(a,o||E.options.dictResponseError.replace("{{statusCode}}",r.status),r));return e},p=function(b){var c,e,f,g,h,i,j,k,l;if(null!=b)for(e=100*b.loaded/b.total,f=0,i=a.length;i>f;f++)d=a[f],d.upload={progress:e,total:b.total,bytesSent:b.loaded};else{for(c=!0,e=100,g=0,j=a.length;j>g;g++)d=a[g],(100!==d.upload.progress||d.upload.bytesSent!==d.upload.total)&&(c=!1),d.upload.progress=e,d.upload.bytesSent=d.upload.total;if(c)return}for(l=[],h=0,k=a.length;k>h;h++)d=a[h],l.push(E.emit("uploadprogress",d,e,d.upload.bytesSent));return l},r.onload=function(c){var d;if(a[0].status!==b.CANCELED&&4===r.readyState){if(o=r.responseText,r.getResponseHeader("content-type")&&~r.getResponseHeader("content-type").indexOf("application/json"))try{o=JSON.parse(o)}catch(e){c=e,o="Invalid JSON response from server."}return p(),200<=(d=r.status)&&300>d?E._finished(a,o,c):f()}},r.onerror=function(){return a[0].status!==b.CANCELED?f():void 0},n=null!=(A=r.upload)?A:r,n.onprogress=p,i={Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"},this.options.headers&&c(i,this.options.headers);for(g in i)h=i[g],r.setRequestHeader(g,h);if(e=new FormData,this.options.params){B=this.options.params;for(m in B)q=B[m],e.append(m,q)}for(t=0,x=a.length;x>t;t++)d=a[t],this.emit("sending",d,r,e);if(this.options.uploadMultiple&&this.emit("sendingmultiple",a,r,e),"FORM"===this.element.tagName)for(C=this.element.querySelectorAll("input, textarea, select, button"),u=0,y=C.length;y>u;u++)j=C[u],k=j.getAttribute("name"),l=j.getAttribute("type"),(!l||"checkbox"!==(D=l.toLowerCase())&&"radio"!==D||j.checked)&&e.append(k,j.value);for(v=0,z=a.length;z>v;v++)d=a[v],e.append(""+this.options.paramName+(this.options.uploadMultiple?"[]":""),d,d.name);return r.send(e)},b.prototype._finished=function(a,c,d){var e,f,g;for(f=0,g=a.length;g>f;f++)e=a[f],e.status=b.SUCCESS,this.emit("success",e,c,d),this.emit("complete",e);return this.options.uploadMultiple&&(this.emit("successmultiple",a,c,d),this.emit("completemultiple",a)),this.options.autoProcessQueue?this.processQueue():void 0},b.prototype._errorProcessing=function(a,c,d){var e,f,g;for(f=0,g=a.length;g>f;f++)e=a[f],e.status=b.ERROR,this.emit("error",e,c,d),this.emit("complete",e);return this.options.uploadMultiple&&(this.emit("errormultiple",a,c,d),this.emit("completemultiple",a)),this.options.autoProcessQueue?this.processQueue():void 0},b}(e),c.version="3.7.1",c.options={},c.optionsForElement=function(a){return a.id?c.options[f(a.id)]:void 0},c.instances=[],c.forElement=function(a){if("string"==typeof a&&(a=document.querySelector(a)),null==(null!=a?a.dropzone:void 0))throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");return a.dropzone},c.autoDiscover=!0,c.discover=function(){var a,b,d,e,f,g;for(document.querySelectorAll?d=document.querySelectorAll(".dropzone"):(d=[],a=function(a){var b,c,e,f;for(f=[],c=0,e=a.length;e>c;c++)b=a[c],/(^| )dropzone($| )/.test(b.className)?f.push(d.push(b)):f.push(void 0);return f},a(document.getElementsByTagName("div")),a(document.getElementsByTagName("form"))),g=[],e=0,f=d.length;f>e;e++)b=d[e],c.optionsForElement(b)!==!1?g.push(new c(b)):g.push(void 0);return g},c.blacklistedBrowsers=[/opera.*Macintosh.*version\/12/i],c.isBrowserSupported=function(){var a,b,d,e,f;if(a=!0,window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(f=c.blacklistedBrowsers,d=0,e=f.length;e>d;d++)b=f[d],b.test(navigator.userAgent)&&(a=!1);else a=!1;else a=!1;return a},i=function(a,b){var c,d,e,f;for(f=[],d=0,e=a.length;e>d;d++)c=a[d],c!==b&&f.push(c);return f},f=function(a){return a.replace(/[\-_](\w)/g,function(a){return a[1].toUpperCase()})},c.createElement=function(a){var b;return b=document.createElement("div"),b.innerHTML=a,b.childNodes[0]},c.elementInside=function(a,b){if(a===b)return!0;for(;a=a.parentNode;)if(a===b)return!0;return!1},c.getElement=function(a,b){var c;if("string"==typeof a?c=document.querySelector(a):null!=a.nodeType&&(c=a),null==c)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector or a plain HTML element.");return c},c.getElements=function(a,b){var c,d,e,f,g,h,i,j;if(a instanceof Array){e=[];try{for(f=0,h=a.length;h>f;f++)d=a[f],e.push(this.getElement(d,b))}catch(k){c=k,e=null}}else if("string"==typeof a)for(e=[],j=document.querySelectorAll(a),g=0,i=j.length;i>g;g++)d=j[g],e.push(d);else null!=a.nodeType&&(e=[a]);if(null==e||!e.length)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return e},c.confirm=function(a,b,c){return window.confirm(a)?b():null!=c?c():void 0},c.isValidFile=function(a,b){var c,d,e,f,g;if(!b)return!0;for(b=b.split(","),d=a.type,c=d.replace(/\/.*$/,""),f=0,g=b.length;g>f;f++)if(e=b[f],e=e.trim(),"."===e.charAt(0)){if(-1!==a.name.indexOf(e,a.name.length-e.length))return!0}else if(/\/\*$/.test(e)){if(c===e.replace(/\/.*$/,""))return!0}else if(d===e)return!0;return!1},"undefined"!=typeof a&&null!==a&&(a.fn.dropzone=function(a){return this.each(function(){return new c(this,a)})}),"undefined"!=typeof d&&null!==d?d.exports=c:window.Dropzone=c,c.ADDED="added",c.QUEUED="queued",c.ACCEPTED=c.QUEUED,c.UPLOADING="uploading",c.PROCESSING=c.UPLOADING,c.CANCELED="canceled",c.ERROR="error",c.SUCCESS="success",g=function(a,b){var c,d,e,f,g,h,i,j,k;if(e=!1,k=!0,d=a.document,j=d.documentElement,c=d.addEventListener?"addEventListener":"attachEvent",i=d.addEventListener?"removeEventListener":"detachEvent",h=d.addEventListener?"":"on",f=function(c){return"readystatechange"!==c.type||"complete"===d.readyState?(("load"===c.type?a:d)[i](h+c.type,f,!1),!e&&(e=!0)?b.call(a,c.type||c):void 0):void 0},g=function(){var a;try{j.doScroll("left")}catch(b){return a=b,setTimeout(g,50),void 0}return f("poll")},"complete"!==d.readyState){if(d.createEventObject&&j.doScroll){try{k=!a.frameElement}catch(l){}k&&g()}return d[c](h+"DOMContentLoaded",f,!1),d[c](h+"readystatechange",f,!1),a[c](h+"load",f,!1)}},c._autoDiscoverFunction=function(){return c.autoDiscover?c.discover():void 0},g(window,c._autoDiscoverFunction)}.call(this),d.exports}); -------------------------------------------------------------------------------- /mysite/main/static/main/js/dropzone.js: -------------------------------------------------------------------------------- 1 | ;(function(){ 2 | 3 | /** 4 | * Require the given path. 5 | * 6 | * @param {String} path 7 | * @return {Object} exports 8 | * @api public 9 | */ 10 | 11 | function require(path, parent, orig) { 12 | var resolved = require.resolve(path); 13 | 14 | // lookup failed 15 | if (null == resolved) { 16 | orig = orig || path; 17 | parent = parent || 'root'; 18 | var err = new Error('Failed to require "' + orig + '" from "' + parent + '"'); 19 | err.path = orig; 20 | err.parent = parent; 21 | err.require = true; 22 | throw err; 23 | } 24 | 25 | var module = require.modules[resolved]; 26 | 27 | // perform real require() 28 | // by invoking the module's 29 | // registered function 30 | if (!module.exports) { 31 | module.exports = {}; 32 | module.client = module.component = true; 33 | module.call(this, module.exports, require.relative(resolved), module); 34 | } 35 | 36 | return module.exports; 37 | } 38 | 39 | /** 40 | * Registered modules. 41 | */ 42 | 43 | require.modules = {}; 44 | 45 | /** 46 | * Registered aliases. 47 | */ 48 | 49 | require.aliases = {}; 50 | 51 | /** 52 | * Resolve `path`. 53 | * 54 | * Lookup: 55 | * 56 | * - PATH/index.js 57 | * - PATH.js 58 | * - PATH 59 | * 60 | * @param {String} path 61 | * @return {String} path or null 62 | * @api private 63 | */ 64 | 65 | require.resolve = function(path) { 66 | if (path.charAt(0) === '/') path = path.slice(1); 67 | 68 | var paths = [ 69 | path, 70 | path + '.js', 71 | path + '.json', 72 | path + '/index.js', 73 | path + '/index.json' 74 | ]; 75 | 76 | for (var i = 0; i < paths.length; i++) { 77 | var path = paths[i]; 78 | if (require.modules.hasOwnProperty(path)) return path; 79 | if (require.aliases.hasOwnProperty(path)) return require.aliases[path]; 80 | } 81 | }; 82 | 83 | /** 84 | * Normalize `path` relative to the current path. 85 | * 86 | * @param {String} curr 87 | * @param {String} path 88 | * @return {String} 89 | * @api private 90 | */ 91 | 92 | require.normalize = function(curr, path) { 93 | var segs = []; 94 | 95 | if ('.' != path.charAt(0)) return path; 96 | 97 | curr = curr.split('/'); 98 | path = path.split('/'); 99 | 100 | for (var i = 0; i < path.length; ++i) { 101 | if ('..' == path[i]) { 102 | curr.pop(); 103 | } else if ('.' != path[i] && '' != path[i]) { 104 | segs.push(path[i]); 105 | } 106 | } 107 | 108 | return curr.concat(segs).join('/'); 109 | }; 110 | 111 | /** 112 | * Register module at `path` with callback `definition`. 113 | * 114 | * @param {String} path 115 | * @param {Function} definition 116 | * @api private 117 | */ 118 | 119 | require.register = function(path, definition) { 120 | require.modules[path] = definition; 121 | }; 122 | 123 | /** 124 | * Alias a module definition. 125 | * 126 | * @param {String} from 127 | * @param {String} to 128 | * @api private 129 | */ 130 | 131 | require.alias = function(from, to) { 132 | if (!require.modules.hasOwnProperty(from)) { 133 | throw new Error('Failed to alias "' + from + '", it does not exist'); 134 | } 135 | require.aliases[to] = from; 136 | }; 137 | 138 | /** 139 | * Return a require function relative to the `parent` path. 140 | * 141 | * @param {String} parent 142 | * @return {Function} 143 | * @api private 144 | */ 145 | 146 | require.relative = function(parent) { 147 | var p = require.normalize(parent, '..'); 148 | 149 | /** 150 | * lastIndexOf helper. 151 | */ 152 | 153 | function lastIndexOf(arr, obj) { 154 | var i = arr.length; 155 | while (i--) { 156 | if (arr[i] === obj) return i; 157 | } 158 | return -1; 159 | } 160 | 161 | /** 162 | * The relative require() itself. 163 | */ 164 | 165 | function localRequire(path) { 166 | var resolved = localRequire.resolve(path); 167 | return require(resolved, parent, path); 168 | } 169 | 170 | /** 171 | * Resolve relative to the parent. 172 | */ 173 | 174 | localRequire.resolve = function(path) { 175 | var c = path.charAt(0); 176 | if ('/' == c) return path.slice(1); 177 | if ('.' == c) return require.normalize(p, path); 178 | 179 | // resolve deps by returning 180 | // the dep in the nearest "deps" 181 | // directory 182 | var segs = parent.split('/'); 183 | var i = lastIndexOf(segs, 'deps') + 1; 184 | if (!i) i = 0; 185 | path = segs.slice(0, i + 1).join('/') + '/deps/' + path; 186 | return path; 187 | }; 188 | 189 | /** 190 | * Check if module is defined at `path`. 191 | */ 192 | 193 | localRequire.exists = function(path) { 194 | return require.modules.hasOwnProperty(localRequire.resolve(path)); 195 | }; 196 | 197 | return localRequire; 198 | }; 199 | require.register("component-emitter/index.js", function(exports, require, module){ 200 | 201 | /** 202 | * Expose `Emitter`. 203 | */ 204 | 205 | module.exports = Emitter; 206 | 207 | /** 208 | * Initialize a new `Emitter`. 209 | * 210 | * @api public 211 | */ 212 | 213 | function Emitter(obj) { 214 | if (obj) return mixin(obj); 215 | }; 216 | 217 | /** 218 | * Mixin the emitter properties. 219 | * 220 | * @param {Object} obj 221 | * @return {Object} 222 | * @api private 223 | */ 224 | 225 | function mixin(obj) { 226 | for (var key in Emitter.prototype) { 227 | obj[key] = Emitter.prototype[key]; 228 | } 229 | return obj; 230 | } 231 | 232 | /** 233 | * Listen on the given `event` with `fn`. 234 | * 235 | * @param {String} event 236 | * @param {Function} fn 237 | * @return {Emitter} 238 | * @api public 239 | */ 240 | 241 | Emitter.prototype.on = function(event, fn){ 242 | this._callbacks = this._callbacks || {}; 243 | (this._callbacks[event] = this._callbacks[event] || []) 244 | .push(fn); 245 | return this; 246 | }; 247 | 248 | /** 249 | * Adds an `event` listener that will be invoked a single 250 | * time then automatically removed. 251 | * 252 | * @param {String} event 253 | * @param {Function} fn 254 | * @return {Emitter} 255 | * @api public 256 | */ 257 | 258 | Emitter.prototype.once = function(event, fn){ 259 | var self = this; 260 | this._callbacks = this._callbacks || {}; 261 | 262 | function on() { 263 | self.off(event, on); 264 | fn.apply(this, arguments); 265 | } 266 | 267 | fn._off = on; 268 | this.on(event, on); 269 | return this; 270 | }; 271 | 272 | /** 273 | * Remove the given callback for `event` or all 274 | * registered callbacks. 275 | * 276 | * @param {String} event 277 | * @param {Function} fn 278 | * @return {Emitter} 279 | * @api public 280 | */ 281 | 282 | Emitter.prototype.off = 283 | Emitter.prototype.removeListener = 284 | Emitter.prototype.removeAllListeners = function(event, fn){ 285 | this._callbacks = this._callbacks || {}; 286 | var callbacks = this._callbacks[event]; 287 | if (!callbacks) return this; 288 | 289 | // remove all handlers 290 | if (1 == arguments.length) { 291 | delete this._callbacks[event]; 292 | return this; 293 | } 294 | 295 | // remove specific handler 296 | var i = callbacks.indexOf(fn._off || fn); 297 | if (~i) callbacks.splice(i, 1); 298 | return this; 299 | }; 300 | 301 | /** 302 | * Emit `event` with the given args. 303 | * 304 | * @param {String} event 305 | * @param {Mixed} ... 306 | * @return {Emitter} 307 | */ 308 | 309 | Emitter.prototype.emit = function(event){ 310 | this._callbacks = this._callbacks || {}; 311 | var args = [].slice.call(arguments, 1) 312 | , callbacks = this._callbacks[event]; 313 | 314 | if (callbacks) { 315 | callbacks = callbacks.slice(0); 316 | for (var i = 0, len = callbacks.length; i < len; ++i) { 317 | callbacks[i].apply(this, args); 318 | } 319 | } 320 | 321 | return this; 322 | }; 323 | 324 | /** 325 | * Return array of callbacks for `event`. 326 | * 327 | * @param {String} event 328 | * @return {Array} 329 | * @api public 330 | */ 331 | 332 | Emitter.prototype.listeners = function(event){ 333 | this._callbacks = this._callbacks || {}; 334 | return this._callbacks[event] || []; 335 | }; 336 | 337 | /** 338 | * Check if this emitter has `event` handlers. 339 | * 340 | * @param {String} event 341 | * @return {Boolean} 342 | * @api public 343 | */ 344 | 345 | Emitter.prototype.hasListeners = function(event){ 346 | return !! this.listeners(event).length; 347 | }; 348 | 349 | }); 350 | require.register("dropzone/index.js", function(exports, require, module){ 351 | 352 | 353 | /** 354 | * Exposing dropzone 355 | */ 356 | module.exports = require("./lib/dropzone.js"); 357 | 358 | }); 359 | require.register("dropzone/lib/dropzone.js", function(exports, require, module){ 360 | /* 361 | # 362 | # More info at [www.dropzonejs.com](http://www.dropzonejs.com) 363 | # 364 | # Copyright (c) 2012, Matias Meno 365 | # 366 | # Permission is hereby granted, free of charge, to any person obtaining a copy 367 | # of this software and associated documentation files (the "Software"), to deal 368 | # in the Software without restriction, including without limitation the rights 369 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 370 | # copies of the Software, and to permit persons to whom the Software is 371 | # furnished to do so, subject to the following conditions: 372 | # 373 | # The above copyright notice and this permission notice shall be included in 374 | # all copies or substantial portions of the Software. 375 | # 376 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 377 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 378 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 379 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 380 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 381 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 382 | # THE SOFTWARE. 383 | # 384 | */ 385 | 386 | 387 | (function() { 388 | var Dropzone, Em, camelize, contentLoaded, noop, without, 389 | __hasProp = {}.hasOwnProperty, 390 | __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, 391 | __slice = [].slice; 392 | 393 | Em = typeof Emitter !== "undefined" && Emitter !== null ? Emitter : require("emitter"); 394 | 395 | noop = function() {}; 396 | 397 | Dropzone = (function(_super) { 398 | var extend; 399 | 400 | __extends(Dropzone, _super); 401 | 402 | /* 403 | This is a list of all available events you can register on a dropzone object. 404 | 405 | You can register an event handler like this: 406 | 407 | dropzone.on("dragEnter", function() { }); 408 | */ 409 | 410 | 411 | Dropzone.prototype.events = ["drop", "dragstart", "dragend", "dragenter", "dragover", "dragleave", "selectedfiles", "addedfile", "removedfile", "thumbnail", "error", "errormultiple", "processing", "processingmultiple", "uploadprogress", "totaluploadprogress", "sending", "sendingmultiple", "success", "successmultiple", "canceled", "canceledmultiple", "complete", "completemultiple", "reset", "maxfilesexceeded"]; 412 | 413 | Dropzone.prototype.defaultOptions = { 414 | url: null, 415 | method: "post", 416 | withCredentials: false, 417 | parallelUploads: 2, 418 | uploadMultiple: false, 419 | maxFilesize: 256, 420 | paramName: "file", 421 | createImageThumbnails: true, 422 | maxThumbnailFilesize: 10, 423 | thumbnailWidth: 100, 424 | thumbnailHeight: 100, 425 | maxFiles: null, 426 | params: {}, 427 | clickable: true, 428 | ignoreHiddenFiles: true, 429 | acceptedFiles: null, 430 | acceptedMimeTypes: null, 431 | autoProcessQueue: true, 432 | addRemoveLinks: false, 433 | previewsContainer: null, 434 | dictDefaultMessage: "Drop files here to upload", 435 | dictFallbackMessage: "Your browser does not support drag'n'drop file uploads.", 436 | dictFallbackText: "Please use the fallback form below to upload your files like in the olden days.", 437 | dictFileTooBig: "File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.", 438 | dictInvalidFileType: "You can't upload files of this type.", 439 | dictResponseError: "Server responded with {{statusCode}} code.", 440 | dictCancelUpload: "Cancel upload", 441 | dictCancelUploadConfirmation: "Are you sure you want to cancel this upload?", 442 | dictRemoveFile: "Remove file", 443 | dictRemoveFileConfirmation: null, 444 | dictMaxFilesExceeded: "You can only upload {{maxFiles}} files.", 445 | accept: function(file, done) { 446 | return done(); 447 | }, 448 | init: function() { 449 | return noop; 450 | }, 451 | forceFallback: false, 452 | fallback: function() { 453 | var child, messageElement, span, _i, _len, _ref; 454 | this.element.className = "" + this.element.className + " dz-browser-not-supported"; 455 | _ref = this.element.getElementsByTagName("div"); 456 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 457 | child = _ref[_i]; 458 | if (/(^| )dz-message($| )/.test(child.className)) { 459 | messageElement = child; 460 | child.className = "dz-message"; 461 | continue; 462 | } 463 | } 464 | if (!messageElement) { 465 | messageElement = Dropzone.createElement("
"); 466 | this.element.appendChild(messageElement); 467 | } 468 | span = messageElement.getElementsByTagName("span")[0]; 469 | if (span) { 470 | span.textContent = this.options.dictFallbackMessage; 471 | } 472 | return this.element.appendChild(this.getFallbackForm()); 473 | }, 474 | resize: function(file) { 475 | var info, srcRatio, trgRatio; 476 | info = { 477 | srcX: 0, 478 | srcY: 0, 479 | srcWidth: file.width, 480 | srcHeight: file.height 481 | }; 482 | srcRatio = file.width / file.height; 483 | trgRatio = this.options.thumbnailWidth / this.options.thumbnailHeight; 484 | if (file.height < this.options.thumbnailHeight || file.width < this.options.thumbnailWidth) { 485 | info.trgHeight = info.srcHeight; 486 | info.trgWidth = info.srcWidth; 487 | } else { 488 | if (srcRatio > trgRatio) { 489 | info.srcHeight = file.height; 490 | info.srcWidth = info.srcHeight * trgRatio; 491 | } else { 492 | info.srcWidth = file.width; 493 | info.srcHeight = info.srcWidth / trgRatio; 494 | } 495 | } 496 | info.srcX = (file.width - info.srcWidth) / 2; 497 | info.srcY = (file.height - info.srcHeight) / 2; 498 | return info; 499 | }, 500 | /* 501 | Those functions register themselves to the events on init and handle all 502 | the user interface specific stuff. Overwriting them won't break the upload 503 | but can break the way it's displayed. 504 | You can overwrite them if you don't like the default behavior. If you just 505 | want to add an additional event handler, register it on the dropzone object 506 | and don't overwrite those options. 507 | */ 508 | 509 | drop: function(e) { 510 | return this.element.classList.remove("dz-drag-hover"); 511 | }, 512 | dragstart: noop, 513 | dragend: function(e) { 514 | return this.element.classList.remove("dz-drag-hover"); 515 | }, 516 | dragenter: function(e) { 517 | return this.element.classList.add("dz-drag-hover"); 518 | }, 519 | dragover: function(e) { 520 | return this.element.classList.add("dz-drag-hover"); 521 | }, 522 | dragleave: function(e) { 523 | return this.element.classList.remove("dz-drag-hover"); 524 | }, 525 | selectedfiles: function(files) { 526 | if (this.element === this.previewsContainer) { 527 | return this.element.classList.add("dz-started"); 528 | } 529 | }, 530 | reset: function() { 531 | return this.element.classList.remove("dz-started"); 532 | }, 533 | addedfile: function(file) { 534 | var _this = this; 535 | file.previewElement = Dropzone.createElement(this.options.previewTemplate); 536 | file.previewTemplate = file.previewElement; 537 | this.previewsContainer.appendChild(file.previewElement); 538 | file.previewElement.querySelector("[data-dz-name]").textContent = file.name; 539 | file.previewElement.querySelector("[data-dz-size]").innerHTML = this.filesize(file.size); 540 | if (this.options.addRemoveLinks) { 541 | file._removeLink = Dropzone.createElement("" + this.options.dictRemoveFile + ""); 542 | file._removeLink.addEventListener("click", function(e) { 543 | e.preventDefault(); 544 | e.stopPropagation(); 545 | if (file.status === Dropzone.UPLOADING) { 546 | return Dropzone.confirm(_this.options.dictCancelUploadConfirmation, function() { 547 | return _this.removeFile(file); 548 | }); 549 | } else { 550 | if (_this.options.dictRemoveFileConfirmation) { 551 | return Dropzone.confirm(_this.options.dictRemoveFileConfirmation, function() { 552 | return _this.removeFile(file); 553 | }); 554 | } else { 555 | return _this.removeFile(file); 556 | } 557 | } 558 | }); 559 | file.previewElement.appendChild(file._removeLink); 560 | } 561 | return this._updateMaxFilesReachedClass(); 562 | }, 563 | removedfile: function(file) { 564 | var _ref; 565 | if ((_ref = file.previewElement) != null) { 566 | _ref.parentNode.removeChild(file.previewElement); 567 | } 568 | return this._updateMaxFilesReachedClass(); 569 | }, 570 | thumbnail: function(file, dataUrl) { 571 | var thumbnailElement; 572 | file.previewElement.classList.remove("dz-file-preview"); 573 | file.previewElement.classList.add("dz-image-preview"); 574 | thumbnailElement = file.previewElement.querySelector("[data-dz-thumbnail]"); 575 | thumbnailElement.alt = file.name; 576 | return thumbnailElement.src = dataUrl; 577 | }, 578 | error: function(file, message) { 579 | file.previewElement.classList.add("dz-error"); 580 | return file.previewElement.querySelector("[data-dz-errormessage]").textContent = message; 581 | }, 582 | errormultiple: noop, 583 | processing: function(file) { 584 | file.previewElement.classList.add("dz-processing"); 585 | if (file._removeLink) { 586 | return file._removeLink.textContent = this.options.dictCancelUpload; 587 | } 588 | }, 589 | processingmultiple: noop, 590 | uploadprogress: function(file, progress, bytesSent) { 591 | return file.previewElement.querySelector("[data-dz-uploadprogress]").style.width = "" + progress + "%"; 592 | }, 593 | totaluploadprogress: noop, 594 | sending: noop, 595 | sendingmultiple: noop, 596 | success: function(file) { 597 | return file.previewElement.classList.add("dz-success"); 598 | }, 599 | successmultiple: noop, 600 | canceled: function(file) { 601 | return this.emit("error", file, "Upload canceled."); 602 | }, 603 | canceledmultiple: noop, 604 | complete: function(file) { 605 | if (file._removeLink) { 606 | return file._removeLink.textContent = this.options.dictRemoveFile; 607 | } 608 | }, 609 | completemultiple: noop, 610 | maxfilesexceeded: noop, 611 | previewTemplate: "
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
" 612 | }; 613 | 614 | extend = function() { 615 | var key, object, objects, target, val, _i, _len; 616 | target = arguments[0], objects = 2 <= arguments.length ? __slice.call(arguments, 1) : []; 617 | for (_i = 0, _len = objects.length; _i < _len; _i++) { 618 | object = objects[_i]; 619 | for (key in object) { 620 | val = object[key]; 621 | target[key] = val; 622 | } 623 | } 624 | return target; 625 | }; 626 | 627 | function Dropzone(element, options) { 628 | var elementOptions, fallback, _ref; 629 | this.element = element; 630 | this.version = Dropzone.version; 631 | this.defaultOptions.previewTemplate = this.defaultOptions.previewTemplate.replace(/\n*/g, ""); 632 | this.clickableElements = []; 633 | this.listeners = []; 634 | this.files = []; 635 | if (typeof this.element === "string") { 636 | this.element = document.querySelector(this.element); 637 | } 638 | if (!(this.element && (this.element.nodeType != null))) { 639 | throw new Error("Invalid dropzone element."); 640 | } 641 | if (this.element.dropzone) { 642 | throw new Error("Dropzone already attached."); 643 | } 644 | Dropzone.instances.push(this); 645 | element.dropzone = this; 646 | elementOptions = (_ref = Dropzone.optionsForElement(this.element)) != null ? _ref : {}; 647 | this.options = extend({}, this.defaultOptions, elementOptions, options != null ? options : {}); 648 | if (this.options.forceFallback || !Dropzone.isBrowserSupported()) { 649 | return this.options.fallback.call(this); 650 | } 651 | if (this.options.url == null) { 652 | this.options.url = this.element.getAttribute("action"); 653 | } 654 | if (!this.options.url) { 655 | throw new Error("No URL provided."); 656 | } 657 | if (this.options.acceptedFiles && this.options.acceptedMimeTypes) { 658 | throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated."); 659 | } 660 | if (this.options.acceptedMimeTypes) { 661 | this.options.acceptedFiles = this.options.acceptedMimeTypes; 662 | delete this.options.acceptedMimeTypes; 663 | } 664 | this.options.method = this.options.method.toUpperCase(); 665 | if ((fallback = this.getExistingFallback()) && fallback.parentNode) { 666 | fallback.parentNode.removeChild(fallback); 667 | } 668 | if (this.options.previewsContainer) { 669 | this.previewsContainer = Dropzone.getElement(this.options.previewsContainer, "previewsContainer"); 670 | } else { 671 | this.previewsContainer = this.element; 672 | } 673 | if (this.options.clickable) { 674 | if (this.options.clickable === true) { 675 | this.clickableElements = [this.element]; 676 | } else { 677 | this.clickableElements = Dropzone.getElements(this.options.clickable, "clickable"); 678 | } 679 | } 680 | this.init(); 681 | } 682 | 683 | Dropzone.prototype.getAcceptedFiles = function() { 684 | var file, _i, _len, _ref, _results; 685 | _ref = this.files; 686 | _results = []; 687 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 688 | file = _ref[_i]; 689 | if (file.accepted) { 690 | _results.push(file); 691 | } 692 | } 693 | return _results; 694 | }; 695 | 696 | Dropzone.prototype.getRejectedFiles = function() { 697 | var file, _i, _len, _ref, _results; 698 | _ref = this.files; 699 | _results = []; 700 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 701 | file = _ref[_i]; 702 | if (!file.accepted) { 703 | _results.push(file); 704 | } 705 | } 706 | return _results; 707 | }; 708 | 709 | Dropzone.prototype.getQueuedFiles = function() { 710 | var file, _i, _len, _ref, _results; 711 | _ref = this.files; 712 | _results = []; 713 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 714 | file = _ref[_i]; 715 | if (file.status === Dropzone.QUEUED) { 716 | _results.push(file); 717 | } 718 | } 719 | return _results; 720 | }; 721 | 722 | Dropzone.prototype.getUploadingFiles = function() { 723 | var file, _i, _len, _ref, _results; 724 | _ref = this.files; 725 | _results = []; 726 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 727 | file = _ref[_i]; 728 | if (file.status === Dropzone.UPLOADING) { 729 | _results.push(file); 730 | } 731 | } 732 | return _results; 733 | }; 734 | 735 | Dropzone.prototype.init = function() { 736 | var eventName, noPropagation, setupHiddenFileInput, _i, _len, _ref, _ref1, 737 | _this = this; 738 | if (this.element.tagName === "form") { 739 | this.element.setAttribute("enctype", "multipart/form-data"); 740 | } 741 | if (this.element.classList.contains("dropzone") && !this.element.querySelector(".dz-message")) { 742 | this.element.appendChild(Dropzone.createElement("
" + this.options.dictDefaultMessage + "
")); 743 | } 744 | if (this.clickableElements.length) { 745 | setupHiddenFileInput = function() { 746 | if (_this.hiddenFileInput) { 747 | document.body.removeChild(_this.hiddenFileInput); 748 | } 749 | _this.hiddenFileInput = document.createElement("input"); 750 | _this.hiddenFileInput.setAttribute("type", "file"); 751 | _this.hiddenFileInput.setAttribute("multiple", "multiple"); 752 | if (_this.options.acceptedFiles != null) { 753 | _this.hiddenFileInput.setAttribute("accept", _this.options.acceptedFiles); 754 | } 755 | _this.hiddenFileInput.style.visibility = "hidden"; 756 | _this.hiddenFileInput.style.position = "absolute"; 757 | _this.hiddenFileInput.style.top = "0"; 758 | _this.hiddenFileInput.style.left = "0"; 759 | _this.hiddenFileInput.style.height = "0"; 760 | _this.hiddenFileInput.style.width = "0"; 761 | document.body.appendChild(_this.hiddenFileInput); 762 | return _this.hiddenFileInput.addEventListener("change", function() { 763 | var files; 764 | files = _this.hiddenFileInput.files; 765 | if (files.length) { 766 | _this.emit("selectedfiles", files); 767 | _this.handleFiles(files); 768 | } 769 | return setupHiddenFileInput(); 770 | }); 771 | }; 772 | setupHiddenFileInput(); 773 | } 774 | this.URL = (_ref = window.URL) != null ? _ref : window.webkitURL; 775 | _ref1 = this.events; 776 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) { 777 | eventName = _ref1[_i]; 778 | this.on(eventName, this.options[eventName]); 779 | } 780 | this.on("uploadprogress", function() { 781 | return _this.updateTotalUploadProgress(); 782 | }); 783 | this.on("removedfile", function() { 784 | return _this.updateTotalUploadProgress(); 785 | }); 786 | this.on("canceled", function(file) { 787 | return _this.emit("complete", file); 788 | }); 789 | noPropagation = function(e) { 790 | e.stopPropagation(); 791 | if (e.preventDefault) { 792 | return e.preventDefault(); 793 | } else { 794 | return e.returnValue = false; 795 | } 796 | }; 797 | this.listeners = [ 798 | { 799 | element: this.element, 800 | events: { 801 | "dragstart": function(e) { 802 | return _this.emit("dragstart", e); 803 | }, 804 | "dragenter": function(e) { 805 | noPropagation(e); 806 | return _this.emit("dragenter", e); 807 | }, 808 | "dragover": function(e) { 809 | noPropagation(e); 810 | return _this.emit("dragover", e); 811 | }, 812 | "dragleave": function(e) { 813 | return _this.emit("dragleave", e); 814 | }, 815 | "drop": function(e) { 816 | noPropagation(e); 817 | return _this.drop(e); 818 | }, 819 | "dragend": function(e) { 820 | return _this.emit("dragend", e); 821 | } 822 | } 823 | } 824 | ]; 825 | this.clickableElements.forEach(function(clickableElement) { 826 | return _this.listeners.push({ 827 | element: clickableElement, 828 | events: { 829 | "click": function(evt) { 830 | if ((clickableElement !== _this.element) || (evt.target === _this.element || Dropzone.elementInside(evt.target, _this.element.querySelector(".dz-message")))) { 831 | return _this.hiddenFileInput.click(); 832 | } 833 | } 834 | } 835 | }); 836 | }); 837 | this.enable(); 838 | return this.options.init.call(this); 839 | }; 840 | 841 | Dropzone.prototype.destroy = function() { 842 | var _ref; 843 | this.disable(); 844 | this.removeAllFiles(true); 845 | if ((_ref = this.hiddenFileInput) != null ? _ref.parentNode : void 0) { 846 | this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput); 847 | this.hiddenFileInput = null; 848 | } 849 | return delete this.element.dropzone; 850 | }; 851 | 852 | Dropzone.prototype.updateTotalUploadProgress = function() { 853 | var acceptedFiles, file, totalBytes, totalBytesSent, totalUploadProgress, _i, _len, _ref; 854 | totalBytesSent = 0; 855 | totalBytes = 0; 856 | acceptedFiles = this.getAcceptedFiles(); 857 | if (acceptedFiles.length) { 858 | _ref = this.getAcceptedFiles(); 859 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 860 | file = _ref[_i]; 861 | totalBytesSent += file.upload.bytesSent; 862 | totalBytes += file.upload.total; 863 | } 864 | totalUploadProgress = 100 * totalBytesSent / totalBytes; 865 | } else { 866 | totalUploadProgress = 100; 867 | } 868 | return this.emit("totaluploadprogress", totalUploadProgress, totalBytes, totalBytesSent); 869 | }; 870 | 871 | Dropzone.prototype.getFallbackForm = function() { 872 | var existingFallback, fields, fieldsString, form; 873 | if (existingFallback = this.getExistingFallback()) { 874 | return existingFallback; 875 | } 876 | fieldsString = "
"; 877 | if (this.options.dictFallbackText) { 878 | fieldsString += "

" + this.options.dictFallbackText + "

"; 879 | } 880 | fieldsString += "
"; 881 | fields = Dropzone.createElement(fieldsString); 882 | if (this.element.tagName !== "FORM") { 883 | form = Dropzone.createElement("
"); 884 | form.appendChild(fields); 885 | } else { 886 | this.element.setAttribute("enctype", "multipart/form-data"); 887 | this.element.setAttribute("method", this.options.method); 888 | } 889 | return form != null ? form : fields; 890 | }; 891 | 892 | Dropzone.prototype.getExistingFallback = function() { 893 | var fallback, getFallback, tagName, _i, _len, _ref; 894 | getFallback = function(elements) { 895 | var el, _i, _len; 896 | for (_i = 0, _len = elements.length; _i < _len; _i++) { 897 | el = elements[_i]; 898 | if (/(^| )fallback($| )/.test(el.className)) { 899 | return el; 900 | } 901 | } 902 | }; 903 | _ref = ["div", "form"]; 904 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 905 | tagName = _ref[_i]; 906 | if (fallback = getFallback(this.element.getElementsByTagName(tagName))) { 907 | return fallback; 908 | } 909 | } 910 | }; 911 | 912 | Dropzone.prototype.setupEventListeners = function() { 913 | var elementListeners, event, listener, _i, _len, _ref, _results; 914 | _ref = this.listeners; 915 | _results = []; 916 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 917 | elementListeners = _ref[_i]; 918 | _results.push((function() { 919 | var _ref1, _results1; 920 | _ref1 = elementListeners.events; 921 | _results1 = []; 922 | for (event in _ref1) { 923 | listener = _ref1[event]; 924 | _results1.push(elementListeners.element.addEventListener(event, listener, false)); 925 | } 926 | return _results1; 927 | })()); 928 | } 929 | return _results; 930 | }; 931 | 932 | Dropzone.prototype.removeEventListeners = function() { 933 | var elementListeners, event, listener, _i, _len, _ref, _results; 934 | _ref = this.listeners; 935 | _results = []; 936 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 937 | elementListeners = _ref[_i]; 938 | _results.push((function() { 939 | var _ref1, _results1; 940 | _ref1 = elementListeners.events; 941 | _results1 = []; 942 | for (event in _ref1) { 943 | listener = _ref1[event]; 944 | _results1.push(elementListeners.element.removeEventListener(event, listener, false)); 945 | } 946 | return _results1; 947 | })()); 948 | } 949 | return _results; 950 | }; 951 | 952 | Dropzone.prototype.disable = function() { 953 | var file, _i, _len, _ref, _results; 954 | this.clickableElements.forEach(function(element) { 955 | return element.classList.remove("dz-clickable"); 956 | }); 957 | this.removeEventListeners(); 958 | _ref = this.files; 959 | _results = []; 960 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 961 | file = _ref[_i]; 962 | _results.push(this.cancelUpload(file)); 963 | } 964 | return _results; 965 | }; 966 | 967 | Dropzone.prototype.enable = function() { 968 | this.clickableElements.forEach(function(element) { 969 | return element.classList.add("dz-clickable"); 970 | }); 971 | return this.setupEventListeners(); 972 | }; 973 | 974 | Dropzone.prototype.filesize = function(size) { 975 | var string; 976 | if (size >= 100000000000) { 977 | size = size / 100000000000; 978 | string = "TB"; 979 | } else if (size >= 100000000) { 980 | size = size / 100000000; 981 | string = "GB"; 982 | } else if (size >= 100000) { 983 | size = size / 100000; 984 | string = "MB"; 985 | } else if (size >= 100) { 986 | size = size / 100; 987 | string = "KB"; 988 | } else { 989 | size = size * 10; 990 | string = "b"; 991 | } 992 | return "" + (Math.round(size) / 10) + " " + string; 993 | }; 994 | 995 | Dropzone.prototype._updateMaxFilesReachedClass = function() { 996 | if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) { 997 | return this.element.classList.add("dz-max-files-reached"); 998 | } else { 999 | return this.element.classList.remove("dz-max-files-reached"); 1000 | } 1001 | }; 1002 | 1003 | Dropzone.prototype.drop = function(e) { 1004 | var files, items; 1005 | if (!e.dataTransfer) { 1006 | return; 1007 | } 1008 | this.emit("drop", e); 1009 | files = e.dataTransfer.files; 1010 | this.emit("selectedfiles", files); 1011 | if (files.length) { 1012 | items = e.dataTransfer.items; 1013 | if (items && items.length && ((items[0].webkitGetAsEntry != null) || (items[0].getAsEntry != null))) { 1014 | this.handleItems(items); 1015 | } else { 1016 | this.handleFiles(files); 1017 | } 1018 | } 1019 | }; 1020 | 1021 | Dropzone.prototype.handleFiles = function(files) { 1022 | var file, _i, _len, _results; 1023 | _results = []; 1024 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1025 | file = files[_i]; 1026 | _results.push(this.addFile(file)); 1027 | } 1028 | return _results; 1029 | }; 1030 | 1031 | Dropzone.prototype.handleItems = function(items) { 1032 | var entry, item, _i, _len; 1033 | for (_i = 0, _len = items.length; _i < _len; _i++) { 1034 | item = items[_i]; 1035 | if (item.webkitGetAsEntry != null) { 1036 | entry = item.webkitGetAsEntry(); 1037 | if (entry.isFile) { 1038 | this.addFile(item.getAsFile()); 1039 | } else if (entry.isDirectory) { 1040 | this.addDirectory(entry, entry.name); 1041 | } 1042 | } else { 1043 | this.addFile(item.getAsFile()); 1044 | } 1045 | } 1046 | }; 1047 | 1048 | Dropzone.prototype.accept = function(file, done) { 1049 | if (file.size > this.options.maxFilesize * 1024 * 1024) { 1050 | return done(this.options.dictFileTooBig.replace("{{filesize}}", Math.round(file.size / 1024 / 10.24) / 100).replace("{{maxFilesize}}", this.options.maxFilesize)); 1051 | } else if (!Dropzone.isValidFile(file, this.options.acceptedFiles)) { 1052 | return done(this.options.dictInvalidFileType); 1053 | } else if (this.options.maxFiles && this.getAcceptedFiles().length >= this.options.maxFiles) { 1054 | done(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}", this.options.maxFiles)); 1055 | return this.emit("maxfilesexceeded", file); 1056 | } else { 1057 | return this.options.accept.call(this, file, done); 1058 | } 1059 | }; 1060 | 1061 | Dropzone.prototype.addFile = function(file) { 1062 | var _this = this; 1063 | file.upload = { 1064 | progress: 0, 1065 | total: file.size, 1066 | bytesSent: 0 1067 | }; 1068 | this.files.push(file); 1069 | file.status = Dropzone.ADDED; 1070 | this.emit("addedfile", file); 1071 | if (this.options.createImageThumbnails && file.type.match(/image.*/) && file.size <= this.options.maxThumbnailFilesize * 1024 * 1024) { 1072 | this.createThumbnail(file); 1073 | } 1074 | return this.accept(file, function(error) { 1075 | if (error) { 1076 | file.accepted = false; 1077 | return _this._errorProcessing([file], error); 1078 | } else { 1079 | return _this.enqueueFile(file); 1080 | } 1081 | }); 1082 | }; 1083 | 1084 | Dropzone.prototype.enqueueFiles = function(files) { 1085 | var file, _i, _len; 1086 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1087 | file = files[_i]; 1088 | this.enqueueFile(file); 1089 | } 1090 | return null; 1091 | }; 1092 | 1093 | Dropzone.prototype.enqueueFile = function(file) { 1094 | var _this = this; 1095 | file.accepted = true; 1096 | if (file.status === Dropzone.ADDED) { 1097 | file.status = Dropzone.QUEUED; 1098 | if (this.options.autoProcessQueue) { 1099 | return setTimeout((function() { 1100 | return _this.processQueue(); 1101 | }), 1); 1102 | } 1103 | } else { 1104 | throw new Error("This file can't be queued because it has already been processed or was rejected."); 1105 | } 1106 | }; 1107 | 1108 | Dropzone.prototype.addDirectory = function(entry, path) { 1109 | var dirReader, entriesReader, 1110 | _this = this; 1111 | dirReader = entry.createReader(); 1112 | entriesReader = function(entries) { 1113 | var _i, _len; 1114 | for (_i = 0, _len = entries.length; _i < _len; _i++) { 1115 | entry = entries[_i]; 1116 | if (entry.isFile) { 1117 | entry.file(function(file) { 1118 | if (_this.options.ignoreHiddenFiles && file.name.substring(0, 1) === '.') { 1119 | return; 1120 | } 1121 | file.fullPath = "" + path + "/" + file.name; 1122 | return _this.addFile(file); 1123 | }); 1124 | } else if (entry.isDirectory) { 1125 | _this.addDirectory(entry, "" + path + "/" + entry.name); 1126 | } 1127 | } 1128 | }; 1129 | return dirReader.readEntries(entriesReader, function(error) { 1130 | return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log(error) : void 0 : void 0; 1131 | }); 1132 | }; 1133 | 1134 | Dropzone.prototype.removeFile = function(file) { 1135 | if (file.status === Dropzone.UPLOADING) { 1136 | this.cancelUpload(file); 1137 | } 1138 | this.files = without(this.files, file); 1139 | this.emit("removedfile", file); 1140 | if (this.files.length === 0) { 1141 | return this.emit("reset"); 1142 | } 1143 | }; 1144 | 1145 | Dropzone.prototype.removeAllFiles = function(cancelIfNecessary) { 1146 | var file, _i, _len, _ref; 1147 | if (cancelIfNecessary == null) { 1148 | cancelIfNecessary = false; 1149 | } 1150 | _ref = this.files.slice(); 1151 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 1152 | file = _ref[_i]; 1153 | if (file.status !== Dropzone.UPLOADING || cancelIfNecessary) { 1154 | this.removeFile(file); 1155 | } 1156 | } 1157 | return null; 1158 | }; 1159 | 1160 | Dropzone.prototype.createThumbnail = function(file) { 1161 | var fileReader, 1162 | _this = this; 1163 | fileReader = new FileReader; 1164 | fileReader.onload = function() { 1165 | var img; 1166 | img = new Image; 1167 | img.onload = function() { 1168 | var canvas, ctx, resizeInfo, thumbnail, _ref, _ref1, _ref2, _ref3; 1169 | file.width = img.width; 1170 | file.height = img.height; 1171 | resizeInfo = _this.options.resize.call(_this, file); 1172 | if (resizeInfo.trgWidth == null) { 1173 | resizeInfo.trgWidth = _this.options.thumbnailWidth; 1174 | } 1175 | if (resizeInfo.trgHeight == null) { 1176 | resizeInfo.trgHeight = _this.options.thumbnailHeight; 1177 | } 1178 | canvas = document.createElement("canvas"); 1179 | ctx = canvas.getContext("2d"); 1180 | canvas.width = resizeInfo.trgWidth; 1181 | canvas.height = resizeInfo.trgHeight; 1182 | ctx.drawImage(img, (_ref = resizeInfo.srcX) != null ? _ref : 0, (_ref1 = resizeInfo.srcY) != null ? _ref1 : 0, resizeInfo.srcWidth, resizeInfo.srcHeight, (_ref2 = resizeInfo.trgX) != null ? _ref2 : 0, (_ref3 = resizeInfo.trgY) != null ? _ref3 : 0, resizeInfo.trgWidth, resizeInfo.trgHeight); 1183 | thumbnail = canvas.toDataURL("image/png"); 1184 | return _this.emit("thumbnail", file, thumbnail); 1185 | }; 1186 | return img.src = fileReader.result; 1187 | }; 1188 | return fileReader.readAsDataURL(file); 1189 | }; 1190 | 1191 | Dropzone.prototype.processQueue = function() { 1192 | var i, parallelUploads, processingLength, queuedFiles; 1193 | parallelUploads = this.options.parallelUploads; 1194 | processingLength = this.getUploadingFiles().length; 1195 | i = processingLength; 1196 | if (processingLength >= parallelUploads) { 1197 | return; 1198 | } 1199 | queuedFiles = this.getQueuedFiles(); 1200 | if (!(queuedFiles.length > 0)) { 1201 | return; 1202 | } 1203 | if (this.options.uploadMultiple) { 1204 | return this.processFiles(queuedFiles.slice(0, parallelUploads - processingLength)); 1205 | } else { 1206 | while (i < parallelUploads) { 1207 | if (!queuedFiles.length) { 1208 | return; 1209 | } 1210 | this.processFile(queuedFiles.shift()); 1211 | i++; 1212 | } 1213 | } 1214 | }; 1215 | 1216 | Dropzone.prototype.processFile = function(file) { 1217 | return this.processFiles([file]); 1218 | }; 1219 | 1220 | Dropzone.prototype.processFiles = function(files) { 1221 | var file, _i, _len; 1222 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1223 | file = files[_i]; 1224 | file.processing = true; 1225 | file.status = Dropzone.UPLOADING; 1226 | this.emit("processing", file); 1227 | } 1228 | if (this.options.uploadMultiple) { 1229 | this.emit("processingmultiple", files); 1230 | } 1231 | return this.uploadFiles(files); 1232 | }; 1233 | 1234 | Dropzone.prototype._getFilesWithXhr = function(xhr) { 1235 | var file, files; 1236 | return files = (function() { 1237 | var _i, _len, _ref, _results; 1238 | _ref = this.files; 1239 | _results = []; 1240 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 1241 | file = _ref[_i]; 1242 | if (file.xhr === xhr) { 1243 | _results.push(file); 1244 | } 1245 | } 1246 | return _results; 1247 | }).call(this); 1248 | }; 1249 | 1250 | Dropzone.prototype.cancelUpload = function(file) { 1251 | var groupedFile, groupedFiles, _i, _j, _len, _len1, _ref; 1252 | if (file.status === Dropzone.UPLOADING) { 1253 | groupedFiles = this._getFilesWithXhr(file.xhr); 1254 | for (_i = 0, _len = groupedFiles.length; _i < _len; _i++) { 1255 | groupedFile = groupedFiles[_i]; 1256 | groupedFile.status = Dropzone.CANCELED; 1257 | } 1258 | file.xhr.abort(); 1259 | for (_j = 0, _len1 = groupedFiles.length; _j < _len1; _j++) { 1260 | groupedFile = groupedFiles[_j]; 1261 | this.emit("canceled", groupedFile); 1262 | } 1263 | if (this.options.uploadMultiple) { 1264 | this.emit("canceledmultiple", groupedFiles); 1265 | } 1266 | } else if ((_ref = file.status) === Dropzone.ADDED || _ref === Dropzone.QUEUED) { 1267 | file.status = Dropzone.CANCELED; 1268 | this.emit("canceled", file); 1269 | if (this.options.uploadMultiple) { 1270 | this.emit("canceledmultiple", [file]); 1271 | } 1272 | } 1273 | if (this.options.autoProcessQueue) { 1274 | return this.processQueue(); 1275 | } 1276 | }; 1277 | 1278 | Dropzone.prototype.uploadFile = function(file) { 1279 | return this.uploadFiles([file]); 1280 | }; 1281 | 1282 | Dropzone.prototype.uploadFiles = function(files) { 1283 | var file, formData, handleError, headerName, headerValue, headers, input, inputName, inputType, key, progressObj, response, updateProgress, value, xhr, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3, 1284 | _this = this; 1285 | xhr = new XMLHttpRequest(); 1286 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1287 | file = files[_i]; 1288 | file.xhr = xhr; 1289 | } 1290 | xhr.open(this.options.method, this.options.url, true); 1291 | xhr.withCredentials = !!this.options.withCredentials; 1292 | response = null; 1293 | handleError = function() { 1294 | var _j, _len1, _results; 1295 | _results = []; 1296 | for (_j = 0, _len1 = files.length; _j < _len1; _j++) { 1297 | file = files[_j]; 1298 | _results.push(_this._errorProcessing(files, response || _this.options.dictResponseError.replace("{{statusCode}}", xhr.status), xhr)); 1299 | } 1300 | return _results; 1301 | }; 1302 | updateProgress = function(e) { 1303 | var allFilesFinished, progress, _j, _k, _l, _len1, _len2, _len3, _results; 1304 | if (e != null) { 1305 | progress = 100 * e.loaded / e.total; 1306 | for (_j = 0, _len1 = files.length; _j < _len1; _j++) { 1307 | file = files[_j]; 1308 | file.upload = { 1309 | progress: progress, 1310 | total: e.total, 1311 | bytesSent: e.loaded 1312 | }; 1313 | } 1314 | } else { 1315 | allFilesFinished = true; 1316 | progress = 100; 1317 | for (_k = 0, _len2 = files.length; _k < _len2; _k++) { 1318 | file = files[_k]; 1319 | if (!(file.upload.progress === 100 && file.upload.bytesSent === file.upload.total)) { 1320 | allFilesFinished = false; 1321 | } 1322 | file.upload.progress = progress; 1323 | file.upload.bytesSent = file.upload.total; 1324 | } 1325 | if (allFilesFinished) { 1326 | return; 1327 | } 1328 | } 1329 | _results = []; 1330 | for (_l = 0, _len3 = files.length; _l < _len3; _l++) { 1331 | file = files[_l]; 1332 | _results.push(_this.emit("uploadprogress", file, progress, file.upload.bytesSent)); 1333 | } 1334 | return _results; 1335 | }; 1336 | xhr.onload = function(e) { 1337 | var _ref; 1338 | if (files[0].status === Dropzone.CANCELED) { 1339 | return; 1340 | } 1341 | if (xhr.readyState !== 4) { 1342 | return; 1343 | } 1344 | response = xhr.responseText; 1345 | if (xhr.getResponseHeader("content-type") && ~xhr.getResponseHeader("content-type").indexOf("application/json")) { 1346 | try { 1347 | response = JSON.parse(response); 1348 | } catch (_error) { 1349 | e = _error; 1350 | response = "Invalid JSON response from server."; 1351 | } 1352 | } 1353 | updateProgress(); 1354 | if (!((200 <= (_ref = xhr.status) && _ref < 300))) { 1355 | return handleError(); 1356 | } else { 1357 | return _this._finished(files, response, e); 1358 | } 1359 | }; 1360 | xhr.onerror = function() { 1361 | if (files[0].status === Dropzone.CANCELED) { 1362 | return; 1363 | } 1364 | return handleError(); 1365 | }; 1366 | progressObj = (_ref = xhr.upload) != null ? _ref : xhr; 1367 | progressObj.onprogress = updateProgress; 1368 | headers = { 1369 | "Accept": "application/json", 1370 | "Cache-Control": "no-cache", 1371 | "X-Requested-With": "XMLHttpRequest" 1372 | }; 1373 | if (this.options.headers) { 1374 | extend(headers, this.options.headers); 1375 | } 1376 | for (headerName in headers) { 1377 | headerValue = headers[headerName]; 1378 | xhr.setRequestHeader(headerName, headerValue); 1379 | } 1380 | formData = new FormData(); 1381 | if (this.options.params) { 1382 | _ref1 = this.options.params; 1383 | for (key in _ref1) { 1384 | value = _ref1[key]; 1385 | formData.append(key, value); 1386 | } 1387 | } 1388 | for (_j = 0, _len1 = files.length; _j < _len1; _j++) { 1389 | file = files[_j]; 1390 | this.emit("sending", file, xhr, formData); 1391 | } 1392 | if (this.options.uploadMultiple) { 1393 | this.emit("sendingmultiple", files, xhr, formData); 1394 | } 1395 | if (this.element.tagName === "FORM") { 1396 | _ref2 = this.element.querySelectorAll("input, textarea, select, button"); 1397 | for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { 1398 | input = _ref2[_k]; 1399 | inputName = input.getAttribute("name"); 1400 | inputType = input.getAttribute("type"); 1401 | if (!inputType || ((_ref3 = inputType.toLowerCase()) !== "checkbox" && _ref3 !== "radio") || input.checked) { 1402 | formData.append(inputName, input.value); 1403 | } 1404 | } 1405 | } 1406 | for (_l = 0, _len3 = files.length; _l < _len3; _l++) { 1407 | file = files[_l]; 1408 | formData.append("" + this.options.paramName + (this.options.uploadMultiple ? "[]" : ""), file, file.name); 1409 | } 1410 | return xhr.send(formData); 1411 | }; 1412 | 1413 | Dropzone.prototype._finished = function(files, responseText, e) { 1414 | var file, _i, _len; 1415 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1416 | file = files[_i]; 1417 | file.status = Dropzone.SUCCESS; 1418 | this.emit("success", file, responseText, e); 1419 | this.emit("complete", file); 1420 | } 1421 | if (this.options.uploadMultiple) { 1422 | this.emit("successmultiple", files, responseText, e); 1423 | this.emit("completemultiple", files); 1424 | } 1425 | if (this.options.autoProcessQueue) { 1426 | return this.processQueue(); 1427 | } 1428 | }; 1429 | 1430 | Dropzone.prototype._errorProcessing = function(files, message, xhr) { 1431 | var file, _i, _len; 1432 | for (_i = 0, _len = files.length; _i < _len; _i++) { 1433 | file = files[_i]; 1434 | file.status = Dropzone.ERROR; 1435 | this.emit("error", file, message, xhr); 1436 | this.emit("complete", file); 1437 | } 1438 | if (this.options.uploadMultiple) { 1439 | this.emit("errormultiple", files, message, xhr); 1440 | this.emit("completemultiple", files); 1441 | } 1442 | if (this.options.autoProcessQueue) { 1443 | return this.processQueue(); 1444 | } 1445 | }; 1446 | 1447 | return Dropzone; 1448 | 1449 | })(Em); 1450 | 1451 | Dropzone.version = "3.7.1"; 1452 | 1453 | Dropzone.options = {}; 1454 | 1455 | Dropzone.optionsForElement = function(element) { 1456 | if (element.id) { 1457 | return Dropzone.options[camelize(element.id)]; 1458 | } else { 1459 | return void 0; 1460 | } 1461 | }; 1462 | 1463 | Dropzone.instances = []; 1464 | 1465 | Dropzone.forElement = function(element) { 1466 | if (typeof element === "string") { 1467 | element = document.querySelector(element); 1468 | } 1469 | if ((element != null ? element.dropzone : void 0) == null) { 1470 | throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone."); 1471 | } 1472 | return element.dropzone; 1473 | }; 1474 | 1475 | Dropzone.autoDiscover = true; 1476 | 1477 | Dropzone.discover = function() { 1478 | var checkElements, dropzone, dropzones, _i, _len, _results; 1479 | if (document.querySelectorAll) { 1480 | dropzones = document.querySelectorAll(".dropzone"); 1481 | } else { 1482 | dropzones = []; 1483 | checkElements = function(elements) { 1484 | var el, _i, _len, _results; 1485 | _results = []; 1486 | for (_i = 0, _len = elements.length; _i < _len; _i++) { 1487 | el = elements[_i]; 1488 | if (/(^| )dropzone($| )/.test(el.className)) { 1489 | _results.push(dropzones.push(el)); 1490 | } else { 1491 | _results.push(void 0); 1492 | } 1493 | } 1494 | return _results; 1495 | }; 1496 | checkElements(document.getElementsByTagName("div")); 1497 | checkElements(document.getElementsByTagName("form")); 1498 | } 1499 | _results = []; 1500 | for (_i = 0, _len = dropzones.length; _i < _len; _i++) { 1501 | dropzone = dropzones[_i]; 1502 | if (Dropzone.optionsForElement(dropzone) !== false) { 1503 | _results.push(new Dropzone(dropzone)); 1504 | } else { 1505 | _results.push(void 0); 1506 | } 1507 | } 1508 | return _results; 1509 | }; 1510 | 1511 | Dropzone.blacklistedBrowsers = [/opera.*Macintosh.*version\/12/i]; 1512 | 1513 | Dropzone.isBrowserSupported = function() { 1514 | var capableBrowser, regex, _i, _len, _ref; 1515 | capableBrowser = true; 1516 | if (window.File && window.FileReader && window.FileList && window.Blob && window.FormData && document.querySelector) { 1517 | if (!("classList" in document.createElement("a"))) { 1518 | capableBrowser = false; 1519 | } else { 1520 | _ref = Dropzone.blacklistedBrowsers; 1521 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 1522 | regex = _ref[_i]; 1523 | if (regex.test(navigator.userAgent)) { 1524 | capableBrowser = false; 1525 | continue; 1526 | } 1527 | } 1528 | } 1529 | } else { 1530 | capableBrowser = false; 1531 | } 1532 | return capableBrowser; 1533 | }; 1534 | 1535 | without = function(list, rejectedItem) { 1536 | var item, _i, _len, _results; 1537 | _results = []; 1538 | for (_i = 0, _len = list.length; _i < _len; _i++) { 1539 | item = list[_i]; 1540 | if (item !== rejectedItem) { 1541 | _results.push(item); 1542 | } 1543 | } 1544 | return _results; 1545 | }; 1546 | 1547 | camelize = function(str) { 1548 | return str.replace(/[\-_](\w)/g, function(match) { 1549 | return match[1].toUpperCase(); 1550 | }); 1551 | }; 1552 | 1553 | Dropzone.createElement = function(string) { 1554 | var div; 1555 | div = document.createElement("div"); 1556 | div.innerHTML = string; 1557 | return div.childNodes[0]; 1558 | }; 1559 | 1560 | Dropzone.elementInside = function(element, container) { 1561 | if (element === container) { 1562 | return true; 1563 | } 1564 | while (element = element.parentNode) { 1565 | if (element === container) { 1566 | return true; 1567 | } 1568 | } 1569 | return false; 1570 | }; 1571 | 1572 | Dropzone.getElement = function(el, name) { 1573 | var element; 1574 | if (typeof el === "string") { 1575 | element = document.querySelector(el); 1576 | } else if (el.nodeType != null) { 1577 | element = el; 1578 | } 1579 | if (element == null) { 1580 | throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector or a plain HTML element."); 1581 | } 1582 | return element; 1583 | }; 1584 | 1585 | Dropzone.getElements = function(els, name) { 1586 | var e, el, elements, _i, _j, _len, _len1, _ref; 1587 | if (els instanceof Array) { 1588 | elements = []; 1589 | try { 1590 | for (_i = 0, _len = els.length; _i < _len; _i++) { 1591 | el = els[_i]; 1592 | elements.push(this.getElement(el, name)); 1593 | } 1594 | } catch (_error) { 1595 | e = _error; 1596 | elements = null; 1597 | } 1598 | } else if (typeof els === "string") { 1599 | elements = []; 1600 | _ref = document.querySelectorAll(els); 1601 | for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) { 1602 | el = _ref[_j]; 1603 | elements.push(el); 1604 | } 1605 | } else if (els.nodeType != null) { 1606 | elements = [els]; 1607 | } 1608 | if (!((elements != null) && elements.length)) { 1609 | throw new Error("Invalid `" + name + "` option provided. Please provide a CSS selector, a plain HTML element or a list of those."); 1610 | } 1611 | return elements; 1612 | }; 1613 | 1614 | Dropzone.confirm = function(question, accepted, rejected) { 1615 | if (window.confirm(question)) { 1616 | return accepted(); 1617 | } else if (rejected != null) { 1618 | return rejected(); 1619 | } 1620 | }; 1621 | 1622 | Dropzone.isValidFile = function(file, acceptedFiles) { 1623 | var baseMimeType, mimeType, validType, _i, _len; 1624 | if (!acceptedFiles) { 1625 | return true; 1626 | } 1627 | acceptedFiles = acceptedFiles.split(","); 1628 | mimeType = file.type; 1629 | baseMimeType = mimeType.replace(/\/.*$/, ""); 1630 | for (_i = 0, _len = acceptedFiles.length; _i < _len; _i++) { 1631 | validType = acceptedFiles[_i]; 1632 | validType = validType.trim(); 1633 | if (validType.charAt(0) === ".") { 1634 | if (file.name.indexOf(validType, file.name.length - validType.length) !== -1) { 1635 | return true; 1636 | } 1637 | } else if (/\/\*$/.test(validType)) { 1638 | if (baseMimeType === validType.replace(/\/.*$/, "")) { 1639 | return true; 1640 | } 1641 | } else { 1642 | if (mimeType === validType) { 1643 | return true; 1644 | } 1645 | } 1646 | } 1647 | return false; 1648 | }; 1649 | 1650 | if (typeof jQuery !== "undefined" && jQuery !== null) { 1651 | jQuery.fn.dropzone = function(options) { 1652 | return this.each(function() { 1653 | return new Dropzone(this, options); 1654 | }); 1655 | }; 1656 | } 1657 | 1658 | if (typeof module !== "undefined" && module !== null) { 1659 | module.exports = Dropzone; 1660 | } else { 1661 | window.Dropzone = Dropzone; 1662 | } 1663 | 1664 | Dropzone.ADDED = "added"; 1665 | 1666 | Dropzone.QUEUED = "queued"; 1667 | 1668 | Dropzone.ACCEPTED = Dropzone.QUEUED; 1669 | 1670 | Dropzone.UPLOADING = "uploading"; 1671 | 1672 | Dropzone.PROCESSING = Dropzone.UPLOADING; 1673 | 1674 | Dropzone.CANCELED = "canceled"; 1675 | 1676 | Dropzone.ERROR = "error"; 1677 | 1678 | Dropzone.SUCCESS = "success"; 1679 | 1680 | /* 1681 | # contentloaded.js 1682 | # 1683 | # Author: Diego Perini (diego.perini at gmail.com) 1684 | # Summary: cross-browser wrapper for DOMContentLoaded 1685 | # Updated: 20101020 1686 | # License: MIT 1687 | # Version: 1.2 1688 | # 1689 | # URL: 1690 | # http://javascript.nwbox.com/ContentLoaded/ 1691 | # http://javascript.nwbox.com/ContentLoaded/MIT-LICENSE 1692 | */ 1693 | 1694 | 1695 | contentLoaded = function(win, fn) { 1696 | var add, doc, done, init, poll, pre, rem, root, top; 1697 | done = false; 1698 | top = true; 1699 | doc = win.document; 1700 | root = doc.documentElement; 1701 | add = (doc.addEventListener ? "addEventListener" : "attachEvent"); 1702 | rem = (doc.addEventListener ? "removeEventListener" : "detachEvent"); 1703 | pre = (doc.addEventListener ? "" : "on"); 1704 | init = function(e) { 1705 | if (e.type === "readystatechange" && doc.readyState !== "complete") { 1706 | return; 1707 | } 1708 | (e.type === "load" ? win : doc)[rem](pre + e.type, init, false); 1709 | if (!done && (done = true)) { 1710 | return fn.call(win, e.type || e); 1711 | } 1712 | }; 1713 | poll = function() { 1714 | var e; 1715 | try { 1716 | root.doScroll("left"); 1717 | } catch (_error) { 1718 | e = _error; 1719 | setTimeout(poll, 50); 1720 | return; 1721 | } 1722 | return init("poll"); 1723 | }; 1724 | if (doc.readyState !== "complete") { 1725 | if (doc.createEventObject && root.doScroll) { 1726 | try { 1727 | top = !win.frameElement; 1728 | } catch (_error) {} 1729 | if (top) { 1730 | poll(); 1731 | } 1732 | } 1733 | doc[add](pre + "DOMContentLoaded", init, false); 1734 | doc[add](pre + "readystatechange", init, false); 1735 | return win[add](pre + "load", init, false); 1736 | } 1737 | }; 1738 | 1739 | Dropzone._autoDiscoverFunction = function() { 1740 | if (Dropzone.autoDiscover) { 1741 | return Dropzone.discover(); 1742 | } 1743 | }; 1744 | 1745 | contentLoaded(window, Dropzone._autoDiscoverFunction); 1746 | 1747 | }).call(this); 1748 | 1749 | }); 1750 | require.alias("component-emitter/index.js", "dropzone/deps/emitter/index.js"); 1751 | require.alias("component-emitter/index.js", "emitter/index.js"); 1752 | if (typeof exports == "object") { 1753 | module.exports = require("dropzone"); 1754 | } else if (typeof define == "function" && define.amd) { 1755 | define(function(){ return require("dropzone"); }); 1756 | } else { 1757 | this["Dropzone"] = require("dropzone"); 1758 | }})(); -------------------------------------------------------------------------------- /mysite/main/static/main/js/dropzone.min.js: -------------------------------------------------------------------------------- 1 | !function(){function a(b,c,d){var e=a.resolve(b);if(null==e){d=d||b,c=c||"root";var f=new Error('Failed to require "'+d+'" from "'+c+'"');throw f.path=d,f.parent=c,f.require=!0,f}var g=a.modules[e];return g.exports||(g.exports={},g.client=g.component=!0,g.call(this,g.exports,a.relative(e),g)),g.exports}a.modules={},a.aliases={},a.resolve=function(b){"/"===b.charAt(0)&&(b=b.slice(1));for(var c=[b,b+".js",b+".json",b+"/index.js",b+"/index.json"],d=0;dd;++d)c[d].apply(this,b)}return this},d.prototype.listeners=function(a){return this._callbacks=this._callbacks||{},this._callbacks[a]||[]},d.prototype.hasListeners=function(a){return!!this.listeners(a).length}}),a.register("dropzone/index.js",function(a,b,c){c.exports=b("./lib/dropzone.js")}),a.register("dropzone/lib/dropzone.js",function(a,b,c){!function(){var a,d,e,f,g,h,i={}.hasOwnProperty,j=function(a,b){function c(){this.constructor=a}for(var d in b)i.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},k=[].slice;d="undefined"!=typeof Emitter&&null!==Emitter?Emitter:b("emitter"),g=function(){},a=function(a){function b(a,d){var e,f,g;if(this.element=a,this.version=b.version,this.defaultOptions.previewTemplate=this.defaultOptions.previewTemplate.replace(/\n*/g,""),this.clickableElements=[],this.listeners=[],this.files=[],"string"==typeof this.element&&(this.element=document.querySelector(this.element)),!this.element||null==this.element.nodeType)throw new Error("Invalid dropzone element.");if(this.element.dropzone)throw new Error("Dropzone already attached.");if(b.instances.push(this),a.dropzone=this,e=null!=(g=b.optionsForElement(this.element))?g:{},this.options=c({},this.defaultOptions,e,null!=d?d:{}),this.options.forceFallback||!b.isBrowserSupported())return this.options.fallback.call(this);if(null==this.options.url&&(this.options.url=this.element.getAttribute("action")),!this.options.url)throw new Error("No URL provided.");if(this.options.acceptedFiles&&this.options.acceptedMimeTypes)throw new Error("You can't provide both 'acceptedFiles' and 'acceptedMimeTypes'. 'acceptedMimeTypes' is deprecated.");this.options.acceptedMimeTypes&&(this.options.acceptedFiles=this.options.acceptedMimeTypes,delete this.options.acceptedMimeTypes),this.options.method=this.options.method.toUpperCase(),(f=this.getExistingFallback())&&f.parentNode&&f.parentNode.removeChild(f),this.previewsContainer=this.options.previewsContainer?b.getElement(this.options.previewsContainer,"previewsContainer"):this.element,this.options.clickable&&(this.clickableElements=this.options.clickable===!0?[this.element]:b.getElements(this.options.clickable,"clickable")),this.init()}var c;return j(b,a),b.prototype.events=["drop","dragstart","dragend","dragenter","dragover","dragleave","selectedfiles","addedfile","removedfile","thumbnail","error","errormultiple","processing","processingmultiple","uploadprogress","totaluploadprogress","sending","sendingmultiple","success","successmultiple","canceled","canceledmultiple","complete","completemultiple","reset","maxfilesexceeded"],b.prototype.defaultOptions={url:null,method:"post",withCredentials:!1,parallelUploads:2,uploadMultiple:!1,maxFilesize:256,paramName:"file",createImageThumbnails:!0,maxThumbnailFilesize:10,thumbnailWidth:100,thumbnailHeight:100,maxFiles:null,params:{},clickable:!0,ignoreHiddenFiles:!0,acceptedFiles:null,acceptedMimeTypes:null,autoProcessQueue:!0,addRemoveLinks:!1,previewsContainer:null,dictDefaultMessage:"Drop files here to upload",dictFallbackMessage:"Your browser does not support drag'n'drop file uploads.",dictFallbackText:"Please use the fallback form below to upload your files like in the olden days.",dictFileTooBig:"File is too big ({{filesize}}MB). Max filesize: {{maxFilesize}}MB.",dictInvalidFileType:"You can't upload files of this type.",dictResponseError:"Server responded with {{statusCode}} code.",dictCancelUpload:"Cancel upload",dictCancelUploadConfirmation:"Are you sure you want to cancel this upload?",dictRemoveFile:"Remove file",dictRemoveFileConfirmation:null,dictMaxFilesExceeded:"You can only upload {{maxFiles}} files.",accept:function(a,b){return b()},init:function(){return g},forceFallback:!1,fallback:function(){var a,c,d,e,f,g;for(this.element.className=""+this.element.className+" dz-browser-not-supported",g=this.element.getElementsByTagName("div"),e=0,f=g.length;f>e;e++)a=g[e],/(^| )dz-message($| )/.test(a.className)&&(c=a,a.className="dz-message");return c||(c=b.createElement('
'),this.element.appendChild(c)),d=c.getElementsByTagName("span")[0],d&&(d.textContent=this.options.dictFallbackMessage),this.element.appendChild(this.getFallbackForm())},resize:function(a){var b,c,d;return b={srcX:0,srcY:0,srcWidth:a.width,srcHeight:a.height},c=a.width/a.height,d=this.options.thumbnailWidth/this.options.thumbnailHeight,a.heightd?(b.srcHeight=a.height,b.srcWidth=b.srcHeight*d):(b.srcWidth=a.width,b.srcHeight=b.srcWidth/d),b.srcX=(a.width-b.srcWidth)/2,b.srcY=(a.height-b.srcHeight)/2,b},drop:function(){return this.element.classList.remove("dz-drag-hover")},dragstart:g,dragend:function(){return this.element.classList.remove("dz-drag-hover")},dragenter:function(){return this.element.classList.add("dz-drag-hover")},dragover:function(){return this.element.classList.add("dz-drag-hover")},dragleave:function(){return this.element.classList.remove("dz-drag-hover")},selectedfiles:function(){return this.element===this.previewsContainer?this.element.classList.add("dz-started"):void 0},reset:function(){return this.element.classList.remove("dz-started")},addedfile:function(a){var c=this;return a.previewElement=b.createElement(this.options.previewTemplate),a.previewTemplate=a.previewElement,this.previewsContainer.appendChild(a.previewElement),a.previewElement.querySelector("[data-dz-name]").textContent=a.name,a.previewElement.querySelector("[data-dz-size]").innerHTML=this.filesize(a.size),this.options.addRemoveLinks&&(a._removeLink=b.createElement(''+this.options.dictRemoveFile+""),a._removeLink.addEventListener("click",function(d){return d.preventDefault(),d.stopPropagation(),a.status===b.UPLOADING?b.confirm(c.options.dictCancelUploadConfirmation,function(){return c.removeFile(a)}):c.options.dictRemoveFileConfirmation?b.confirm(c.options.dictRemoveFileConfirmation,function(){return c.removeFile(a)}):c.removeFile(a)}),a.previewElement.appendChild(a._removeLink)),this._updateMaxFilesReachedClass()},removedfile:function(a){var b;return null!=(b=a.previewElement)&&b.parentNode.removeChild(a.previewElement),this._updateMaxFilesReachedClass()},thumbnail:function(a,b){var c;return a.previewElement.classList.remove("dz-file-preview"),a.previewElement.classList.add("dz-image-preview"),c=a.previewElement.querySelector("[data-dz-thumbnail]"),c.alt=a.name,c.src=b},error:function(a,b){return a.previewElement.classList.add("dz-error"),a.previewElement.querySelector("[data-dz-errormessage]").textContent=b},errormultiple:g,processing:function(a){return a.previewElement.classList.add("dz-processing"),a._removeLink?a._removeLink.textContent=this.options.dictCancelUpload:void 0},processingmultiple:g,uploadprogress:function(a,b){return a.previewElement.querySelector("[data-dz-uploadprogress]").style.width=""+b+"%"},totaluploadprogress:g,sending:g,sendingmultiple:g,success:function(a){return a.previewElement.classList.add("dz-success")},successmultiple:g,canceled:function(a){return this.emit("error",a,"Upload canceled.")},canceledmultiple:g,complete:function(a){return a._removeLink?a._removeLink.textContent=this.options.dictRemoveFile:void 0},completemultiple:g,maxfilesexceeded:g,previewTemplate:'
\n
\n
\n
\n \n
\n
\n
\n
\n
\n
'},c=function(){var a,b,c,d,e,f,g;for(d=arguments[0],c=2<=arguments.length?k.call(arguments,1):[],f=0,g=c.length;g>f;f++){b=c[f];for(a in b)e=b[a],d[a]=e}return d},b.prototype.getAcceptedFiles=function(){var a,b,c,d,e;for(d=this.files,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.accepted&&e.push(a);return e},b.prototype.getRejectedFiles=function(){var a,b,c,d,e;for(d=this.files,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.accepted||e.push(a);return e},b.prototype.getQueuedFiles=function(){var a,c,d,e,f;for(e=this.files,f=[],c=0,d=e.length;d>c;c++)a=e[c],a.status===b.QUEUED&&f.push(a);return f},b.prototype.getUploadingFiles=function(){var a,c,d,e,f;for(e=this.files,f=[],c=0,d=e.length;d>c;c++)a=e[c],a.status===b.UPLOADING&&f.push(a);return f},b.prototype.init=function(){var a,c,d,e,f,g,h,i=this;for("form"===this.element.tagName&&this.element.setAttribute("enctype","multipart/form-data"),this.element.classList.contains("dropzone")&&!this.element.querySelector(".dz-message")&&this.element.appendChild(b.createElement('
'+this.options.dictDefaultMessage+"
")),this.clickableElements.length&&(d=function(){return i.hiddenFileInput&&document.body.removeChild(i.hiddenFileInput),i.hiddenFileInput=document.createElement("input"),i.hiddenFileInput.setAttribute("type","file"),i.hiddenFileInput.setAttribute("multiple","multiple"),null!=i.options.acceptedFiles&&i.hiddenFileInput.setAttribute("accept",i.options.acceptedFiles),i.hiddenFileInput.style.visibility="hidden",i.hiddenFileInput.style.position="absolute",i.hiddenFileInput.style.top="0",i.hiddenFileInput.style.left="0",i.hiddenFileInput.style.height="0",i.hiddenFileInput.style.width="0",document.body.appendChild(i.hiddenFileInput),i.hiddenFileInput.addEventListener("change",function(){var a;return a=i.hiddenFileInput.files,a.length&&(i.emit("selectedfiles",a),i.handleFiles(a)),d()})},d()),this.URL=null!=(g=window.URL)?g:window.webkitURL,h=this.events,e=0,f=h.length;f>e;e++)a=h[e],this.on(a,this.options[a]);return this.on("uploadprogress",function(){return i.updateTotalUploadProgress()}),this.on("removedfile",function(){return i.updateTotalUploadProgress()}),this.on("canceled",function(a){return i.emit("complete",a)}),c=function(a){return a.stopPropagation(),a.preventDefault?a.preventDefault():a.returnValue=!1},this.listeners=[{element:this.element,events:{dragstart:function(a){return i.emit("dragstart",a)},dragenter:function(a){return c(a),i.emit("dragenter",a)},dragover:function(a){return c(a),i.emit("dragover",a)},dragleave:function(a){return i.emit("dragleave",a)},drop:function(a){return c(a),i.drop(a)},dragend:function(a){return i.emit("dragend",a)}}}],this.clickableElements.forEach(function(a){return i.listeners.push({element:a,events:{click:function(c){return a!==i.element||c.target===i.element||b.elementInside(c.target,i.element.querySelector(".dz-message"))?i.hiddenFileInput.click():void 0}}})}),this.enable(),this.options.init.call(this)},b.prototype.destroy=function(){var a;return this.disable(),this.removeAllFiles(!0),(null!=(a=this.hiddenFileInput)?a.parentNode:void 0)&&(this.hiddenFileInput.parentNode.removeChild(this.hiddenFileInput),this.hiddenFileInput=null),delete this.element.dropzone},b.prototype.updateTotalUploadProgress=function(){var a,b,c,d,e,f,g,h;if(d=0,c=0,a=this.getAcceptedFiles(),a.length){for(h=this.getAcceptedFiles(),f=0,g=h.length;g>f;f++)b=h[f],d+=b.upload.bytesSent,c+=b.upload.total;e=100*d/c}else e=100;return this.emit("totaluploadprogress",e,c,d)},b.prototype.getFallbackForm=function(){var a,c,d,e;return(a=this.getExistingFallback())?a:(d='
',this.options.dictFallbackText&&(d+="

"+this.options.dictFallbackText+"

"),d+='
',c=b.createElement(d),"FORM"!==this.element.tagName?(e=b.createElement('
'),e.appendChild(c)):(this.element.setAttribute("enctype","multipart/form-data"),this.element.setAttribute("method",this.options.method)),null!=e?e:c)},b.prototype.getExistingFallback=function(){var a,b,c,d,e,f;for(b=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)if(b=a[c],/(^| )fallback($| )/.test(b.className))return b},f=["div","form"],d=0,e=f.length;e>d;d++)if(c=f[d],a=b(this.element.getElementsByTagName(c)))return a},b.prototype.setupEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.addEventListener(b,c,!1));return e}());return g},b.prototype.removeEventListeners=function(){var a,b,c,d,e,f,g;for(f=this.listeners,g=[],d=0,e=f.length;e>d;d++)a=f[d],g.push(function(){var d,e;d=a.events,e=[];for(b in d)c=d[b],e.push(a.element.removeEventListener(b,c,!1));return e}());return g},b.prototype.disable=function(){var a,b,c,d,e;for(this.clickableElements.forEach(function(a){return a.classList.remove("dz-clickable")}),this.removeEventListeners(),d=this.files,e=[],b=0,c=d.length;c>b;b++)a=d[b],e.push(this.cancelUpload(a));return e},b.prototype.enable=function(){return this.clickableElements.forEach(function(a){return a.classList.add("dz-clickable")}),this.setupEventListeners()},b.prototype.filesize=function(a){var b;return a>=1e11?(a/=1e11,b="TB"):a>=1e8?(a/=1e8,b="GB"):a>=1e5?(a/=1e5,b="MB"):a>=100?(a/=100,b="KB"):(a=10*a,b="b"),""+Math.round(a)/10+" "+b},b.prototype._updateMaxFilesReachedClass=function(){return this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?this.element.classList.add("dz-max-files-reached"):this.element.classList.remove("dz-max-files-reached")},b.prototype.drop=function(a){var b,c;a.dataTransfer&&(this.emit("drop",a),b=a.dataTransfer.files,this.emit("selectedfiles",b),b.length&&(c=a.dataTransfer.items,c&&c.length&&(null!=c[0].webkitGetAsEntry||null!=c[0].getAsEntry)?this.handleItems(c):this.handleFiles(b)))},b.prototype.handleFiles=function(a){var b,c,d,e;for(e=[],c=0,d=a.length;d>c;c++)b=a[c],e.push(this.addFile(b));return e},b.prototype.handleItems=function(a){var b,c,d,e;for(d=0,e=a.length;e>d;d++)c=a[d],null!=c.webkitGetAsEntry?(b=c.webkitGetAsEntry(),b.isFile?this.addFile(c.getAsFile()):b.isDirectory&&this.addDirectory(b,b.name)):this.addFile(c.getAsFile())},b.prototype.accept=function(a,c){return a.size>1024*1024*this.options.maxFilesize?c(this.options.dictFileTooBig.replace("{{filesize}}",Math.round(a.size/1024/10.24)/100).replace("{{maxFilesize}}",this.options.maxFilesize)):b.isValidFile(a,this.options.acceptedFiles)?this.options.maxFiles&&this.getAcceptedFiles().length>=this.options.maxFiles?(c(this.options.dictMaxFilesExceeded.replace("{{maxFiles}}",this.options.maxFiles)),this.emit("maxfilesexceeded",a)):this.options.accept.call(this,a,c):c(this.options.dictInvalidFileType)},b.prototype.addFile=function(a){var c=this;return a.upload={progress:0,total:a.size,bytesSent:0},this.files.push(a),a.status=b.ADDED,this.emit("addedfile",a),this.options.createImageThumbnails&&a.type.match(/image.*/)&&a.size<=1024*1024*this.options.maxThumbnailFilesize&&this.createThumbnail(a),this.accept(a,function(b){return b?(a.accepted=!1,c._errorProcessing([a],b)):c.enqueueFile(a)})},b.prototype.enqueueFiles=function(a){var b,c,d;for(c=0,d=a.length;d>c;c++)b=a[c],this.enqueueFile(b);return null},b.prototype.enqueueFile=function(a){var c=this;if(a.accepted=!0,a.status!==b.ADDED)throw new Error("This file can't be queued because it has already been processed or was rejected.");return a.status=b.QUEUED,this.options.autoProcessQueue?setTimeout(function(){return c.processQueue()},1):void 0},b.prototype.addDirectory=function(a,b){var c,d,e=this;return c=a.createReader(),d=function(c){var d,f;for(d=0,f=c.length;f>d;d++)a=c[d],a.isFile?a.file(function(a){return e.options.ignoreHiddenFiles&&"."===a.name.substring(0,1)?void 0:(a.fullPath=""+b+"/"+a.name,e.addFile(a))}):a.isDirectory&&e.addDirectory(a,""+b+"/"+a.name)},c.readEntries(d,function(a){return"undefined"!=typeof console&&null!==console?"function"==typeof console.log?console.log(a):void 0:void 0})},b.prototype.removeFile=function(a){return a.status===b.UPLOADING&&this.cancelUpload(a),this.files=h(this.files,a),this.emit("removedfile",a),0===this.files.length?this.emit("reset"):void 0},b.prototype.removeAllFiles=function(a){var c,d,e,f;for(null==a&&(a=!1),f=this.files.slice(),d=0,e=f.length;e>d;d++)c=f[d],(c.status!==b.UPLOADING||a)&&this.removeFile(c);return null},b.prototype.createThumbnail=function(a){var b,c=this;return b=new FileReader,b.onload=function(){var d;return d=new Image,d.onload=function(){var b,e,f,g,h,i,j,k;return a.width=d.width,a.height=d.height,f=c.options.resize.call(c,a),null==f.trgWidth&&(f.trgWidth=c.options.thumbnailWidth),null==f.trgHeight&&(f.trgHeight=c.options.thumbnailHeight),b=document.createElement("canvas"),e=b.getContext("2d"),b.width=f.trgWidth,b.height=f.trgHeight,e.drawImage(d,null!=(h=f.srcX)?h:0,null!=(i=f.srcY)?i:0,f.srcWidth,f.srcHeight,null!=(j=f.trgX)?j:0,null!=(k=f.trgY)?k:0,f.trgWidth,f.trgHeight),g=b.toDataURL("image/png"),c.emit("thumbnail",a,g)},d.src=b.result},b.readAsDataURL(a)},b.prototype.processQueue=function(){var a,b,c,d;if(b=this.options.parallelUploads,c=this.getUploadingFiles().length,a=c,!(c>=b)&&(d=this.getQueuedFiles(),d.length>0)){if(this.options.uploadMultiple)return this.processFiles(d.slice(0,b-c));for(;b>a;){if(!d.length)return;this.processFile(d.shift()),a++}}},b.prototype.processFile=function(a){return this.processFiles([a])},b.prototype.processFiles=function(a){var c,d,e;for(d=0,e=a.length;e>d;d++)c=a[d],c.processing=!0,c.status=b.UPLOADING,this.emit("processing",c);return this.options.uploadMultiple&&this.emit("processingmultiple",a),this.uploadFiles(a)},b.prototype._getFilesWithXhr=function(a){var b,c;return c=function(){var c,d,e,f;for(e=this.files,f=[],c=0,d=e.length;d>c;c++)b=e[c],b.xhr===a&&f.push(b);return f}.call(this)},b.prototype.cancelUpload=function(a){var c,d,e,f,g,h,i;if(a.status===b.UPLOADING){for(d=this._getFilesWithXhr(a.xhr),e=0,g=d.length;g>e;e++)c=d[e],c.status=b.CANCELED;for(a.xhr.abort(),f=0,h=d.length;h>f;f++)c=d[f],this.emit("canceled",c);this.options.uploadMultiple&&this.emit("canceledmultiple",d)}else((i=a.status)===b.ADDED||i===b.QUEUED)&&(a.status=b.CANCELED,this.emit("canceled",a),this.options.uploadMultiple&&this.emit("canceledmultiple",[a]));return this.options.autoProcessQueue?this.processQueue():void 0},b.prototype.uploadFile=function(a){return this.uploadFiles([a])},b.prototype.uploadFiles=function(a){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E=this;for(r=new XMLHttpRequest,s=0,w=a.length;w>s;s++)d=a[s],d.xhr=r;r.open(this.options.method,this.options.url,!0),r.withCredentials=!!this.options.withCredentials,o=null,f=function(){var b,c,e;for(e=[],b=0,c=a.length;c>b;b++)d=a[b],e.push(E._errorProcessing(a,o||E.options.dictResponseError.replace("{{statusCode}}",r.status),r));return e},p=function(b){var c,e,f,g,h,i,j,k,l;if(null!=b)for(e=100*b.loaded/b.total,f=0,i=a.length;i>f;f++)d=a[f],d.upload={progress:e,total:b.total,bytesSent:b.loaded};else{for(c=!0,e=100,g=0,j=a.length;j>g;g++)d=a[g],(100!==d.upload.progress||d.upload.bytesSent!==d.upload.total)&&(c=!1),d.upload.progress=e,d.upload.bytesSent=d.upload.total;if(c)return}for(l=[],h=0,k=a.length;k>h;h++)d=a[h],l.push(E.emit("uploadprogress",d,e,d.upload.bytesSent));return l},r.onload=function(c){var d;if(a[0].status!==b.CANCELED&&4===r.readyState){if(o=r.responseText,r.getResponseHeader("content-type")&&~r.getResponseHeader("content-type").indexOf("application/json"))try{o=JSON.parse(o)}catch(e){c=e,o="Invalid JSON response from server."}return p(),200<=(d=r.status)&&300>d?E._finished(a,o,c):f()}},r.onerror=function(){return a[0].status!==b.CANCELED?f():void 0},n=null!=(A=r.upload)?A:r,n.onprogress=p,i={Accept:"application/json","Cache-Control":"no-cache","X-Requested-With":"XMLHttpRequest"},this.options.headers&&c(i,this.options.headers);for(g in i)h=i[g],r.setRequestHeader(g,h);if(e=new FormData,this.options.params){B=this.options.params;for(m in B)q=B[m],e.append(m,q)}for(t=0,x=a.length;x>t;t++)d=a[t],this.emit("sending",d,r,e);if(this.options.uploadMultiple&&this.emit("sendingmultiple",a,r,e),"FORM"===this.element.tagName)for(C=this.element.querySelectorAll("input, textarea, select, button"),u=0,y=C.length;y>u;u++)j=C[u],k=j.getAttribute("name"),l=j.getAttribute("type"),(!l||"checkbox"!==(D=l.toLowerCase())&&"radio"!==D||j.checked)&&e.append(k,j.value);for(v=0,z=a.length;z>v;v++)d=a[v],e.append(""+this.options.paramName+(this.options.uploadMultiple?"[]":""),d,d.name);return r.send(e)},b.prototype._finished=function(a,c,d){var e,f,g;for(f=0,g=a.length;g>f;f++)e=a[f],e.status=b.SUCCESS,this.emit("success",e,c,d),this.emit("complete",e);return this.options.uploadMultiple&&(this.emit("successmultiple",a,c,d),this.emit("completemultiple",a)),this.options.autoProcessQueue?this.processQueue():void 0},b.prototype._errorProcessing=function(a,c,d){var e,f,g;for(f=0,g=a.length;g>f;f++)e=a[f],e.status=b.ERROR,this.emit("error",e,c,d),this.emit("complete",e);return this.options.uploadMultiple&&(this.emit("errormultiple",a,c,d),this.emit("completemultiple",a)),this.options.autoProcessQueue?this.processQueue():void 0},b}(d),a.version="3.7.1",a.options={},a.optionsForElement=function(b){return b.id?a.options[e(b.id)]:void 0},a.instances=[],a.forElement=function(a){if("string"==typeof a&&(a=document.querySelector(a)),null==(null!=a?a.dropzone:void 0))throw new Error("No Dropzone found for given element. This is probably because you're trying to access it before Dropzone had the time to initialize. Use the `init` option to setup any additional observers on your Dropzone.");return a.dropzone},a.autoDiscover=!0,a.discover=function(){var b,c,d,e,f,g;for(document.querySelectorAll?d=document.querySelectorAll(".dropzone"):(d=[],b=function(a){var b,c,e,f;for(f=[],c=0,e=a.length;e>c;c++)b=a[c],/(^| )dropzone($| )/.test(b.className)?f.push(d.push(b)):f.push(void 0);return f},b(document.getElementsByTagName("div")),b(document.getElementsByTagName("form"))),g=[],e=0,f=d.length;f>e;e++)c=d[e],a.optionsForElement(c)!==!1?g.push(new a(c)):g.push(void 0);return g},a.blacklistedBrowsers=[/opera.*Macintosh.*version\/12/i],a.isBrowserSupported=function(){var b,c,d,e,f;if(b=!0,window.File&&window.FileReader&&window.FileList&&window.Blob&&window.FormData&&document.querySelector)if("classList"in document.createElement("a"))for(f=a.blacklistedBrowsers,d=0,e=f.length;e>d;d++)c=f[d],c.test(navigator.userAgent)&&(b=!1);else b=!1;else b=!1;return b},h=function(a,b){var c,d,e,f;for(f=[],d=0,e=a.length;e>d;d++)c=a[d],c!==b&&f.push(c);return f},e=function(a){return a.replace(/[\-_](\w)/g,function(a){return a[1].toUpperCase()})},a.createElement=function(a){var b;return b=document.createElement("div"),b.innerHTML=a,b.childNodes[0]},a.elementInside=function(a,b){if(a===b)return!0;for(;a=a.parentNode;)if(a===b)return!0;return!1},a.getElement=function(a,b){var c;if("string"==typeof a?c=document.querySelector(a):null!=a.nodeType&&(c=a),null==c)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector or a plain HTML element.");return c},a.getElements=function(a,b){var c,d,e,f,g,h,i,j;if(a instanceof Array){e=[];try{for(f=0,h=a.length;h>f;f++)d=a[f],e.push(this.getElement(d,b))}catch(k){c=k,e=null}}else if("string"==typeof a)for(e=[],j=document.querySelectorAll(a),g=0,i=j.length;i>g;g++)d=j[g],e.push(d);else null!=a.nodeType&&(e=[a]);if(null==e||!e.length)throw new Error("Invalid `"+b+"` option provided. Please provide a CSS selector, a plain HTML element or a list of those.");return e},a.confirm=function(a,b,c){return window.confirm(a)?b():null!=c?c():void 0},a.isValidFile=function(a,b){var c,d,e,f,g;if(!b)return!0;for(b=b.split(","),d=a.type,c=d.replace(/\/.*$/,""),f=0,g=b.length;g>f;f++)if(e=b[f],e=e.trim(),"."===e.charAt(0)){if(-1!==a.name.indexOf(e,a.name.length-e.length))return!0}else if(/\/\*$/.test(e)){if(c===e.replace(/\/.*$/,""))return!0}else if(d===e)return!0;return!1},"undefined"!=typeof jQuery&&null!==jQuery&&(jQuery.fn.dropzone=function(b){return this.each(function(){return new a(this,b)})}),"undefined"!=typeof c&&null!==c?c.exports=a:window.Dropzone=a,a.ADDED="added",a.QUEUED="queued",a.ACCEPTED=a.QUEUED,a.UPLOADING="uploading",a.PROCESSING=a.UPLOADING,a.CANCELED="canceled",a.ERROR="error",a.SUCCESS="success",f=function(a,b){var c,d,e,f,g,h,i,j,k;if(e=!1,k=!0,d=a.document,j=d.documentElement,c=d.addEventListener?"addEventListener":"attachEvent",i=d.addEventListener?"removeEventListener":"detachEvent",h=d.addEventListener?"":"on",f=function(c){return"readystatechange"!==c.type||"complete"===d.readyState?(("load"===c.type?a:d)[i](h+c.type,f,!1),!e&&(e=!0)?b.call(a,c.type||c):void 0):void 0},g=function(){var a;try{j.doScroll("left")}catch(b){return a=b,setTimeout(g,50),void 0}return f("poll")},"complete"!==d.readyState){if(d.createEventObject&&j.doScroll){try{k=!a.frameElement}catch(l){}k&&g()}return d[c](h+"DOMContentLoaded",f,!1),d[c](h+"readystatechange",f,!1),a[c](h+"load",f,!1)}},a._autoDiscoverFunction=function(){return a.autoDiscover?a.discover():void 0},f(window,a._autoDiscoverFunction)}.call(this)}),a.alias("component-emitter/index.js","dropzone/deps/emitter/index.js"),a.alias("component-emitter/index.js","emitter/index.js"),"object"==typeof exports?module.exports=a("dropzone"):"function"==typeof define&&define.amd?define(function(){return a("dropzone")}):this.Dropzone=a("dropzone")}(); -------------------------------------------------------------------------------- /mysite/main/templates/main/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Upload a file in Django 1.5 using Dropzone.js 6 | {% load staticfiles %} 7 | 8 | 9 | 10 | 11 | 12 |
13 | {% csrf_token %} 14 |
15 | 18 | 19 | 20 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /mysite/main/tests.py: -------------------------------------------------------------------------------- 1 | """ 2 | This file demonstrates writing tests using the unittest module. These will pass 3 | when you run "manage.py test". 4 | 5 | Replace this with more appropriate tests for your application. 6 | """ 7 | 8 | from django.test import TestCase 9 | 10 | 11 | class SimpleTest(TestCase): 12 | def test_basic_addition(self): 13 | """ 14 | Tests that 1 + 1 always equals 2. 15 | """ 16 | self.assertEqual(1 + 1, 2) 17 | -------------------------------------------------------------------------------- /mysite/main/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import patterns, include, url 2 | 3 | # Uncomment the next two lines to enable the admin: 4 | # from django.contrib import admin 5 | # admin.autodiscover() 6 | 7 | urlpatterns = patterns('', 8 | url(r'^$', 'main.views.home', name='home'), 9 | # Examples: 10 | # url(r'^$', 'mysite.views.home', name='home'), 11 | # url(r'^mysite/', include('mysite.foo.urls')), 12 | 13 | # Uncomment the admin/doc line below to enable admin documentation: 14 | # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 15 | 16 | # Uncomment the next line to enable the admin: 17 | # url(r'^admin/', include(admin.site.urls)), 18 | ) -------------------------------------------------------------------------------- /mysite/main/views.py: -------------------------------------------------------------------------------- 1 | from django.http import HttpResponseRedirect 2 | from django.template import RequestContext 3 | from django.core.urlresolvers import reverse 4 | from django.shortcuts import render_to_response 5 | 6 | from forms import UploadFileForm 7 | from models import UploadFile 8 | 9 | 10 | def home(request): 11 | if request.method == 'POST': 12 | form = UploadFileForm(request.POST, request.FILES) 13 | if form.is_valid(): 14 | new_file = UploadFile(file = request.FILES['file']) 15 | new_file.save() 16 | 17 | return HttpResponseRedirect(reverse('main:home')) 18 | else: 19 | form = UploadFileForm() 20 | 21 | data = {'form': form} 22 | return render_to_response('main/index.html', data, context_instance=RequestContext(request)) -------------------------------------------------------------------------------- /mysite/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import sys 4 | 5 | if __name__ == "__main__": 6 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 7 | 8 | from django.core.management import execute_from_command_line 9 | 10 | execute_from_command_line(sys.argv) 11 | -------------------------------------------------------------------------------- /mysite/mysite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amatellanes/dropzonejs-django-file-upload/abd8ceae931ee14e89d748d595c8e402d78cb9f6/mysite/mysite/__init__.py -------------------------------------------------------------------------------- /mysite/mysite/settings.py: -------------------------------------------------------------------------------- 1 | # Django settings for mysite project. 2 | 3 | DEBUG = True 4 | TEMPLATE_DEBUG = DEBUG 5 | 6 | ADMINS = ( 7 | # ('Your Name', 'your_email@example.com'), 8 | ) 9 | 10 | MANAGERS = ADMINS 11 | 12 | DATABASES = { 13 | 'default': { 14 | 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. 15 | 'NAME': 'database.sqlite', # Or path to database file if using sqlite3. 16 | # The following settings are not used with sqlite3: 17 | 'USER': '', 18 | 'PASSWORD': '', 19 | 'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. 20 | 'PORT': '', # Set to empty string for default. 21 | } 22 | } 23 | 24 | # Hosts/domain names that are valid for this site; required if DEBUG is False 25 | # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts 26 | ALLOWED_HOSTS = [] 27 | 28 | # Local time zone for this installation. Choices can be found here: 29 | # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 30 | # although not all choices may be available on all operating systems. 31 | # In a Windows environment this must be set to your system time zone. 32 | TIME_ZONE = 'America/Chicago' 33 | 34 | # Language code for this installation. All choices can be found here: 35 | # http://www.i18nguy.com/unicode/language-identifiers.html 36 | LANGUAGE_CODE = 'en-us' 37 | 38 | SITE_ID = 1 39 | 40 | # If you set this to False, Django will make some optimizations so as not 41 | # to load the internationalization machinery. 42 | USE_I18N = True 43 | 44 | # If you set this to False, Django will not format dates, numbers and 45 | # calendars according to the current locale. 46 | USE_L10N = True 47 | 48 | # If you set this to False, Django will not use timezone-aware datetimes. 49 | USE_TZ = True 50 | 51 | # Absolute filesystem path to the directory that will hold user-uploaded files. 52 | # Example: "/var/www/example.com/media/" 53 | MEDIA_ROOT = '' 54 | 55 | # URL that handles the media served from MEDIA_ROOT. Make sure to use a 56 | # trailing slash. 57 | # Examples: "http://example.com/media/", "http://media.example.com/" 58 | MEDIA_URL = '' 59 | 60 | # Absolute path to the directory static files should be collected to. 61 | # Don't put anything in this directory yourself; store your static files 62 | # in apps' "static/" subdirectories and in STATICFILES_DIRS. 63 | # Example: "/var/www/example.com/static/" 64 | STATIC_ROOT = '' 65 | 66 | # URL prefix for static files. 67 | # Example: "http://example.com/static/", "http://static.example.com/" 68 | STATIC_URL = '/static/' 69 | 70 | # Additional locations of static files 71 | STATICFILES_DIRS = ( 72 | # Put strings here, like "/home/html/static" or "C:/www/django/static". 73 | # Always use forward slashes, even on Windows. 74 | # Don't forget to use absolute paths, not relative paths. 75 | ) 76 | 77 | # List of finder classes that know how to find static files in 78 | # various locations. 79 | STATICFILES_FINDERS = ( 80 | 'django.contrib.staticfiles.finders.FileSystemFinder', 81 | 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 82 | # 'django.contrib.staticfiles.finders.DefaultStorageFinder', 83 | ) 84 | 85 | # Make this unique, and don't share it with anybody. 86 | SECRET_KEY = '@ohx*g@6&_=_lvhj6nct63srum(1d3%_0+*71^g4$mqx@4r-6a' 87 | 88 | # List of callables that know how to import templates from various sources. 89 | TEMPLATE_LOADERS = ( 90 | 'django.template.loaders.filesystem.Loader', 91 | 'django.template.loaders.app_directories.Loader', 92 | # 'django.template.loaders.eggs.Loader', 93 | ) 94 | 95 | MIDDLEWARE_CLASSES = ( 96 | 'django.middleware.common.CommonMiddleware', 97 | 'django.contrib.sessions.middleware.SessionMiddleware', 98 | 'django.middleware.csrf.CsrfViewMiddleware', 99 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 100 | 'django.contrib.messages.middleware.MessageMiddleware', 101 | # Uncomment the next line for simple clickjacking protection: 102 | # 'django.middleware.clickjacking.XFrameOptionsMiddleware', 103 | ) 104 | 105 | ROOT_URLCONF = 'mysite.urls' 106 | 107 | # Python dotted path to the WSGI application used by Django's runserver. 108 | WSGI_APPLICATION = 'mysite.wsgi.application' 109 | 110 | TEMPLATE_DIRS = ( 111 | # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". 112 | # Always use forward slashes, even on Windows. 113 | # Don't forget to use absolute paths, not relative paths. 114 | ) 115 | 116 | INSTALLED_APPS = ( 117 | 'django.contrib.auth', 118 | 'django.contrib.contenttypes', 119 | 'django.contrib.sessions', 120 | 'django.contrib.sites', 121 | 'django.contrib.messages', 122 | 'django.contrib.staticfiles', 123 | 'main', 124 | # Uncomment the next line to enable the admin: 125 | # 'django.contrib.admin', 126 | # Uncomment the next line to enable admin documentation: 127 | # 'django.contrib.admindocs', 128 | ) 129 | 130 | SESSION_SERIALIZER = 'django.contrib.sessions.serializers.JSONSerializer' 131 | 132 | # A sample logging configuration. The only tangible logging 133 | # performed by this configuration is to send an email to 134 | # the site admins on every HTTP 500 error when DEBUG=False. 135 | # See http://docs.djangoproject.com/en/dev/topics/logging for 136 | # more details on how to customize your logging configuration. 137 | LOGGING = { 138 | 'version': 1, 139 | 'disable_existing_loggers': False, 140 | 'filters': { 141 | 'require_debug_false': { 142 | '()': 'django.utils.log.RequireDebugFalse' 143 | } 144 | }, 145 | 'handlers': { 146 | 'mail_admins': { 147 | 'level': 'ERROR', 148 | 'filters': ['require_debug_false'], 149 | 'class': 'django.utils.log.AdminEmailHandler' 150 | } 151 | }, 152 | 'loggers': { 153 | 'django.request': { 154 | 'handlers': ['mail_admins'], 155 | 'level': 'ERROR', 156 | 'propagate': True, 157 | }, 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /mysite/mysite/urls.py: -------------------------------------------------------------------------------- 1 | from django.conf.urls import patterns, include, url 2 | 3 | # Uncomment the next two lines to enable the admin: 4 | # from django.contrib import admin 5 | # admin.autodiscover() 6 | 7 | urlpatterns = patterns('', 8 | url(r'^$', include('main.urls', namespace="main", app_name="main")), 9 | # Examples: 10 | # url(r'^$', 'mysite.views.home', name='home'), 11 | # url(r'^mysite/', include('mysite.foo.urls')), 12 | 13 | # Uncomment the admin/doc line below to enable admin documentation: 14 | # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 15 | 16 | # Uncomment the next line to enable the admin: 17 | # url(r'^admin/', include(admin.site.urls)), 18 | ) 19 | -------------------------------------------------------------------------------- /mysite/mysite/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for mysite project. 3 | 4 | This module contains the WSGI application used by Django's development server 5 | and any production WSGI deployments. It should expose a module-level variable 6 | named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover 7 | this application via the ``WSGI_APPLICATION`` setting. 8 | 9 | Usually you will have the standard Django WSGI application here, but it also 10 | might make sense to replace the whole Django WSGI application with a custom one 11 | that later delegates to the Django one. For example, you could introduce WSGI 12 | middleware here, or combine a Django application with an application of another 13 | framework. 14 | 15 | """ 16 | import os 17 | 18 | # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks 19 | # if running multiple sites in the same mod_wsgi process. To fix this, use 20 | # mod_wsgi daemon mode with each site in its own daemon process, or use 21 | # os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings" 22 | os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") 23 | 24 | # This application object is used by any WSGI server configured to use this 25 | # file. This includes Django's development server, if the WSGI_APPLICATION 26 | # setting points here. 27 | from django.core.wsgi import get_wsgi_application 28 | application = get_wsgi_application() 29 | 30 | # Apply WSGI middleware here. 31 | # from helloworld.wsgi import HelloWorldApplication 32 | # application = HelloWorldApplication(application) 33 | --------------------------------------------------------------------------------