nitdoc: Fix bug: Add a function to close comments
authorStefan Lage <lagestfan@gmail.com>
Fri, 24 May 2013 01:01:16 +0000 (21:01 -0400)
committerStefan Lage <lagestfan@gmail.com>
Fri, 24 May 2013 02:26:50 +0000 (22:26 -0400)
Adding function which close all comments which are being edit when we close the session

signed-off by: Stefan Lage <lagestfan@gmail.com>

share/nitdoc/scripts/js-facilities.js

index a946d9b..2e07202 100644 (file)
@@ -440,6 +440,7 @@ $(document).ready(function() {
                {\r
                        // Delete cookie and reset settings\r
                        del_cookie("logginNitdoc");\r
+                       closeAllCommentInEdtiting();\r
                }       \r
                displayLogginModal();\r
        });\r
@@ -481,16 +482,8 @@ $(document).ready(function() {
 \r
        // Disable the edit mode\r
        $('a[id=cancelBtn]').click(function(){\r
-               if(editComment > 0){ editComment -= 1; }\r
-               // Hide itself\r
-               $(this).hide();\r
-               // Hide commitBtn\r
-               $(this).next().hide();\r
-               // Hide Textarea\r
-               $(this).prev().hide();\r
-               // Show comment\r
-               $(this).prev().prev().show();\r
-        });\r
+               closeEditing($(this));\r
+       });\r
 \r
        // Display commit form\r
        $('a[id=commitBtn]').click(function(){\r
@@ -622,6 +615,7 @@ $(document).ready(function() {
                        }\r
                });\r
                $.when(updateCookie(userName, password, repoName, branchName)).done(function(){\r
+                       closeAllCommentInEdtiting();\r
                        reloadComment();\r
                });\r
        });\r
@@ -1285,4 +1279,22 @@ function getListBranches()
 // Delete all option in the list\r
 function cleanListBranches(){\r
        $('#dropBranches').children("option").remove();\r
-}
+}\r
+\r
+function closeAllCommentInEdtiting(){\r
+       $('a[id=cancelBtn]').each(function(){\r
+               closeEditing($(this));\r
+       });\r
+}\r
+\r
+function closeEditing(tag){\r
+       if(editComment > 0){ editComment -= 1; }\r
+       // Hide itself\r
+       tag.hide();\r
+       // Hide commitBtn\r
+       tag.next().hide();\r
+       // Hide Textarea\r
+       tag.prev().hide();\r
+       // Show comment\r
+       tag.prev().prev().show();\r
+}\r