reply to comment now nests to max. level of 1, part of #79

This commit is contained in:
Martin Zimmermann 2014-04-20 16:30:18 +02:00
parent 5d2daa1244
commit 9ee0a1a2eb
3 changed files with 3 additions and 34 deletions

View File

@ -75,7 +75,6 @@ define(["app/text/html", "app/dom", "app/utils", "app/config", "app/api", "app/m
if (parent !== null) { if (parent !== null) {
el.onsuccess(); el.onsuccess();
el.remove();
} }
}); });
}); });
@ -85,16 +84,8 @@ define(["app/text/html", "app/dom", "app/utils", "app/config", "app/api", "app/m
return el; return el;
}; };
// lookup table for responses (to link to the parent)
var map = {id: {}, name: {}};
var insert = function(comment, scrollIntoView) { var insert = function(comment, scrollIntoView) {
map.name[comment.id] = comment.author;
if (comment.parent) {
comment["replyto"] = map.name[comment.parent];
}
var el = $.htmlify(Mark.up(templates["comment"], comment)); var el = $.htmlify(Mark.up(templates["comment"], comment));
// update datetime every 60 seconds // update datetime every 60 seconds
@ -113,12 +104,7 @@ define(["app/text/html", "app/dom", "app/utils", "app/config", "app/api", "app/m
if (comment.parent === null) { if (comment.parent === null) {
entrypoint = $("#isso-root"); entrypoint = $("#isso-root");
} else { } else {
var key = comment.parent; entrypoint = $("#isso-" + comment.parent + " > .text-wrapper > .isso-follow-up");
while (key in map.id) {
key = map.id[key];
}
map.id[comment.id] = comment.parent;
entrypoint = $("#isso-" + key + " > .text-wrapper > .isso-follow-up");
} }
entrypoint.append(el); entrypoint.append(el);
@ -134,26 +120,17 @@ define(["app/text/html", "app/dom", "app/utils", "app/config", "app/api", "app/m
var form = null; // XXX: probably a good place for a closure var form = null; // XXX: probably a good place for a closure
$("a.reply", footer).toggle("click", $("a.reply", footer).toggle("click",
function(toggler) { function(toggler) {
form = footer.insertAfter(new Postbox(comment.id)); form = footer.insertAfter(new Postbox(comment.parent === null ? comment.id : comment.parent));
form.onsuccess = function() { toggler.next(); }; form.onsuccess = function() { toggler.next(); };
$(".textarea", form).focus(); $(".textarea", form).focus();
$("a.reply", footer).textContent = msgs["comment-close"]; $("a.reply", footer).textContent = msgs["comment-close"];
}, },
function() { function() {
form.remove(); form.remove()
$("a.reply", footer).textContent = msgs["comment-reply"]; $("a.reply", footer).textContent = msgs["comment-reply"];
} }
); );
if (comment.parent !== null) {
$("a.parent", header).on("mouseover", function() {
$("#isso-" + comment.parent).classList.add("parent-highlight");
});
$("a.parent", header).on("mouseout", function() {
$("#isso-" + comment.parent).classList.remove("parent-highlight");
});
}
// update vote counter, but hide if votes sum to 0 // update vote counter, but hide if votes sum to 0
var votes = function(value) { var votes = function(value) {
var span = $("span.votes", footer); var span = $("span.votes", footer);

View File

@ -14,13 +14,6 @@
</span> </span>
{{ /if }} {{ /if }}
{{ if parent }}
<span class="spacer"></span>
<a class="parent" href="#isso-{{ parent }}">
<i>{{ svg-forward }}</i>{{ replyto | blank: `i18n-comment-anonymous` }}
</a>
{{ /if }}
<span class="spacer"></span> <span class="spacer"></span>
<a class="permalink" href="#isso-{{ id }}"> <a class="permalink" href="#isso-{{ id }}">

View File

@ -9,7 +9,6 @@ import sqlite3
import tempfile import tempfile
from isso.db import SQLite3 from isso.db import SQLite3
from isso.db.comments import Comments
from isso.core import Config from isso.core import Config
from isso.compat import iteritems from isso.compat import iteritems