Commits

Don Brown committed be5fa59

Works now in confxhtml, fixed focus

Comments (0)

Files changed (2)

                 <configuration>
                     <productVersion>${confluence.version}</productVersion>
                     <productDataVersion>${confluence.data.version}</productDataVersion>
+                    <compressResources>false</compressResources>
                     <pluginArtifacts>
                         <pluginArtifact>
                             <groupId>com.atlassian.labs</groupId>

src/main/resources/js/annotate.js

 
 (function() {
 
-    var MAGIC_DELIMITOR = "pw3sx"
-    function submitComment(selection) {
+    var MAGIC_DELIMITOR = "pw3sx";
+    var wikiCommentTemplate = AJS.template("{quote}{quoteText}{quote}\n{commentText} {anchor:{anchorValue}}");
+    var xhtmlCommentTemplate = AJS.template('<blockquote><p>{quoteText}</p></blockquote>' +
+                                            '<p>{commentText} <img class="editor-bodyless-macro" src="https://confxhtml.atlassian.com/plugins/servlet/macro/placeholder/anchor" macro-name="anchor" macro-default-parameter="{anchorValue}" /></p>');
+    function submitComment(data) {
         var pageId = jQuery('#pageId').val();
         var contextPath = jQuery('#contextPath').val();
         var token = jQuery('meta[name=atlassian-token]').attr('content');
             type: 'post',
             url: contextPath + '/pages/doaddcomment.action?pageId=' + pageId,
             data: {
-                'content' : selection,
+                'content' : wikiCommentTemplate.fill(data),
+                'wysiwygContent' : xhtmlCommentTemplate.fill(data),
                 'atl_token' : token
             },
             success: function(response)
         var parsed = selection.split(' ');
         var signature = MAGIC_DELIMITOR + parsed[0] + MAGIC_DELIMITOR + (parsed.length - 2) + MAGIC_DELIMITOR +  parsed[parsed.length-1];
         dialog.addButton("Save", function (dialog) {
-            submitComment("{quote}" + selection + "{quote}\n" + jQuery('#inlineComment').val() + " {anchor:" + signature + "}");
+            submitComment({quoteText: selection, commentText: jQuery('#inlineComment').val(), anchorValue : signature});
             dialog.hide();
         });
         dialog.addButton("Cancel", function (dialog) {
         });
 
         dialog.show();
-
-
+        jQuery('#inlineComment').focus();
     }
 
     function insertAfter( referenceNode, newNode )
                 jQuery(this).attr('data-inlineid', counter);
                 var commentDiv = jQuery(this).closest('.comment');
                 var commentId = commentDiv.attr('id');
-                commentId = commentId.substring(commentId.indexOf('-') + 1);
                 var userId = jQuery('.userLogoLink', commentDiv).attr("data-username");
 
 
                             AJS.InlineDialog(jQuery('#inline-sub-' + this.index), 1, function(contents, trigger, showPopup) {
                                 contents.empty();
                                 jQuery.each(match.comments, function() {
-                                    contents.append('<p>' + this.user  + ': ' + this.comment + ' <a href="#comment-' + this.id + '">' +
+                                    contents.append('<p>' + this.user  + ': ' + this.comment + ' <a href="#' + this.id + '">' +
                                             ' <img src="' + contextPath + '/images/icons/down_16.gif" /></a></p>');
                                 });
                                 showPopup();