/
stylish_file_input.js
40 lines (40 loc) · 1.44 KB
/
stylish_file_input.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
31
32
33
34
35
36
37
38
39
40
(function() {
var exports;
exports = window;
(function(exports) {
var stylizeFileInput, _hideInput;
stylizeFileInput = function(htmlFileInputElement, text) {
var inputSibling, label, parentNode, textSpan;
if (text == null) {
text = "Choose File";
}
parentNode = htmlFileInputElement.parentNode;
label = document.createElement("label");
label.className = "stylish-file-input";
inputSibling = htmlFileInputElement.nextSibling;
parentNode.insertBefore(label, inputSibling);
label.appendChild(htmlFileInputElement);
textSpan = document.createElement("span");
textSpan.className = "text";
textSpan.innerHTML = text;
label.insertBefore(textSpan, htmlFileInputElement);
return _hideInput(label, htmlFileInputElement);
};
_hideInput = function(label, input) {
var inputStyle, labelStyle;
labelStyle = label.style;
labelStyle.position = "relative";
labelStyle.display = "inline-block";
labelStyle.overflow = "hidden";
inputStyle = input.style;
inputStyle.position = "absolute";
inputStyle.right = "0px";
inputStyle.top = "0px";
inputStyle.cursor = "pointer";
inputStyle.fontSize = "500px";
inputStyle.opacity = 0;
return inputStyle.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
};
return exports.stylizeFileInput = stylizeFileInput;
})(exports);
}).call(this);