nitdoc: Adds action to commit button when we are in "edit mode".
[nit.git] / share / nitdoc / scripts / js-facilities.js
index b3e5d9d..75f618b 100644 (file)
@@ -399,7 +399,7 @@ $(document).ready(function() {
                displayLogginModal();\r
        });\r
 \r
-       // Open edit file\r
+       // Activate edit mode\r
        $('pre[class=text_label]').click(function(){\r
                // the customer is loggued ?\r
                if(!sessionStarted || userName == ""){\r
@@ -434,6 +434,7 @@ $(document).ready(function() {
                }\r
        });\r
 \r
+       // Disable the edit mode\r
        $('a[id=cancelBtn]').click(function(){\r
                if(editComment > 0){ editComment -= 1; }\r
                // Hide itself\r
@@ -446,6 +447,42 @@ $(document).ready(function() {
                $(this).prev().prev().show();\r
         });\r
 \r
+       // Display commit form\r
+       $('a[id=commitBtn]').click(function(){\r
+               updateComment = $(this).prev().prev().val();\r
+               commentType = $(this).prev().prev().prev().attr('type');\r
+\r
+               if(updateComment == ""){ displayMessage('The comment field is empty!', 40, 45); }\r
+               else{\r
+                       if(!sessionStarted){\r
+                               displayMessage("You need to be loggued before commit something", 45, 40);\r
+                               displayLogginModal();\r
+                               return;\r
+                       }\r
+                       $('#commitMessage').val('New commit');\r
+                       pathFile = $(this).prev().prev().prev().attr('tag');\r
+                       $('#modal').show().prepend('<a class="close"><img src="resources/icons/close.png" class="btn_close" title="Close" alt="Close" /></a>');\r
+                       $('body').append('<div id="fade"></div>');\r
+                       $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();\r
+               }\r
+        });\r
+\r
+       // Close commit form\r
+       $('.btn_close').click(function(){\r
+               $(this).hide();                 \r
+               $(this).next().hide();                  \r
+               if(editComment > 0){ editComment -= 1; }\r
+        });\r
+\r
+       //Close Popups and Fade Layer\r
+       $('body').on('click', 'a.close, #fade', function() {\r
+               if(editComment > 0){ editComment -= 1; }\r
+               $('#fade , #modal').fadeOut(function() {\r
+                       $('#fade, a.close').remove();  \r
+               });             \r
+               $('#modalQuestion').hide();\r
+       });\r
+\r
 });\r
 \r
 /* Parse current URL and return anchor name */\r