merge change1 into change, refreshFile -> resetFile
This commit is contained in:
parent
234c9faae3
commit
34daa5fd2f
@ -1275,7 +1275,6 @@
|
||||
});
|
||||
file = $('input', div);
|
||||
$.bind(file, 'change', QR.change);
|
||||
$.bind(file, 'change', QR.change1);
|
||||
$.bind($('a', div), 'click', function() {
|
||||
return $.rm(this.parentNode);
|
||||
});
|
||||
@ -1289,7 +1288,7 @@
|
||||
$.rm(file.parentNode);
|
||||
return $.replace(old, file);
|
||||
} else {
|
||||
return $.refreshFile(old);
|
||||
return $.resetFile(old);
|
||||
}
|
||||
},
|
||||
captchaNode: function(e) {
|
||||
@ -1328,25 +1327,18 @@
|
||||
return captcha;
|
||||
},
|
||||
change: function(e) {
|
||||
if (!(this.files[0].size > QR.MAX_FILE_SIZE)) {
|
||||
return;
|
||||
var a, p;
|
||||
if (this.files[0].size > QR.MAX_FILE_SIZE) {
|
||||
alert('Error: File too large.');
|
||||
QR.resetFile(this);
|
||||
return $('[type=file]', QR.qr).click();
|
||||
} else {
|
||||
p = this.parentNode;
|
||||
a = p.parentNode;
|
||||
if (a.id === 'files' && !p.nextSibling) {
|
||||
return QR.attach();
|
||||
}
|
||||
}
|
||||
alert('Error: File too large.');
|
||||
QR.refreshFile(this);
|
||||
return $('[type=file]', QR.qr).click();
|
||||
},
|
||||
refreshFile: function(old) {
|
||||
var div, file;
|
||||
div = $.el('div', {
|
||||
innerHTML: QR.file
|
||||
});
|
||||
file = div.firstChild;
|
||||
$.bind(file, 'change', QR.change);
|
||||
return $.replace(old, file);
|
||||
},
|
||||
change1: function() {
|
||||
$.unbind(this, 'change', QR.change1);
|
||||
return QR.attach();
|
||||
},
|
||||
close: function() {
|
||||
$.rm(QR.qr);
|
||||
@ -1478,6 +1470,15 @@
|
||||
$('textarea', QR.qr).value = '';
|
||||
return QR.attachNext();
|
||||
},
|
||||
resetFile: function(old) {
|
||||
var div, file;
|
||||
div = $.el('div', {
|
||||
innerHTML: QR.file
|
||||
});
|
||||
file = div.firstChild;
|
||||
$.bind(file, 'change', QR.change);
|
||||
return $.replace(old, file);
|
||||
},
|
||||
submit: function(e) {
|
||||
var captcha, challenge, el, id, op, qr, response;
|
||||
if (!($('textarea', QR.qr).value || $('[type=file]', QR.qr).files.length)) {
|
||||
|
||||
@ -1002,7 +1002,6 @@ QR =
|
||||
innerHTML: "#{QR.file}<a class=close>X</a>"
|
||||
file = $ 'input', div
|
||||
$.bind file, 'change', QR.change
|
||||
$.bind file, 'change', QR.change1
|
||||
$.bind $('a', div), 'click', -> $.rm @parentNode
|
||||
$.append $('#files', QR.qr), div
|
||||
file.click()
|
||||
@ -1012,7 +1011,7 @@ QR =
|
||||
$.rm file.parentNode
|
||||
$.replace old, file
|
||||
else
|
||||
$.refreshFile old
|
||||
$.resetFile old
|
||||
captchaNode: (e) ->
|
||||
c = e.target.value
|
||||
$('img', QR.qr).src = "http://www.google.com/recaptcha/api/image?c=#{c}" if QR.qr
|
||||
@ -1038,19 +1037,15 @@ QR =
|
||||
$('#cl', QR.qr).textContent = captchas.length + ' captchas'
|
||||
captcha
|
||||
change: (e) ->
|
||||
return unless @files[0].size > QR.MAX_FILE_SIZE
|
||||
alert 'Error: File too large.'
|
||||
QR.refreshFile @
|
||||
$('[type=file]', QR.qr).click()
|
||||
refreshFile: (old) ->
|
||||
div = $.el 'div'
|
||||
innerHTML: QR.file
|
||||
file = div.firstChild
|
||||
$.bind file, 'change', QR.change
|
||||
$.replace old, file
|
||||
change1: ->
|
||||
$.unbind @, 'change', QR.change1
|
||||
QR.attach()
|
||||
if @files[0].size > QR.MAX_FILE_SIZE
|
||||
alert 'Error: File too large.'
|
||||
QR.resetFile @
|
||||
$('[type=file]', QR.qr).click()
|
||||
else
|
||||
p = @parentNode
|
||||
a = p.parentNode
|
||||
if a.id is 'files' and not p.nextSibling
|
||||
QR.attach()
|
||||
close: ->
|
||||
$.rm QR.qr
|
||||
QR.qr = null
|
||||
@ -1158,6 +1153,12 @@ QR =
|
||||
$('[name=spoiler]', QR.qr)?.checked = false unless conf['Remember Spoiler']
|
||||
$('textarea', QR.qr).value = ''
|
||||
QR.attachNext()
|
||||
resetFile: (old) ->
|
||||
div = $.el 'div'
|
||||
innerHTML: QR.file
|
||||
file = div.firstChild
|
||||
$.bind file, 'change', QR.change
|
||||
$.replace old, file
|
||||
submit: (e) ->
|
||||
#XXX e is undefined if method is called explicitly, eg, from auto posting
|
||||
unless $('textarea', QR.qr).value or $('[type=file]', QR.qr).files.length
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user