*/\r
define([\r
"jquery",\r
+ "jQueryUI",\r
"plugins/github/user",\r
"plugins/github/github_api",\r
"plugins/github/utils",\r
"plugins/github/commentbox",\r
- "base64",\r
-], function($, User, GithubAPI, Utils, CommentBox, Base64) {\r
+ "plugins/github/modalbox",\r
+ "base64"\r
+], function($, UI, User, GithubAPI, Utils, CommentBox, ModalBox, Base64) {\r
var UI = {\r
openedComments: 0, // currently edited comments count\r
user: false, // logged user\r
\r
// clear storage\r
disactivate: function() {\r
- if(UI.getOpenedComments() > 0){\r
+ if(this.openedComments > 0){\r
if(!confirm('There is uncommited modified comments. Are you sure you want to leave this page?')) {\r
return false;\r
}\r
infos.location = Utils.parseLocation(baseTextarea.attr("data-comment-location"));\r
infos.namespace = baseTextarea.attr("data-comment-namespace");\r
infos.oldComment = baseTextarea.val();\r
- var box = new CommentBox(infos);\r
- box.open(baseTextarea);\r
+\r
+ if(infos.requestID) {\r
+ // get comment from last pull request\r
+ var requests = JSON.parse(localStorage.requests);\r
+ infos.newComment = Base64.decode(requests[infos.requestID].comment);\r
+ } else {\r
+ infos.newComment = false;\r
+ }\r
+\r
+ baseTextarea.commentbox();\r
+ baseTextarea.bind("commentbox_preview", function(event, data) {\r
+ var converter = new Markdown.Converter()\r
+ var html = converter.makeHtml(data.value);\r
+ ModalBox.open("Preview", html, false);\r
+ });\r
+ baseTextarea.bind("commentbox_open", function() {\r
+ UI.openedComments++;\r
+ });\r
+ baseTextarea.bind("commentbox_close", function(event, data) {\r
+ UI.openedComments--;\r
+ if(infos.isNew) {\r
+ data.commentBox.commentBox.next().find("span.nitdoc-github-editComment").show();\r
+ } else if(infos.requestID) {\r
+ data.commentBox.commentBox.next().show();\r
+ data.commentBox.commentBox.next().next().show();\r
+ } else {\r
+ data.commentBox.commentBox.next().show();\r
+ data.commentBox.commentBox.next().next().find("span.nitdoc-github-editComment").show();\r
+ }\r
+ });\r
+ baseTextarea.commentbox("open", baseTextarea.val());\r
});\r
});\r
},\r