max file size

This commit is contained in:
James Campos 2011-09-03 15:07:15 -07:00
parent d60d214f1b
commit ee040e52ad
2 changed files with 15 additions and 4 deletions

View File

@ -1255,6 +1255,7 @@
} }
}); });
QR.accept = "'" + accept + "'"; QR.accept = "'" + accept + "'";
QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value;
QR.spoiler = $('.postarea label') ? ' <label>[<input type=checkbox name=spoiler>Spoiler Image?]</label>' : ''; QR.spoiler = $('.postarea label') ? ' <label>[<input type=checkbox name=spoiler>Spoiler Image?]</label>' : '';
if (conf['Persistent QR']) { if (conf['Persistent QR']) {
QR.dialog(); QR.dialog();
@ -1332,8 +1333,13 @@
return captcha; return captcha;
}, },
change: function() { change: function() {
$.unbind(this, 'change', QR.change); if (this.files[0].size > QR.MAX_FILE_SIZE) {
return QR.attach(); alert('Error: File too large.');
return this.click();
} else {
$.unbind(this, 'change', QR.change);
return QR.attach();
}
}, },
close: function() { close: function() {
$.rm(QR.qr); $.rm(QR.qr);

View File

@ -987,6 +987,7 @@ QR =
else else
'image/' + type 'image/' + type
QR.accept = "'#{accept}'" QR.accept = "'#{accept}'"
QR.MAX_FILE_SIZE = $('input[name=MAX_FILE_SIZE]').value
QR.spoiler = if $('.postarea label') then ' <label>[<input type=checkbox name=spoiler>Spoiler Image?]</label>' else '' QR.spoiler = if $('.postarea label') then ' <label>[<input type=checkbox name=spoiler>Spoiler Image?]</label>' else ''
if conf['Persistent QR'] if conf['Persistent QR']
QR.dialog() QR.dialog()
@ -1040,8 +1041,12 @@ QR =
$('#cl', QR.qr).textContent = captchas.length + ' captchas' $('#cl', QR.qr).textContent = captchas.length + ' captchas'
captcha captcha
change: -> change: ->
$.unbind @, 'change', QR.change if @files[0].size > QR.MAX_FILE_SIZE
QR.attach() alert 'Error: File too large.'
@.click()
else
$.unbind @, 'change', QR.change
QR.attach()
close: -> close: ->
$.rm QR.qr $.rm QR.qr
QR.qr = null QR.qr = null