More name/email/subject set/load work.
This commit is contained in:
parent
b50564c70f
commit
50ffdb417c
@ -1312,12 +1312,10 @@
|
|||||||
reply: (function() {
|
reply: (function() {
|
||||||
|
|
||||||
function _Class(file) {
|
function _Class(file) {
|
||||||
var name, _ref;
|
var previous, _ref;
|
||||||
this.file = file;
|
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;
|
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);
|
qr.replies.push(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1325,6 +1323,8 @@
|
|||||||
return log(this);
|
return log(this);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_Class.prototype.rm = function() {};
|
||||||
|
|
||||||
return _Class;
|
return _Class;
|
||||||
|
|
||||||
})(),
|
})(),
|
||||||
@ -1350,7 +1350,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
qr.mimeTypes = mimeTypes.split(', ');
|
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) {
|
if (!g.REPLY) {
|
||||||
$.on($('select', qr.el), 'mousedown', function(e) {
|
$.on($('select', qr.el), 'mousedown', function(e) {
|
||||||
return e.stopPropagation();
|
return e.stopPropagation();
|
||||||
@ -1363,11 +1363,6 @@
|
|||||||
});
|
});
|
||||||
$.on($('form', qr.el), 'submit', qr.submit);
|
$.on($('form', qr.el), 'submit', qr.submit);
|
||||||
$.on($('[type=file]', qr.el), 'change', qr.fileInput);
|
$.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();
|
new qr.reply().load();
|
||||||
return $.add(d.body, qr.el);
|
return $.add(d.body, qr.el);
|
||||||
},
|
},
|
||||||
@ -1381,21 +1376,16 @@
|
|||||||
return qr.cleanError();
|
return qr.cleanError();
|
||||||
},
|
},
|
||||||
response: function(e) {
|
response: function(e) {
|
||||||
var input, name, _ref, _results;
|
var reply, sage;
|
||||||
log(e);
|
log(e);
|
||||||
if (!conf['Persistent QR']) qr.close();
|
if (!(conf['Persistent QR'] || qr.replies.length > 1)) qr.close();
|
||||||
if (/sage/i.test(qr.inputs.email.value)) {
|
sage = /sage/i.test(reply.email);
|
||||||
qr.sage = true;
|
reply = qr.replies[0];
|
||||||
qr.inputs.email.value = null;
|
$.set("qr_name", reply.name);
|
||||||
}
|
$.set("qr_email", /^sage$/.test(reply.email) ? null : reply.email);
|
||||||
if (!conf['Remember Subject']) $('[name=subject]', qr.el).value = null;
|
if (conf['Remember Subject']) $.set("qr_sub", reply.sub);
|
||||||
_ref = qr.inputs;
|
if (qr.replies.length === 1) new qr.reply().load();
|
||||||
_results = [];
|
return reply.rm();
|
||||||
for (name in _ref) {
|
|
||||||
input = _ref[name];
|
|
||||||
_results.push($.set("qr_" + name, input.value));
|
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -971,13 +971,28 @@ qr =
|
|||||||
replies: []
|
replies: []
|
||||||
reply: class
|
reply: class
|
||||||
constructor: (@file) ->
|
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
|
@com = null
|
||||||
for name of qr.inputs
|
|
||||||
@[name] = qr.replies[qr.replies.length-1]?[name] or $.get "qr_#{name}", null
|
|
||||||
qr.replies.push @
|
qr.replies.push @
|
||||||
load: ->
|
load: ->
|
||||||
# load reply's data in the QR dialog
|
# load reply's data in the QR dialog
|
||||||
|
# visual feedback in the list
|
||||||
log @
|
log @
|
||||||
|
rm: ->
|
||||||
|
# rm reply from qr.replies and the UI
|
||||||
|
|
||||||
|
|
||||||
dialog: ->
|
dialog: ->
|
||||||
# create a new thread or select thread to reply to
|
# 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>
|
<span>#{if g.REPLY then '' else threads} <a class=close>⨯</a></span>
|
||||||
</div>
|
</div>
|
||||||
<form>
|
<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 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 class=captcha><img></div>
|
||||||
<div><input name=captcha title=Verification placeholder=Verification class=field size=1></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>
|
<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 $('form', qr.el), 'submit', qr.submit
|
||||||
$.on $('[type=file]', qr.el), 'change', qr.fileInput
|
$.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()
|
new qr.reply().load()
|
||||||
|
#onchange this reply =
|
||||||
# sync between tabs
|
# sync between tabs
|
||||||
# $.on window, 'storage', (e) ->
|
# $.on window, 'storage', (e) ->
|
||||||
# if match = e.key.match /qr_(.+)$/
|
# if match = e.key.match /qr_(.+)$/
|
||||||
@ -1131,16 +1142,19 @@ textarea.field {
|
|||||||
log e
|
log e
|
||||||
# successful posting/error handling
|
# successful posting/error handling
|
||||||
|
|
||||||
unless conf['Persistent QR'] # or more replies to post
|
unless conf['Persistent QR'] or qr.replies.length > 1
|
||||||
qr.close()
|
qr.close()
|
||||||
|
|
||||||
if /sage/i.test qr.inputs.email.value
|
sage = /sage/i.test reply.email
|
||||||
qr.sage = true
|
# cooldown
|
||||||
qr.inputs.email.value = null
|
|
||||||
unless conf['Remember Subject']
|
reply = qr.replies[0]
|
||||||
$('[name=subject]', qr.el).value = null
|
$.set "qr_name", reply.name
|
||||||
for name, input of qr.inputs
|
$.set "qr_email", if /^sage$/.test reply.email then null else reply.email
|
||||||
$.set "qr_#{name}", input.value
|
$.set "qr_sub", reply.sub if conf['Remember Subject']
|
||||||
|
|
||||||
|
new qr.reply().load() if qr.replies.length is 1
|
||||||
|
reply.rm()
|
||||||
|
|
||||||
options =
|
options =
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user