Scroll the list to center the focused reply.

This commit is contained in:
Nicolas Stepien 2012-01-26 19:12:15 +01:00
parent 018753689e
commit 0e7cb3a42a
2 changed files with 8 additions and 1 deletions

View File

@ -1454,10 +1454,13 @@
};
_Class.prototype.select = function() {
var data, _i, _len, _ref, _ref2;
var data, rectEl, rectList, _i, _len, _ref, _ref2;
if ((_ref = qr.selected) != null) _ref.el.id = null;
qr.selected = this;
this.el.id = 'selected';
rectEl = this.el.getBoundingClientRect();
rectList = this.el.parentNode.getBoundingClientRect();
this.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2;
_ref2 = ['name', 'email', 'sub', 'com'];
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
data = _ref2[_i];

View File

@ -1070,6 +1070,10 @@ qr =
qr.selected?.el.id = null
qr.selected = @
@el.id = 'selected'
# Scroll the list to center the focused reply.
rectEl = @el.getBoundingClientRect()
rectList = @el.parentNode.getBoundingClientRect()
@el.parentNode.scrollLeft += rectEl.left + rectEl.width/2 - rectList.left - rectList.width/2
for data in ['name', 'email', 'sub', 'com']
$("[name=#{data}]", qr.el).value = @[data]
$('#spoiler', qr.el).checked = @spoiler