From 50b7a3fc4d56b4ab339c90dd47825f6d22d8e5d7 Mon Sep 17 00:00:00 2001 From: Stefan Lage Date: Thu, 23 May 2013 21:01:16 -0400 Subject: [PATCH] nitdoc: Fix bug: Add a function to close comments Adding function which close all comments which are being edit when we close the session signed-off by: Stefan Lage --- share/nitdoc/scripts/js-facilities.js | 34 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/share/nitdoc/scripts/js-facilities.js b/share/nitdoc/scripts/js-facilities.js index a946d9b..2e07202 100644 --- a/share/nitdoc/scripts/js-facilities.js +++ b/share/nitdoc/scripts/js-facilities.js @@ -440,6 +440,7 @@ $(document).ready(function() { { // Delete cookie and reset settings del_cookie("logginNitdoc"); + closeAllCommentInEdtiting(); } displayLogginModal(); }); @@ -481,16 +482,8 @@ $(document).ready(function() { // Disable the edit mode $('a[id=cancelBtn]').click(function(){ - if(editComment > 0){ editComment -= 1; } - // Hide itself - $(this).hide(); - // Hide commitBtn - $(this).next().hide(); - // Hide Textarea - $(this).prev().hide(); - // Show comment - $(this).prev().prev().show(); - }); + closeEditing($(this)); + }); // Display commit form $('a[id=commitBtn]').click(function(){ @@ -622,6 +615,7 @@ $(document).ready(function() { } }); $.when(updateCookie(userName, password, repoName, branchName)).done(function(){ + closeAllCommentInEdtiting(); reloadComment(); }); }); @@ -1285,4 +1279,22 @@ function getListBranches() // Delete all option in the list function cleanListBranches(){ $('#dropBranches').children("option").remove(); -} +} + +function closeAllCommentInEdtiting(){ + $('a[id=cancelBtn]').each(function(){ + closeEditing($(this)); + }); +} + +function closeEditing(tag){ + if(editComment > 0){ editComment -= 1; } + // Hide itself + tag.hide(); + // Hide commitBtn + tag.next().hide(); + // Hide Textarea + tag.prev().hide(); + // Show comment + tag.prev().prev().show(); +} -- 1.7.9.5