only create a reply box when needed

Previously this led to unnecessary object creation which impacted the
rendering time (on my machine 200 comments -> 1200ms) just to create
the postbox per comment (just the object initialization)).
This commit is contained in:
Martin Zimmermann 2013-11-01 15:25:44 +01:00
parent cac4694f43
commit 2b7d263735
3 changed files with 5 additions and 5 deletions

View File

@ -120,10 +120,10 @@ define(["app/text/html", "app/dom", "app/utils", "app/api", "app/markup", "app/i
header = $("#isso-" + comment.id + " > .text-wrapper > .isso-comment-header"), header = $("#isso-" + comment.id + " > .text-wrapper > .isso-comment-header"),
text = $("#isso-" + comment.id + " > .text-wrapper > .text"); text = $("#isso-" + comment.id + " > .text-wrapper > .text");
var form = new Postbox(comment.id); var form = null;
$("a.reply", footer).toggle("click", $("a.reply", footer).toggle("click",
function(toggler) { function(toggler) {
footer.insertAfter(form); form = footer.insertAfter(new Postbox(comment.id));
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"];