Sync name/email/subject if there's only one reply.

This commit is contained in:
Nicolas Stepien 2012-01-25 04:34:20 +01:00
parent 5dbc9a2480
commit 6810c84e6a
2 changed files with 18 additions and 3 deletions

View File

@ -1555,6 +1555,19 @@
return qr.selected[this.name] = this.value;
});
}
$.on(window, 'storage', function(e) {
var key, val, _ref3, _results;
if (e.key === ("" + NAMESPACE + "qr.persona") && qr.replies.length === 1) {
_ref3 = JSON.parse(e.newValue);
_results = [];
for (key in _ref3) {
val = _ref3[key];
qr.selected[key] = val;
_results.push($("[name=" + key + "]", qr.el).value = val);
}
return _results;
}
});
qr.status.input = $('[type=submit]', qr.el);
qr.status();
qr.captcha.init();

View File

@ -1143,9 +1143,11 @@ qr =
for input in ['name', 'email', 'sub', 'com']
$.on $("[name=#{input}]", qr.el), 'change', -> qr.selected[@name] = @value
# sync between tabs
# $.on window, 'storage', (e) ->
# if match = e.key.match /qr_(.+)$/
# qr.inputs[match[1]].value = JSON.parse e.newValue
$.on window, 'storage', (e) ->
if e.key is "#{NAMESPACE}qr.persona" and qr.replies.length is 1
for key, val of JSON.parse e.newValue
qr.selected[key] = val
$("[name=#{key}]", qr.el).value = val
qr.status.input = $ '[type=submit]', qr.el
qr.status()