This commit is contained in:
Nicolas Stepien 2013-02-23 16:12:40 +01:00
parent a796597108
commit e8c54cc6e0
2 changed files with 32 additions and 10 deletions

View File

@ -6029,24 +6029,34 @@
}; };
_Class.prototype.select = function() { _Class.prototype.select = function() {
var data, rectEl, rectList, _i, _len, _ref, _ref1; var name, rectEl, rectList, _i, _len, _ref;
if ((_ref = QR.selected) != null) { if (QR.selected) {
_ref.el.id = null; QR.selected.el.id = null;
QR.selected.forceSave();
} }
QR.selected = this; QR.selected = this;
this.el.id = 'selected'; this.el.id = 'selected';
rectEl = this.el.getBoundingClientRect(); rectEl = this.el.getBoundingClientRect();
rectList = this.el.parentNode.getBoundingClientRect(); rectList = this.el.parentNode.getBoundingClientRect();
this.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2; this.el.parentNode.scrollLeft += rectEl.left + rectEl.width / 2 - rectList.left - rectList.width / 2;
_ref1 = ['name', 'email', 'sub', 'com']; _ref = ['name', 'email', 'sub', 'com'];
for (_i = 0, _len = _ref1.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
data = _ref1[_i]; name = _ref[_i];
$("[name=" + data + "]", QR.el).value = this[data]; $("[name=" + name + "]", QR.el).value = this[name];
} }
QR.characterCount.call($('textarea', QR.el)); QR.characterCount.call($('textarea', QR.el));
return $('#spoiler', QR.el).checked = this.spoiler; return $('#spoiler', QR.el).checked = this.spoiler;
}; };
_Class.prototype.forceSave = function() {
var name, _i, _len, _ref;
_ref = ['name', 'email', 'sub', 'com'];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i];
this[name] = $("[name=" + name + "]", QR.el).value;
}
};
_Class.prototype.dragStart = function() { _Class.prototype.dragStart = function() {
return $.addClass(this, 'drag'); return $.addClass(this, 'drag');
}; };
@ -6325,6 +6335,9 @@
return; return;
} }
reply = QR.replies[0]; reply = QR.replies[0];
if (reply === QR.selected) {
reply.forceSave();
}
if (g.BOARD.ID === 'f' && g.VIEW === 'index') { if (g.BOARD.ID === 'f' && g.VIEW === 'index') {
filetag = QR.threadSelector.value; filetag = QR.threadSelector.value;
threadID = 'new'; threadID = 'new';

View File

@ -407,7 +407,9 @@ QR =
return unless window.URL return unless window.URL
URL.revokeObjectURL @url URL.revokeObjectURL @url
select: -> select: ->
QR.selected?.el.id = null if QR.selected
QR.selected.el.id = null
QR.selected.forceSave()
QR.selected = @ QR.selected = @
@el.id = 'selected' @el.id = 'selected'
# Scroll the list to center the focused reply. # Scroll the list to center the focused reply.
@ -415,10 +417,16 @@ QR =
rectList = @el.parentNode.getBoundingClientRect() rectList = @el.parentNode.getBoundingClientRect()
@el.parentNode.scrollLeft += rectEl.left + rectEl.width/2 - rectList.left - rectList.width/2 @el.parentNode.scrollLeft += rectEl.left + rectEl.width/2 - rectList.left - rectList.width/2
# Load this reply's values. # Load this reply's values.
for data in ['name', 'email', 'sub', 'com'] for name in ['name', 'email', 'sub', 'com']
$("[name=#{data}]", QR.el).value = @[data] $("[name=#{name}]", QR.el).value = @[name]
QR.characterCount.call $ 'textarea', QR.el QR.characterCount.call $ 'textarea', QR.el
$('#spoiler', QR.el).checked = @spoiler $('#spoiler', QR.el).checked = @spoiler
forceSave: ->
# Do this in case people use extensions
# that do not trigger the `input` event.
for name in ['name', 'email', 'sub', 'com']
@[name] = $("[name=#{name}]", QR.el).value
return
dragStart: -> dragStart: ->
$.addClass @, 'drag' $.addClass @, 'drag'
dragEnter: -> dragEnter: ->
@ -632,6 +640,7 @@ QR =
return return
reply = QR.replies[0] reply = QR.replies[0]
reply.forceSave() if reply is QR.selected
if g.BOARD.ID is 'f' and g.VIEW is 'index' if g.BOARD.ID is 'f' and g.VIEW is 'index'
filetag = QR.threadSelector.value filetag = QR.threadSelector.value
threadID = 'new' threadID = 'new'