More name/email/subject set/load work.

This commit is contained in:
Nicolas Stepien 2012-01-11 11:28:01 +01:00
parent b50564c70f
commit 50ffdb417c
2 changed files with 45 additions and 41 deletions

View File

@ -1312,12 +1312,10 @@
reply: (function() {
function _Class(file) {
var name, _ref;
var previous, _ref;
this.file = file;
_ref = (previous = qr.replies[qr.replies.length - 1]) ? [previous.name, /^sage$/.test(previous.email) ? null : previous.email, conf['Remember Subject'] ? previous.sub : null] : [$.get("qr_name", null), $.get("qr_email", null), conf['Remember Subject'] ? $.get("qr_sub", null) : null], this.name = _ref[0], this.email = _ref[1], this.sub = _ref[2];
this.com = null;
for (name in qr.inputs) {
this[name] = ((_ref = qr.replies[qr.replies.length - 1]) != null ? _ref[name] : void 0) || $.get("qr_" + name, null);
}
qr.replies.push(this);
}
@ -1325,6 +1323,8 @@
return log(this);
};
_Class.prototype.rm = function() {};
return _Class;
})(),
@ -1350,7 +1350,7 @@
}
});
qr.mimeTypes = mimeTypes.split(', ');
qr.el = ui.dialog('qr', 'top:0;right:0;', "<style>.autohide:not(:hover) > form { display: none;}#qr > .move { min-width: 300px; overflow: hidden; box-sizing: border-box; padding: 0 2px;}#qr > .move > span { float: right;}#autohide, #qr select, #dump, .captcha { cursor: pointer;}#qr select,#qr > form { margin: 0;}#dump { background: -webkit-linear-gradient(#EEE, #CCC); background: -moz-linear-gradient(#EEE, #CCC); background: -o-linear-gradient(#EEE, #CCC); background: linear-gradient(#EEE, #CCC); width: 10%;}#dump:hover, #dump:focus { background: -webkit-linear-gradient(#FFF, #DDD); background: -moz-linear-gradient(#FFF, #DDD); background: -o-linear-gradient(#FFF, #DDD); background: linear-gradient(#FFF, #DDD);}#dump:active, .dump #dump:not(:hover):not(:focus) { background: -webkit-linear-gradient(#CCC, #DDD); background: -moz-linear-gradient(#CCC, #DDD); background: -o-linear-gradient(#CCC, #DDD); background: linear-gradient(#CCC, #DDD);}#qr:not(.dump) #replies { display: none;}.field { border: 1px solid #CCC; color: #333; font: 13px sans-serif; margin: 0; padding: 2px 4px 3px; width: 30%; -webkit-transition: color .25s, border .25s; -moz-transition: color .25s, border .25s; -o-transition: color .25s, border .25s; transition: color .25s, border .25s;}.field:-moz-placeholder,.field:hover:-moz-placeholder { color: #AAA;}.field:hover, .field:focus { border-color: #999; color: #000; outline: none;}textarea.field { min-height: 120px; width: 100%;}.captcha { background: #FFF; text-align: center;}.captcha > img { height: 57px; width: 300px;}.field[name=captcha] { width: 100%;}#qr [type=file] { width: 80%;}#qr [type=submit] { padding: 0 -moz-calc(1px); /* Gecko does not respect box-sizing: border-box */ width: 20%;}</style><div class=move> Quick Reply <input type=checkbox name=autohide id=autohide title=Auto-hide> <span>" + (g.REPLY ? '' : threads) + " <a class=close></a></span></div><form> <div><input id=dump class=field type=button title='Dump mode' value=+><input name=name title=Name placeholder=Name class=field size=1><input name=email title=E-mail placeholder=E-mail class=field size=1><input name=subject title=Subject placeholder=Subject class=field size=1></div> <div id=replies></div> <div><textarea title=Comment placeholder=Comment class=field></textarea></div> <div class=captcha><img></div> <div><input name=captcha title=Verification placeholder=Verification class=field size=1></div> <div><input type=file name=upfile max=" + ($('[name=MAX_FILE_SIZE]').value) + " accept='" + mimeTypes + "' multiple><input type=submit value=" + (g.dead ? '404 disabled' : 'Submit') + "></div> <div class=error></div></form>");
qr.el = ui.dialog('qr', 'top:0;right:0;', "<style>.autohide:not(:hover) > form { display: none;}#qr > .move { min-width: 300px; overflow: hidden; box-sizing: border-box; padding: 0 2px;}#qr > .move > span { float: right;}#autohide, #qr select, #dump, .captcha { cursor: pointer;}#qr select,#qr > form { margin: 0;}#dump { background: -webkit-linear-gradient(#EEE, #CCC); background: -moz-linear-gradient(#EEE, #CCC); background: -o-linear-gradient(#EEE, #CCC); background: linear-gradient(#EEE, #CCC); width: 10%;}#dump:hover, #dump:focus { background: -webkit-linear-gradient(#FFF, #DDD); background: -moz-linear-gradient(#FFF, #DDD); background: -o-linear-gradient(#FFF, #DDD); background: linear-gradient(#FFF, #DDD);}#dump:active, .dump #dump:not(:hover):not(:focus) { background: -webkit-linear-gradient(#CCC, #DDD); background: -moz-linear-gradient(#CCC, #DDD); background: -o-linear-gradient(#CCC, #DDD); background: linear-gradient(#CCC, #DDD);}#qr:not(.dump) #replies { display: none;}.field { border: 1px solid #CCC; color: #333; font: 13px sans-serif; margin: 0; padding: 2px 4px 3px; width: 30%; -webkit-transition: color .25s, border .25s; -moz-transition: color .25s, border .25s; -o-transition: color .25s, border .25s; transition: color .25s, border .25s;}.field:-moz-placeholder,.field:hover:-moz-placeholder { color: #AAA;}.field:hover, .field:focus { border-color: #999; color: #000; outline: none;}textarea.field { min-height: 120px; width: 100%;}.captcha { background: #FFF; text-align: center;}.captcha > img { height: 57px; width: 300px;}.field[name=captcha] { width: 100%;}#qr [type=file] { width: 80%;}#qr [type=submit] { padding: 0 -moz-calc(1px); /* Gecko does not respect box-sizing: border-box */ width: 20%;}</style><div class=move> Quick Reply <input type=checkbox name=autohide id=autohide title=Auto-hide> <span>" + (g.REPLY ? '' : threads) + " <a class=close></a></span></div><form> <div><input id=dump class=field type=button title='Dump mode' value=+><input name=name title=Name placeholder=Name class=field size=1><input name=email title=E-mail placeholder=E-mail class=field size=1><input name=sub title=Subject placeholder=Subject class=field size=1></div> <div id=replies></div> <div><textarea name=com title=Comment placeholder=Comment class=field></textarea></div> <div class=captcha><img></div> <div><input name=captcha title=Verification placeholder=Verification class=field size=1></div> <div><input type=file name=upfile max=" + ($('[name=MAX_FILE_SIZE]').value) + " accept='" + mimeTypes + "' multiple><input type=submit value=" + (g.dead ? '404 disabled' : 'Submit') + "></div> <div class=error></div></form>");
if (!g.REPLY) {
$.on($('select', qr.el), 'mousedown', function(e) {
return e.stopPropagation();
@ -1363,11 +1363,6 @@
});
$.on($('form', qr.el), 'submit', qr.submit);
$.on($('[type=file]', qr.el), 'change', qr.fileInput);
qr.inputs = {
name: $('[name=name]', qr.el),
email: $('[name=email]', qr.el)
};
if (conf['Remember Subject']) qr.inputs.subject = $('[name=subject]', qr.el);
new qr.reply().load();
return $.add(d.body, qr.el);
},
@ -1381,21 +1376,16 @@
return qr.cleanError();
},
response: function(e) {
var input, name, _ref, _results;
var reply, sage;
log(e);
if (!conf['Persistent QR']) qr.close();
if (/sage/i.test(qr.inputs.email.value)) {
qr.sage = true;
qr.inputs.email.value = null;
}
if (!conf['Remember Subject']) $('[name=subject]', qr.el).value = null;
_ref = qr.inputs;
_results = [];
for (name in _ref) {
input = _ref[name];
_results.push($.set("qr_" + name, input.value));
}
return _results;
if (!(conf['Persistent QR'] || qr.replies.length > 1)) qr.close();
sage = /sage/i.test(reply.email);
reply = qr.replies[0];
$.set("qr_name", reply.name);
$.set("qr_email", /^sage$/.test(reply.email) ? null : reply.email);
if (conf['Remember Subject']) $.set("qr_sub", reply.sub);
if (qr.replies.length === 1) new qr.reply().load();
return reply.rm();
}
};

