define([ "jquery", "underscore", "utils", "crel", "rangy", "classes/Extension", "text!html/commentsPopoverContent.html", "bootstrap" ], function($, _, utils, crel, rangy, Extension, commentsPopoverContentHTML) { var comments = new Extension("comments", 'Comments'); var offsetMap = {}; var inputElt; var marginElt; var newCommentElt = crel('a', { class: 'icon-comment new' }); comments.onCursorCoordinates = function(cursorX, cursorY) { var top = (cursorY - 8) + 'px'; var right = 10 + 'px'; newCommentElt.style.top = top; newCommentElt.style.right = right; }; var fileDesc; comments.onFileSelected = function(selectedFileDesc) { fileDesc = selectedFileDesc; }; comments.onReady = function() { var cssApplier = rangy.createCssClassApplier("comment-highlight", { normalize: false }); var openedPopover; var selectionRange; var rangyRange; var currentDiscussion; inputElt = document.getElementById('wmd-input'); marginElt = document.querySelector('#wmd-input > .editor-margin'); marginElt.appendChild(newCommentElt); $(document.body).append($('