changeset 5157:765fe407eda4

comments: refactor the DOM handling for previous/next comment links Make it more clear which div the links are put into and set the whole content of that div instead of appending. This prepares for repeatedly re-linking the comments when new comments or comment forms are inserted in the text.
author Mads Kiilerich <madski@unity3d.com>
date Sun, 17 May 2015 21:54:55 +0200
parents b3299a079fa6
children 2c1ae0b188ae
files kallithea/public/css/style.css kallithea/public/js/base.js kallithea/templates/changeset/changeset_file_comment.html
diffstat 3 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/public/css/style.css	Wed May 27 23:15:36 2015 +0200
+++ b/kallithea/public/css/style.css	Sun May 17 21:54:55 2015 +0200
@@ -5065,8 +5065,8 @@
     margin: 5px;
 }
 
-div.prev-next-comment div.prev-comment,
-div.prev-next-comment div.next-comment {
+div.comment-prev-next-links div.prev-comment,
+div.comment-prev-next-links div.next-comment {
     display: inline-block;
     min-width: 150px;
     margin: 3px 6px;
--- a/kallithea/public/js/base.js	Wed May 27 23:15:36 2015 +0200
+++ b/kallithea/public/js/base.js	Sun May 17 21:54:55 2015 +0200
@@ -866,10 +866,9 @@
                 var next_anchor = $($comments.get(i+1)).attr('id');
                 next = '<a href="#{0}">Next comment</a>'.format(next_anchor);
             }
-            var $div = $(('<div class="prev-next-comment">'+
-                          '<div class="prev-comment">{0}</div>'+
-                          '<div class="next-comment">{1}</div>').format(prev, next));
-            $div.prependTo(this);
+            $(this).find('.comment-prev-next-links').html(
+                '<div class="prev-comment">{0}</div>'.format(prev) +
+                '<div class="next-comment">{0}</div>'.format(next));
         });
 }
 
--- a/kallithea/templates/changeset/changeset_file_comment.html	Wed May 27 23:15:36 2015 +0200
+++ b/kallithea/templates/changeset/changeset_file_comment.html	Sun May 17 21:54:55 2015 +0200
@@ -5,6 +5,7 @@
 ##
 <%def name="comment_block(co)">
   <div class="comment" id="comment-${co.comment_id}" line="${co.line_no}">
+    <div class="comment-prev-next-links"></div>
     <div class="comment-wrapp">
       <div class="meta">
           <div style="float:left">