ni_nitdoc: github login box is now generated by JS
[nit.git] / share / nitdoc / scripts / github.js
index 35b51de..54ed212 100644 (file)
@@ -56,13 +56,13 @@ window.onbeforeunload = function() {
 };\r
 \r
 $(document).ready(function() {\r
-\r
+       createLoginBox();\r
        // Hide edit tags\r
        $('textarea').hide();\r
        $('a[id=commitBtn]').hide();\r
        $('a[id=cancelBtn]').hide();\r
        // Display Login modal\r
-       $("#logGitHub").click(function(){ displayLogginModal(); }); \r
+       $("#logGitHub").click(function(){ toggleLoginBox(); });\r
        // Update display\r
        updateDisplaying();\r
        // If cookie existing the session is opened\r
@@ -102,7 +102,7 @@ $(document).ready(function() {
                        del_cookie("logginNitdoc");\r
                        closeAllCommentInEdtiting();\r
                }       \r
-               displayLogginModal();\r
+               toggleLoginBox();\r
        });\r
 \r
        // Activate edit mode\r
@@ -159,7 +159,7 @@ $(document).ready(function() {
                else{\r
                        if(!sessionStarted){\r
                                displayMessage("You need to be loggued before commit something", 45, 40);\r
-                               displayLogginModal();\r
+                               toggleLoginBox();\r
                                return;\r
                        }\r
                        \r
@@ -260,7 +260,7 @@ $(document).ready(function() {
                                        $('#loginGit').val("");\r
                                        $('#passwordGit').val("");\r
                                        loginProcess = false;          \r
-                                       displayLogginModal();\r
+                                       toggleLoginBox();\r
                        }\r
                        else{\r
                                        if ($.trim(updateComment) == ''){ this.value = (this.defaultValue ? this.defaultValue : ''); }\r
@@ -353,15 +353,6 @@ function startCommitProcess()
        }\r
 }\r
 \r
-function displayLogginModal(){\r
-       if ($('.popover').is(':hidden')) { \r
-               if(sessionStarted){ getListBranches(); }\r
-               $('.popover').show(); \r
-       }\r
-       else { $('.popover').hide(); }  \r
-       updateDisplaying();\r
-}\r
-\r
 function updateDisplaying(){\r
        if (checkCookie())\r
        {\r
@@ -993,3 +984,58 @@ function showComment(element){
        textarea.height(textarea.prop("scrollHeight"));\r
        resizeTextarea(textarea);\r
 }\r
+\r
+/* GitHub login box management */\r
+\r
+function createLoginBox() {\r
+       $("nav.main ul").append(\r
+               "<li id='liGitHub'>" +\r
+               "  <a class='btn' id='logGitHub'>" +\r
+               "    <img id='imgGitHub' src='resources/icons/github-icon.png' alt='GitHub'/>" +\r
+               "  </a>" +\r
+               "  <div class='popover bottom' style='display: none;'>" +\r
+               "    <div class='arrow'>&nbsp;</div>" +\r
+               "      <div class='githubTitle'>" +\r
+               "        <h3>Github Sign In</h3>" +\r
+               "      </div>" +\r
+               "      <div>" +\r
+               "        <label id='lbloginGit'>Username</label>" +\r
+               "        <input id='loginGit' name='login' type='text'/>" +\r
+               "        <label id='logginMessage'>Hello " +\r
+               "          <a id='githubAccount'><strong id='nickName'></strong></a>" +\r
+               "        </label>" +\r
+               "      </div>" +\r
+               "      <div>" +\r
+               "        <label id='lbpasswordGit'>Password</label>" +\r
+               "        <input id='passwordGit' name='password' type='password'/>" +\r
+               "        <div id='listBranches'>" +\r
+               "          <label id='lbBranches'>Branch</label>" +\r
+               "          <select class='dropdown' id='dropBranches' name='dropBranches' tabindex='1'></select>" +\r
+               "        </div>" +\r
+               "      </div>" +\r
+               "      <div>" +\r
+               "        <label id='lbrepositoryGit'>Repository</label>" +\r
+               "        <input id='repositoryGit' name='repository' type='text'/>" +\r
+               "      </div>" +\r
+               "      <div>" +\r
+               "        <label id='lbbranchGit'>Branch</label>" +\r
+               "        <input id='branchGit' name='branch' type='text'/>" +\r
+               "      </div>" +\r
+               "      <div>" +\r
+               "        <a id='signIn'>Sign In</a>" +\r
+               "      </div>" +\r
+               "    </div>" +\r
+               "  </div>" +\r
+               "</li>"\r
+       );\r
+}\r
+\r
+function toggleLoginBox(){\r
+       if ($('.popover').is(':hidden')) {\r
+               if(sessionStarted){ getListBranches(); }\r
+               $('.popover').show();\r
+       } else {\r
+               $('.popover').hide();\r
+       }\r
+       updateDisplaying();\r
+}\r