Each paragraph (<p>
) in the document has an ID (cn0, cn1,
etc.) and a class (cn
). This is the only part of the comment system rendered near the text. Also on the page is the div
that acts as the popup, which also contains the comment form.
The rest is done with Javascript. When the page is loaded, they send an AJAX request back to get the number and location of all the comments in the document. It looks like:
[[0,4],[3,2],...]
With this, it adds a div
in the margin with the speech bubble and number of comments on that line.
When you click on the bubbles, another AJAX request is initiated to get the comments for that bubble. In this case, they send down the actual HTML to be rendered instead of a JSON object like before.
On the backend (this is all conjecture now) they're tying each set of comments to a document and a location in that document (this allows them to show all comments for a document at once). I would probably use the built-in comments app to do this, and either package both items into one foreign key, by creating a model to link the document and location, or by subclassing the Comment model itself.
Hope this gets you in the right direction. You can probably learn more by looking at their Javascript, but it's been minified, so it's a little hard to read(UPDATE: found unminified js). They're building on YUI, but the code is pretty straight forward.