diff options
Diffstat (limited to 'bootstrap/comments/frontend/replytocomment.js')
-rw-r--r-- | bootstrap/comments/frontend/replytocomment.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/bootstrap/comments/frontend/replytocomment.js b/bootstrap/comments/frontend/replytocomment.js new file mode 100644 index 0000000..2e0fc45 --- /dev/null +++ b/bootstrap/comments/frontend/replytocomment.js @@ -0,0 +1,55 @@ +// Displays reply form (replytocomment.js) +HashOver.prototype.replyToComment = function (permalink) +{ + // Reference to this object + var hashover = this; + + // Get reply link element + var link = this.elements.get ('reply-link-' + permalink, true); + + // Get file + var file = this.permalinks.getFile (permalink); + + // Create reply form element + var form = this.elements.create ('form', { + id: 'hashover-reply-' + permalink, + className: 'hashover-reply-form', + action: '/formactions', + method: 'post' + }); + + // Place reply fields into form + form.innerHTML = hashover.strings.parseTemplate (hashover.ui['reply-form'], { + permalink: permalink, + file: file + }); + + // Prevent input submission + this.preventSubmit (form); + + // Add form to page + var replyForm = this.elements.get ('placeholder-reply-form-' + permalink, true); + replyForm.appendChild (form); + + // Change "Reply" link to "Cancel" link + this.cancelSwitcher ('reply', link, replyForm, permalink); + + // Attach event listeners to "Post Reply" button + var postReply = this.elements.get ('reply-post-' + permalink, true); + + // Get the element of comment being replied to + var destination = this.elements.get (permalink, true); + + // Attach click event to formatting revealer hyperlink + this.formattingOnclick ('reply', permalink); + + // Set onclick and onsubmit event handlers + this.elements.duplicateProperties (postReply, [ 'onclick', 'onsubmit' ], function () { + return hashover.postComment (destination, form, this, hashover.AJAXPost, 'reply', permalink, link.onclick, true, false); + }); + + // Focus comment field + form.comment.focus (); + + return true; +}; |