Some changes in elements, preparing submit function, sync name/mail/subject only on submit because we have to take into account the mail field containing sage or not.
This commit is contained in:
parent
4d821dc210
commit
07990f29a2
@ -1243,28 +1243,27 @@
|
|||||||
return ta.selectionEnd = ta.selectionStart = caretPos + text.length;
|
return ta.selectionEnd = ta.selectionStart = caretPos + text.length;
|
||||||
},
|
},
|
||||||
dialog: function() {
|
dialog: function() {
|
||||||
var input, inputs, _i, _len;
|
var input, _i, _len, _ref;
|
||||||
qr.el = ui.dialog('qr', 'top:0;right:0;', '\
|
qr.el = ui.dialog('qr', 'top:0;right:0;', '\
|
||||||
<style>\
|
<style>\
|
||||||
.autohide:not(:hover) > #form {\
|
.autohide:not(:hover) > form {\
|
||||||
display: none;\
|
display: none;\
|
||||||
}\
|
}\
|
||||||
#qr > .move {\
|
#qr > .move {\
|
||||||
min-width: 300px;\
|
min-width: 300px;\
|
||||||
text-align: right;\
|
text-align: right;\
|
||||||
}\
|
}\
|
||||||
.fields > input {\
|
#qr > form {\
|
||||||
|
margin: 0;\
|
||||||
|
}\
|
||||||
|
.field {\
|
||||||
border: 1px solid #AAA;\
|
border: 1px solid #AAA;\
|
||||||
margin: 0;\
|
margin: 0;\
|
||||||
padding: 2px 4px 3px;\
|
padding: 2px 4px 3px;\
|
||||||
width: 33%;\
|
width: 33%;\
|
||||||
}\
|
}\
|
||||||
#form > textarea {\
|
textarea.field {\
|
||||||
font-family: sans-serif;\
|
font-family: sans-serif;\
|
||||||
border-color: #AAA;\
|
|
||||||
border-width: 1px 0;\
|
|
||||||
margin: 0;\
|
|
||||||
padding: 2px 4px 3px;\
|
|
||||||
min-height: 120px;\
|
min-height: 120px;\
|
||||||
width: 100%;\
|
width: 100%;\
|
||||||
}\
|
}\
|
||||||
@ -1276,28 +1275,30 @@
|
|||||||
height: 57px;\
|
height: 57px;\
|
||||||
width: 300px;\
|
width: 300px;\
|
||||||
}\
|
}\
|
||||||
|
.field[name=captcha] {\
|
||||||
|
width: 100%;\
|
||||||
|
}\
|
||||||
</style>\
|
</style>\
|
||||||
\
|
\
|
||||||
<div class=move>\
|
<div class=move>\
|
||||||
<input type=checkbox name=autohide id=autohide title=Auto-hide>\
|
<input type=checkbox name=autohide id=autohide title=Auto-hide>\
|
||||||
<a class=close>⨯</a>\
|
<a class=close>⨯</a>\
|
||||||
</div>\
|
</div>\
|
||||||
<div id=form>\
|
<form>\
|
||||||
<div class=fields><input name=name title=Name placeholder=Name size=1><input name=email title=E-mail placeholder=E-mail size=1><input name=subject title=Subject placeholder=Subject size=1></div>\
|
<div><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>\
|
||||||
<textarea title=Comment placeholder=Comment></textarea>\
|
<textarea title=Comment placeholder=Comment class=field></textarea>\
|
||||||
<div class=captcha><img></div>\
|
<div class=captcha><img></div>\
|
||||||
<input name=captcha title=Verification placeholder=Verification>\
|
<input name=captcha title=Verification placeholder=Verification class=field size=1>\
|
||||||
</div>');
|
</form>');
|
||||||
$.on($('#autohide', qr.el), 'click', qr.hide);
|
$.on($('#autohide', qr.el), 'click', qr.hide);
|
||||||
$.on($('.close', qr.el), 'click', qr.close);
|
$.on($('.close', qr.el), 'click', qr.close);
|
||||||
inputs = [$('[name=name]', qr.el), $('[name=email]', qr.el)];
|
$.on($('form', qr.el), 'submit', qr.submit);
|
||||||
if (conf['Remember Subject']) inputs.push($('[name=subject]', qr.el));
|
qr.inputs = [$('[name=name]', qr.el), $('[name=email]', qr.el)];
|
||||||
for (_i = 0, _len = inputs.length; _i < _len; _i++) {
|
if (conf['Remember Subject']) qr.inputs.push($('[name=subject]', qr.el));
|
||||||
input = inputs[_i];
|
_ref = qr.inputs;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
input = _ref[_i];
|
||||||
input.value = $.get("qr_" + input.name, null);
|
input.value = $.get("qr_" + input.name, null);
|
||||||
$.on(input, 'change', function() {
|
|
||||||
return $.set("qr_" + this.name, this.value);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
$.on(window, 'storage', function(e) {
|
$.on(window, 'storage', function(e) {
|
||||||
var match;
|
var match;
|
||||||
@ -1306,6 +1307,24 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
return $.add(d.body, qr.el);
|
return $.add(d.body, qr.el);
|
||||||
|
},
|
||||||
|
submit: function(e) {
|
||||||
|
var input, _i, _len, _ref, _results;
|
||||||
|
if (e != null) e.preventDefault();
|
||||||
|
if (conf['Auto Hide QR']) qr.hide();
|
||||||
|
if (/sage/i.test(qr.inputs[1].value)) {
|
||||||
|
qr.sage = true;
|
||||||
|
qr.inputs[1].value = null;
|
||||||
|
}
|
||||||
|
_ref = qr.inputs;
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
input = _ref[_i];
|
||||||
|
_results.push($.on(input, 'change', function() {
|
||||||
|
return $.set("qr_" + this.name, this.value);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -887,7 +887,6 @@ qr =
|
|||||||
if this.checked
|
if this.checked
|
||||||
$.addClass qr.el, 'autohide'
|
$.addClass qr.el, 'autohide'
|
||||||
else
|
else
|
||||||
|
|
||||||
$.removeClass qr.el, 'autohide'
|
$.removeClass qr.el, 'autohide'
|
||||||
|
|
||||||
close: ->
|
close: ->
|
||||||
@ -916,25 +915,24 @@ qr =
|
|||||||
dialog: ->
|
dialog: ->
|
||||||
qr.el = ui.dialog 'qr', 'top:0;right:0;', '
|
qr.el = ui.dialog 'qr', 'top:0;right:0;', '
|
||||||
<style>
|
<style>
|
||||||
.autohide:not(:hover) > #form {
|
.autohide:not(:hover) > form {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
#qr > .move {
|
#qr > .move {
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
.fields > input {
|
#qr > form {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.field {
|
||||||
border: 1px solid #AAA;
|
border: 1px solid #AAA;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 2px 4px 3px;
|
padding: 2px 4px 3px;
|
||||||
width: 33%;
|
width: 33%;
|
||||||
}
|
}
|
||||||
#form > textarea {
|
textarea.field {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
border-color: #AAA;
|
|
||||||
border-width: 1px 0;
|
|
||||||
margin: 0;
|
|
||||||
padding: 2px 4px 3px;
|
|
||||||
min-height: 120px;
|
min-height: 120px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
@ -946,27 +944,30 @@ qr =
|
|||||||
height: 57px;
|
height: 57px;
|
||||||
width: 300px;
|
width: 300px;
|
||||||
}
|
}
|
||||||
|
.field[name=captcha] {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<div class=move>
|
<div class=move>
|
||||||
<input type=checkbox name=autohide id=autohide title=Auto-hide>
|
<input type=checkbox name=autohide id=autohide title=Auto-hide>
|
||||||
<a class=close>⨯</a>
|
<a class=close>⨯</a>
|
||||||
</div>
|
</div>
|
||||||
<div id=form>
|
<form>
|
||||||
<div class=fields><input name=name title=Name placeholder=Name size=1><input name=email title=E-mail placeholder=E-mail size=1><input name=subject title=Subject placeholder=Subject size=1></div>
|
<div><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>
|
||||||
<textarea title=Comment placeholder=Comment></textarea>
|
<textarea title=Comment placeholder=Comment class=field></textarea>
|
||||||
<div class=captcha><img></div>
|
<div class=captcha><img></div>
|
||||||
<input name=captcha title=Verification placeholder=Verification>
|
<input name=captcha title=Verification placeholder=Verification class=field size=1>
|
||||||
</div>'
|
</form>'
|
||||||
$.on $('#autohide', qr.el), 'click', qr.hide
|
$.on $('#autohide', qr.el), 'click', qr.hide
|
||||||
$.on $('.close', qr.el), 'click', qr.close
|
$.on $('.close', qr.el), 'click', qr.close
|
||||||
|
$.on $('form', qr.el), 'submit', qr.submit
|
||||||
|
|
||||||
# save & load inputs' value with localStorage
|
# save & load inputs' value with localStorage
|
||||||
inputs = [$('[name=name]', qr.el), $('[name=email]', qr.el)]
|
qr.inputs = [$('[name=name]', qr.el), $('[name=email]', qr.el)]
|
||||||
inputs.push $('[name=subject]', qr.el) if conf['Remember Subject']
|
qr.inputs.push $('[name=subject]', qr.el) if conf['Remember Subject']
|
||||||
for input in inputs
|
for input in qr.inputs
|
||||||
input.value = $.get "qr_#{input.name}", null
|
input.value = $.get "qr_#{input.name}", null
|
||||||
$.on input, 'change', -> $.set "qr_#{@name}", @value
|
|
||||||
# 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_(.+)$/
|
||||||
@ -974,6 +975,17 @@ qr =
|
|||||||
|
|
||||||
$.add d.body, qr.el
|
$.add d.body, qr.el
|
||||||
|
|
||||||
|
submit: (e) ->
|
||||||
|
e?.preventDefault()
|
||||||
|
qr.hide() if conf['Auto Hide QR']
|
||||||
|
|
||||||
|
if /sage/i.test qr.inputs[1].value
|
||||||
|
qr.sage = true
|
||||||
|
qr.inputs[1].value = null
|
||||||
|
|
||||||
|
for input in qr.inputs
|
||||||
|
$.on input, 'change', -> $.set "qr_#{@name}", @value
|
||||||
|
|
||||||
options =
|
options =
|
||||||
init: ->
|
init: ->
|
||||||
home = $ '#navtopr a'
|
home = $ '#navtopr a'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user