-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
30 lines (26 loc) · 879 Bytes
/
popup.js
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
document.addEventListener('DOMContentLoaded', function() {
var fsPopup = (function() {
var callback,
form = document.createElement('form'),
input = document.createElement('input');
form.appendChild(input);
form.style.display = 'none';
input.type = 'file';
input.addEventListener('change', function() {
callback(input.files);
form.reset();
});
return {
add: function(elem, func, multiple) {
if (window.FileList) {
elem.addEventListener('click', function(evt) {
callback = func;
evt.preventDefault();
input.multiple = !!multiple;
input.click();
});
}
}
}
})();
});