diff --git a/common/lib/xmodule/xmodule/annotatable_module.py b/common/lib/xmodule/xmodule/annotatable_module.py index 92ba987256..f4c1d80408 100644 --- a/common/lib/xmodule/xmodule/annotatable_module.py +++ b/common/lib/xmodule/xmodule/annotatable_module.py @@ -43,11 +43,11 @@ class AnnotatableModule(XModule): index += 1 def _set_span_data(self, span, index, xmltree): - """ Sets the discussion anchor for the span. """ + """ Sets the associated discussion id for the span. """ - if 'anchor' in span.attrib: - span.set('data-discussion-anchor', span.get('anchor')) - del span.attrib['anchor'] + if 'discussion' in span.attrib: + span.set('data-discussion-id', span.get('discussion')) + del span.attrib['discussion'] def _decorate_span(self, span, index, xmltree): """ Decorates the span highlight. """ diff --git a/common/lib/xmodule/xmodule/js/src/annotatable/display.coffee b/common/lib/xmodule/xmodule/js/src/annotatable/display.coffee index dc580125d8..493d8c7110 100644 --- a/common/lib/xmodule/xmodule/js/src/annotatable/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/annotatable/display.coffee @@ -7,6 +7,7 @@ class @Annotatable commentSelector: '.annotatable-comment' replySelector: '.annotatable-reply' helpSelector: '.annotatable-help-icon' + inlineDiscussionSelector: '.xmodule_DiscussionModule .discussion-module' constructor: (el) -> console.log 'loaded Annotatable' if @_debug @@ -73,15 +74,14 @@ class @Annotatable onClickReply: (e) => e.preventDefault() - anchorEl = @getAnchorByName e.currentTarget - @scrollTo anchorEl if anchorEl + @scrollTo(@getInlineDiscussion e.currentTarget) - getAnchorByName: (el) -> - hash = $(el).attr('href') - if hash?.charAt(0) == '#' - name = hash.substr(1) - anchor = $("a[name='#{name}']").first() - anchor + getInlineDiscussion: (el) -> + discussion_id = @getDiscussionId(el) + $(@inlineDiscussionSelector).filter("[data-discussion-id='#{discussion_id}']") + + getDiscussionId: (el) -> + $(el).data('discussion-id') toggleAnnotations: () -> @annotationsHidden = not @annotationsHidden @@ -105,14 +105,14 @@ class @Annotatable onAfter: @makeAfterScroll(el) }) - makeAfterScroll: (el, duration = 2000) -> - @_once -> el.effect 'highlight', {}, duration + makeAfterScroll: (el, duration = 500) -> + @_once -> el.effect 'shake', {}, duration makeTipContent: (el) -> (api) => - anchor = $(el).data('discussion-anchor') + discussion_id = @getDiscussionId(el) comment = $(@commentSelector, el).first().clone() - comment = comment.after(@createReplyLink anchor) if anchor + comment = comment.after(@createReplyLink discussion_id) if discussion_id comment makeTipTitle: (el) -> @@ -121,11 +121,8 @@ class @Annotatable title = comment.attr('title') (if title then title else 'Commentary') - createReplyLink: (anchor) -> - cls = 'annotatable-reply' - href = '#' + anchor - text = 'See Full Discussion' - $("#{text}") + createReplyLink: (discussion_id) -> + $("See Full Discussion") openSavedTips: () -> @showTips @savedTips