/
sample.html
82 lines (65 loc) · 1.95 KB
/
sample.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>sample</title>
<script type="text/javascript" src="file-input.js"></script>
<style type="text/css">
body {
font-family: sans-serif;
}
.my-input {
display: inline-block;
margin: 1rem;
}
a {
display: inline-block;
border: 1px solid #aaa;
border-radius: 1.5px;
margin-right: 0.5rem;
cursor: pointer;
}
.button {
padding: 0.5rem 1rem;
background-color: #ddd;
}
.button.primary {
border: none;
background-color: #369;
color: white;
}
.some-class {
font-style: italic;
color: #666;
}
</style>
</head>
<body>
<input type="file" class="my-input my-input-1" />
<script type="text/javascript">
// omitting the selector affects all file input elements (that aren't already affected)
fileInput();
document.write('<input type="file" class="my-input my-input-2" />');
document.write('<input type="file" class="my-input my-input-3" />');
// passing a custom selector
fileInput('.my-input:last-child');
document.write('<input type="file" class="my-input my-input-4" id="foo" />');
// passing an HTMLElement object
fileInput(document.getElementById('foo'));
// passing options only
fileInput({
buttonText: 'Select a file...',
buttonClasses: ['button']
});
document.write('<input type="file" class="my-input my-input-5" multiple />');
// passing a selector and options
fileInput('.my-input-5', {
buttonText: 'Select another file...',
buttonClasses: ['button', 'primary'],
noFilesText: 'Nothing selected.',
multiFilesText: 'There are {num} files.',
fileNameClasses: ['some-class']
})
</script>
</body>
</html>