Chose files with allowed mime-type.

This commit is contained in:
Nicolas Stepien 2012-01-01 04:07:21 +01:00
parent e1cc2309a1
commit ff34fa6de1
2 changed files with 23 additions and 1 deletions

View File

@ -1234,7 +1234,7 @@
return ta.selectionEnd = ta.selectionStart = caretPos + text.length;
},
dialog: function() {
var input, name, _ref;
var file, input, name, _ref;
qr.el = ui.dialog('qr', 'top:0;right:0;', '\
<style>\
.autohide:not(:hover) > form {\
@ -1336,6 +1336,17 @@ textarea.field {\
return qr.inputs[match[1]].value = JSON.parse(e.newValue);
}
});
file = $('[type=file]', qr.el);
file.accept = $('.rules').textContent.match(/: (.+)/)[1].replace(/\w+/g, function(type) {
switch (type) {
case 'JPG':
return 'image/JPEG';
case 'PDF':
return 'application/PDF';
default:
return 'image/' + type;
}
});
return $.add(d.body, qr.el);
},
submit: function(e) {

View File

@ -1004,6 +1004,17 @@ textarea.field {
if match = e.key.match /qr_(.+)$/
qr.inputs[match[1]].value = JSON.parse e.newValue
file = $ '[type=file]', qr.el
# chose only allowed files
file.accept = $('.rules').textContent.match(/: (.+)/)[1].replace /\w+/g, (type) ->
switch type
when 'JPG'
'image/JPEG'
when 'PDF'
'application/PDF'
else
'image/' + type
$.add d.body, qr.el
submit: (e) ->