summaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/fileselect.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/script/fileselect.js b/script/fileselect.js
new file mode 100644
index 00000000..df4ff7b9
--- /dev/null
+++ b/script/fileselect.js
@@ -0,0 +1,26 @@
+$(document).on('change', '.btn-file :file', function() {
+ var input = $(this);
+ var numFiles = input.get(0).files ? input.get(0).files.length : 1;
+ var label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
+ input.trigger('fileselect', [numFiles, label]);
+});
+
+$(document).ready(function() {
+ $('.btn-file :file').on('fileselect', function(event, numFiles, label) {
+
+ var input = $(this).parents('.upload-ex').find(':text');
+ var log = numFiles > 1 ? numFiles + ' files selected' : label;
+
+ if (input.length) {
+ input.val(log);
+ } else {
+ if (log)
+ alert(log);
+ }
+
+ });
+});
+
+$('.upload-ex :text').click(function () {
+ $(this).parents('.upload-ex').find(':file').click();
+}); \ No newline at end of file