-
Notifications
You must be signed in to change notification settings - Fork 5
/
droponly.html
executable file
·139 lines (92 loc) · 3.83 KB
/
droponly.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>DropZone : Modal MooTools HTML5 uploader : Drag and Drop</title>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.9.0/build/base/base-min.css">
<link rel="stylesheet" type="text/css" media="all" href="css/style.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/mootools/1.4.0/mootools-yui-compressed.js"></script>
<script type="text/javascript" src="../Source/DropZone/Request.Blob.js"></script>
<script type="text/javascript" src="../Source/DropZone/DropZone.js"></script>
<script type="text/javascript" src="../Source/DropZone/DropZone.HTML5.js"></script>
<script type="text/javascript">
window.addEvent('domready', function() {
// Basic example using the best upload method (Autodetect the best method)
var w = $('someWrap');
var myUpload = new DropZone({
ui_list: w.getElement('.list'),
ui_drop_area: $(document.body), //w.getElement('.drop_area')
url: 'upload.php',
onItemAdded: function(el, file, imagedata){
el.addClass('item_box').adopt(new Element('div', {'class': 'text filename', 'html': file.name}))
.adopt(new Element('div', {'class': 'text type', 'html': file.type}))
.adopt(new Element('div', {'class': 'progress'}).set('tween', {duration: 200}))
.adopt(new Element('div', {'class': 'delete', 'html': 'x'}).addEvent('click', function(e){e.stop(); myUpload.cancel(file.id, el)}));
el.setStyle('opacity', .3);
// remember file type can't be collected for some files,
// extensions are used then
if(!file.type) return;
if(file.type.match('image') && imagedata){
el.addClass('image');
new Element('img', {'src': imagedata}).inject(el, 'top');
} else if (file.type.match('audio') || file.type.match('flac')){
el.addClass('audio');
}
},
onItemProgress: function(el, perc){
console.log('ITEM PROGRESS: ' + perc);
if(!el.getElement('.progress')) return;
console.log(Math.round(160 * perc/100));
el.getElement('.progress').tween('width', Math.round(140 * perc/100));
el.getElement('.progress').innerHTML = Math.floor(perc) + '%';
},
onItemComplete: function(el){
console.log('ITEM COMPLETE');
var perc = 100;
el.getElement('.progress').tween('width', Math.round(140 * perc/100));
el.getElement('.progress').innerHTML = Math.floor(perc) + '%';
//el.getElement('.progress').destroy();
el.getElement('.delete').destroy();
el.setStyle('opacity', 1);
},
onItemCancel: function(el){
el.destroy();
},
onUploadStart: function(){
console.log('ON QUEUE START!');
},
onUploadProgress: function(perc){
w.getElement('.progress_bar').tween('width', 540 * perc/100);
w.getElement('.progress_bar').innerHTML = Math.floor(perc) + '%';
},
onUploadComplete: function(num_uploaded){
console.log('ON QUEUE COMPLETE! (' + num_uploaded + ' uploaded)');
if(num_uploaded > 0){
w.getElement('.progress_bar').tween('width', 540);
w.getElement('.progress_bar').innerHTML = 'Job done!';
} else {
w.getElement('.progress_bar').setStyle('width', 0);
}
}
});
});
</script>
</head>
<body>
<div class="wrap">
<p>
<a href="index.html">Multi + List + Drop</a> |
<a href="single.html">Only button</a> |
<a href="droponly.html">Only Drag&Drop</a>
</p>
<div id="someWrap">
<div id="uploadWrap" class="drop_area">
<div class="list"></div>
<div class="clear"></div>
</div>
<div class="progress_bar"></div>
</div>
<p><i><small>This one doesn't have button and loads only the HTML5 module. Drag and drop files to test.</small></i></p>
</div>
</body>
</html>