97b544362630d20fed278ef86339e31116702d81
[Portfolio.git] / skins / fileupload.js
1 // © 2013 Benoît Pin MINES ParisTech
2 var DDFileUploader;
3
4 (function(){
5
6 DDFileUploader = function(dropbox) {
7 this.dropbox = dropbox;
8 var thisDDFU = this;
9 addListener(dropbox, 'dragenter', function(evt){thisDDFU.dragenter(evt);});
10 addListener(dropbox, 'dragover', function(evt){thisDDFU.dragover(evt);});
11 addListener(dropbox, 'drop', function(evt){thisDDFU.drop(evt);});
12 };
13
14 DDFileUploader.prototype.dragenter = function(evt) {
15 disableDefault(evt);
16 disablePropagation(evt);
17 };
18
19 DDFileUploader.prototype.dragover = function(evt) {
20 disableDefault(evt);
21 disablePropagation(evt);
22 evt = getEventObject(evt);
23 var dt = evt.dataTransfer;
24 dt.dropEffect = 'copy';
25 };
26
27
28 DDFileUploader.prototype.drop = function(evt) {
29 disableDefault(evt);
30 disablePropagation(evt);
31 getEventObject(evt);
32 var dt = evt.dataTransfer;
33 dt.dropEffect = 'copy';
34 this.handleFiles(dt.files);
35 };
36
37 DDFileUploader.prototype.handleFiles = function(files) {
38 var file, i;
39 for (i = 0; i < files.length; i++) {
40 file = files[i];
41 console.log(file.type);
42 }
43 };
44
45 }());