Commit 7e7911a0 by Arthur Barrett

Changed the markup and js for associating spans with discussion threads. Uses…

Changed the markup and js for associating spans with discussion threads. Uses the discussion id now.
parent 45a27f30
...@@ -43,11 +43,11 @@ class AnnotatableModule(XModule): ...@@ -43,11 +43,11 @@ class AnnotatableModule(XModule):
index += 1 index += 1
def _set_span_data(self, span, index, xmltree): 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: if 'discussion' in span.attrib:
span.set('data-discussion-anchor', span.get('anchor')) span.set('data-discussion-id', span.get('discussion'))
del span.attrib['anchor'] del span.attrib['discussion']
def _decorate_span(self, span, index, xmltree): def _decorate_span(self, span, index, xmltree):
""" Decorates the span highlight. """ """ Decorates the span highlight. """
......
...@@ -7,6 +7,7 @@ class @Annotatable ...@@ -7,6 +7,7 @@ class @Annotatable
commentSelector: '.annotatable-comment' commentSelector: '.annotatable-comment'
replySelector: '.annotatable-reply' replySelector: '.annotatable-reply'
helpSelector: '.annotatable-help-icon' helpSelector: '.annotatable-help-icon'
inlineDiscussionSelector: '.xmodule_DiscussionModule .discussion-module'
constructor: (el) -> constructor: (el) ->
console.log 'loaded Annotatable' if @_debug console.log 'loaded Annotatable' if @_debug
...@@ -73,15 +74,14 @@ class @Annotatable ...@@ -73,15 +74,14 @@ class @Annotatable
onClickReply: (e) => onClickReply: (e) =>
e.preventDefault() e.preventDefault()
anchorEl = @getAnchorByName e.currentTarget @scrollTo(@getInlineDiscussion e.currentTarget)
@scrollTo anchorEl if anchorEl
getAnchorByName: (el) -> getInlineDiscussion: (el) ->
hash = $(el).attr('href') discussion_id = @getDiscussionId(el)
if hash?.charAt(0) == '#' $(@inlineDiscussionSelector).filter("[data-discussion-id='#{discussion_id}']")
name = hash.substr(1)
anchor = $("a[name='#{name}']").first() getDiscussionId: (el) ->
anchor $(el).data('discussion-id')
toggleAnnotations: () -> toggleAnnotations: () ->
@annotationsHidden = not @annotationsHidden @annotationsHidden = not @annotationsHidden
...@@ -105,14 +105,14 @@ class @Annotatable ...@@ -105,14 +105,14 @@ class @Annotatable
onAfter: @makeAfterScroll(el) onAfter: @makeAfterScroll(el)
}) })
makeAfterScroll: (el, duration = 2000) -> makeAfterScroll: (el, duration = 500) ->
@_once -> el.effect 'highlight', {}, duration @_once -> el.effect 'shake', {}, duration
makeTipContent: (el) -> makeTipContent: (el) ->
(api) => (api) =>
anchor = $(el).data('discussion-anchor') discussion_id = @getDiscussionId(el)
comment = $(@commentSelector, el).first().clone() comment = $(@commentSelector, el).first().clone()
comment = comment.after(@createReplyLink anchor) if anchor comment = comment.after(@createReplyLink discussion_id) if discussion_id
comment comment
makeTipTitle: (el) -> makeTipTitle: (el) ->
...@@ -121,11 +121,8 @@ class @Annotatable ...@@ -121,11 +121,8 @@ class @Annotatable
title = comment.attr('title') title = comment.attr('title')
(if title then title else 'Commentary') (if title then title else 'Commentary')
createReplyLink: (anchor) -> createReplyLink: (discussion_id) ->
cls = 'annotatable-reply' $("<a class=\"annotatable-reply\" href=\"javascript:void(0);\" data-discussion-id=\"#{discussion_id}\">See Full Discussion</a>")
href = '#' + anchor
text = 'See Full Discussion'
$("<a class=\"#{cls}\" href=\"#{href}\">#{text}</a>")
openSavedTips: () -> openSavedTips: () ->
@showTips @savedTips @showTips @savedTips
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment