Below is an example of SideComments.js in action. Each section of text can be commented on. Go ahead and give it a try!
How to start using SideComments.js on your website immediately.
Overview of all events and method you can leverage in SideComments.js
The constructor takes one required and two optional arguments:
The element which contains all the
The user representation new comments will be posted under. As it's optional, you can just pass
nullif there is no current user at the time and set one at a later time with the
setCurrentUsermethod, which is documented below. The current user object needs to look like this: https://gist.github.com/aroc/02a0f8badf219da12667
An array of existing comments that you want inserted at initialization time. You can also insert comments yourself at later time with the
insertCommentmethod, outlined below. The structure of the objects in this array needs to look like this: https://gist.github.com/aroc/54a2669783231a0d2215
Description: De-select a section and make it inactive, hiding the side comments. If the side comments are already hidden, this method will have no effect.
Description: Sets the currentUser to be used for all new comments.
Description: Removes the currentUser. Without a currentUser, comments amy not be posted. Instead, the
addCommentAttempted event gets triggered when a user clicks the "Add Comment" button.
Description: Inserts a comment into the markup. It will insert into the section specified by the comment object.
Description: Removes a comment from the SideComments object and from the markup.
Description: Returns true if the comments are visbile, false if they are not.
Description: Removing the sideComments object, cleaning up any event bindings and removing any markup from the DOM.
|Event Name||Values Passed||Description|
|commentPosted||comment (Object)||Fired after a user fills out the comment form and clicks "Post".|
|addCommentAttempted||None||Fired when a sideComments object doesn't have a current user and the "Add Comment" button is clicked.|
|commentDeleted||comment (Object)||Fired after a user has clicked "Delete" on one of their comments and has confirmed with the dialog that they do want to delete it.|