Archived
1
0
This commit is contained in:
Jeff Becker 2017-01-16 14:39:08 -05:00
parent 8d6bd12346
commit cfa83a7db8
2 changed files with 24 additions and 5 deletions

View File

@ -88,6 +88,7 @@ function ReplyBox() {
table.appendChild(tbody); table.appendChild(tbody);
this.elem.appendChild(table); this.elem.appendChild(table);
document.body.appendChild(this.elem); document.body.appendChild(this.elem);
this._open = false;
} }
ReplyBox.prototype.result = function(msg, color) { ReplyBox.prototype.result = function(msg, color) {
@ -102,6 +103,10 @@ ReplyBox.prototype.result = function(msg, color) {
}, 1000); }, 1000);
} }
ReplyBox.prototype.visible = function() {
return this._open != false;
}
ReplyBox.prototype.makePost = function(info) { ReplyBox.prototype.makePost = function(info) {
var self = this; var self = this;
@ -130,8 +135,10 @@ ReplyBox.prototype.reload = function() {
} }
ReplyBox.prototype.show = function(info) { ReplyBox.prototype.show = function(info) {
console.log("reply box show for "+info.reference);
var self = this; var self = this;
self.reload();
self._open = true;
console.log("reply box show for "+info.reference);
$(self.elem).css("display", "inline-block"); $(self.elem).css("display", "inline-block");
$(self.elem).css("position", "fixed"); $(self.elem).css("position", "fixed");
var off = $(info.elem).offset(); var off = $(info.elem).offset();
@ -149,7 +156,9 @@ ReplyBox.prototype.show = function(info) {
if(xhr.statusCode == 201) { if(xhr.statusCode == 201) {
self.result("posted as "+data.message_id, "green"); self.result("posted as "+data.message_id, "green");
self.clear(); self.clear();
self.submit.onclick = function(ev) {}; setTimeout(1000, function() {
self.hide();
});
} else { } else {
self.result("error: " + data.error, "red"); self.result("error: " + data.error, "red");
} }
@ -163,13 +172,17 @@ ReplyBox.prototype.show = function(info) {
ReplyBox.prototype.hide = function() { ReplyBox.prototype.hide = function() {
var self = this; var self = this;
$(self.elem).css("display", "none"); if(!self.visible()) return;
self._open = false;
$(self.elem).fadeout(400, function() {
self.submit.onclick = function(ev) {}; self.submit.onclick = function(ev) {};
});
} }
onready(function(){ onready(function(){
var replyBox = new ReplyBox(); var replyBox = new ReplyBox();
replyBox.hide(); replyBox.hide();
document.reply = replyBox;
$(".post").each(function(_, elem) { $(".post").each(function(_, elem) {
var replyInfo = { var replyInfo = {
show: false, show: false,

View File

@ -11,7 +11,13 @@ function nntpchan_reply(parent, shorthash) {
// show it // show it
replyto.show(); replyto.show();
} }
var elem = document.getElementById("postform_message");
var elem;
if(document.reply && document.reply.visible()) {
elem = document.reply.message;
} else {
elem = document.getElementById("postform_message");
}
if ( elem ) if ( elem )
{ {
elem.value += ">>" + shorthash.substr(0,10) + "\n"; elem.value += ">>" + shorthash.substr(0,10) + "\n";