View File

@ -971,13 +971,28 @@ qr =
replies: []
reply: class
constructor: (@file) ->
[@name, @email, @sub] =
if previous = qr.replies[qr.replies.length-1]
[
previous.name,
if /^sage$/.test(previous.email) then null else previous.email,
if conf['Remember Subject'] then previous.sub else null
]
else
[
$.get("qr_name", null),
$.get("qr_email", null),
if conf['Remember Subject'] then $.get("qr_sub", null) else null
]
@com = null
for name of qr.inputs
@[name] = qr.replies[qr.replies.length-1]?[name] or $.get "qr_#{name}", null
qr.replies.push @
load: ->
# load reply's data in the QR dialog
# visual feedback in the list
log @
rm: ->
# rm reply from qr.replies and the UI
dialog: ->
# create a new thread or select thread to reply to
@ -1089,9 +1104,9 @@ textarea.field {
<span>#{if g.REPLY then '' else threads} <a class=close></a></span>
</div>
<form>
<div><input id=dump class=field type=button title='Dump mode' value=+><input name=name title=Name placeholder=Name class=field size=1><input name=email title=E-mail placeholder=E-mail class=field size=1><input name=subject title=Subject placeholder=Subject class=field size=1></div>
<div><input id=dump class=field type=button title='Dump mode' value=+><input name=name title=Name placeholder=Name class=field size=1><input name=email title=E-mail placeholder=E-mail class=field size=1><input name=sub title=Subject placeholder=Subject class=field size=1></div>
<div id=replies></div>
<div><textarea title=Comment placeholder=Comment class=field></textarea></div>
<div><textarea name=com title=Comment placeholder=Comment class=field></textarea></div>
<div class=captcha><img></div>
<div><input name=captcha title=Verification placeholder=Verification class=field size=1></div>
<div><input type=file name=upfile max=#{$('[name=MAX_FILE_SIZE]').value} accept='#{mimeTypes}' multiple><input type=submit value=#{if g.dead then '404 disabled' else 'Submit'}></div>
@ -1105,12 +1120,8 @@ textarea.field {
$.on $('form', qr.el), 'submit', qr.submit
$.on $('[type=file]', qr.el), 'change', qr.fileInput
# save & load inputs' value with localStorage
qr.inputs =
name: $ '[name=name]', qr.el
email: $ '[name=email]', qr.el
qr.inputs.subject = $ '[name=subject]', qr.el if conf['Remember Subject']
new qr.reply().load()
#onchange this reply =
# sync between tabs
# $.on window, 'storage', (e) ->
# if match = e.key.match /qr_(.+)$/
@ -1131,16 +1142,19 @@ textarea.field {
log e
# successful posting/error handling
unless conf['Persistent QR'] # or more replies to post
unless conf['Persistent QR'] or qr.replies.length > 1
qr.close()
if /sage/i.test qr.inputs.email.value
qr.sage = true
qr.inputs.email.value = null
unless conf['Remember Subject']
$('[name=subject]', qr.el).value = null
for name, input of qr.inputs
$.set "qr_#{name}", input.value
sage = /sage/i.test reply.email
# cooldown
reply = qr.replies[0]
$.set "qr_name", reply.name
$.set "qr_email", if /^sage$/.test reply.email then null else reply.email
$.set "qr_sub", reply.sub if conf['Remember Subject']
new qr.reply().load() if qr.replies.length is 1
reply.rm()
options =
init: ->