ni_nitdoc: github edit mode activation is now triggered by a button
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 28 Aug 2013 01:19:28 +0000 (21:19 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 28 Aug 2013 01:19:28 +0000 (21:19 -0400)
We use a button instead of clicking on the comment itself
to allow click on urls contained in markdown comments

Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/ni_nitdoc/scripts/github.js
share/ni_nitdoc/styles/github.css

index 6ab4f39..89b0ce5 100644 (file)
@@ -449,25 +449,28 @@ function GitHubUI() {
 \r
                // Add hidden <pre> to empty commits\r
                $("span.noComment").each(function() {\r
+                       $(this).addClass("editComment");\r
                        var baseComment = $(this).parent().prev();\r
                        var location = ui.parseLocation(baseComment.attr("data-comment-location"));\r
                        location.lend = location.lstart;\r
                        var locString = "../" + location.path + ":" + location.lstart + "," + location.tabpos + "--" + location.lend + ",0";\r
                        baseComment.attr("data-comment-location", locString);\r
-                       $(this).html("<a class='noComment'>add comment</a> for ");\r
-               });\r
-               $('span.noComment a').each(function() {\r
-                       $(this).css("cursor", "pointer")\r
-                       $(this).click(function() {\r
-                               $(this).parent().hide();\r
-                               ui.openCommentBox($(this).parent().parent().prev());\r
-                       });\r
+                       $(this).html("<a class='editComment noComment'>add comment</a> for ");\r
                });\r
                $('.description div.comment').each(function() {\r
+                       var p = $(this).next();\r
+                       p.prepend("<span class='editComment'><a class='editComment'>edit comment</a> for </span>")\r
+               });\r
+               $('a.editComment').each(function() {\r
                        $(this).css("cursor", "pointer")\r
                        $(this).click(function() {\r
-                               ui.openCommentBox($(this).prev());\r
-                               $(this).hide();\r
+                               $(this).parent().hide();\r
+                               if(!$(this).hasClass("noComment")) {\r
+                                       $(this).parent().parent().prev().hide();\r
+                                       ui.openCommentBox($(this).parent().parent().prev().prev());\r
+                               } else {\r
+                                       ui.openCommentBox($(this).parent().parent().prev());\r
+                               }\r
                        });\r
                });\r
 \r
@@ -501,7 +504,6 @@ function GitHubUI() {
        }\r
 \r
        this.openCommentBox = function(baseArea) {\r
-               console.log(baseArea);\r
                this.openedComments += 1;\r
                // get text and format it\r
                var formated = "";\r
@@ -563,11 +565,12 @@ function GitHubUI() {
 \r
        this.closeCommentBox = function(commentBox) {\r
                this.openedComments -= 1;\r
-               if(!!commentBox.parent().find(".baseComment").text()) {\r
-                       commentBox.parent().find("div.comment").show();\r
-               } else if(commentBox.hasClass("newComment")) {\r
-                       commentBox.next().find("span.noComment").show();\r
+               var target = commentBox.next();\r
+               if(!commentBox.hasClass("newComment")) {\r
+                       target.show();\r
+                       target = target.next();\r
                }\r
+               target.find("span.editComment").show();\r
                commentBox.remove();\r
        }\r
 \r
index c66eb18..fc5a225 100644 (file)
@@ -252,13 +252,6 @@ button.github img {
        border: 1px solid #9f312c;\r
 }\r
 \r
-span.noComment a {\r
-       color: #0D8921;\r
-}\r
-span.noComment a:hover {\r
-       color: #333;\r
-}\r
-\r
 div.comment.locked {\r
        color: gray;\r
 }\r