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