no form.reset()

This commit is contained in:
James Campos 2011-08-23 21:50:44 -07:00
parent 17c594e19a
commit 0ff4dc3f08
2 changed files with 25 additions and 16 deletions

View File

@ -1297,7 +1297,7 @@
return qr.el = null; return qr.el = null;
}, },
dialog: function(link) { dialog: function(link) {
var THREAD_ID, challenge, html, spoiler, submitDisabled, submitValue; var THREAD_ID, challenge, el, html, spoiler, submitDisabled, submitValue, _i, _len, _ref;
submitValue = $('#com_submit').value; submitValue = $('#com_submit').value;
submitDisabled = $('#com_submit').disabled ? 'disabled' : ''; submitDisabled = $('#com_submit').disabled ? 'disabled' : '';
THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id; THREAD_ID = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', link).id;
@ -1308,8 +1308,11 @@
top: '0px', top: '0px',
left: '0px' left: '0px'
}, html); }, html);
qr.refresh(); _ref = $$('form[name=post] [name]');
$('textarea', qr.el).value = $('textarea').value; for (_i = 0, _len = _ref.length; _i < _len; _i++) {
el = _ref[_i];
$("[name=" + el.name + "]", qr.el).value = el.value;
}
$.bind($('input[name=name]', qr.el), 'mousedown', function(e) { $.bind($('input[name=name]', qr.el), 'mousedown', function(e) {
return e.stopPropagation(); return e.stopPropagation();
}); });
@ -1419,12 +1422,16 @@
return ta.value += text; return ta.value += text;
}, },
refresh: function() { refresh: function() {
var c, m; var newFile, oldFile;
$('form', qr.el).reset(); $('[name=sub]', qr.el).value = '';
c = d.cookie; $('[name=com]', qr.el).value = '';
$('input[name=name]', qr.el).value = (m = c.match(/4chan_name=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; $('[name=recaptcha_response_field]', qr.el).value = '';
$('input[name=email]', qr.el).value = (m = c.match(/4chan_email=([^;]+)/)) ? decodeURIComponent(m[1]) : ''; oldFile = $('[type=file]', qr.el);
return $('input[name=pwd]', qr.el).value = (m = c.match(/4chan_pass=([^;]+)/)) ? decodeURIComponent(m[1]) : $('input[name=pwd]').value; newFile = $.el('input', {
type: 'file',
name: 'upfile'
});
return $.replace(oldFile, newFile);
}, },
submit: function(e) { submit: function(e) {
var id, msg, op; var id, msg, op;

View File

@ -1060,8 +1060,8 @@ qr =
" "
qr.el = ui.dialog 'qr', top: '0px', left: '0px', html qr.el = ui.dialog 'qr', top: '0px', left: '0px', html
qr.refresh() for el in $$ 'form[name=post] [name]'
$('textarea', qr.el).value = $('textarea').value $("[name=#{el.name}]", qr.el).value = el.value
$.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation() $.bind $('input[name=name]', qr.el), 'mousedown', (e) -> e.stopPropagation()
$.bind $('input[name=upfile]', qr.el), 'change', qr.validateFileSize $.bind $('input[name=upfile]', qr.el), 'change', qr.validateFileSize
@ -1161,11 +1161,13 @@ qr =
ta.value += text ta.value += text
refresh: -> refresh: ->
$('form', qr.el).reset() $('[name=sub]', qr.el).value = ''
c = d.cookie $('[name=com]', qr.el).value = ''
$('input[name=name]', qr.el).value = if m = c.match(/4chan_name=([^;]+)/) then decodeURIComponent m[1] else '' $('[name=recaptcha_response_field]', qr.el).value = ''
$('input[name=email]', qr.el).value = if m = c.match(/4chan_email=([^;]+)/) then decodeURIComponent m[1] else '' # XXX opera doesn't allow resetting file inputs w/ file.value = ''
$('input[name=pwd]', qr.el).value = if m = c.match(/4chan_pass=([^;]+)/) then decodeURIComponent m[1] else $('input[name=pwd]').value oldFile = $ '[type=file]', qr.el
newFile = $.el 'input', type: 'file', name: 'upfile'
$.replace oldFile, newFile
submit: (e) -> submit: (e) ->
if msg = qr.postInvalid() if msg = qr.postInvalid()